Changeset 2140

Show
Ignore:
Timestamp:
03/15/07 13:39:26 (2 years ago)
Author:
jstenar
Message:

pyreadline-refactor: Fix buggy get_begidx and get_endidx. Ensure unicode can print in write_x methods on Console.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyreadline/branches/refactor/pyreadline/console/console.py

    r1877 r2140  
    2020 
    2121try: 
    22     # I developed this with ctypes 0.6 
    2322    from ctypes import * 
    2423    from _ctypes import call_function 
     
    116115    _fields_ = [("dwSize", c_int), 
    117116                ("bVisible", c_byte)] 
     117 
     118consolecodepage=sys.stdout.encoding 
     119def ensure_text(text): 
     120    """helper to ensure that text passed to WriteConsoleA is ascii""" 
     121    if isinstance(text, unicode): 
     122        return text.encode(consolecodepage,"replace") 
     123    return text 
    118124 
    119125# I didn't want to have to individually import these so I made a list, they are 
     
    348354                attr = self.attr 
    349355            self.SetConsoleTextAttribute(self.hout, attr) 
    350             self.WriteConsoleA(self.hout, chunk, len(chunk), byref(junk), None) 
     356            self.WriteConsoleA(self.hout, ensure_text(chunk), len(chunk), byref(junk), None) 
    351357        return n 
    352358 
     
    358364            log(str(chunk)) 
    359365            self.SetConsoleTextAttribute(self.hout, attr.winattr) 
    360             self.WriteConsoleA(self.hout, chunk, len(chunk), byref(junk), None) 
     366            self.WriteConsoleA(self.hout, ensure_text(chunk), len(chunk), byref(junk), None) 
    361367        return n 
    362368 
     
    369375        n = c_int(0) 
    370376        self.SetConsoleTextAttribute(self.hout, attr) 
    371         self.WriteConsoleA(self.hout, text, len(text), byref(n), None) 
     377        self.WriteConsoleA(self.hout, ensure_text(chunk), len(chunk), byref(junk), None) 
    372378        return len(text) 
    373379 
  • pyreadline/branches/refactor/pyreadline/modes/basemode.py

    r2132 r2140  
    5959    mark_directories=property(*_gs("mark_directories")) 
    6060    completer=property(*_gs("completer")) 
     61    begidx=property(*_gs("begidx")) 
     62    endidx=property(*_gs("endidx")) 
    6163     
    6264    console=property(_g("console")) 
  • pyreadline/branches/refactor/pyreadline/release.py

    r1219 r2140  
    2323branch = 'refactor' 
    2424 
    25 version = 'refactor
     25version = '1.4.svn
    2626 
    2727revision = '$Revision$'