Reduce handle_vertical_arrows
This commit is contained in:
parent
494bfcf654
commit
7eab2be989
8
kls
8
kls
|
@ -93,7 +93,7 @@ def refresh_third_menu():
|
||||||
if api_resource() and namespace():
|
if api_resource() and namespace():
|
||||||
menu.rows = kubectl(f"-n {namespace()} get {api_resource()} --no-headers --ignore-not-found")
|
menu.rows = kubectl(f"-n {namespace()} get {api_resource()} --no-headers --ignore-not-found")
|
||||||
menu.filtered_rows = CircularList([x for x in menu.rows if menu.filter in x]) # filtered rows
|
menu.filtered_rows = CircularList([x for x in menu.rows if menu.filter in x]) # filtered rows
|
||||||
if 1 + menu.visible_row_index > len(menu.visible_rows()):
|
if menu.visible_row_index >= len(menu.visible_rows()):
|
||||||
menu.visible_row_index = 0
|
menu.visible_row_index = 0
|
||||||
draw_menu(menu)
|
draw_menu(menu)
|
||||||
|
|
||||||
|
@ -159,13 +159,13 @@ def handle_mouse(mouse_info: tuple, menu: Menu):
|
||||||
MENUS[2].visible_row_index = 0 # reset the selected row index of third menu before redrawing
|
MENUS[2].visible_row_index = 0 # reset the selected row index of third menu before redrawing
|
||||||
|
|
||||||
|
|
||||||
def handle_vertical_arrows(key, menu):
|
def handle_vertical_arrows(key: str, menu: Menu):
|
||||||
if key == "KEY_DOWN" and len(menu.visible_rows()) > 1:
|
if key == "KEY_DOWN":
|
||||||
if (menu.visible_row_index + 1) == ROWS_HEIGHT and len(menu.filtered_rows) > ROWS_HEIGHT:
|
if (menu.visible_row_index + 1) == ROWS_HEIGHT and len(menu.filtered_rows) > ROWS_HEIGHT:
|
||||||
menu.filtered_rows.forward(1)
|
menu.filtered_rows.forward(1)
|
||||||
else:
|
else:
|
||||||
menu.visible_row_index = (menu.visible_row_index + 1) % len(menu.filtered_rows) # index of the selected visible row
|
menu.visible_row_index = (menu.visible_row_index + 1) % len(menu.filtered_rows) # index of the selected visible row
|
||||||
elif key == "KEY_UP" and len(menu.visible_rows()) > 1:
|
elif key == "KEY_UP":
|
||||||
if menu.visible_row_index == 0 and len(menu.filtered_rows) > ROWS_HEIGHT:
|
if menu.visible_row_index == 0 and len(menu.filtered_rows) > ROWS_HEIGHT:
|
||||||
menu.filtered_rows.backward(1)
|
menu.filtered_rows.backward(1)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue