Show More
@@ -242,7 +242,9 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
242 | 242 | |
|
243 | 243 | |
|
244 | 244 | def continuation_prompt(self): |
|
245 | """Returns the current continuation prompt. | |
|
245 | """ Returns the current continuation prompt. | |
|
246 | We need to implement this method here to deal with the | |
|
247 | ascii escape sequences cleaning up. | |
|
246 | 248 | """ |
|
247 | 249 | # ASCII-less prompt |
|
248 | 250 | ascii_less = ''.join(self.color_pat.split(self.last_prompt)[2::2]) |
@@ -271,21 +273,6 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
271 | 273 | return self.GetSize()[0]/self.GetCharWidth() |
|
272 | 274 | |
|
273 | 275 | |
|
274 | ||
|
275 | #-------------------------------------------------------------------------- | |
|
276 | # EditWindow API | |
|
277 | #-------------------------------------------------------------------------- | |
|
278 | ||
|
279 | def OnUpdateUI(self, event): | |
|
280 | """ Override the OnUpdateUI of the EditWindow class, to prevent | |
|
281 | syntax highlighting both for faster redraw, and for more | |
|
282 | consistent look and feel. | |
|
283 | """ | |
|
284 | ||
|
285 | #-------------------------------------------------------------------------- | |
|
286 | # Styling API | |
|
287 | #-------------------------------------------------------------------------- | |
|
288 | ||
|
289 | 276 | def configure_scintilla(self): |
|
290 | 277 | |
|
291 | 278 | p = self.style |
@@ -461,7 +448,18 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
461 | 448 | self.SetEdgeMode(stc.STC_EDGE_LINE) |
|
462 | 449 | self.SetEdgeColumn(88) |
|
463 | 450 | |
|
464 | ||
|
451 | ||
|
452 | #-------------------------------------------------------------------------- | |
|
453 | # EditWindow API | |
|
454 | #-------------------------------------------------------------------------- | |
|
455 | ||
|
456 | def OnUpdateUI(self, event): | |
|
457 | """ Override the OnUpdateUI of the EditWindow class, to prevent | |
|
458 | syntax highlighting both for faster redraw, and for more | |
|
459 | consistent look and feel. | |
|
460 | """ | |
|
461 | ||
|
462 | ||
|
465 | 463 | #-------------------------------------------------------------------------- |
|
466 | 464 | # Private API |
|
467 | 465 | #-------------------------------------------------------------------------- |
@@ -572,6 +570,7 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
572 | 570 | self._keep_cursor_in_buffer() |
|
573 | 571 | |
|
574 | 572 | |
|
573 | # XXX: I need to avoid the problem of having an empty glass; | |
|
575 | 574 | def _keep_cursor_in_buffer(self, pos=None): |
|
576 | 575 | """ Checks if the cursor is where it is allowed to be. If not, |
|
577 | 576 | put it back. |
@@ -602,7 +601,7 b' class ConsoleWidget(editwindow.EditWindow):' | |||
|
602 | 601 | # Jump the continuation prompt |
|
603 | 602 | continuation_prompt = self.continuation_prompt() |
|
604 | 603 | if ( line.startswith(continuation_prompt) |
|
605 |
and line_pos < len(continuation_prompt) |
|
|
604 | and line_pos < len(continuation_prompt)): | |
|
606 | 605 | if line_pos < 2: |
|
607 | 606 | # We are at the beginning of the line, trying to move |
|
608 | 607 | # forward: jump forward. |
@@ -459,8 +459,36 b' class WxController(ConsoleWidget, PrefilterFrontEnd):' | |||
|
459 | 459 | wx.CallAfter(self._popup_completion, create=True) |
|
460 | 460 | else: |
|
461 | 461 | event.Skip() |
|
462 | elif event.KeyCode == wx.WXK_BACK: | |
|
463 | # If characters where erased, check if we have to | |
|
464 | # remove a line. | |
|
465 | # XXX: What about DEL? | |
|
466 | current_line, _ = self.CurLine | |
|
467 | current_pos = self.GetCurrentPos() | |
|
468 | current_line_number = self.LineFromPosition(current_pos) | |
|
469 | current_col = self.GetColumn(current_pos) | |
|
470 | len_prompt = len(self.continuation_prompt()) | |
|
471 | if ( current_line.startswith(self.continuation_prompt()) | |
|
472 | and current_col == len_prompt): | |
|
473 | print 'BACK', current_line, self.current_prompt_line, \ | |
|
474 | current_line_number | |
|
475 | new_lines = [] | |
|
476 | for line_num, line in enumerate( | |
|
477 | self.input_buffer.split('\n')): | |
|
478 | if (line_num + self.current_prompt_line == | |
|
479 | current_line_number): | |
|
480 | new_lines.append(line[len_prompt:]) | |
|
481 | else: | |
|
482 | new_lines.append('\n'+line) | |
|
483 | # The first character is '\n', due to the above | |
|
484 | # code: | |
|
485 | self.input_buffer = ''.join(new_lines)[1:] | |
|
486 | self.GotoPos(current_pos - 1 - len_prompt) | |
|
487 | else: | |
|
488 | ConsoleWidget._on_key_down(self, event, skip=skip) | |
|
462 | 489 | else: |
|
463 | 490 | ConsoleWidget._on_key_down(self, event, skip=skip) |
|
491 | ||
|
464 | 492 | |
|
465 | 493 | |
|
466 | 494 | def _on_key_up(self, event, skip=True): |
@@ -472,11 +500,15 b' class WxController(ConsoleWidget, PrefilterFrontEnd):' | |||
|
472 | 500 | wx.CallAfter(self._popup_completion, create=True) |
|
473 | 501 | else: |
|
474 | 502 | ConsoleWidget._on_key_up(self, event, skip=skip) |
|
475 | if (self.input_buffer.split('\n')[-1] == self.continuation_prompt() | |
|
476 | and self._input_state == 'readline'): | |
|
477 | # Make sure the continuation_prompt is followed by a whitespace | |
|
503 | # Make sure the continuation_prompts are always followed by a | |
|
504 | # whitespace | |
|
505 | new_lines = [] | |
|
506 | if self._input_state == 'readline': | |
|
478 | 507 | position = self.GetCurrentPos() |
|
479 |
self.input_buffer |
|
|
508 | for line in self.input_buffer.split('\n'): | |
|
509 | if not line == self.continuation_prompt()[:-1]: | |
|
510 | new_lines.append(line) | |
|
511 | self.input_buffer = '\n'.join(new_lines) | |
|
480 | 512 | self.GotoPos(position) |
|
481 | 513 | |
|
482 | 514 |
General Comments 0
You need to be logged in to leave comments.
Login now