| 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. |