MCPcopy Index your code
hub / github.com/bpython/bpython / process_key_event

Method process_key_event

bpython/curtsiesfrontend/repl.py:720–822  ·  view source on GitHub ↗
(self, e: str)

Source from the content-addressed store, hash-verified

718 return None
719
720 def process_key_event(self, e: str) -> None:
721 # To find the curtsies name for a keypress, try
722 # python -m curtsies.events
723 if self.status_bar.has_focus:
724 return self.status_bar.process_event(e)
725 if self.stdin.has_focus:
726 return self.stdin.process_event(e)
727
728 if (
729 e
730 in (
731 key_dispatch[self.config.right_key]
732 + key_dispatch[self.config.end_of_line_key]
733 + ("<RIGHT>",)
734 )
735 and self.config.curtsies_right_arrow_completion
736 and self.cursor_offset == len(self.current_line)
737 # if at end of current line and user presses RIGHT (to autocomplete)
738 ):
739 # then autocomplete
740 self.current_line += self.current_suggestion
741 self.cursor_offset = len(self.current_line)
742 elif e in ("<UP>",) + key_dispatch[self.config.up_one_line_key]:
743 self.up_one_line()
744 elif e in ("<DOWN>",) + key_dispatch[self.config.down_one_line_key]:
745 self.down_one_line()
746 elif e == "<Ctrl-d>":
747 self.on_control_d()
748 elif e == "<Ctrl-o>":
749 self.operate_and_get_next()
750 elif e == "<Esc+.>":
751 self.get_last_word()
752 elif e in key_dispatch[self.config.reverse_incremental_search_key]:
753 self.incremental_search(reverse=True)
754 elif e in key_dispatch[self.config.incremental_search_key]:
755 self.incremental_search()
756 elif (
757 e in (("<BACKSPACE>",) + key_dispatch[self.config.backspace_key])
758 and self.incr_search_mode != SearchMode.NO_SEARCH
759 ):
760 self.add_to_incremental_search(self, backspace=True)
761 elif e in self.edit_keys.cut_buffer_edits:
762 self.readline_kill(e)
763 elif e in self.edit_keys.simple_edits:
764 self.cursor_offset, self.current_line = self.edit_keys.call(
765 e,
766 cursor_offset=self.cursor_offset,
767 line=self.current_line,
768 cut_buffer=self.cut_buffer,
769 )
770 elif e in key_dispatch[self.config.cut_to_buffer_key]:
771 self.cut_to_buffer()
772 elif e in key_dispatch[self.config.reimport_key]:
773 self.clear_modules_and_reevaluate()
774 elif e in key_dispatch[self.config.toggle_file_watch_key]:
775 self.toggle_file_watch()
776 elif e in key_dispatch[self.config.clear_screen_key]:
777 self.request_paint_to_clear_screen = True

Callers 1

process_eventMethod · 0.95

Calls 15

up_one_lineMethod · 0.95
down_one_lineMethod · 0.95
on_control_dMethod · 0.95
operate_and_get_nextMethod · 0.95
get_last_wordMethod · 0.95
incremental_searchMethod · 0.95
readline_killMethod · 0.95
cut_to_bufferMethod · 0.95
toggle_file_watchMethod · 0.95
show_sourceMethod · 0.95

Tested by

no test coverage detected