Changeset 1895

Show
Ignore:
Timestamp:
11/13/06 12:06:44 (2 years ago)
Author:
jstenar
Message:

pyreadline-refactor: More improvements of ironpython handling, more testcases

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyreadline/branches/refactor/doc/ChangeLog

    r1843 r1895  
     12006-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     
     82006-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     
    1222006-10-25 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
    223    * port set_text_color and set_prompt_color config file options from trunk 
  • pyreadline/branches/refactor/pyreadline/console/ansi.py

    r1843 r1895  
    11# -*- coding: ISO-8859-1 -*- 
    2 import re,sys,os,pprint 
    3 pprint=pprint.pprint 
     2import re,sys,os 
    43 
    54terminal_escape = re.compile('(\001?\033\\[[0-9;]*m\002?)') 
     
    154153 
    155154if __name__=="__main__": 
    156     import startup 
     155    import pprint 
     156    pprint=pprint.pprint 
     157 
    157158    s="\033[0;31mred\033[0;32mgreen\033[0;33myellow\033[0;34mblue\033[0;35mmagenta\033[0;36mcyan\033[0;37mwhite\033[0m" 
    158159    pprint (write_color(s))     
  • pyreadline/branches/refactor/pyreadline/console/ironpython_console.py

    r1877 r1895  
    2323# 
    2424# 
    25  
    26  
    2725# primitive debug printing that won't interfere with the screen 
    2826 
    29 import clr 
    30 clr.AddReference("ipy.exe"
     27import clr,sys 
     28clr.AddReferenceToFileAndPath(sys.executable
    3129import IronPythonConsole 
    3230 
    3331import sys 
    34 import traceback 
    3532import re 
    3633import os 
     
    402399 
    403400 
    404 def getconsole(buffer=1): 
    405         """Get a console handle. 
    406  
    407         If buffer is non-zero, a new console buffer is allocated and 
    408         installed.  Otherwise, this returns a handle to the current 
    409         console buffer""" 
    410         c = Console(buffer) 
    411         return c 
    412401 
    413402if __name__ == '__main__': 
  • pyreadline/branches/refactor/pyreadline/keysyms/__init__.py

    r1419 r1895  
    1 import glob 
     1import sys 
    22 
    33success=False 
    4 try: 
    5     from keysyms import * 
    6     success=True 
    7 except ImportError,x: 
     4in_ironpython=sys.version.startswith("IronPython") 
    85 
     6if in_ironpython: 
    97    try: 
    108        from ironpython_keysyms import * 
     9        success=True 
     10    except ImportError,x: 
     11        pass 
     12else: 
     13    try: 
     14        from keysyms import * 
    1115        success=True 
    1216    except ImportError,x: 
  • pyreadline/branches/refactor/pyreadline/keysyms/ironpython_keysyms.py

    r1877 r1895  
    99import System 
    1010from common import validkey,KeyPress,make_KeyPress_from_keydescr 
    11 from pyreadline.logger import log_sock 
     11#from pyreadline.logger import log_sock 
    1212c32=System.ConsoleKey 
    1313Shift=System.ConsoleModifiers.Shift 
     
    197197    meta=bool(int(state)&int(Alt)) 
    198198    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") 
    200200    if control and meta: #equivalent to altgr so clear flags 
    201201        control=False 
  • pyreadline/branches/refactor/pyreadline/lineeditor/history.py

    r1877 r1895  
    143143 
    144144            event = c.getkeypress() 
    145             log_sock(str(event)
     145            log_sock(str(event),"history"
    146146             
    147147            if event.keyinfo.keyname == 'backspace': 
     
    156156            else: 
    157157                pyreadline.rl._bell() 
    158         log_sock(query
     158        log_sock(query,"history"
    159159        res="" 
    160160        if query: 
     
    164164            else: 
    165165                res=self.forward_search_history(query) 
    166             log_sock(res
     166            log_sock(res,"history"
    167167        return lineobj.ReadLineTextBuffer(res,point=0) 
    168168         
     
    185185                self.query = ''.join(partial[0:partial.point].get_line_text()) 
    186186            hcstart=max(self.history_cursor,0)  
    187             log_sock("hcstart %s"%hcstart
     187            log_sock("hcstart %s"%hcstart,"history"
    188188            hc = self.history_cursor + direction 
    189189            while (direction < 0 and hc >= 0) or (direction > 0 and hc < len(self.history)): 
     
    210210                return lineobj.ReadLineTextBuffer(self.query,point=min(len(self.query),partial.point)) 
    211211        except IndexError: 
    212             log_sock("hcstart:%s %s"%(hcstart,len(self.history))
     212            log_sock("hcstart:%s %s"%(hcstart,len(self.history)),"history"
    213213            raise 
    214214 
  • pyreadline/branches/refactor/pyreadline/modes/basemode.py

    r1877 r1895  
    99import os,re,math,glob,sys 
    1010import pyreadline.logger as logger 
    11 from   pyreadline.logger import log 
     11from   pyreadline.logger import log,log_sock 
    1212from   pyreadline.keysyms.common import make_KeyPress_from_keydescr 
    1313import pyreadline.lineeditor.lineobj as lineobj 
     
    187187            cprefix = commonprefix(completions) 
    188188            rep = [ c for c in cprefix ] 
     189            point=self.l_buffer.point 
    189190            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) 
    191192            if len(completions) > 1: 
    192193                if self.show_all_if_ambiguous == 'on': 
  • pyreadline/branches/refactor/pyreadline/modes/emacs.py

    r1877 r1895  
    6363             
    6464            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"
    6666            r = None 
    6767            if dispatch_func: 
     
    120120 
    121121        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' 
    123126 
    124127#########  History commands 
  • pyreadline/branches/refactor/pyreadline/rlmain.py

    r1877 r1895  
    88#***************************************************************************** 
    99''' an attempt to implement readline for Python in Python using ctypes''' 
    10  
    11 import string 
    12 import math 
    13 import sys 
     10import sys,os,re 
    1411from glob import glob 
    15 import os,pdb 
    16 import re 
    17 import traceback 
    18 import operator 
    19 import exceptions 
    2012 
    2113import clipboard,logger,console 
     
    3628else: 
    3729    default_prompt="" 
     30    import pdb 
    3831 
    3932 
     
    144137        except: 
    145138            log('error') 
    146             traceback.print_exc() 
    147139            raise 
    148140 
     
    269261            pass 
    270262        elif self.bell_style == 'visible': 
    271             raise exceptions.NotImplementedError("Bellstyle visible is not implemented yet.") 
     263            raise NotImplementedError("Bellstyle visible is not implemented yet.") 
    272264        elif self.bell_style == 'audible': 
    273265            self.console.bell() 
  • pyreadline/branches/refactor/pyreadline/test/emacs_test.py

    r1877 r1895  
    1616 
    1717from common import * 
     18from pyreadline.logger import log_sock 
     19import pyreadline.logger as logger 
     20logger.sock_silent=True 
     21logger.show_event=["debug"] 
     22 
    1823#---------------------------------------------------------------------- 
    1924 
     
    2934        self.completer_delims = ' ' 
    3035        self.tabstop = 4 
     36        self.mark_directories=False 
     37        self.show_all_if_ambiguous=False 
    3138         
    3239    def get_mock_console (self): 
     
    5461            dispatch_func = self.key_dispatch.get(keyinfo.tuple(),self.self_insert) 
    5562            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") 
    5764            dispatch_func (event) 
    58             log_sock("emacs readline from keyboard:%s->%s"%(keyinfo.tuple(),dispatch_func)) 
    5965            self.previous_func=dispatch_func 
    6066 
     
    318324        self.assert_line(r,'k',1) 
    319325 
    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         
    322353    def assert_line(self,r,line,cursor): 
    323354        self.assertEqual (r.line, line) 
     
    333364    tested=EmacsModeTest.tested_commands.keys()     
    334365    tested.sort() 
    335     print " Tested functions ".center(60,"-") 
    336     print "\n".join(tested) 
    337     print 
     366#    print " Tested functions ".center(60,"-") 
     367#    print "\n".join(tested) 
     368#    print 
    338369     
    339370    all_funcs=dict([(x.__name__,x) for x in EmacsModeTest().key_dispatch.values()])