@@ -485,8 +485,11 @@ def _display(
485485 line_index_str = str (line_index ).rjust (index_width )
486486 prefix = f"{ line_index_str } \u2502 "
487487 # 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+ ):
490493 # Rebuild the line with reverse-video decoration added
491494 highlighted_parts = tuple (
492495 CursesLinePart (
@@ -947,8 +950,9 @@ def _show_menu(
947950 # Determine which row to highlight, if enabled
948951 self ._highlight_line_offset = None
949952 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+ )
952956 selected_global_index = self ._menu_indices [self ._menu_cursor_pos ]
953957 try :
954958 self ._highlight_line_offset = showing_indices .index (selected_global_index )
@@ -970,17 +974,22 @@ def _show_menu(
970974
971975 # Handle arrow navigation for menus when enabled
972976 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 :
974978 # Move the cursor position
975979 if entry == "KEY_DOWN" and self ._menu_cursor_pos < len (self ._menu_indices ) - 1 :
976980 self ._menu_cursor_pos += 1
977981 # 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+ ):
980986 # Mimic _display scroll down
981987 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+ )
984993 elif entry == "KEY_UP" and self ._menu_cursor_pos > 0 :
985994 self ._menu_cursor_pos -= 1
986995 # If moved before the first visible item, scroll up one
@@ -993,10 +1002,14 @@ def _show_menu(
9931002 continue
9941003
9951004 # 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+ )
10001013 index_to_select = self ._menu_indices [self ._menu_cursor_pos ]
10011014 entry = str (index_to_select )
10021015 self ._logger .debug ("Changed entry to: '%s'" , entry )
0 commit comments