Show More
@@ -401,17 +401,28 b' class ConsoleWidget(editwindow.EditWindow):' | |||||
401 | catched = True |
|
401 | catched = True | |
402 |
|
402 | |||
403 | elif event.KeyCode in (wx.WXK_LEFT, wx.WXK_BACK): |
|
403 | elif event.KeyCode in (wx.WXK_LEFT, wx.WXK_BACK): | |
404 | if not self._keep_cursor_in_buffer(): |
|
404 | if not self._keep_cursor_in_buffer(self.GetCurrentPos() - 1): | |
|
405 | event.Skip() | |||
|
406 | catched = True | |||
|
407 | ||||
|
408 | elif event.KeyCode == wx.WXK_RIGHT: | |||
|
409 | if not self._keep_cursor_in_buffer(self.GetCurrentPos() + 1): | |||
|
410 | event.Skip() | |||
|
411 | catched = True | |||
|
412 | ||||
|
413 | ||||
|
414 | elif event.KeyCode == wx.WXK_DELETE: | |||
|
415 | if not self._keep_cursor_in_buffer(self.GetCurrentPos() - 1): | |||
405 | event.Skip() |
|
416 | event.Skip() | |
406 | catched = True |
|
417 | catched = True | |
407 |
|
418 | |||
408 | if skip and not catched: |
|
419 | if skip and not catched: | |
409 | # Put the cursor back in the edit region |
|
420 | # Put the cursor back in the edit region | |
410 | if not self._keep_cursor_in_buffer(): |
|
421 | if not self._keep_cursor_in_buffer(): | |
411 | if (self.GetCurrentPos() == self.GetLength() |
|
422 | if not (self.GetCurrentPos() == self.GetLength() | |
412 | and event.KeyCode == wx.WXK_DELETE): |
|
423 | and event.KeyCode == wx.WXK_DELETE): | |
413 | pass |
|
|||
414 | event.Skip() |
|
424 | event.Skip() | |
|
425 | catched = True | |||
415 |
|
426 | |||
416 | return catched |
|
427 | return catched | |
417 |
|
428 | |||
@@ -424,7 +435,7 b' class ConsoleWidget(editwindow.EditWindow):' | |||||
424 | self._keep_cursor_in_buffer() |
|
435 | self._keep_cursor_in_buffer() | |
425 |
|
436 | |||
426 |
|
437 | |||
427 | def _keep_cursor_in_buffer(self): |
|
438 | def _keep_cursor_in_buffer(self, pos=None): | |
428 | """ Checks if the cursor is where it is allowed to be. If not, |
|
439 | """ Checks if the cursor is where it is allowed to be. If not, | |
429 | put it back. |
|
440 | put it back. | |
430 |
|
441 | |||
@@ -438,11 +449,19 b' class ConsoleWidget(editwindow.EditWindow):' | |||||
438 | WARNING: This does proper checks only for horizontal |
|
449 | WARNING: This does proper checks only for horizontal | |
439 | movements. |
|
450 | movements. | |
440 | """ |
|
451 | """ | |
|
452 | if pos is None: | |||
441 |
current_pos |
|
453 | current_pos = self.GetCurrentPos() | |
|
454 | else: | |||
|
455 | current_pos = pos | |||
442 | if current_pos < self.current_prompt_pos: |
|
456 | if current_pos < self.current_prompt_pos: | |
443 | self.GotoPos(self.current_prompt_pos) |
|
457 | self.GotoPos(self.current_prompt_pos) | |
444 | return True |
|
458 | return True | |
445 | line, line_pos = self.GetCurLine() |
|
459 | line_num = self.LineFromPosition(current_pos) | |
|
460 | if not current_pos > self.GetLength(): | |||
|
461 | line_pos = self.GetColumn(current_pos) | |||
|
462 | else: | |||
|
463 | line_pos = self.GetColumn(self.GetLength()) | |||
|
464 | line = self.GetLine(line_num) | |||
446 | # Jump the continuation prompt |
|
465 | # Jump the continuation prompt | |
447 | continuation_prompt = self.continuation_prompt() |
|
466 | continuation_prompt = self.continuation_prompt() | |
448 | if ( line.startswith(continuation_prompt) |
|
467 | if ( line.startswith(continuation_prompt) | |
@@ -454,7 +473,13 b' class ConsoleWidget(editwindow.EditWindow):' | |||||
454 | len(continuation_prompt) - line_pos) |
|
473 | len(continuation_prompt) - line_pos) | |
455 | else: |
|
474 | else: | |
456 | # Jump back up |
|
475 | # Jump back up | |
457 |
self.GotoPos(self.GetLineEndPosition( |
|
476 | self.GotoPos(self.GetLineEndPosition(line_num-1)) | |
|
477 | return True | |||
|
478 | elif ( current_pos > self.GetLineEndPosition(line_num) | |||
|
479 | and not current_pos == self.GetLength()): | |||
|
480 | # Jump to next line | |||
|
481 | self.GotoPos(current_pos + 1 + | |||
|
482 | len(continuation_prompt)) | |||
458 | return True |
|
483 | return True | |
459 | return False |
|
484 | return False | |
460 |
|
485 |
General Comments 0
You need to be logged in to leave comments.
Login now