Clean up, simplified key commands.
This commit is contained in:
@@ -38,7 +38,6 @@ class Navigator(object):
|
||||
|
||||
valid, redraw = True, False
|
||||
|
||||
# TODO: add variable movement
|
||||
forward = ((direction*self.step) > 0)
|
||||
|
||||
if forward:
|
||||
|
||||
@@ -5,7 +5,7 @@ import six
|
||||
|
||||
from .content import SubmissionContent
|
||||
from .page import BasePage
|
||||
from .utils import LoadScreen, Color
|
||||
from .utils import LoadScreen, Color, ESCAPE
|
||||
|
||||
class SubmissionPage(BasePage):
|
||||
|
||||
@@ -42,7 +42,7 @@ class SubmissionPage(BasePage):
|
||||
self.draw()
|
||||
|
||||
# Show / hide a comment tree
|
||||
elif cmd in (curses.KEY_RIGHT, ord(' ')):
|
||||
elif cmd in (curses.KEY_RIGHT, curses.KEY_ENTER):
|
||||
self.toggle_comment()
|
||||
self.draw()
|
||||
|
||||
@@ -50,7 +50,7 @@ class SubmissionPage(BasePage):
|
||||
self.draw()
|
||||
|
||||
# Go back
|
||||
elif cmd in (ord('b'), 27, curses.KEY_LEFT):
|
||||
elif cmd in (ESCAPE, curses.KEY_LEFT):
|
||||
break
|
||||
|
||||
# Quit
|
||||
|
||||
@@ -6,7 +6,7 @@ from .errors import SubredditNameError
|
||||
from .page import BasePage
|
||||
from .submission import SubmissionPage
|
||||
from .content import SubredditContent
|
||||
from .utils import LoadScreen, text_input, display_message, Color
|
||||
from .utils import LoadScreen, text_input, display_message, Color, ESCAPE
|
||||
|
||||
class SubredditPage(BasePage):
|
||||
|
||||
@@ -34,7 +34,7 @@ class SubredditPage(BasePage):
|
||||
self.clear_input_queue()
|
||||
|
||||
# View submission
|
||||
elif cmd in (curses.KEY_RIGHT, curses.KEY_ENTER, ord(' '), 10):
|
||||
elif cmd in (curses.KEY_RIGHT, curses.KEY_ENTER):
|
||||
self.open_submission()
|
||||
self.draw()
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ from contextlib import contextmanager
|
||||
|
||||
from .errors import EscapePressed
|
||||
|
||||
ESCAPE = 27
|
||||
|
||||
class Color(object):
|
||||
|
||||
COLORS = {
|
||||
@@ -57,7 +59,7 @@ def text_input(window):
|
||||
|
||||
def validate(ch):
|
||||
"Filters characters for special key sequences"
|
||||
if ch == 27:
|
||||
if ch == ESCAPE:
|
||||
raise EscapePressed
|
||||
return ch
|
||||
|
||||
@@ -166,7 +168,7 @@ def curses_session():
|
||||
# Curses must wait for some time after the Escape key is pressed to see
|
||||
# check if it is the beginning of an escape sequence indicating a
|
||||
# special key. The default wait time is 1 second, which means that
|
||||
# getch() will not return the escape key (ord(27)), until a full second
|
||||
# getch() will not return the escape key (27), until a full second
|
||||
# after it has been pressed. Turn this down to 25 ms, which is close to
|
||||
# what VIM uses.
|
||||
# http://stackoverflow.com/questions/27372068
|
||||
|
||||
Reference in New Issue
Block a user