Fixed an additional character being deleted when pressing alt+backspace in legacy mode
This commit is contained in:
parent
a956f0a5d7
commit
3634f457b4
|
@ -125,6 +125,7 @@ class Legacy(BaseMode, component.Component):
|
||||||
# Holds the user input and is cleared on 'enter'
|
# Holds the user input and is cleared on 'enter'
|
||||||
self.input = ""
|
self.input = ""
|
||||||
self.input_incomplete = ""
|
self.input_incomplete = ""
|
||||||
|
self._last_char = 0
|
||||||
# Keep track of where the cursor is
|
# Keep track of where the cursor is
|
||||||
self.input_cursor = 0
|
self.input_cursor = 0
|
||||||
# Keep a history of inputs
|
# Keep a history of inputs
|
||||||
|
@ -225,6 +226,8 @@ class Legacy(BaseMode, component.Component):
|
||||||
# Read the character
|
# Read the character
|
||||||
c = self.stdscr.getch()
|
c = self.stdscr.getch()
|
||||||
|
|
||||||
|
self._last_char = c
|
||||||
|
|
||||||
# We remove the tab count if the key wasn't a tab
|
# We remove the tab count if the key wasn't a tab
|
||||||
if c != 9:
|
if c != 9:
|
||||||
self.tab_count = 0
|
self.tab_count = 0
|
||||||
|
@ -317,6 +320,9 @@ class Legacy(BaseMode, component.Component):
|
||||||
|
|
||||||
# Delete a character in the input string based on cursor position
|
# Delete a character in the input string based on cursor position
|
||||||
elif c == curses.KEY_BACKSPACE or c == 127:
|
elif c == curses.KEY_BACKSPACE or c == 127:
|
||||||
|
#It's alt+backspace, bail out
|
||||||
|
if self._last_char:
|
||||||
|
return
|
||||||
if self.input and self.input_cursor > 0:
|
if self.input and self.input_cursor > 0:
|
||||||
self.input = self.input[:self.input_cursor - 1] + self.input[self.input_cursor:]
|
self.input = self.input[:self.input_cursor - 1] + self.input[self.input_cursor:]
|
||||||
self.input_cursor -= 1
|
self.input_cursor -= 1
|
||||||
|
|
Loading…
Reference in New Issue