diff --git a/rtv/objects.py b/rtv/objects.py index 214bdde..dcd6118 100644 --- a/rtv/objects.py +++ b/rtv/objects.py @@ -4,13 +4,13 @@ from __future__ import unicode_literals import re import os import time -import curses import signal import inspect import weakref import logging import threading -from curses import ascii +import curses +import curses.ascii from contextlib import contextmanager import six @@ -545,9 +545,9 @@ class Controller(object): # different function. if controller.character_map.get(val, func) != func: raise exceptions.ConfigError( - 'Invalid configuration, cannot bind the `%s`' - ' key to two different commands in the `%s`' - ' context' % (key, self.__class__.__name__)) + "Invalid configuration! `%s` is bound to " + "duplicate commands in the " + "%s" % (key, controller.__name__)) controller.character_map[val] = func def trigger(self, char, *args, **kwargs): @@ -632,8 +632,8 @@ class KeyMap(object): try: return self._keymap[command] except KeyError: - raise exceptions.ConfigError( - 'Invalid configuration, `%s` key undefined' % command.val) + raise exceptions.ConfigError('Invalid configuration! `%s` key is ' + 'undefined' % command.val) @staticmethod def parse(key): @@ -649,7 +649,7 @@ class KeyMap(object): return getattr(curses, key[1:-1]) elif re.match('[<].*[>]', key): # Ascii control character - return getattr(ascii, key[1:-1]) + return getattr(curses.ascii, key[1:-1]) elif key.startswith('0x'): # Ascii hex code return int(key, 16) @@ -660,8 +660,9 @@ class KeyMap(object): return code # Python 3.3 has a curses.get_wch() function that we can use # for unicode keys, but Python 2.7 is limited to ascii. - raise exceptions.ConfigError( - 'Invalid key `%s`, must be in the ascii range' % key) + raise exceptions.ConfigError('Invalid configuration! `%s` is ' + 'not in the ascii range' % key) except (AttributeError, ValueError, TypeError): - raise exceptions.ConfigError('Invalid key string `%s`' % key) \ No newline at end of file + raise exceptions.ConfigError('Invalid configuration! "%s" is not a ' + 'valid key' % key) \ No newline at end of file diff --git a/rtv/page.py b/rtv/page.py index 9441c2d..0e006b1 100644 --- a/rtv/page.py +++ b/rtv/page.py @@ -39,6 +39,7 @@ class Page(object): self.oauth = oauth self.content = None self.nav = None + self.controller = None self.active = True self._row = 0 diff --git a/rtv/rtv.cfg b/rtv/rtv.cfg index 6e88069..1aa0a62 100644 --- a/rtv/rtv.cfg +++ b/rtv/rtv.cfg @@ -77,7 +77,10 @@ oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,sav ; Notes: ; - Curses is unreliable and should always be used in conjunction ; with . -; - Use 0x20 for the space key +; - Use 0x20 for the space key. +; - A subset of Ctrl modifiers are available through the ascii control codes. +; For example, Ctrl-D will trigger an signal. See the table above for +; a complete reference. ; Base page EXIT = q @@ -90,8 +93,8 @@ SORT_NEW = 4 SORT_CONTROVERSIAL = 5 MOVE_UP = k, MOVE_DOWN = j, -PAGE_UP = m, -PAGE_DOWN = n, +PAGE_UP = m, , +PAGE_DOWN = n, , UPVOTE = a DOWNVOTE = z LOGIN = u diff --git a/rtv/submission.py b/rtv/submission.py index 3e9fbe2..5e18abd 100644 --- a/rtv/submission.py +++ b/rtv/submission.py @@ -17,9 +17,9 @@ class SubmissionController(PageController): class SubmissionPage(Page): def __init__(self, reddit, term, config, oauth, url=None, submission=None): - self.controller = SubmissionController(self, keymap=config.keymap) - super(SubmissionPage, self).__init__(reddit, term, config, oauth) + + self.controller = SubmissionController(self, keymap=config.keymap) if url: self.content = SubmissionContent.from_url(reddit, url, term.loader) else: diff --git a/rtv/subreddit.py b/rtv/subreddit.py index 95e3177..4c85fe5 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -24,9 +24,9 @@ class SubredditPage(Page): name (string): Name of subreddit to open url (string): Optional submission to load upon start """ - self.controller = SubredditController(self, keymap=config.keymap) - super(SubredditPage, self).__init__(reddit, term, config, oauth) + + self.controller = SubredditController(self, keymap=config.keymap) self.content = SubredditContent.from_name(reddit, name, term.loader) self.nav = Navigator(self.content.get) diff --git a/rtv/subscription.py b/rtv/subscription.py index d6dbda2..44a443d 100644 --- a/rtv/subscription.py +++ b/rtv/subscription.py @@ -15,9 +15,9 @@ class SubscriptionController(PageController): class SubscriptionPage(Page): def __init__(self, reddit, term, config, oauth): - self.controller = SubscriptionController(self, keymap=config.keymap) - super(SubscriptionPage, self).__init__(reddit, term, config, oauth) + + self.controller = SubscriptionController(self, keymap=config.keymap) self.content = SubscriptionContent.from_user(reddit, term.loader) self.nav = Navigator(self.content.get) self.subreddit_data = None