Changeset 1843
- Timestamp:
- 10/25/06 15:40:17 (2 years ago)
- Files:
-
- pyreadline/branches/refactor/doc/ChangeLog (modified) (1 diff)
- pyreadline/branches/refactor/pyreadline/console/ansi.py (modified) (1 diff)
- pyreadline/branches/refactor/pyreadline/console/console.py (modified) (2 diffs)
- pyreadline/branches/refactor/pyreadline/lineeditor/history.py (modified) (3 diffs)
- pyreadline/branches/refactor/pyreadline/modes/basemode.py (modified) (1 diff)
- pyreadline/branches/refactor/pyreadline/rlmain.py (modified) (2 diffs)
- pyreadline/branches/refactor/pyreadline/test/emacs_test.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyreadline/branches/refactor/doc/ChangeLog
r1836 r1843 1 2006-10-25 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 * port set_text_color and set_prompt_color config file options from trunk 3 * Fix bug in history search and add tests for the case. 4 * port ansi color changes from trunk 5 1 6 2006-10-19 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 7 * Fixed bug in history_search_* 3 8 * Fixed bug in beginning_of_line_extend_selection and end_of_line_extend_selection 4 9 * Fixd bugs to make vi_test work again, one test failure remains 5 *6 7 10 8 11 2006-10-19 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> pyreadline/branches/refactor/pyreadline/console/ansi.py
r1775 r1843 85 85 m = escape_parts.match(chunk) 86 86 if m: 87 for part in m.group(1).split(";"): 87 parts=m.group(1).split(";") 88 if len(parts)==1 and parts[0]=="0": 89 attr = self.defaultstate.copy() 90 continue 91 for part in parts: 88 92 if part == "0": # No text attribute 89 93 attr = self.defaultstate.copy() 94 attr.bold=False 90 95 elif part == "7": # switch on reverse 91 96 attr.inverse=True pyreadline/branches/refactor/pyreadline/console/console.py
r1775 r1843 189 189 self.defaultstate.winattr=info.wAttributes 190 190 self.ansiwriter=AnsiWriter(self.defaultstate) 191 191 # self.ansiwriter.defaultstate.bold=False 192 192 193 background = self.attr & 0xf0 193 194 for escape in self.escape_to_color: … … 344 345 345 346 def write_color(self, text, attr=None): 347 log_sock(text) 348 log_sock("%s"%attr) 346 349 n,res= self.ansiwriter.write_color(text,attr) 347 350 junk = c_int(0) 348 351 for attr,chunk in res: 352 log_sock("%s:%s"%(attr,chunk)) 349 353 log(str(attr)) 350 354 log(str(chunk)) pyreadline/branches/refactor/pyreadline/lineeditor/history.py
r1836 r1843 27 27 def __init__(self): 28 28 self.history=[] 29 self. history_length=10030 self. history_cursor=029 self._history_length=100 30 self._history_cursor=0 31 31 self.history_filename=os.path.expanduser('~/.history') 32 32 self.lastcommand=None … … 34 34 35 35 def get_history_length(self): 36 return self.history_length 36 value=self._history_length 37 log_sock("get_history_length:%d"%value,"history") 38 return value 37 39 38 40 def set_history_length(self,value): 39 self.history_length=value 41 log_sock("set_history_length: old:%d new:%d"%(self._history_length,value),"history") 42 self._history_length=value 43 44 def get_history_cursor(self): 45 value=self._history_cursor 46 log_sock("get_history_cursor:%d"%value,"history") 47 return value 48 49 def set_history_cursor(self,value): 50 log_sock("set_history_cursor: old:%d new:%d"%(self._history_cursor,value),"history") 51 self._history_cursor=value 52 53 history_length=property(get_history_length,set_history_length) 54 history_cursor=property(get_history_cursor,set_history_cursor) 40 55 41 56 def read_history_file(self, filename=None): … … 185 200 pass 186 201 elif hc>=len(self.history) and not self.query: 202 self.history_cursor=len(self.history) 187 203 return lineobj.ReadLineTextBuffer("",point=0) 188 204 elif self.history[hcstart].get_line_text().startswith(self.query) and self.query: pyreadline/branches/refactor/pyreadline/modes/basemode.py
r1836 r1843 364 364 def self_insert(self, e): # (a, b, A, 1, !, ...) 365 365 '''Insert yourself. ''' 366 if ord(e.char)!=0: #don't insert null character in buffer, can happen with dead keys. 366 367 if e.char and ord(e.char)!=0: #don't insert null character in buffer, can happen with dead keys. 367 368 self.insert_text(e.char) 368 369 pyreadline/branches/refactor/pyreadline/rlmain.py
r1832 r1843 367 367 logger.log("STARTING LOG") 368 368 # print release.branch 369 def set_prompt_color(color): 370 trtable={"black":0,"darkred":4,"darkgreen":2,"darkyellow":6,"darkblue":1,"darkmagenta":5,"darkcyan":3,"gray":7, 371 "red":4+8,"green":2+8,"yellow":6+8,"blue":1+8,"magenta":5+8,"cyan":3+8,"white":7+8} 372 self.prompt_color=trtable.get(color.lower(),7) 373 374 def set_input_color(color): 375 trtable={"black":0,"darkred":4,"darkgreen":2,"darkyellow":6,"darkblue":1,"darkmagenta":5,"darkcyan":3,"gray":7, 376 "red":4+8,"green":2+8,"yellow":6+8,"blue":1+8,"magenta":5+8,"cyan":3+8,"white":7+8} 377 self.command_color=trtable.get(color.lower(),7) 369 378 loc={"branch":release.branch, 379 "version":release.version, 370 380 "mode":mode, 371 381 "modes":modes, … … 381 391 "debug_output":debug_output, 382 392 "history_filename":sethistoryfilename, 383 "history_length":sethistorylength} 393 "history_length":sethistorylength, 394 "set_prompt_color":set_prompt_color, 395 "set_input_color":set_input_color, 396 } 384 397 if os.path.isfile(inputrcpath): 385 398 try: pyreadline/branches/refactor/pyreadline/test/emacs_test.py
r1836 r1843 46 46 47 47 def input (self, keytext): 48 if keytext[0 ] == '"' and keytext[-1] == '"':48 if keytext[0:1] == '"' and keytext[-1:] == '"': 49 49 lst_key = ['"%s"' % c for c in keytext[1:-1]] 50 50 else: … … 255 255 r.add_history ('bbb') 256 256 r.add_history ('ako') 257 self.assert Equal (r.line, '')257 self.assert_line(r,'',0) 258 258 r.input ('"a"') 259 259 r.input ('Up') 260 self.assertEqual (r.line, 'ako') 261 self.assertEqual (r.line_cursor, 1) 262 r.input ('Up') 263 self.assertEqual (r.line, 'akca') 264 self.assertEqual (r.line_cursor, 1) 265 r.input ('Up') 266 self.assertEqual (r.line, 'aaca') 267 self.assertEqual (r.line_cursor, 1) 268 r.input ('Up') 269 self.assertEqual (r.line, 'aaba') 270 self.assertEqual (r.line_cursor, 1) 271 r.input ('Up') 272 self.assertEqual (r.line, 'aaaa') 273 self.assertEqual (r.line_cursor, 1) 260 self.assert_line(r,'ako',1) 261 r.input ('Up') 262 self.assert_line(r,'akca',1) 263 r.input ('Up') 264 self.assert_line(r,'aaca',1) 265 r.input ('Up') 266 self.assert_line(r,'aaba',1) 267 r.input ('Up') 268 self.assert_line(r,'aaaa',1) 274 269 r.input ('Right') 275 self.assertEqual (r.line, 'aaaa') 276 self.assertEqual (r.line_cursor, 2) 277 r.input ('Down') 278 self.assertEqual (r.line, 'aaba') 279 self.assertEqual (r.line_cursor, 2) 280 r.input ('Down') 281 self.assertEqual (r.line, 'aaca') 282 self.assertEqual (r.line_cursor, 2) 283 r.input ('Down') 284 self.assertEqual (r.line, 'aaca') 285 self.assertEqual (r.line_cursor, 2) 270 self.assert_line(r,'aaaa',2) 271 r.input ('Down') 272 self.assert_line(r,'aaba',2) 273 r.input ('Down') 274 self.assert_line(r,'aaca',2) 275 r.input ('Down') 276 self.assert_line(r,'aaca',2) 286 277 r.input ('Left') 287 278 r.input ('Left') 288 279 r.input ('Down') 289 280 r.input ('Down') 290 self.assertEqual (r.line, 'bbb') 291 self.assertEqual (r.line_cursor, 3) 281 self.assert_line(r,'bbb',3) 292 282 r.input ('Left') 293 self.assertEqual (r.line, 'bbb') 294 self.assertEqual (r.line_cursor, 2) 295 r.input ('Down') 296 self.assertEqual (r.line, 'bbb') 297 self.assertEqual (r.line_cursor, 2) 298 r.input ('Up') 299 self.assertEqual (r.line, 'bbb') 300 self.assertEqual (r.line_cursor, 2) 301 283 self.assert_line(r,'bbb',2) 284 r.input ('Down') 285 self.assert_line(r,'bbb',2) 286 r.input ('Up') 287 self.assert_line(r,'bbb',2) 288 289 290 def test_history_3 (self): 291 r = EmacsModeTest () 292 r.add_history ('aaaa') 293 r.add_history ('aaba') 294 r.add_history ('aaca') 295 r.add_history ('akca') 296 r.add_history ('bbb') 297 r.add_history ('ako') 298 self.assert_line(r,'',0) 299 r.input ('') 300 r.input ('Up') 301 self.assert_line(r,'ako',3) 302 r.input ('Down') 303 self.assert_line(r,'',0) 304 r.input ('Up') 305 self.assert_line(r,'ako',3) 306 307 308 309 def assert_line(self,r,line,cursor): 310 self.assertEqual (r.line, line) 311 self.assertEqual (r.line_cursor, cursor) 312 302 313 #---------------------------------------------------------------------- 303 314 # utility functions
