diff --git a/README.rst b/README.rst index caec5a0..f7c4c9c 100644 --- a/README.rst +++ b/README.rst @@ -73,9 +73,9 @@ Example config: # Default submission link - will be opened every time the program starts # link=http://www.reddit.com/r/CollegeBasketball/comments/31irjq - # Enable unicode characters (experimental) - # This is known to be unstable with east asian wide character sets - # unicode=true + # Enable ascii-only mode and disable unicode characters + # This may be necessary for compatability with some terminal browsers + # ascii=True RTV allows users to compose comments and replys using their preferred text editor (**vi**, **nano**, **gedit**, etc). Set the environment variable ``RTV_EDITOR`` to specify which editor the program should use. diff --git a/rtv/__main__.py b/rtv/__main__.py index 6619a19..645f05e 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -44,8 +44,8 @@ def load_config(): if config.has_section('rtv'): defaults = dict(config.items('rtv')) - if 'unicode' in defaults: - defaults['unicode'] = config.getboolean('rtv', 'unicode') + if 'ascii' in defaults: + defaults['ascii'] = config.getboolean('rtv', 'ascii') return defaults @@ -59,8 +59,8 @@ def command_line(): parser.add_argument('-s', dest='subreddit', help='subreddit name') parser.add_argument('-l', dest='link', help='full link to a submission') - parser.add_argument('--unicode', action='store_const', const=False, - help='enable unicode (experimental)') + parser.add_argument('--ascii', action='store_true', + help='enable ascii-only mode') parser.add_argument('--log', metavar='FILE', action='store', help='Log HTTP requests') @@ -95,7 +95,7 @@ def main(): if getattr(args, key, None) is None: setattr(args, key, val) - config.unicode = False if args.unicode is None else args.unicode + config.unicode = (not args.ascii) # Squelch SSL warnings for Ubuntu logging.captureWarnings(True) diff --git a/rtv/curses_helpers.py b/rtv/curses_helpers.py index 3e1de6c..faefd78 100644 --- a/rtv/curses_helpers.py +++ b/rtv/curses_helpers.py @@ -5,6 +5,7 @@ import curses from curses import textpad, ascii from contextlib import contextmanager +from . import config from .docs import HELP from .helpers import strip_textpad, clean from .exceptions import EscapeInterrupt @@ -20,10 +21,10 @@ ESCAPE = 27 # found to be buggy and a PITA to work with. By defining them as unicode # points they can be added via the more reliable curses.addstr(). # http://bugs.python.org/issue21088 -UARROW = u'\u25b2' -DARROW = u'\u25bc' -BULLET = u'\u2022' -GOLD = u'\u272A' +UARROW = u'\u25b2' if config.unicode else '^' +DARROW = u'\u25bc' if config.unicode else 'v' +BULLET = u'\u2022' if config.unicode else 'o' +GOLD = u'\u272A' if config.unicode else '*' def get_arrow(likes): """ diff --git a/rtv/page.py b/rtv/page.py index 41911ee..006ce25 100644 --- a/rtv/page.py +++ b/rtv/page.py @@ -477,8 +477,7 @@ class BasePage(object): username = self.reddit.user.name s_col = (n_cols - textual_width(username) - 1) # Only print username if it fits in the empty space on the right - if (s_col - 1) >= len(sub_name): - n = (n_cols - s_col - 1) + if (s_col - 1) >= textual_width(sub_name): add_line(self._header_window, username, 0, s_col) self._header_window.refresh() diff --git a/rtv/subreddit.py b/rtv/subreddit.py index 5ae1f6a..7782cab 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -12,6 +12,7 @@ from .submission import SubmissionPage from .content import SubredditContent from .helpers import open_browser, open_editor from .docs import SUBMISSION_FILE +from .history import load_history, save_history from .curses_helpers import (GOLD, Color, LoadScreen, add_line, get_arrow, show_notification, prompt_input) @@ -21,7 +22,6 @@ _logger = logging.getLogger(__name__) history = load_history() - @atexit.register def save_links(): global history