Changeset 2852

Show
Ignore:
Timestamp:
10/30/07 15:02:10 (1 year ago)
Author:
jstenar
Message:

pyreadline: Adding test suite for history buffer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyreadline/trunk/doc/ChangeLog

    r2849 r2852  
     12007-10-30 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
     2    * Add tests for history buffer. Add ignore_leading_spaces option for  
     3      history searches for forward_search_history, and reverse_search_history. 
     4     
    152007-10-29 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
    26    * Patch as provided by pan. Changed ensure_text to decode to  
  • pyreadline/trunk/pyreadline/lineeditor/history.py

    r2849 r2852  
    2323 
    2424from pyreadline.logger import log_sock 
     25 
     26_ignore_leading_spaces=False 
    2527 
    2628class LineHistory(object): 
     
    122124        if startpos is None: 
    123125            startpos=self.history_cursor 
    124         res=[(idx,line)  for idx,line in enumerate(self.history[startpos:0:-1]) if line.startswith(searchfor)] 
     126        if _ignore_leading_spaces: 
     127            res=[(idx,line.lstrip())  for idx,line in enumerate(self.history[startpos:0:-1]) if line.lstrip().startswith(searchfor.lstrip())] 
     128            logger.log_sock(res) 
     129        else: 
     130            res=[(idx,line)  for idx,line in enumerate(self.history[startpos:0:-1]) if line.startswith(searchfor)] 
    125131        if res: 
    126132            self.history_cursor-=res[0][0] 
     
    131137        if startpos is None: 
    132138            startpos=self.history_cursor 
    133         res=[(idx,line) for idx,line in enumerate(self.history[startpos:]) if line.startswith(searchfor)] 
     139        if _ignore_leading_spaces: 
     140            res=[(idx,line.lstrip()) for idx,line in enumerate(self.history[startpos:]) if line.lstrip().startswith(searchfor.lstrip())] 
     141        else: 
     142            res=[(idx,line) for idx,line in enumerate(self.history[startpos:]) if line.startswith(searchfor)] 
    134143        if res: 
    135144            self.history_cursor+=res[0][0] 
     
    198207                    result=lineobj.ReadLineTextBuffer(h,point=len(h.get_line_text())) 
    199208                    return result 
    200                 elif h.get_line_text().startswith(self.query) and h != partial.get_line_text(): 
     209                elif (h.get_line_text().startswith(self.query) and (h != partial.get_line_text())): 
    201210                    self.history_cursor = hc 
    202211                    result=lineobj.ReadLineTextBuffer(h,point=partial.point) 
     
    233242        return q 
    234243 
    235  
    236          
    237244if __name__=="__main__": 
    238245    q=LineHistory()