Changeset 1834
- Timestamp:
- 10/19/06 14:35:35 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyreadline/branches/refactor/doc/ChangeLog
r1833 r1834 1 2006-10-19 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 * Adding argument handling. 3 * Adding argument to functions:forward_char, backward_char, forward_word, backward_word 4 forward_word_end, backward_word_end, beginning_of_line_extend_selection, end_of_line_extend_selection 5 forward_char_extend_selection, backward_char_extend_selection, forward_word_extend_selection, 6 backward_word_extend_selection, forward_word_end_extend_selection, backward_word_end_extend_selection, 7 delete_char, backward_delete_char, backward_delete_word, forward_delete_word, 8 1 9 2006-10-18 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 10 * Adding functionality to dump_functions pyreadline/branches/refactor/pyreadline/lineeditor/lineobj.py
r1832 r1834 416 416 self.selection_mark=-1 417 417 self.point=EndOfLine 418 419 def forward_char(self): 420 self.selection_mark=-1 421 self.point=NextChar 422 423 def backward_char(self): 424 self.selection_mark=-1 425 self.point=PrevChar 426 427 def forward_word(self): 428 self.selection_mark=-1 429 self.point=NextWordStart 418 419 def forward_char(self,argument=1): 420 if argument<0: 421 self.backward_char(-argument) 422 self.selection_mark=-1 423 for x in range(argument): 424 self.point=NextChar 425 426 def backward_char(self,argument=1): 427 if argument<0: 428 self.forward_char(-argument) 429 self.selection_mark=-1 430 for x in range(argument): 431 self.point=PrevChar 432 433 def forward_word(self,argument=1): 434 if argument<0: 435 self.backward_word(-argument) 436 self.selection_mark=-1 437 for x in range(argument): 438 self.point=NextWordStart 430 439 431 def forward_word_end(self): 432 self.selection_mark=-1 433 self.point=NextWordEnd 434 435 def backward_word(self): 436 self.selection_mark=-1 437 self.point=PrevWordStart 440 def backward_word(self,argument=1): 441 if argument<0: 442 self.forward_word(-argument) 443 self.selection_mark=-1 444 for x in range(argument): 445 self.point=PrevWordStart 446 447 def forward_word_end(self,argument=1): 448 if argument<0: 449 self.backward_word_end(-argument) 450 self.selection_mark=-1 451 for x in range(argument): 452 self.point=NextWordEnd 453 454 def backward_word_end(self,argument=1): 455 if argument<0: 456 self.forward_word_end(-argument) 457 self.selection_mark=-1 458 for x in range(argument): 459 self.point=NextWordEnd 438 460 439 461 ######### Movement select … … 447 469 self.selection_mark=self.point 448 470 self.point=EndOfLine 449 450 def forward_char_extend_selection(self): 471 472 def forward_char_extend_selection(self,argument=1): 473 if argument<0: 474 self.backward_char_extend_selection(-argument) 451 475 if self.enable_selection and self.selection_mark<0: 452 476 self.selection_mark=self.point 453 self.point=NextChar 454 455 def backward_char_extend_selection(self): 477 for x in range(argument): 478 self.point=NextChar 479 480 def backward_char_extend_selection(self,argument=1): 481 if argument<0: 482 self.forward_char_extend_selection(-argument) 456 483 if self.enable_selection and self.selection_mark<0: 457 484 self.selection_mark=self.point 458 self.point=PrevChar 459 460 def forward_word_extend_selection(self): 485 for x in range(argument): 486 self.point=PrevChar 487 488 def forward_word_extend_selection(self,argument=1): 489 if argument<0: 490 self.backward_word_extend_selection(-argument) 461 491 if self.enable_selection and self.selection_mark<0: 462 492 self.selection_mark=self.point 463 self.point=NextWordStart 493 for x in range(argument): 494 self.point=NextWordStart 464 495 465 def forward_word_end_extend_selection(self): 496 def backward_word_extend_selection(self,argument=1): 497 if argument<0: 498 self.forward_word_extend_selection(-argument) 466 499 if self.enable_selection and self.selection_mark<0: 467 500 self.selection_mark=self.point 468 self.point=NextWordEnd 501 for x in range(argument): 502 self.point=PrevWordStart 503 469 504 470 def backward_word_extend_selection(self): 505 def forward_word_end_extend_selection(self,argument=1): 506 if argument<0: 507 self.backward_word_end_extend_selection(-argument) 471 508 if self.enable_selection and self.selection_mark<0: 472 509 self.selection_mark=self.point 473 self.point=PrevWordStart 510 for x in range(argument): 511 self.point=NextWordEnd 512 513 def backward_word_end_extend_selection(self,argument=1): 514 if argument<0: 515 self.forward_word_end_extend_selection(-argument) 516 if self.enable_selection and self.selection_mark<0: 517 self.selection_mark=self.point 518 for x in range(argument): 519 self.point=PrevWordEnd 520 474 521 475 522 ######### delete … … 479 526 if self.selection_mark<self.point: 480 527 del self[self.selection_mark:self.point] 528 self.selection_mark=-1 481 529 else: 482 530 del self[self.point:self.selection_mark] 531 self.selection_mark=-1 483 532 return True 484 533 else: 534 self.selection_mark=-1 485 535 return False 486 self.selection_mark=-1 487 488 def delete_char(self): 489 if not self.delete_selection(): 536 537 def delete_char(self,argument=1): 538 if argument<0: 539 self.backward_delete_char(-argument) 540 if self.delete_selection(): 541 argument-=1 542 for x in range(argument): 490 543 del self[Point] 491 self.selection_mark=-1 492 493 def backward_delete_char(self): 494 if not self.delete_selection(): 544 545 def backward_delete_char(self,argument=1): 546 if argument<0: 547 self.delete_char(-argument) 548 if self.delete_selection(): 549 argument-=1 550 for x in range(argument): 495 551 if self.point>0: 496 552 self.backward_char() 497 553 self.delete_char() 498 self.selection_mark=-1 499 500 def backward_delete_word(self): 501 if not self.delete_selection(): 502 #del self[PrevWordEnd:Point] 554 555 def forward_delete_word(self,argument=1): 556 if argument<0: 557 self.backward_delete_word(-argument) 558 if self.delete_selection(): 559 argument-=1 560 for x in range(argument): 561 del self[Point:NextWordStart] 562 563 def backward_delete_word(self,argument=1): 564 if argument<0: 565 self.forward_delete_word(-argument) 566 if self.delete_selection(): 567 argument-=1 568 for x in range(argument): 503 569 del self[PrevWordStart:Point] 504 self.selection_mark=-1505 506 def forward_delete_word(self):507 if not self.delete_selection():508 #del self[PrevWordEnd:Point]509 del self[Point:NextWordStart]510 self.selection_mark=-1511 570 512 571 def delete_current_word(self): pyreadline/branches/refactor/pyreadline/modes/basemode.py
r1832 r1834 24 24 self.startup_hook=None 25 25 self.pre_input_hook=None 26 self.argument=1 27 self.prevargument=None 26 28 27 29 def __repr__(self): … … 39 41 return getattr(self.rlobj,x) 40 42 return g 43 44 def _argreset(self): 45 val=self.argument 46 self.argument=1 47 return val 48 argument_reset=property(_argreset) 41 49 42 50 l_buffer=property(*_gs("l_buffer")) … … 58 66 _clear_after=property(_g("_clear_after")) 59 67 _set_cursor=property(_g("_set_cursor")) 60 _print_prompt=property(_g("_print_prompt"))61 68 _update_prompt_pos=property(_g("_update_prompt_pos")) 62 69 _update_line=property(_g("_update_line")) … … 230 237 def forward_char(self, e): # (C-f) 231 238 '''Move forward a character. ''' 232 self.l_buffer.forward_char( )239 self.l_buffer.forward_char(self.argument_reset) 233 240 234 241 def backward_char(self, e): # (C-b) 235 242 '''Move back a character. ''' 236 self.l_buffer.backward_char( )243 self.l_buffer.backward_char(self.argument_reset) 237 244 238 245 def forward_word(self, e): # (M-f) 239 246 '''Move forward to the end of the next word. Words are composed of 240 247 letters and digits.''' 241 self.l_buffer.forward_word() 242 243 def forward_word_end(self, e): # (M-f) 244 '''Move forward to the end of the next word. Words are composed of 245 letters and digits.''' 246 self.l_buffer.forward_word_end() 248 self.l_buffer.forward_word(self.argument_reset) 247 249 248 250 def backward_word(self, e): # (M-b) 249 251 '''Move back to the start of the current or previous word. Words are 250 252 composed of letters and digits.''' 251 self.l_buffer.backward_word() 252 253 253 self.l_buffer.backward_word(self.argument_reset) 254 255 def forward_word_end(self, e): # () 256 '''Move forward to the end of the next word. Words are composed of 257 letters and digits.''' 258 self.l_buffer.forward_word_end(self.argument_reset) 259 260 def backward_word_end(self, e): # () 261 '''Move forward to the end of the next word. Words are composed of 262 letters and digits.''' 263 self.l_buffer.backward_word_end(self.argument_reset) 264 265 ### Movement with extend selection 254 266 def beginning_of_line_extend_selection(self, e): # 255 267 '''Move to the start of the current line. ''' 256 self.l_buffer.beginning_of_line_extend_selection( )268 self.l_buffer.beginning_of_line_extend_selection(self.argument_reset) 257 269 258 270 def end_of_line_extend_selection(self, e): # 259 271 '''Move to the end of the line. ''' 260 self.l_buffer.end_of_line_extend_selection( )272 self.l_buffer.end_of_line_extend_selection(self.argument_reset) 261 273 262 274 def forward_char_extend_selection(self, e): # 263 275 '''Move forward a character. ''' 264 self.l_buffer.forward_char_extend_selection( )276 self.l_buffer.forward_char_extend_selection(self.argument_reset) 265 277 266 278 def backward_char_extend_selection(self, e): # 267 279 '''Move back a character. ''' 268 self.l_buffer.backward_char_extend_selection( )280 self.l_buffer.backward_char_extend_selection(self.argument_reset) 269 281 270 282 def forward_word_extend_selection(self, e): # 271 283 '''Move forward to the end of the next word. Words are composed of 272 284 letters and digits.''' 273 self.l_buffer.forward_word_extend_selection() 274 275 def forward_word_end_extend_selection(self, e): # 276 '''Move forward to the end of the next word. Words are composed of 277 letters and digits.''' 278 self.l_buffer.forward_word_end_extend_selection() 285 self.l_buffer.forward_word_extend_selection(self.argument_reset) 279 286 280 287 def backward_word_extend_selection(self, e): # 281 288 '''Move back to the start of the current or previous word. Words are 282 289 composed of letters and digits.''' 283 self.l_buffer.backward_word_extend_selection() 284 290 self.l_buffer.backward_word_extend_selection(self.argument_reset) 291 292 def forward_word_end_extend_selection(self, e): # 293 '''Move forward to the end of the next word. Words are composed of 294 letters and digits.''' 295 self.l_buffer.forward_word_end_extend_selection(self.argument_reset) 296 297 def backward_word_end_extend_selection(self, e): # 298 '''Move forward to the end of the next word. Words are composed of 299 letters and digits.''' 300 self.l_buffer.forward_word_end_extend_selection(self.argument_reset) 301 302 303 ######## Change case 285 304 286 305 def upcase_word(self, e): # (M-u) … … 300 319 301 320 302 321 ######## 303 322 def clear_screen(self, e): # (C-l) 304 323 '''Clear the screen and redraw the current line, leaving the current … … 322 341 the line, there are no characters in the line, and the last 323 342 character typed was not bound to delete-char, then return EOF.''' 324 self.l_buffer.delete_char( )343 self.l_buffer.delete_char(self.argument_reset) 325 344 326 345 def backward_delete_char(self, e): # (Rubout) 327 346 '''Delete the character behind the cursor. A numeric argument means 328 347 to kill the characters instead of deleting them.''' 329 self.l_buffer.backward_delete_char( )348 self.l_buffer.backward_delete_char(self.argument_reset) 330 349 331 350 def backward_delete_word(self, e): # (Control-Rubout) 332 351 '''Delete the character behind the cursor. A numeric argument means 333 352 to kill the characters instead of deleting them.''' 334 self.l_buffer.backward_delete_word( )353 self.l_buffer.backward_delete_word(self.argument_reset) 335 354 336 355 def forward_delete_word(self, e): # (Control-Delete) 337 356 '''Delete the character behind the cursor. A numeric argument means 338 357 to kill the characters instead of deleting them.''' 339 self.l_buffer.forward_delete_word( )358 self.l_buffer.forward_delete_word(self.argument_reset) 340 359 341 360 def delete_horizontal_space(self, e): # () pyreadline/branches/refactor/pyreadline/modes/emacs.py
r1832 r1834 357 357 '''Add this digit to the argument already accumulating, or start a 358 358 new argument. M-- starts a negative argument.''' 359 pass 359 args=e.char 360 361 c = self.console 362 line = self.l_buffer.get_line_text() 363 oldprompt=self.prompt 364 def nop(e): 365 pass 366 while 1: 367 x, y = self.prompt_end_pos 368 c.pos(0, y) 369 self.prompt="(arg: %s) "%args 370 self._print_prompt() 371 self._update_line() 372 373 event = c.getkeypress() 374 if event.keyinfo.keyname == 'enter': 375 break 376 elif event.char in "0123456789": 377 args+=event.char 378 else: 379 self.argument=int(args) 380 keyinfo=event.keyinfo.tuple() 381 if len(keyinfo[-1])>1: 382 default=nop 383 else: 384 default=self.self_insert 385 dispatch_func = self.key_dispatch.get(keyinfo,default) 386 log_sock("%s|%s"%(dispatch_func,str(keyinfo))) 387 dispatch_func(event) 388 break 389 log_sock("END arg=%s"%(self.argument)) 390 self.prompt=oldprompt 391 x, y = self.prompt_end_pos 392 c.pos(0, y) 393 self._print_prompt() 394 self._update_line() 395 396 397 360 398 361 399 def universal_argument(self, e): # ()
