|
|
@ -74,11 +74,11 @@ class InputBox(Widget): |
|
|
|
elif cursor_x > self._text_offset + visible_width: |
|
|
|
elif cursor_x > self._text_offset + visible_width: |
|
|
|
self._text_offset = cursor_x - visible_width + padding |
|
|
|
self._text_offset = cursor_x - visible_width + padding |
|
|
|
|
|
|
|
|
|
|
|
def add_char_at_cursor(self, char): |
|
|
|
def add_text_at_cursor(self, text): |
|
|
|
"""Add a character at the current cursor position.""" |
|
|
|
"""Add text at the current cursor position.""" |
|
|
|
if len(self._input_text) < self._max_text_size: |
|
|
|
if len(self._input_text) < self._max_text_size: |
|
|
|
self._input_text = self._input_text[: self._cursor_position] + char + self._input_text[self._cursor_position:] |
|
|
|
self._input_text = self._input_text[: self._cursor_position] + text + self._input_text[self._cursor_position:] |
|
|
|
self.set_cursor_position(self._cursor_position + 1) |
|
|
|
self.set_cursor_position(self._cursor_position + len(text)) |
|
|
|
|
|
|
|
|
|
|
|
if self._password_mode: |
|
|
|
if self._password_mode: |
|
|
|
self._last_char_time = time.monotonic() |
|
|
|
self._last_char_time = time.monotonic() |
|
|
@ -209,7 +209,7 @@ class InputBox(Widget): |
|
|
|
# Handle text input |
|
|
|
# Handle text input |
|
|
|
char = rl.get_char_pressed() |
|
|
|
char = rl.get_char_pressed() |
|
|
|
if char != 0 and char >= 32: # Filter out control characters |
|
|
|
if char != 0 and char >= 32: # Filter out control characters |
|
|
|
self.add_char_at_cursor(chr(char)) |
|
|
|
self.add_text_at_cursor(chr(char)) |
|
|
|
|
|
|
|
|
|
|
|
def _process_key(self, key): |
|
|
|
def _process_key(self, key): |
|
|
|
if key == rl.KEY_LEFT: |
|
|
|
if key == rl.KEY_LEFT: |
|
|
|