Skip to content

Commit e9810d1

Browse files
committed
fixing navigation when items are less than number of lines in screen in PyRadioKeyboardConfig
1 parent 9bac031 commit e9810d1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pyradio/config_window.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3537,7 +3537,10 @@ def _go_top(self):
35373537

35383538
def _go_bottom(self):
35393539
self._selection = len(self._list) -1
3540-
self._start = self._selection - self._number_of_lines + 1
3540+
if len(self._list) <= self._number_of_lines:
3541+
self._start = 0
3542+
else:
3543+
self._start = self._selection - self._number_of_lines + 1
35413544
self._needs_update = True
35423545

35433546
def _go_down(self, step=1):
@@ -3591,7 +3594,10 @@ def _go_up(self, step=1):
35913594
logger.error(f'{next_selection = }')
35923595
if next_selection < 0:
35933596
self._selection = len(self._list) - 1
3594-
self._start = len(self._list) - self._number_of_lines
3597+
if len(self._list) <= self._number_of_lines:
3598+
self._start = 0
3599+
else:
3600+
self._start = len(self._list) - self._number_of_lines
35953601
self._needs_update = True
35963602
return
35973603
line = next_selection - self._start - 2
@@ -3649,6 +3655,9 @@ def _init_win(self):
36493655
self._make_selection_visible()
36503656

36513657
def _make_selection_visible(self):
3658+
if len(self._list) <= self._number_of_lines:
3659+
self._start = 0
3660+
return
36523661
# Check if the current selection is already visible
36533662
if self._start <= self._selection < self._start + self._number_of_lines:
36543663
# Ensure that we use the expanded window space effectively
@@ -3692,7 +3701,6 @@ def _unselect_line(self, a_line):
36923701
self._win.chgat(a_line, self._max_length, self.maxX-self._max_length-2, curses.color_pair(4))
36933702

36943703
def show(self, parent=None):
3695-
logger.error('def show()')
36963704
if parent is not None:
36973705
self._parent = parent
36983706
self._init_win()

0 commit comments

Comments
 (0)