@@ -234,13 +234,27 @@ def _print_title(self):
234234 def refresh_selection (self ):
235235 self ._print_title ()
236236 if not self .too_small :
237+ # logger.error('\n\n================\nself._start = {}'.format(self._start))
238+ # logger.error(self._config_options)
237239 it_list = list (self ._config_options .values ())
238- for i in range (self ._start , len (it_list )):
239- it = it_list [i ]
240- logger .error ('selecyion = {}' .format (self .selection ))
240+ for i in range (len (it_list )- 1 , 0 , - 1 ):
241+ if it_list [i ][0 ] == '' :
242+ it_list .pop ()
243+ logger .error (it_list )
244+ if self .__selection < self .maxY - 2 :
245+ self ._start = 0
246+ else :
247+ self ._start += 1
248+ # logger.error('self._start = {}'.format(self._start))
249+ # for i in range(self._start, len(it_list)):
250+ for i in range (self ._start , self ._start + self .maxY - 2 ):
251+ try :
252+ it = it_list [i ]
253+ except IndexError :
254+ break
255+ # logger.error('selection = {0}, i = {1}, max = {2}'.format(self.selection, i, self.maxY))
241256 # if i < self.number_of_items:
242- if i < self .maxY - 2 :
243- logger .error ('i = {}' .format (i ))
257+ if i <= self .maxY - 2 :
244258 if i == self .__selection :
245259 col = hcol = curses .color_pair (6 )
246260 self ._print_options_help ()
@@ -249,13 +263,13 @@ def refresh_selection(self):
249263 hcol = curses .color_pair (4 )
250264 hline_width = self ._second_column - 2
251265 try :
252- self ._win .hline (i + 1 , 1 , ' ' , hline_width , col )
266+ self ._win .hline (i + 1 - self . _start , 1 , ' ' , hline_width , col )
253267 except :
254268 logger .error ('===== ERROR: {}' .format (i + 1 ))
255269 if i in self ._headers :
256- self ._win .addstr (i + 1 , 1 , it [0 ], curses .color_pair (4 ))
270+ self ._win .addstr (i + 1 - self . _start , 1 , it [0 ], curses .color_pair (4 ))
257271 else :
258- self ._win .addstr (i + 1 , 3 , it [0 ], col )
272+ self ._win .addstr (i + 1 - self . _start , 1 , ' ' + it [0 ], col )
259273 if isinstance (it [1 ], bool ):
260274 self ._win .addstr ('{}' .format (it [1 ]), hcol )
261275 else :
0 commit comments