Fixed edge case when expanding bottom item the content is cut off.
This commit is contained in:
@@ -92,6 +92,7 @@ class Content(object):
|
|||||||
data['type'] = 'MoreComments'
|
data['type'] = 'MoreComments'
|
||||||
data['count'] = comment.count
|
data['count'] = comment.count
|
||||||
data['body'] = 'More comments'
|
data['body'] = 'More comments'
|
||||||
|
data['hidden'] = True
|
||||||
else:
|
else:
|
||||||
author = getattr(comment, 'author', '[deleted]')
|
author = getattr(comment, 'author', '[deleted]')
|
||||||
name = getattr(author, 'name', '[deleted]')
|
name = getattr(author, 'name', '[deleted]')
|
||||||
@@ -114,6 +115,7 @@ class Content(object):
|
|||||||
data['gold'] = comment.gilded > 0
|
data['gold'] = comment.gilded > 0
|
||||||
data['permalink'] = permalink
|
data['permalink'] = permalink
|
||||||
data['stickied'] = stickied
|
data['stickied'] = stickied
|
||||||
|
data['hidden'] = False
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -154,6 +156,7 @@ class Content(object):
|
|||||||
data['gold'] = sub.gilded > 0
|
data['gold'] = sub.gilded > 0
|
||||||
data['nsfw'] = sub.over_18
|
data['nsfw'] = sub.over_18
|
||||||
data['stickied'] = sub.stickied
|
data['stickied'] = sub.stickied
|
||||||
|
data['hidden'] = False
|
||||||
data['index'] = None # This is filled in later by the method caller
|
data['index'] = None # This is filled in later by the method caller
|
||||||
|
|
||||||
if sub.url.split('/r/')[-1] == sub.permalink.split('/r/')[-1]:
|
if sub.url.split('/r/')[-1] == sub.permalink.split('/r/')[-1]:
|
||||||
@@ -317,7 +320,8 @@ class SubmissionContent(Content):
|
|||||||
'cache': cache,
|
'cache': cache,
|
||||||
'count': count,
|
'count': count,
|
||||||
'level': data['level'],
|
'level': data['level'],
|
||||||
'body': 'Hidden'}
|
'body': 'Hidden',
|
||||||
|
'hidden': True}
|
||||||
|
|
||||||
self._comment_data[index:index + len(cache)] = [comment]
|
self._comment_data[index:index + len(cache)] = [comment]
|
||||||
|
|
||||||
|
|||||||
17
rtv/page.py
17
rtv/page.py
@@ -314,21 +314,8 @@ class Page(object):
|
|||||||
Loop through submissions and fill up the content page.
|
Loop through submissions and fill up the content page.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Case 1. Inverted, hiding the bottom element
|
|
||||||
# Case 2. Inverted, hiding or expanding middle elements
|
|
||||||
# Case 1+2. Inverted, hiding or expanding elements
|
|
||||||
|
|
||||||
# In both cases the screen jumps and is re-aligned with the selected
|
|
||||||
# item at the bottom of the screen. What we need to do is
|
|
||||||
# 1.) Grab the height of the top row (subwin.getmaxyx())
|
|
||||||
# 2.) Draw the page as non inverted, except for the top element. This
|
|
||||||
# element will be drawn as inverted with the smaller height
|
|
||||||
# 3.) If expanding and the bottom element also doesn't fit, redraw
|
|
||||||
# everything inverted as normal.
|
|
||||||
# 4.) Otherwise, this should ensure that the bottom element is always
|
|
||||||
# full visible and the cursor doesn't jump lines.
|
|
||||||
|
|
||||||
# TODO: If only one comment, add (Not enough space to display)
|
# TODO: If only one comment, add (Not enough space to display)
|
||||||
|
# TODO: Jumps up one space sometimes
|
||||||
|
|
||||||
n_rows, n_cols = self.term.stdscr.getmaxyx()
|
n_rows, n_cols = self.term.stdscr.getmaxyx()
|
||||||
window = self.term.stdscr.derwin(
|
window = self.term.stdscr.derwin(
|
||||||
@@ -376,7 +363,7 @@ class Page(object):
|
|||||||
cancel_inverted = True
|
cancel_inverted = True
|
||||||
|
|
||||||
if cancel_inverted and self.nav.inverted:
|
if cancel_inverted and self.nav.inverted:
|
||||||
# In some special cases we need to make sure that the screen is NOT
|
# In some cases we need to make sure that the screen is NOT
|
||||||
# inverted. Unfortunately, this currently means drawing the whole
|
# inverted. Unfortunately, this currently means drawing the whole
|
||||||
# page over again. Could not think of a better way to pre-determine
|
# page over again. Could not think of a better way to pre-determine
|
||||||
# if the content will fill up the page, given that it is dependent
|
# if the content will fill up the page, given that it is dependent
|
||||||
|
|||||||
@@ -33,15 +33,19 @@ class SubmissionPage(Page):
|
|||||||
|
|
||||||
current_index = self.nav.absolute_index
|
current_index = self.nav.absolute_index
|
||||||
self.content.toggle(current_index)
|
self.content.toggle(current_index)
|
||||||
|
|
||||||
|
# This logic handles a display edge case after a comment toggle. We want
|
||||||
|
# to make sure that when we re-draw the page, the cursor stays at its
|
||||||
|
# current absolute position on the screen. In order to do this, apply
|
||||||
|
# a fixed offset if, while inverted, we either try to hide the bottom
|
||||||
|
# comment or toggle any of the middle comments.
|
||||||
if self.nav.inverted:
|
if self.nav.inverted:
|
||||||
# Special case when inverted and toggling a comment. We want to
|
data = self.content.get(current_index)
|
||||||
# ensure that when we re-draw the page, the cursor stays at its
|
if data['hidden'] or self.nav.cursor_index != 0:
|
||||||
# current absolute position. Do this by turning off inversion and
|
window = self._subwindows[-1][0]
|
||||||
# applying an offset to the top item.
|
n_rows, _ = window.getmaxyx()
|
||||||
window = self._subwindows[-1][0]
|
self.nav.flip(len(self._subwindows) - 1)
|
||||||
n_rows, _ = window.getmaxyx()
|
self.nav.top_item_height = n_rows
|
||||||
self.nav.flip(len(self._subwindows) - 1)
|
|
||||||
self.nav.top_item_height = n_rows
|
|
||||||
|
|
||||||
@SubmissionController.register(Command('SUBMISSION_EXIT'))
|
@SubmissionController.register(Command('SUBMISSION_EXIT'))
|
||||||
def exit_submission(self):
|
def exit_submission(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user