Still not working.
This commit is contained in:
@@ -59,7 +59,8 @@ def command_line():
|
|||||||
|
|
||||||
parser.add_argument('-s', dest='subreddit', help='subreddit name')
|
parser.add_argument('-s', dest='subreddit', help='subreddit name')
|
||||||
parser.add_argument('-l', dest='link', help='full link to a submission')
|
parser.add_argument('-l', dest='link', help='full link to a submission')
|
||||||
parser.add_argument('--unicode', help='enable unicode (experimental)')
|
parser.add_argument('--unicode', action='store_const', const=False,
|
||||||
|
help='enable unicode (experimental)')
|
||||||
parser.add_argument('--log', metavar='FILE', action='store',
|
parser.add_argument('--log', metavar='FILE', action='store',
|
||||||
help='Log HTTP requests')
|
help='Log HTTP requests')
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import curses
|
|||||||
from curses import textpad, ascii
|
from curses import textpad, ascii
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from kitchen.text.display import textual_width, textual_width_chop
|
|
||||||
|
|
||||||
from .docs import HELP
|
from .docs import HELP
|
||||||
from .helpers import strip_textpad, clean
|
from .helpers import strip_textpad, clean
|
||||||
from .exceptions import EscapeInterrupt
|
from .exceptions import EscapeInterrupt
|
||||||
@@ -66,13 +64,9 @@ def add_line(window, text, row=None, col=None, attr=None):
|
|||||||
# Trying to draw outside of the screen bounds
|
# Trying to draw outside of the screen bounds
|
||||||
return
|
return
|
||||||
|
|
||||||
text = clean(text)
|
text = clean(text, n_cols)
|
||||||
text = textual_width_chop(text, n_cols)
|
params = [] if attr is None else [attr]
|
||||||
|
window.addstr(row, col, text, *params)
|
||||||
if attr is None:
|
|
||||||
window.addnstr(row, col, text, n_cols)
|
|
||||||
else:
|
|
||||||
window.addnstr(row, col, text, n_cols, attr)
|
|
||||||
|
|
||||||
|
|
||||||
def show_notification(stdscr, message):
|
def show_notification(stdscr, message):
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ from datetime import datetime
|
|||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
# kitchen solves deficiencies in textwrap's handling of unicode characters
|
# kitchen solves deficiencies in textwrap's handling of unicode characters
|
||||||
from kitchen.text.display import wrap
|
from kitchen.text.display import wrap, textual_width_chop
|
||||||
|
import six
|
||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
from .exceptions import ProgramError
|
from .exceptions import ProgramError
|
||||||
@@ -56,7 +57,7 @@ def open_browser(url):
|
|||||||
subprocess.check_call(args, stdout=null, stderr=null)
|
subprocess.check_call(args, stdout=null, stderr=null)
|
||||||
|
|
||||||
|
|
||||||
def clean(string):
|
def clean(string, n_cols=None):
|
||||||
"""
|
"""
|
||||||
Required reading!
|
Required reading!
|
||||||
http://nedbatchelder.com/text/unipain.html
|
http://nedbatchelder.com/text/unipain.html
|
||||||
@@ -75,9 +76,19 @@ def clean(string):
|
|||||||
If utf-8 is passed in, addnstr will treat each 'byte' as a single character.
|
If utf-8 is passed in, addnstr will treat each 'byte' as a single character.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if n_cols is not None and n_cols <= 0:
|
||||||
|
return ''
|
||||||
|
|
||||||
if not config.unicode:
|
if not config.unicode:
|
||||||
string = string.encode('ascii', 'replace')
|
if six.PY3 or isinstance(string, unicode):
|
||||||
return string
|
string = string.encode('ascii', 'replace')
|
||||||
|
return string[:n_cols] if n_cols else string
|
||||||
|
else:
|
||||||
|
if n_cols:
|
||||||
|
string = textual_width_chop(string, n_cols)
|
||||||
|
if six.PY3 or isinstance(string, unicode):
|
||||||
|
string = string.encode('utf-8')
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
def wrap_text(text, width):
|
def wrap_text(text, width):
|
||||||
|
|||||||
Reference in New Issue
Block a user