Added loading dialog when opening submissions.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import praw
|
||||
import curses
|
||||
import sys
|
||||
|
||||
from content_generators import SubmissionContent, SubredditContent
|
||||
from utils import curses_session
|
||||
@@ -37,9 +38,13 @@ class SubmissionViewer(BaseViewer):
|
||||
elif cmd == curses.KEY_RESIZE:
|
||||
self.draw()
|
||||
|
||||
# Go back
|
||||
elif cmd in (ord('b'), curses.KEY_LEFT):
|
||||
break
|
||||
|
||||
# Quit
|
||||
elif cmd == ord('q'):
|
||||
break
|
||||
sys.exit()
|
||||
|
||||
else:
|
||||
curses.beep()
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import praw
|
||||
import textwrap
|
||||
import curses
|
||||
import sys
|
||||
|
||||
from content_generators import SubredditContent
|
||||
from utils import curses_session
|
||||
from content_generators import SubredditContent, SubmissionContent
|
||||
from submission_viewer import SubmissionViewer
|
||||
from viewer import BaseViewer
|
||||
from utils import curses_session
|
||||
|
||||
class SubredditViewer(BaseViewer):
|
||||
|
||||
@@ -24,7 +26,8 @@ class SubredditViewer(BaseViewer):
|
||||
|
||||
# View submission
|
||||
elif cmd in (curses.KEY_RIGHT, ord(' ')):
|
||||
pass
|
||||
self.open_submission()
|
||||
self.draw()
|
||||
|
||||
# Enter edit mode to change subreddit
|
||||
elif cmd == ord('/'):
|
||||
@@ -41,11 +44,21 @@ class SubredditViewer(BaseViewer):
|
||||
|
||||
# Quit
|
||||
elif cmd == ord('q'):
|
||||
break
|
||||
sys.exit()
|
||||
|
||||
else:
|
||||
curses.beep()
|
||||
|
||||
def open_submission(self):
|
||||
"Select the current submission to view posts"
|
||||
|
||||
self.add_loading()
|
||||
|
||||
submission = self.content.get(self.nav.absolute_index)['object']
|
||||
content = SubmissionContent(submission)
|
||||
viewer = SubmissionViewer(self.stdscr, content)
|
||||
viewer.loop()
|
||||
|
||||
def draw(self):
|
||||
|
||||
n_rows, n_cols = self.stdscr.getmaxyx()
|
||||
|
||||
@@ -106,6 +106,20 @@ class BaseViewer(object):
|
||||
continue
|
||||
self.stdscr.nodelay(0)
|
||||
|
||||
def add_loading(self):
|
||||
"Draw a `loading` popup dialog in the center of the screen"
|
||||
|
||||
message = 'Loading...'
|
||||
|
||||
n_rows, n_cols = self.stdscr.getmaxyx()
|
||||
win_rows, win_cols = 3, len(message)+2
|
||||
start_row = (n_rows - win_rows) / 2
|
||||
start_col = (n_cols - win_cols) / 2
|
||||
window = self.stdscr.derwin(win_rows, win_cols, start_row, start_col)
|
||||
window.border()
|
||||
window.addstr(1, 1, message)
|
||||
window.refresh()
|
||||
|
||||
def draw_header(self):
|
||||
|
||||
n_rows, n_cols = self._header_window.getmaxyx()
|
||||
|
||||
0
scripts/__init__.py
Normal file
0
scripts/__init__.py
Normal file
Reference in New Issue
Block a user