Skip to content

Commit da6150b

Browse files
PeriGKthomasballinger
authored andcommitted
Initial changes to implement ctrl+o functionality
1 parent 8ac18df commit da6150b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,13 @@ def request_undo(self, n=1):
483483
"""Like request_refresh, but for undo request events."""
484484
raise NotImplementedError
485485

486-
def on_suspend():
486+
def on_suspend(self):
487487
"""Will be called on sigtstp.
488488
489489
Do whatever cleanup would allow the user to use other programs."""
490490
raise NotImplementedError
491491

492-
def after_suspend():
492+
def after_suspend(self):
493493
"""Will be called when process foregrounded after suspend.
494494
495495
See to it that process_event is called with None to trigger a refresh
@@ -675,6 +675,8 @@ def process_key_event(self, e):
675675
self.down_one_line()
676676
elif e in ("<Ctrl-d>",):
677677
self.on_control_d()
678+
elif e in ("<Ctrl-o>",):
679+
self.on_control_o()
678680
elif e in ("<Esc+.>",):
679681
self.get_last_word()
680682
elif e in key_dispatch[self.config.reverse_incremental_search_key]:
@@ -844,6 +846,13 @@ def on_control_d(self):
844846
self.current_line = (self.current_line[:self.cursor_offset] +
845847
self.current_line[(self.cursor_offset + 1):])
846848

849+
def on_control_o(self):
850+
next_idx = -self.rl_history.index + 1
851+
next = self.rl_history.entries[next_idx]
852+
self.on_enter()
853+
print("Next is : " + next)
854+
self._set_current_line(next)
855+
847856
def cut_to_buffer(self):
848857
self.cut_buffer = self.current_line[self.cursor_offset:]
849858
self.current_line = self.current_line[:self.cursor_offset]
@@ -958,18 +967,24 @@ def toggle_file_watch(self):
958967

959968
# Handler Helpers
960969
def add_normal_character(self, char):
970+
print("Char is :" + str(char))
961971
if len(char) > 1 or is_nop(char):
962972
return
963973
if self.incr_search_mode:
974+
print("Incr search mode")
964975
self.add_to_incremental_search(char)
965976
else:
977+
print("In here current line: " + self.current_line)
978+
966979
self._set_current_line((self.current_line[:self.cursor_offset] +
967980
char +
968981
self.current_line[self.cursor_offset:]),
969982
update_completion=False,
970983
reset_rl_history=False,
971984
clear_special_mode=False)
972985
self.cursor_offset += 1
986+
987+
print("but here: " + self.current_line)
973988
if (self.config.cli_trim_prompts and
974989
self.current_line.startswith(self.ps1)):
975990
self.current_line = self.current_line[4:]
@@ -1021,6 +1036,7 @@ def push(self, line, insert_into_history=True):
10211036
10221037
If the interpreter successfully runs the code, clear the buffer
10231038
"""
1039+
10241040
if self.paste_mode:
10251041
self.saved_indent = 0
10261042
else:
@@ -1187,6 +1203,7 @@ def current_line_formatted(self):
11871203
self.old_fs = fs
11881204
return fs
11891205

1206+
11901207
@property
11911208
def lines_for_display(self):
11921209
"""All display lines (wrapped, colored, with prompts)"""

0 commit comments

Comments
 (0)