Changeset 1452

Show
Ignore:
Timestamp:
07/18/06 13:57:25 (2 years ago)
Author:
jstenar
Message:

pyreadline: Improvements to ansi color handling. Added do nothing method as tabcompletion default.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyreadline/trunk/doc/ChangeLog

    r1382 r1452  
     12006-07-18 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
     2    * Added AnsiState class to simplify work with getting the aansi color handling to work properly 
     3    * Added NOP function to readline class to have an empty function to bind to tab completion 
     4    * Tab completion bound to do nothing method NOP by default.  
     5     
    162006-06-27 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
    27    * Changes from yesterday were not correct. Resulted in invisible docstrings 
  • pyreadline/trunk/pyreadline/console.py

    r1382 r1452  
    156156                  0x5b:1, # windows key 
    157157                 } 
     158from ansi import AnsiState,AnsiWriter 
     159 
    158160 
    159161class Console(object): 
     
    184186        self.attr = info.wAttributes 
    185187        self.saveattr = info.wAttributes # remember the initial colors 
     188         
     189        self.defaultstate=AnsiState() 
     190        self.defaultstate.winattr=info.wAttributes 
     191         
     192        self.ansiwriter=AnsiWriter(self.defaultstate) 
     193         
     194         
    186195        log('initial attr=%x' % self.attr) 
    187196 
     
    202211        import atexit 
    203212        atexit.register(exit) 
    204              
     213         
     214         
     215         
     216         
     217         
    205218 
    206219    def __del__(self): 
     
    342355        return n 
    343356 
     357    def write_color(self, text, attr=None): 
     358        n,res= self.ansiwriter.write_color(text,attr) 
     359        junk = c_int(0) 
     360        for attr,chunk in res: 
     361            log(str(attr)) 
     362            log(str(chunk)) 
     363            self.SetConsoleTextAttribute(self.hout, attr.winattr) 
     364            self.WriteConsoleA(self.hout, chunk, len(chunk), byref(junk), None) 
     365        return n 
     366 
    344367    def write_plain(self, text, attr=None): 
    345368        '''write text at current cursor position.''' 
  • pyreadline/trunk/pyreadline/rlmain.py

    r1382 r1452  
    180180                control, meta, shift, code = event.keyinfo 
    181181                event.keyinfo = (control, True, shift, code) 
    182  
     182            log("event:%s,%s"%(str(event.keyinfo),event.char)) 
    183183            #Process exit keys. Only exit on empty line 
    184184            if event.keyinfo in self.exit_dispatch: 
     
    11201120        pass 
    11211121 
     1122    def NOP(self,e): 
     1123        pass 
     1124 
    11221125    def _bind_key(self, key, func): 
    11231126        '''setup the mapping from key to call the function.''' 
     
    11391142 
    11401143        # I often accidentally hold the shift or control while typing space 
     1144        self._bind_key('Tab',               self.NOP) 
    11411145        self._bind_key('Shift-space',       self.self_insert) 
    11421146        self._bind_key('Control-space',     self.self_insert)