Populated submission box in submission viewer.
This commit is contained in:
@@ -181,8 +181,9 @@ class SubmissionContent(BaseContent):
|
||||
|
||||
elif index == -1:
|
||||
data = self._submission_data
|
||||
data['split_title'] = textwrap.wrap(data['title'], width=n_cols)
|
||||
data['n_rows'] = len(data['split_title']) + 3
|
||||
data['split_title'] = textwrap.wrap(data['title'], width=n_cols-2)
|
||||
data['split_text'] = textwrap.wrap(data['text'], width=n_cols-2)
|
||||
data['n_rows'] = (len(data['split_title']) + len(data['split_text']) + 5)
|
||||
data['offset'] = 0
|
||||
|
||||
else:
|
||||
|
||||
@@ -104,14 +104,30 @@ class SubmissionViewer(BaseViewer):
|
||||
def draw_submission(win, data):
|
||||
|
||||
n_rows, n_cols = win.getmaxyx()
|
||||
n_cols -= 1
|
||||
|
||||
# Don't print anything if there is not enough room
|
||||
n_cols -= 3 # one for each side of the border + one for offset
|
||||
# Don't print at all if there is not enough room to fit the whole sub
|
||||
if data['n_rows'] > n_rows:
|
||||
return
|
||||
|
||||
win.border()
|
||||
for row, text in enumerate(data['split_title'], start=1):
|
||||
win.addnstr(row, 1, text, n_cols)
|
||||
|
||||
text = '{} {} {}'.format(data['author'], data['created'], data['subreddit'])
|
||||
row = len(data['split_title']) + 1
|
||||
win.addnstr(row, 1, text, n_cols)
|
||||
|
||||
row = len(data['split_title']) + 2
|
||||
win.addnstr(row, 1, data['url'], n_cols)
|
||||
|
||||
offset = len(data['split_title']) + 3
|
||||
for row, text in enumerate(data['split_text'], start=offset):
|
||||
win.addnstr(row, 1, text, n_cols)
|
||||
|
||||
text = '{} {}'.format(data['score'], data['comments'])
|
||||
row = len(data['split_title']) + len(data['split_text']) + 3
|
||||
win.addnstr(row, 1, text, n_cols)
|
||||
|
||||
win.border()
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
Reference in New Issue
Block a user