From 39b8e6b3486c527291e91838c9adf139a5c95af6 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Sun, 24 Aug 2014 15:01:04 +0900 Subject: [PATCH] fix readline calculation bug with escape sequence in colored mode --- docs/conf.py | 4 ++-- rainbowstream/colors.py | 4 ++-- rainbowstream/interactive.py | 3 --- rainbowstream/rainbow.py | 26 ++++++++++++++------------ setup.py | 2 +- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 552cbbe..7c66007 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2014, Vu Nhat Minh' # built documents. # # The short X.Y version. -version = '0.8.3' +version = '0.8.4' # The full version, including alpha/beta/rc tags. -release = '0.8.3' +release = '0.8.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/rainbowstream/colors.py b/rainbowstream/colors.py index bdbc4b4..d3e5534 100644 --- a/rainbowstream/colors.py +++ b/rainbowstream/colors.py @@ -6,7 +6,7 @@ def basic_color(code): c = code if bold: c = "1;%s" % c - return "\033[%sm%s\033[0m" % (c, text) + return "\001\033[%sm\002%s\001\033[0m\002" % (c, text) return inner @@ -16,7 +16,7 @@ def term_color(code): """ def inner(text): c = code - return "\033[38;5;%sm%s\033[0m" % (c, text) + return "\001\033[38;5;%sm\002%s\001\033[0m\002" % (c, text) return inner diff --git a/rainbowstream/interactive.py b/rainbowstream/interactive.py index 62be3ec..45b7853 100644 --- a/rainbowstream/interactive.py +++ b/rainbowstream/interactive.py @@ -84,9 +84,6 @@ def init_interactive_shell(d): Init the rainbow shell """ readline.set_completer(RainbowCompleter(d).complete) - readline.parse_and_bind('set editing-mode vi') - readline.parse_and_bind('set show-all-if-ambiguous on') - readline.parse_and_bind('set show-all-if-unmodified on') readline.parse_and_bind('set skip-completed-text on') if 'libedit' in readline.__doc__: readline.parse_and_bind("bind ^I rl_complete") diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 03a3f13..c497937 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -1666,19 +1666,19 @@ def listen(): read_history() reset() while True: - # raw_input - if g['prefix']: - line = raw_input(g['decorated_name'](c['PREFIX'])) - else: - line = raw_input() - # Save cmd to compare with readline buffer - g['cmd'] = line.strip() - # Get short cmd to pass to handle function - try: - cmd = line.split()[0] - except: - cmd = '' try: + # raw_input + if g['prefix']: + line = raw_input(g['decorated_name'](c['PREFIX'])) + else: + line = raw_input() + # Save cmd to compare with readline buffer + g['cmd'] = line.strip() + # Get short cmd to pass to handle function + try: + cmd = line.split()[0] + except: + cmd = '' # Lock the semaphore c['lock'] = True # Save cmd to global variable and call process @@ -1692,6 +1692,8 @@ def listen(): g['prefix'] = True # Release the semaphore lock c['lock'] = False + except EOFError: + printNicely('') except Exception: printNicely(red('OMG something is wrong with Twitter right now.')) diff --git a/setup.py b/setup.py index 4066ff1..2e126f6 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '0.8.3' +version = '0.8.4' # Require install_requires = [ -- 2.25.1