Changeset 2852
- Timestamp:
- 10/30/07 15:02:10 (1 year ago)
- Files:
-
- pyreadline/trunk/doc/ChangeLog (modified) (1 diff)
- pyreadline/trunk/pyreadline/lineeditor/history.py (modified) (5 diffs)
- pyreadline/trunk/pyreadline/test/history_test.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyreadline/trunk/doc/ChangeLog
r2849 r2852 1 2007-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 1 5 2007-10-29 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 6 * Patch as provided by pan. Changed ensure_text to decode to pyreadline/trunk/pyreadline/lineeditor/history.py
r2849 r2852 23 23 24 24 from pyreadline.logger import log_sock 25 26 _ignore_leading_spaces=False 25 27 26 28 class LineHistory(object): … … 122 124 if startpos is None: 123 125 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)] 125 131 if res: 126 132 self.history_cursor-=res[0][0] … … 131 137 if startpos is None: 132 138 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)] 134 143 if res: 135 144 self.history_cursor+=res[0][0] … … 198 207 result=lineobj.ReadLineTextBuffer(h,point=len(h.get_line_text())) 199 208 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())): 201 210 self.history_cursor = hc 202 211 result=lineobj.ReadLineTextBuffer(h,point=partial.point) … … 233 242 return q 234 243 235 236 237 244 if __name__=="__main__": 238 245 q=LineHistory()
