Changeset 1895
- Timestamp:
- 11/13/06 12:06:44 (2 years ago)
- Files:
-
- pyreadline/branches/refactor/doc/ChangeLog (modified) (1 diff)
- pyreadline/branches/refactor/pyreadline/console/ansi.py (modified) (2 diffs)
- pyreadline/branches/refactor/pyreadline/console/ironpython_console.py (modified) (2 diffs)
- pyreadline/branches/refactor/pyreadline/keysyms/__init__.py (modified) (1 diff)
- pyreadline/branches/refactor/pyreadline/keysyms/ironpython_keysyms.py (modified) (2 diffs)
- pyreadline/branches/refactor/pyreadline/lineeditor/history.py (modified) (5 diffs)
- pyreadline/branches/refactor/pyreadline/modes/basemode.py (modified) (2 diffs)
- pyreadline/branches/refactor/pyreadline/modes/emacs.py (modified) (2 diffs)
- pyreadline/branches/refactor/pyreadline/rlmain.py (modified) (4 diffs)
- pyreadline/branches/refactor/pyreadline/test/emacs_test.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyreadline/branches/refactor/doc/ChangeLog
r1843 r1895 1 2006-11-06 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 * Fixed bug in tab completion when point is not at end of line 3 * Changed clr.AddReference to clr.AddReferenceToFileAndPath (ironpython_console) 4 * Fix points position after tab completion 5 * Fix for difference in handling of multiline input between cpython and ironpython (emacs.py) 6 * added test_complete case to emacs_test.py 7 8 2006-11-03 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 9 * Improvements in ironpython handling. 10 * Detection of ironpython explicit on sys.version instead of relying on presense of ctypes 11 * Lots of fixes to take care of peculiaritis of System.Console in .NET it does not have 12 the full windows console functionality. Fill a rectangle is missing, writing without 13 affecting cursor is missing, altgr keys show up as alt+ctrl so had to blank alt+ctrl in 14 keyboard event checking, endoffile signal to from readline is not using EOFError in ironpython 15 rather returning None 16 * Set selectioncolor by looking at foregroundcolor at startup 17 * open in ironpython does not ignore unknown letters in mode silently, hade "rt" in history open 18 * Have to print prompt in ironpython since ironpythons readline looks at sys.ps1 and print it instead 19 of passing it into readline explicitly. 20 * Fixed another bug in historysearch 21 1 22 2006-10-25 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 23 * port set_text_color and set_prompt_color config file options from trunk pyreadline/branches/refactor/pyreadline/console/ansi.py
r1843 r1895 1 1 # -*- coding: ISO-8859-1 -*- 2 import re,sys,os,pprint 3 pprint=pprint.pprint 2 import re,sys,os 4 3 5 4 terminal_escape = re.compile('(\001?\033\\[[0-9;]*m\002?)') … … 154 153 155 154 if __name__=="__main__": 156 import startup 155 import pprint 156 pprint=pprint.pprint 157 157 158 s="\033[0;31mred\033[0;32mgreen\033[0;33myellow\033[0;34mblue\033[0;35mmagenta\033[0;36mcyan\033[0;37mwhite\033[0m" 158 159 pprint (write_color(s)) pyreadline/branches/refactor/pyreadline/console/ironpython_console.py
r1877 r1895 23 23 # 24 24 # 25 26 27 25 # primitive debug printing that won't interfere with the screen 28 26 29 import clr 30 clr.AddReference ("ipy.exe")27 import clr,sys 28 clr.AddReferenceToFileAndPath(sys.executable) 31 29 import IronPythonConsole 32 30 33 31 import sys 34 import traceback35 32 import re 36 33 import os … … 402 399 403 400 404 def getconsole(buffer=1):405 """Get a console handle.406 407 If buffer is non-zero, a new console buffer is allocated and408 installed. Otherwise, this returns a handle to the current409 console buffer"""410 c = Console(buffer)411 return c412 401 413 402 if __name__ == '__main__': pyreadline/branches/refactor/pyreadline/keysyms/__init__.py
r1419 r1895 1 import glob1 import sys 2 2 3 3 success=False 4 try: 5 from keysyms import * 6 success=True 7 except ImportError,x: 4 in_ironpython=sys.version.startswith("IronPython") 8 5 6 if in_ironpython: 9 7 try: 10 8 from ironpython_keysyms import * 9 success=True 10 except ImportError,x: 11 pass 12 else: 13 try: 14 from keysyms import * 11 15 success=True 12 16 except ImportError,x: pyreadline/branches/refactor/pyreadline/keysyms/ironpython_keysyms.py
r1877 r1895 9 9 import System 10 10 from common import validkey,KeyPress,make_KeyPress_from_keydescr 11 from pyreadline.logger import log_sock11 #from pyreadline.logger import log_sock 12 12 c32=System.ConsoleKey 13 13 Shift=System.ConsoleModifiers.Shift … … 197 197 meta=bool(int(state)&int(Alt)) 198 198 keyname=code2sym_map.get(keycode,"").lower() 199 log_sock("make key %s %s %s %s"%(shift,control,meta,keycode),"keysyms")199 # log_sock("make key %s %s %s %s"%(shift,control,meta,keycode),"keysyms") 200 200 if control and meta: #equivalent to altgr so clear flags 201 201 control=False pyreadline/branches/refactor/pyreadline/lineeditor/history.py
r1877 r1895 143 143 144 144 event = c.getkeypress() 145 log_sock(str(event) )145 log_sock(str(event),"history") 146 146 147 147 if event.keyinfo.keyname == 'backspace': … … 156 156 else: 157 157 pyreadline.rl._bell() 158 log_sock(query )158 log_sock(query,"history") 159 159 res="" 160 160 if query: … … 164 164 else: 165 165 res=self.forward_search_history(query) 166 log_sock(res )166 log_sock(res,"history") 167 167 return lineobj.ReadLineTextBuffer(res,point=0) 168 168 … … 185 185 self.query = ''.join(partial[0:partial.point].get_line_text()) 186 186 hcstart=max(self.history_cursor,0) 187 log_sock("hcstart %s"%hcstart )187 log_sock("hcstart %s"%hcstart,"history") 188 188 hc = self.history_cursor + direction 189 189 while (direction < 0 and hc >= 0) or (direction > 0 and hc < len(self.history)): … … 210 210 return lineobj.ReadLineTextBuffer(self.query,point=min(len(self.query),partial.point)) 211 211 except IndexError: 212 log_sock("hcstart:%s %s"%(hcstart,len(self.history)) )212 log_sock("hcstart:%s %s"%(hcstart,len(self.history)),"history") 213 213 raise 214 214 pyreadline/branches/refactor/pyreadline/modes/basemode.py
r1877 r1895 9 9 import os,re,math,glob,sys 10 10 import pyreadline.logger as logger 11 from pyreadline.logger import log 11 from pyreadline.logger import log,log_sock 12 12 from pyreadline.keysyms.common import make_KeyPress_from_keydescr 13 13 import pyreadline.lineeditor.lineobj as lineobj … … 187 187 cprefix = commonprefix(completions) 188 188 rep = [ c for c in cprefix ] 189 point=self.l_buffer.point 189 190 self.l_buffer[self.begidx:self.endidx] = rep 190 self.l_buffer.point +=len(rep) - (self.endidx - self.begidx)191 self.l_buffer.point = point + len(rep) - (self.endidx - self.begidx) 191 192 if len(completions) > 1: 192 193 if self.show_all_if_ambiguous == 'on': pyreadline/branches/refactor/pyreadline/modes/emacs.py
r1877 r1895 63 63 64 64 log("readline from keyboard:%s,%s"%(keyinfo,dispatch_func)) 65 log_sock("%s|%s"%(format(keyinfo),dispatch_func.__name__) )65 log_sock("%s|%s"%(format(keyinfo),dispatch_func.__name__),"bound_function") 66 66 r = None 67 67 if dispatch_func: … … 120 120 121 121 log('returning(%s)' % self.l_buffer.get_line_text()) 122 return self.l_buffer.get_line_text() + '\n' 122 if in_ironpython: 123 return self.l_buffer.get_line_text() 124 else: 125 return self.l_buffer.get_line_text() + '\n' 123 126 124 127 ######### History commands pyreadline/branches/refactor/pyreadline/rlmain.py
r1877 r1895 8 8 #***************************************************************************** 9 9 ''' an attempt to implement readline for Python in Python using ctypes''' 10 11 import string 12 import math 13 import sys 10 import sys,os,re 14 11 from glob import glob 15 import os,pdb16 import re17 import traceback18 import operator19 import exceptions20 12 21 13 import clipboard,logger,console … … 36 28 else: 37 29 default_prompt="" 30 import pdb 38 31 39 32 … … 144 137 except: 145 138 log('error') 146 traceback.print_exc()147 139 raise 148 140 … … 269 261 pass 270 262 elif self.bell_style == 'visible': 271 raise exceptions.NotImplementedError("Bellstyle visible is not implemented yet.")263 raise NotImplementedError("Bellstyle visible is not implemented yet.") 272 264 elif self.bell_style == 'audible': 273 265 self.console.bell() pyreadline/branches/refactor/pyreadline/test/emacs_test.py
r1877 r1895 16 16 17 17 from common import * 18 from pyreadline.logger import log_sock 19 import pyreadline.logger as logger 20 logger.sock_silent=True 21 logger.show_event=["debug"] 22 18 23 #---------------------------------------------------------------------- 19 24 … … 29 34 self.completer_delims = ' ' 30 35 self.tabstop = 4 36 self.mark_directories=False 37 self.show_all_if_ambiguous=False 31 38 32 39 def get_mock_console (self): … … 54 61 dispatch_func = self.key_dispatch.get(keyinfo.tuple(),self.self_insert) 55 62 self.tested_commands[dispatch_func.__name__]=dispatch_func 56 # print key,dispatch_func.__name__ 63 log_sock("keydisp: %s %s"%( key,dispatch_func.__name__),"debug") 57 64 dispatch_func (event) 58 log_sock("emacs readline from keyboard:%s->%s"%(keyinfo.tuple(),dispatch_func))59 65 self.previous_func=dispatch_func 60 66 … … 318 324 self.assert_line(r,'k',1) 319 325 320 321 326 def test_complete (self): 327 import rlcompleter 328 logger.sock_silent=False 329 330 log_sock("-"*50,"debug") 331 r=EmacsModeTest() 332 r.completer=rlcompleter.Completer().complete 333 r._bind_key("tab",r.complete) 334 r.input('"exi(ksdjksjd)"') 335 r.input('Control-a') 336 r.input('Right') 337 r.input('Right') 338 r.input('Right') 339 r.input('Tab') 340 self.assert_line(r,"exit(ksdjksjd)",4) 341 342 r.input('Escape') 343 r.input('"exi"') 344 r.input('Control-a') 345 r.input('Right') 346 r.input('Right') 347 r.input('Right') 348 r.input('Tab') 349 self.assert_line(r,"exit",4) 350 351 352 322 353 def assert_line(self,r,line,cursor): 323 354 self.assertEqual (r.line, line) … … 333 364 tested=EmacsModeTest.tested_commands.keys() 334 365 tested.sort() 335 print " Tested functions ".center(60,"-")336 print "\n".join(tested)337 print366 # print " Tested functions ".center(60,"-") 367 # print "\n".join(tested) 368 # print 338 369 339 370 all_funcs=dict([(x.__name__,x) for x in EmacsModeTest().key_dispatch.values()])
