Changeset 1836

Show
Ignore:
Timestamp:
10/22/06 12:29:30 (2 years ago)
Author:
jstenar
Message:

pyreadline-refactor: Fixes to make tests pass. One failure remains in vi_test.py

Files:

Legend:

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

    r1834 r1836  
     12006-10-19 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
     2    * Fixed bug in history_search_* 
     3    * Fixed bug in beginning_of_line_extend_selection and end_of_line_extend_selection 
     4    * Fixd bugs to make vi_test work again, one test failure remains 
     5    * 
     6     
     7     
    182006-10-19 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
    29    * Adding argument handling. 
  • pyreadline/branches/refactor/pyreadline/keysyms/common.py

    r1775 r1836  
    9898        else: 
    9999            if len(keydescr) > 1: 
    100                 if keydescr.strip() in validkey: 
    101                     keyinfo.keyname=keydescr.strip() 
     100                if keydescr.strip().lower() in validkey: 
     101                    keyinfo.keyname=keydescr.strip().lower() 
    102102                    keyinfo.char="" 
    103103                else: 
  • pyreadline/branches/refactor/pyreadline/lineeditor/history.py

    r1830 r1836  
    102102        if startpos is None: 
    103103            startpos=self.history_cursor 
    104         res=[(idx,line)  for idx,line in enumerate(self.history[startpos:0:-1]) if searchfor in line
     104        res=[(idx,line)  for idx,line in enumerate(self.history[startpos:0:-1]) if line.startswith(searchfor)
    105105        if res: 
    106106            self.history_cursor-=res[0][0] 
     
    111111        if startpos is None: 
    112112            startpos=self.history_cursor 
    113         res=[(idx,line) for idx,line in enumerate(self.history[startpos:]) if searchfor in line
     113        res=[(idx,line) for idx,line in enumerate(self.history[startpos:]) if line.startswith(searchfor)
    114114        if res: 
    115115            self.history_cursor+=res[0][0] 
     
    168168                self.lastcommand != self.history_search_backward): 
    169169            self.query = ''.join(partial[0:partial.point].get_line_text()) 
    170         hcstart=max(self.history_cursor-1,0)  
     170        hcstart=max(self.history_cursor,0)  
    171171        hc = self.history_cursor + direction 
    172172        while (direction < 0 and hc >= 0) or (direction > 0 and hc < len(self.history)): 
     
    211211    q=LineHistory() 
    212212    RL=lineobj.ReadLineTextBuffer 
    213     q.add_history(RL("apan")) 
    214     q.add_history(RL("apbn")) 
    215     q.add_history(RL("apcn")) 
    216     q.add_history(RL("apdn")) 
    217     q.add_history(RL("apen")) 
     213    q.add_history(RL("aaaa")) 
     214    q.add_history(RL("aaba")) 
     215    q.add_history(RL("aaca")) 
     216    q.add_history(RL("akca")) 
     217    q.add_history(RL("bbb")) 
     218    q.add_history(RL("ako")) 
  • pyreadline/branches/refactor/pyreadline/logger.py

    r1832 r1836  
    3030show_event=["bound_function"] 
    3131 
     32sock_silent=False 
     33 
    3234def log_sock(s,event_type=None): 
    33     if event_type is None: 
    34         logsocket.sendto(s,(host,port)) 
    35     elif event_type in show_event: 
    36         logsocket.sendto(s,(host,port)) 
     35    if sock_silent: 
     36        pass 
    3737    else: 
    38         pass 
    39      
     38        if event_type is None: 
     39            logsocket.sendto(s,(host,port)) 
     40        elif event_type in show_event: 
     41            logsocket.sendto(s,(host,port)) 
     42        else: 
     43            pass 
     44 
    4045     
    4146log_sock("Starting pyreadline") 
  • pyreadline/branches/refactor/pyreadline/modes/basemode.py

    r1834 r1836  
    266266    def beginning_of_line_extend_selection(self, e): #  
    267267        '''Move to the start of the current line. ''' 
    268         self.l_buffer.beginning_of_line_extend_selection(self.argument_reset
     268        self.l_buffer.beginning_of_line_extend_selection(
    269269 
    270270    def end_of_line_extend_selection(self, e): #  
    271271        '''Move to the end of the line. ''' 
    272         self.l_buffer.end_of_line_extend_selection(self.argument_reset
     272        self.l_buffer.end_of_line_extend_selection(
    273273 
    274274    def forward_char_extend_selection(self, e): #  
  • pyreadline/branches/refactor/pyreadline/modes/vi.py

    r1419 r1836  
    1010import os 
    1111import pyreadline.logger as logger 
    12 from   pyreadline.logger import log 
     12from   pyreadline.logger import log,log_sock 
    1313import pyreadline.lineeditor.lineobj as lineobj 
    1414import pyreadline.lineeditor.history as history 
     
    3939                    raise EOFError 
    4040 
    41             dispatch_func = self.key_dispatch.get(event.keyinfo,self.self_insert
    42             log("readline from keyboard:%s"%(event.keyinfo,)) 
     41            dispatch_func = self.key_dispatch.get(event.keyinfo.tuple(),self.vi_key
     42            log("readline from keyboard:%s->%s"%(event.keyinfo.tuple(),dispatch_func)) 
    4343            r = None 
    4444            if dispatch_func: 
  • pyreadline/branches/refactor/pyreadline/test/common.py

    r1267 r1836  
    99from pyreadline import keysyms 
    1010from pyreadline.lineeditor import lineobj 
    11 from pyreadline.keysyms import key_text_to_keyinfo 
     11from pyreadline.keysyms.common import make_KeyPress_from_keydescr 
     12 
    1213import unittest 
    1314class MockReadline: 
     
    5253class Event: 
    5354    def __init__ (self, char): 
    54         self.char = char 
     55        if char=="escape": 
     56            self.char='\x1b' 
     57        elif char=="backspace": 
     58            self.char='\x08' 
     59        else: 
     60            self.char = char 
    5561 
    5662def keytext_to_keyinfo_and_event (keytext): 
    57     keyinfo = keysyms.key_text_to_keyinfo (keytext) 
     63    keyinfo = keysyms.common.make_KeyPress_from_keydescr (keytext) 
    5864    if len(keytext) == 3 and keytext[0] == '"' and keytext[2] == '"': 
    5965        event = Event (keytext[1]) 
    6066    else: 
    61         event = Event (chr (keyinfo [3])
     67        event = Event (keyinfo.tuple() [3]
    6268    return keyinfo, event 
     69 
     70 
    6371 
    6472#override runTests from from main in unittest to remove sys.exit call 
  • pyreadline/branches/refactor/pyreadline/test/emacs_test.py

    r1267 r1836  
    5252        for key in lst_key: 
    5353            keyinfo, event = keytext_to_keyinfo_and_event (key) 
    54             dispatch_func = self.key_dispatch.get(keyinfo,self.self_insert) 
     54            dispatch_func = self.key_dispatch.get(keyinfo.tuple(),self.self_insert) 
    5555            self.tested_commands[dispatch_func.__name__]=dispatch_func 
    5656#            print key,dispatch_func.__name__ 
    5757            dispatch_func (event) 
     58            log_sock("emacs readline from keyboard:%s->%s"%(keyinfo.tuple(),dispatch_func)) 
    5859            self.previous_func=dispatch_func 
    5960 
  • pyreadline/branches/refactor/pyreadline/test/vi_test.py

    r1267 r1836  
    77#***************************************************************************** 
    88 
    9 import sys, unittest 
     9import sys, unittest,pdb 
    1010sys.path.append ('../..') 
    1111from pyreadline.modes.vi import * 
    1212from pyreadline import keysyms 
    1313from pyreadline.lineeditor import lineobj 
     14from pyreadline.logger import log_sock 
     15import pyreadline.logger as logger 
     16from common import * 
    1417 
    1518from common import * 
     
    5053        for key in lst_key: 
    5154            keyinfo, event = keytext_to_keyinfo_and_event (key) 
    52             dispatch_func = self.key_dispatch [keyinfo] 
     55            dispatch_func = self.key_dispatch.get( keyinfo.tuple(),self.vi_key) 
    5356            self.tested_commands[dispatch_func.__name__]=dispatch_func 
    5457            dispatch_func (event)