Almost functional.
This commit is contained in:
@@ -7,8 +7,7 @@ import curses
|
||||
from . import docs
|
||||
from .content import SubmissionContent
|
||||
from .page import Page, PageController, logged_in
|
||||
from .objects import Navigator, Color
|
||||
from .terminal import Terminal
|
||||
from .objects import Navigator, Color, KeyMap
|
||||
|
||||
|
||||
class SubmissionController(PageController):
|
||||
@@ -29,7 +28,7 @@ class SubmissionPage(Page):
|
||||
# Start at the submission post, which is indexed as -1
|
||||
self.nav = Navigator(self.content.get, page_index=-1)
|
||||
|
||||
@SubmissionController.register(curses.KEY_RIGHT, 'l', ' ')
|
||||
@SubmissionController.register(KeyMap.SUBMISSION_TOGGLE_COMMENT)
|
||||
def toggle_comment(self):
|
||||
"Toggle the selected comment tree between visible and hidden"
|
||||
|
||||
@@ -41,13 +40,13 @@ class SubmissionPage(Page):
|
||||
# causes the cursor index to go out of bounds.
|
||||
self.nav.page_index, self.nav.cursor_index = current_index, 0
|
||||
|
||||
@SubmissionController.register(curses.KEY_LEFT, 'h')
|
||||
@SubmissionController.register(KeyMap.SUBMISSION_EXIT)
|
||||
def exit_submission(self):
|
||||
"Close the submission and return to the subreddit page"
|
||||
|
||||
self.active = False
|
||||
|
||||
@SubmissionController.register(curses.KEY_F5, 'r')
|
||||
@SubmissionController.register(KeyMap.REFRESH)
|
||||
def refresh_content(self, order=None, name=None):
|
||||
"Re-download comments and reset the page index"
|
||||
|
||||
@@ -60,7 +59,7 @@ class SubmissionPage(Page):
|
||||
if not self.term.loader.exception:
|
||||
self.nav = Navigator(self.content.get, page_index=-1)
|
||||
|
||||
@SubmissionController.register(curses.KEY_ENTER, Terminal.RETURN, 'o')
|
||||
@SubmissionController.register(KeyMap.SUBMISSION_OPEN_IN_BROWSER)
|
||||
def open_link(self):
|
||||
"Open the selected item with the webbrowser"
|
||||
|
||||
@@ -71,7 +70,7 @@ class SubmissionPage(Page):
|
||||
else:
|
||||
self.term.flash()
|
||||
|
||||
@SubmissionController.register('c')
|
||||
@SubmissionController.register(KeyMap.SUBMISSION_POST)
|
||||
@logged_in
|
||||
def add_comment(self):
|
||||
"""
|
||||
@@ -114,7 +113,7 @@ class SubmissionPage(Page):
|
||||
if not self.term.loader.exception:
|
||||
self.refresh_content()
|
||||
|
||||
@SubmissionController.register('d')
|
||||
@SubmissionController.register(KeyMap.DELETE)
|
||||
@logged_in
|
||||
def delete_comment(self):
|
||||
"Delete a comment as long as it is not the current submission"
|
||||
|
||||
Reference in New Issue
Block a user