Added flashes invalid GOTO commands
This commit is contained in:
@@ -30,8 +30,8 @@ https://github.com/michael-lazar/rtv
|
|||||||
m : Move up one page
|
m : Move up one page
|
||||||
gg : Jump to the first post
|
gg : Jump to the first post
|
||||||
G : Jump to the last post
|
G : Jump to the last post
|
||||||
J : Jump to next sibling comment
|
J : Jump to the next sibling comment
|
||||||
K : Jump to parent comment
|
K : Jump to the parent comment
|
||||||
1 : Sort by hot
|
1 : Sort by hot
|
||||||
2 : Sort by top
|
2 : Sort by top
|
||||||
3 : Sort by rising
|
3 : Sort by rising
|
||||||
|
|||||||
@@ -183,30 +183,48 @@ class SubmissionPage(Page):
|
|||||||
|
|
||||||
@PageController.register(Command('SUBMISSION_GOTO_PARENT'))
|
@PageController.register(Command('SUBMISSION_GOTO_PARENT'))
|
||||||
def move_parent_up(self):
|
def move_parent_up(self):
|
||||||
cur = self.nav.absolute_index
|
"""
|
||||||
if cur > 0:
|
Move the cursor up to the comment's parent. If the comment is
|
||||||
child_level = self.content.get(cur)['level']
|
top-level, jump to the previous top-level comment.
|
||||||
while self.content.get(cur-1)['level'] >= 1 \
|
"""
|
||||||
and self.content.get(cur-1)['level'] >= child_level:
|
|
||||||
|
cursor = self.nav.absolute_index
|
||||||
|
if cursor > 0:
|
||||||
|
level = max(self.content.get(cursor)['level'], 1)
|
||||||
|
while self.content.get(cursor - 1)['level'] >= level:
|
||||||
self._move_cursor(-1)
|
self._move_cursor(-1)
|
||||||
cur -= 1
|
cursor -= 1
|
||||||
self._move_cursor(-1)
|
self._move_cursor(-1)
|
||||||
|
else:
|
||||||
|
self.term.flash()
|
||||||
|
|
||||||
self.clear_input_queue()
|
self.clear_input_queue()
|
||||||
|
|
||||||
@PageController.register(Command('SUBMISSION_GOTO_SIBLING'))
|
@PageController.register(Command('SUBMISSION_GOTO_SIBLING'))
|
||||||
def move_sibling_next(self):
|
def move_sibling_next(self):
|
||||||
cur = self.nav.absolute_index
|
"""
|
||||||
if cur in range(self.content.range[1]):
|
Jump to the next comment that's at the same level as the selected
|
||||||
sibling_level = self.content.get(cur)['level']
|
comment and shares the same parent.
|
||||||
|
"""
|
||||||
|
|
||||||
|
cursor = self.nav.absolute_index
|
||||||
|
if cursor >= 0:
|
||||||
|
level = self.content.get(cursor)['level']
|
||||||
try:
|
try:
|
||||||
move = 1
|
move = 1
|
||||||
while self.content.get(cur + move)['level'] > sibling_level:
|
while self.content.get(cursor + move)['level'] > level:
|
||||||
move += 1
|
move += 1
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
self.term.flash()
|
||||||
else:
|
else:
|
||||||
if self.content.get(cur + move)['level'] == sibling_level:
|
if self.content.get(cursor + move)['level'] == level:
|
||||||
[self._move_cursor(1) for _ in range(move)]
|
for _ in range(move):
|
||||||
|
self._move_cursor(1)
|
||||||
|
else:
|
||||||
|
self.term.flash()
|
||||||
|
else:
|
||||||
|
self.term.flash()
|
||||||
|
|
||||||
self.clear_input_queue()
|
self.clear_input_queue()
|
||||||
|
|
||||||
def _draw_item(self, win, data, inverted):
|
def _draw_item(self, win, data, inverted):
|
||||||
|
|||||||
Reference in New Issue
Block a user