@@ -485,8 +485,11 @@ def _display(
485
485
line_index_str = str (line_index ).rjust (index_width )
486
486
prefix = f"{ line_index_str } \u2502 "
487
487
# Apply highlight decoration when this is the selected row
488
- if (indent_heading and self ._highlight_line_offset is not None and
489
- idx == self ._highlight_line_offset ):
488
+ if (
489
+ indent_heading
490
+ and self ._highlight_line_offset is not None
491
+ and idx == self ._highlight_line_offset
492
+ ):
490
493
# Rebuild the line with reverse-video decoration added
491
494
highlighted_parts = tuple (
492
495
CursesLinePart (
@@ -947,8 +950,9 @@ def _show_menu(
947
950
# Determine which row to highlight, if enabled
948
951
self ._highlight_line_offset = None
949
952
if self ._menu_indices :
950
- self ._menu_cursor_pos = max (0 , min (self ._menu_cursor_pos ,
951
- len (self ._menu_indices ) - 1 ))
953
+ self ._menu_cursor_pos = max (
954
+ 0 , min (self ._menu_cursor_pos , len (self ._menu_indices ) - 1 )
955
+ )
952
956
selected_global_index = self ._menu_indices [self ._menu_cursor_pos ]
953
957
try :
954
958
self ._highlight_line_offset = showing_indices .index (selected_global_index )
@@ -970,17 +974,22 @@ def _show_menu(
970
974
971
975
# Handle arrow navigation for menus when enabled
972
976
if entry in ["KEY_RESIZE" , "KEY_DOWN" , "KEY_UP" , "KEY_NPAGE" , "KEY_PPAGE" , "^F" , "^B" ]:
973
- if ( entry in ["KEY_DOWN" , "KEY_UP" ] and self ._menu_indices ) :
977
+ if entry in ["KEY_DOWN" , "KEY_UP" ] and self ._menu_indices :
974
978
# Move the cursor position
975
979
if entry == "KEY_DOWN" and self ._menu_cursor_pos < len (self ._menu_indices ) - 1 :
976
980
self ._menu_cursor_pos += 1
977
981
# If moved past the last visible item, scroll down one
978
- if (self ._highlight_line_offset is None or
979
- self ._highlight_line_offset >= len (showing_indices ) - 1 ):
982
+ if (
983
+ self ._highlight_line_offset is None
984
+ or self ._highlight_line_offset >= len (showing_indices ) - 1
985
+ ):
980
986
# Mimic _display scroll down
981
987
viewport_height = self ._screen_height - len (menu_heading ) - 1
982
- self .scroll (max (min (self .scroll () + 1 , len (self ._menu_indices )),
983
- viewport_height ))
988
+ self .scroll (
989
+ max (
990
+ min (self .scroll () + 1 , len (self ._menu_indices )), viewport_height
991
+ )
992
+ )
984
993
elif entry == "KEY_UP" and self ._menu_cursor_pos > 0 :
985
994
self ._menu_cursor_pos -= 1
986
995
# If moved before the first visible item, scroll up one
@@ -993,10 +1002,14 @@ def _show_menu(
993
1002
continue
994
1003
995
1004
# Enter key should select the highlighted item when cursor nav is enabled
996
- if ((entry == "CURSOR_ENTER" or entry in ["^J" , "^M" , "KEY_ENTER" , "KEY_RETURN" ]) and
997
- self ._menu_indices ):
998
- self ._logger .debug ("Enter key selection triggered! Entry: '%s', Selecting index %s" ,
999
- entry , self ._menu_cursor_pos )
1005
+ if (
1006
+ entry == "CURSOR_ENTER" or entry in ["^J" , "^M" , "KEY_ENTER" , "KEY_RETURN" ]
1007
+ ) and self ._menu_indices :
1008
+ self ._logger .debug (
1009
+ "Enter key selection triggered! Entry: '%s', Selecting index %s" ,
1010
+ entry ,
1011
+ self ._menu_cursor_pos ,
1012
+ )
1000
1013
index_to_select = self ._menu_indices [self ._menu_cursor_pos ]
1001
1014
entry = str (index_to_select )
1002
1015
self ._logger .debug ("Changed entry to: '%s'" , entry )
0 commit comments