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

Method add_normal_character

bpython/curtsiesfrontend/repl.py:1172–1199  ·  view source on GitHub ↗
(self, char, narrow_search=True)

Source from the content-addressed store, hash-verified

1170
1171 # Handler Helpers
1172 def add_normal_character(self, char, narrow_search=True):
1173 if len(char) > 1 or is_nop(char):
1174 return
1175 if self.incr_search_mode != SearchMode.NO_SEARCH:
1176 self.add_to_incremental_search(char)
1177 else:
1178 self._set_current_line(
1179 (
1180 self.current_line[: self.cursor_offset]
1181 + char
1182 + self.current_line[self.cursor_offset :]
1183 ),
1184 update_completion=False,
1185 reset_rl_history=False,
1186 clear_special_mode=False,
1187 )
1188 if narrow_search:
1189 self.cursor_offset += 1
1190 else:
1191 self._cursor_offset += 1
1192 if self.config.cli_trim_prompts and self.current_line.startswith(
1193 self.ps1
1194 ):
1195 self.current_line = self.current_line[4:]
1196 if narrow_search:
1197 self.cursor_offset = max(0, self.cursor_offset - 4)
1198 else:
1199 self._cursor_offset += max(0, self.cursor_offset - 4)
1200
1201 def add_to_incremental_search(self, char=None, backspace=False):
1202 """Modify the current search term while in incremental search.

Callers 10

process_key_eventMethod · 0.95
insert_char_pair_endMethod · 0.95
on_tabMethod · 0.95
test_enter_textMethod · 0.45
test_run_lineMethod · 0.45

Calls 3

_set_current_lineMethod · 0.95
is_nopFunction · 0.85