Change filter from ascii to alnum

This commit is contained in:
Digital Studium 2024-05-07 13:32:01 +03:00
parent a53ceded30
commit 657ff57775
1 changed files with 3 additions and 3 deletions

6
sshtui
View File

@ -62,7 +62,7 @@ def draw_menu(menu: Menu):
menu.win.clear() # clear menu window
draw_row(menu.win, menu.title, 1, 2) # draw title
draw_rows(menu) # draw menu rows
draw_row(menu.win, f"/{menu.filter}" if menu.filter else "", curses.LINES - FOOTER_HEIGHT - 2, 2) # draw filter row
draw_row(menu.win, f"filter: {menu.filter}" if menu.filter else "", curses.LINES - FOOTER_HEIGHT - 2, 2) # draw filter row
@ -90,7 +90,7 @@ def handle_filter_state(key: str, menu: Menu):
menu.filter = "" # Escape key exits filter mode
elif key in ["KEY_BACKSPACE", "\x08"]:
menu.filter = menu.filter[:-1] # Backspace key deletes a character (\x08 is also Backspace)
elif key.isascii():
elif key.isalnum():
menu.filter += key.lower()
menu.visible_row_index = 0
menu.filtered_rows = CircularList([x for x in menu.rows if menu.filter in x.lower()]) # update filtered rows
@ -139,7 +139,7 @@ def catch_input(menu: Menu):
handle_mouse(menu)
elif key in KEY_BINDINGS.keys():
handle_key_bindings(key, user(), server(), port(), identity())
elif key in ["\x1b", "KEY_BACKSPACE", "\x08"] or key.isascii(): # \x1b - escape, \x08 - backspace
elif key in ["\x1b", "KEY_BACKSPACE", "\x08"] or key.isalnum(): # \x1b - escape, \x08 - backspace
handle_filter_state(key, menu)