Changeset 2861
- Timestamp:
- 11/09/07 14:40:25 (1 year ago)
- Files:
-
- pyreadline/trunk/doc/ChangeLog (modified) (1 diff)
- pyreadline/trunk/pyreadline/__init__.py (modified) (1 diff)
- pyreadline/trunk/pyreadline/configuration/startup.py (modified) (1 diff)
- pyreadline/trunk/pyreadline/console/console.py (modified) (6 diffs)
- pyreadline/trunk/pyreadline/lineeditor/lineobj.py (modified) (2 diffs)
- pyreadline/trunk/pyreadline/unicode_helper.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyreadline/trunk/doc/ChangeLog
r2853 r2861 1 2007-11-09 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 * More fixes to ensure unicode works when completing on filepaths with non ascii symbols. 3 This fix assumes sys.stdout.encoding is valid for the filesystem. A more correct fix 4 must be applied to the completer code which is outside pyreadline. 5 Any str characters fed into pyreadline should be converted to unicode using 6 unicode_helper.ensure_unicode. 7 * The encoding assumed of strings is sys.stdout.encoding this can be changed by: 8 e.g. pyreadline.unicode_helper.pyreadline_codepage="utf8" 9 1 10 2007-10-30 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 11 * Fixing console.title to work with wide characters pyreadline/trunk/pyreadline/__init__.py
r2238 r2861 7 7 # the file COPYING, distributed as part of this software. 8 8 #***************************************************************************** 9 import logger,clipboard,lineeditor,modes9 import unicode_helper,logger,clipboard,lineeditor,modes 10 10 from rlmain import * 11 11 __all__ = [ 'parse_and_bind', pyreadline/trunk/pyreadline/configuration/startup.py
r1896 r2861 5 5 #pyreadline.rlmain.config_path=r"c:\xxx\pyreadlineconfig.ini" 6 6 import readline,atexit 7 import pyreadline.unicode_helper 8 # 9 # 10 #Normally the codepage for pyreadline is set to be sys.stdout.encoding 11 #if you need to change this uncomment the following line 12 #pyreadline.unicode_helper.pyreadline_codepage="utf8" 7 13 except ImportError: 8 14 print "Module readline not available." pyreadline/trunk/pyreadline/console/console.py
r2853 r2861 18 18 import re 19 19 from pyreadline.logger import log,log_sock 20 20 from pyreadline.unicode_helper import ensure_unicode 21 import pyreadline.unicode_helper as unicode_helper 21 22 try: 22 23 from ctypes import * … … 116 117 ("bVisible", c_byte)] 117 118 118 119 try:120 consolecodepage=sys.stdout.encoding121 except AttributeError: #This error occurs when pdb imports readline and doctest has replaced122 #stdout with stdout collector123 consolecodepage="ascii" #assume ascii codepage124 125 def ensure_text(text):126 """helper to ensure that text passed to WriteConsoleA is ascii"""127 if isinstance(text, str):128 return text.decode(consolecodepage, "replace")129 return text130 119 131 120 # I didn't want to have to individually import these so I made a list, they are … … 364 353 365 354 def write_color(self, text, attr=None): 366 text = ensure_ text(text)355 text = ensure_unicode(text) 367 356 n,res= self.ansiwriter.write_color(text,attr) 368 357 junk = c_int(0) … … 389 378 n = c_int(0) 390 379 self.SetConsoleTextAttribute(self.hout, attr) 391 self.WriteConsoleW(self.hout, ensure_ text(chunk), len(chunk), byref(junk), None)380 self.WriteConsoleW(self.hout, ensure_unicode(chunk), len(chunk), byref(junk), None) 392 381 return len(text) 393 382 … … 689 678 try: 690 679 # call the Python hook 691 res = readline_hook(prompt).encode( consolecodepage)680 res = readline_hook(prompt).encode(unicode_helper.pyreadline_codepage) 692 681 # make sure it returned the right sort of thing 693 682 if res and not isinstance(res, str): … … 713 702 try: 714 703 # call the Python hook 715 res = readline_hook(prompt).encode( consolecodepage)704 res = readline_hook(prompt).encode(unicode_helper.pyreadline_codepage) 716 705 # make sure it returned the right sort of thing 717 706 if res and not isinstance(res, str): pyreadline/trunk/pyreadline/lineeditor/lineobj.py
r2849 r2861 6 6 # the file COPYING, distributed as part of this software. 7 7 #***************************************************************************** 8 import re,operator 8 import re,operator,sys 9 9 10 10 import wordmatcher 11 11 import pyreadline.clipboard as clipboard 12 12 from pyreadline.logger import log,log_sock 13 from pyreadline.unicode_helper import ensure_unicode 13 14 class NotAWordError(IndexError): 14 15 pass … … 242 243 quoted = [ quote_char(c) for c in self.line_buffer ] 243 244 self.line_char_width = [ len(c) for c in quoted ] 244 return ''.join(quoted)245 return u''.join(map(ensure_unicode,quoted)) 245 246 246 247 def get_line_text(self): 247 return ''.join(self.line_buffer) 248 248 buf=self.line_buffer 249 buf=map(ensure_unicode,buf) 250 return u''.join(buf) 251 249 252 def set_line(self, text, cursor=None): 250 253 self.line_buffer = [ c for c in str(text) ]
