Updated help, switch help screen to PAGER.

This commit is contained in:
Michael Lazar
2016-08-03 22:05:13 -07:00
parent 158e6b5059
commit 9894e2ce1d
4 changed files with 55 additions and 34 deletions

View File

@@ -17,37 +17,58 @@ Press `?` to open the help screen.
"""
HELP = """
Reddit Terminal Viewer
https://github.com/michael-lazar/rtv
======================
[Basic Commands]
`j/k` or `UP/DOWN` : Move the cursor up/down
`m/n` or `PgUp/PgDn`: Jump to the previous/next page
`o` or `ENTER` : Open the selected item as a webpage
`1`-`5` : Toggle post order
`r` or `F5` : Refresh page content
`u` : Log in or switch accounts
`?` : Show the help screen
`q/Q` : Quit/Force quit
j/k or ▲/▼ : Move the cursor up/down
m/n or PgUp/PgDn : Jump to the previous/next page
1-5 : Toggle post order
r or F5 : Refresh page content
u : Log in or switch accounts
? : Show the help screen
q/Q : Quit/Force quit
[Authenticated Commands]
`a/z` : Upvote/downvote
`w` : Save/unsave a post
`c` : Compose a new post or comment
`e` : Edit an existing post or comment
`d` : Delete an existing post or comment
`i` : Display new messages prompt
`s` : Open subscribed subreddits
`S` : Open subscribed multireddits
a/z : Upvote/downvote
c : Compose a new post or comment
e : Edit an existing post or comment
d : Delete an existing post or comment
i : Display new messages prompt
s : View a list of subscribed subreddits
S : View a list of subscribed multireddits
w : Save a submission
[Subreddit Mode]
`l` or `RIGHT` : Enter the selected submission
`/` : Open a prompt to switch subreddits
`f` : Open a prompt to search the current subreddit
'p' : Toggle between the front page and last visited subreddit
[Subreddit Commands]
l or : Enter the selected submission
o or ENTER : Open the submission link with your web browser
/ : Open a prompt to switch subreddits
f : Open a prompt to search the current subreddit
p : Return to the front page
[Submission Mode]
`h` or `LEFT` : Return to subreddit mode
`l` or `RIGHT` : Open the selected comment in a new window
`SPACE` : Fold the selected comment, or load additional comments
`b` : Display URLs with urlview
[Submission Commands]
h or : Return to the subreddit
l or : Open the selected comment in a new window
o or ENTER : Open the comment permalink with your web browser
SPACE : Fold the selected comment, or load additional comments
b : Display URLs with urlview
[Navigating]
The `/` prompt accepts subreddits in the following formats
- python
- /r/python
- /r/python/new (sort)
- /r/python/controversial-year (sort and order)
- /r/python+linux (multireddit)
- /r/front (front page)
- /u/me (your submissions)
- /u/saved (your saved posts)
- /u/spez (a user's submissions)
- /u/multi-mod/m/android (curated multireddit)
- /domain/python.org (search by domain)
"""
COMMENT_FILE = """

View File

@@ -82,7 +82,7 @@ class Page(object):
@PageController.register(Command('HELP'))
def show_help(self):
self.term.show_notification(docs.HELP.strip('\n').splitlines())
self.term.open_pager(docs.HELP.strip())
@PageController.register(Command('SORT_HOT'))
def sort_content_hot(self):

View File

@@ -71,9 +71,9 @@ def test_page_unauthenticated(reddit, terminal, config, oauth):
assert sys_exit.called
# Show help
page.controller.trigger('?')
message = '[Basic Commands]'.encode('utf-8')
terminal.stdscr.subwin.addstr.assert_any_call(1, 1, message)
with mock.patch('subprocess.Popen') as Popen:
page.controller.trigger('?')
assert Popen.called
# Sort content
page.controller.trigger('1')

View File

@@ -189,12 +189,12 @@ def test_show_notification(terminal, stdscr, use_ascii):
assert stdscr.subwin.addstr.call_count == 3
stdscr.reset_mock()
# The whole message should fit in 40x80
# The text should be trimmed to fit 40x80
text = HELP.strip().splitlines()
terminal.show_notification(text)
assert stdscr.subwin.nlines == len(text) + 2
assert stdscr.subwin.ncols == 80
assert stdscr.subwin.addstr.call_count == len(text)
assert stdscr.subwin.nlines == 40
assert stdscr.subwin.ncols <= 80
assert stdscr.subwin.addstr.call_count == 38
stdscr.reset_mock()
# The text should be trimmed to fit in 20x20