Added enter command. Make selfpost scroll a little more elegant.
This commit is contained in:
26
rtv/page.py
26
rtv/page.py
@@ -40,17 +40,25 @@ class Navigator(object):
|
|||||||
forward = ((direction*self.step) > 0)
|
forward = ((direction*self.step) > 0)
|
||||||
|
|
||||||
if forward:
|
if forward:
|
||||||
self.cursor_index += 1
|
if self.page_index < 0:
|
||||||
if self.cursor_index >= n_windows - 1:
|
# Special case - advance the page index if less than zero
|
||||||
self.page_index += (self.step * self.cursor_index)
|
self.page_index = 0
|
||||||
self.cursor_index = 0
|
self.cursor_index = 0
|
||||||
self.inverted = not self.inverted
|
|
||||||
redraw = True
|
redraw = True
|
||||||
|
else:
|
||||||
|
self.cursor_index += 1
|
||||||
|
if self.cursor_index >= n_windows - 1:
|
||||||
|
# We have reached the end of the page - flip the orientation
|
||||||
|
self.page_index += (self.step * self.cursor_index)
|
||||||
|
self.cursor_index = 0
|
||||||
|
self.inverted = not self.inverted
|
||||||
|
redraw = True
|
||||||
else:
|
else:
|
||||||
if self.cursor_index > 0:
|
if self.cursor_index > 0:
|
||||||
self.cursor_index -= 1
|
self.cursor_index -= 1
|
||||||
else:
|
else:
|
||||||
if self._is_valid(self.page_index - self.step):
|
if self._is_valid(self.page_index - self.step):
|
||||||
|
# We have reached the beginning of the page - move the index
|
||||||
self.page_index -= self.step
|
self.page_index -= self.step
|
||||||
redraw = True
|
redraw = True
|
||||||
else:
|
else:
|
||||||
@@ -179,11 +187,11 @@ class BasePage(object):
|
|||||||
|
|
||||||
def _edit_cursor(self, attribute):
|
def _edit_cursor(self, attribute):
|
||||||
|
|
||||||
# Don't alow the cursor to go below page index 0
|
# Don't allow the cursor to go below page index 0
|
||||||
if self.nav.absolute_index == -1:
|
if self.nav.absolute_index < 0:
|
||||||
window = self._subwindows[self.nav.cursor_index + 1]
|
return
|
||||||
else:
|
|
||||||
window = self._subwindows[self.nav.cursor_index]
|
window = self._subwindows[self.nav.cursor_index]
|
||||||
|
|
||||||
n_rows, _ = window.getmaxyx()
|
n_rows, _ = window.getmaxyx()
|
||||||
for row in xrange(n_rows):
|
for row in xrange(n_rows):
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ class SubmissionPage(BasePage):
|
|||||||
else:
|
else:
|
||||||
raise ValueError('Must specify url or submission')
|
raise ValueError('Must specify url or submission')
|
||||||
|
|
||||||
super(SubmissionPage, self).__init__(
|
super(SubmissionPage, self).__init__(stdscr, content, page_index=-1)
|
||||||
stdscr, content, page_index=-1, cursor_index=1)
|
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class SubredditPage(BasePage):
|
|||||||
self.clear_input_queue()
|
self.clear_input_queue()
|
||||||
|
|
||||||
# View submission
|
# View submission
|
||||||
elif cmd in (curses.KEY_RIGHT, ord(' ')):
|
elif cmd in (curses.KEY_RIGHT, curses.KEY_ENTER, ord(' '), 10):
|
||||||
self.open_submission()
|
self.open_submission()
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user