fixed cursor position going over the number of windows
This commit is contained in:
26
rtv/page.py
26
rtv/page.py
@@ -85,7 +85,7 @@ class Navigator(object):
|
|||||||
return valid, redraw
|
return valid, redraw
|
||||||
|
|
||||||
def move_page(self, direction, n_windows):
|
def move_page(self, direction, n_windows):
|
||||||
"""Move the page and cursor down (positive direction) or up (negative
|
"""Move the page down (positive direction) or up (negative
|
||||||
direction)"""
|
direction)"""
|
||||||
|
|
||||||
# top of submission page: act as normal move
|
# top of submission page: act as normal move
|
||||||
@@ -101,18 +101,26 @@ class Navigator(object):
|
|||||||
# not submission mode: starting index is 0
|
# not submission mode: starting index is 0
|
||||||
if not self._is_valid(self.absolute_index):
|
if not self._is_valid(self.absolute_index):
|
||||||
self.page_index = 0
|
self.page_index = 0
|
||||||
|
|
||||||
valid = True
|
valid = True
|
||||||
else:
|
else:
|
||||||
self.page_index += n_windows*direction
|
valid = False
|
||||||
valid = self._is_valid(self.absolute_index)
|
adj = 0
|
||||||
if not valid:
|
# check if reached the bottom
|
||||||
self.page_index -= n_windows*direction
|
while not valid:
|
||||||
|
n_move = n_windows-adj
|
||||||
|
if n_move == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
self.page_index += n_move*direction
|
||||||
|
valid = self._is_valid(self.absolute_index)
|
||||||
|
if not valid:
|
||||||
|
self.page_index -= n_move*direction
|
||||||
|
adj += 1
|
||||||
|
|
||||||
redraw = True
|
redraw = True
|
||||||
|
|
||||||
return valid, redraw
|
return valid, redraw
|
||||||
|
|
||||||
def flip(self, n_windows):
|
def flip(self, n_windows):
|
||||||
"Flip the orientation of the page"
|
"Flip the orientation of the page"
|
||||||
|
|
||||||
@@ -432,6 +440,10 @@ class BasePage(object):
|
|||||||
if self.nav.absolute_index < 0:
|
if self.nav.absolute_index < 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Don't allow the cursor to go over the subwindow number
|
||||||
|
if self.nav.cursor_index >= len(self._subwindows):
|
||||||
|
self.nav.cursor_index = len(self._subwindows)-1
|
||||||
|
|
||||||
window, attr = self._subwindows[self.nav.cursor_index]
|
window, attr = self._subwindows[self.nav.cursor_index]
|
||||||
if attr is not None:
|
if attr is not None:
|
||||||
attribute |= attr
|
attribute |= attr
|
||||||
|
|||||||
Reference in New Issue
Block a user