Linter fixes. Added ctrl-d and ctrl-u for pagedown/pageup.
This commit is contained in:
@@ -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)
|
||||
raise exceptions.ConfigError('Invalid configuration! "%s" is not a '
|
||||
'valid key' % key)
|
||||
@@ -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
|
||||
|
||||
@@ -77,7 +77,10 @@ oauth_scope = edit,history,identity,mysubreddits,privatemessages,read,report,sav
|
||||
; Notes:
|
||||
; - Curses <KEY_ENTER> is unreliable and should always be used in conjunction
|
||||
; with <LF>.
|
||||
; - 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 <EOT> 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, <KEY_UP>
|
||||
MOVE_DOWN = j, <KEY_DOWN>
|
||||
PAGE_UP = m, <KEY_PPAGE>
|
||||
PAGE_DOWN = n, <KEY_NPAGE>
|
||||
PAGE_UP = m, <KEY_PPAGE>, <NAK>
|
||||
PAGE_DOWN = n, <KEY_NPAGE>, <EOT>
|
||||
UPVOTE = a
|
||||
DOWNVOTE = z
|
||||
LOGIN = u
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user