From 37cf396abd4e6bd3e0337d0e0125308d3df89a19 Mon Sep 17 00:00:00 2001 From: Orakaro Date: Tue, 26 Aug 2014 22:31:59 +0900 Subject: [PATCH] add color for mytweet --- docs/conf.py | 4 ++-- docs/index.rst | 6 ++++++ rainbowstream/colorset/config | 2 ++ rainbowstream/colorset/larapaste.json | 1 + rainbowstream/colorset/monokai.json | 1 + rainbowstream/colorset/solarized.json | 1 + rainbowstream/colorset/tomorrow_night.json | 1 + rainbowstream/draw.py | 14 +++++++++++++- rainbowstream/rainbow.py | 2 +- setup.py | 2 +- theme.md | 1 + 11 files changed, 30 insertions(+), 5 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index b4ab7bd..3ae8929 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.8' +version = '0.8.9' # The full version, including alpha/beta/rc tags. -release = '0.8.8' +release = '0.8.9' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index 7d280f9..28592b2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -333,6 +333,12 @@ You also can view or set a new value of every config key by ``config`` command ( + ``#owner``: owner's username with '@' + ``#tweet``: original tweet +- ``THREAD_META_LEFT``: format for meta information of messages from partner which is display in the left of screen. + +- ``THREAD_META_RIGHT``: format for meta information of messages from you which is display in the right of screen. + +- ``THREAD_MIN_WIDTH``: minimum width of a message frame. + - ``MESSAGES_DISPLAY``: default messages to display on 'inbox' or 'sent' command. - ``TREND_MAX``: default trends to display on 'trend' command. diff --git a/rainbowstream/colorset/config b/rainbowstream/colorset/config index 47deb6e..d85d658 100644 --- a/rainbowstream/colorset/config +++ b/rainbowstream/colorset/config @@ -24,6 +24,8 @@ // 'thread' meta format "THREAD_META_LEFT" : "(#id) #clock", "THREAD_META_RIGHT" : "#clock (#id)", + // 'thread' frame's minimum width + "THREAD_MIN_WIDTH" : 20, // 'inbox','sent': default number of direct message "MESSAGES_DISPLAY" : 5, // 'trend': max trending topics diff --git a/rainbowstream/colorset/larapaste.json b/rainbowstream/colorset/larapaste.json index 9c7a509..a6bdb45 100644 --- a/rainbowstream/colorset/larapaste.json +++ b/rainbowstream/colorset/larapaste.json @@ -32,6 +32,7 @@ "rt" : 202, "link" : 154, "hashtag" : 37, + "mytweet" : 202, "keyword" : "on_light_green" }, diff --git a/rainbowstream/colorset/monokai.json b/rainbowstream/colorset/monokai.json index 93036bc..d9c7bb3 100644 --- a/rainbowstream/colorset/monokai.json +++ b/rainbowstream/colorset/monokai.json @@ -32,6 +32,7 @@ "rt" : 179, "link" : 74, "hashtag" : 198, + "mytweet" : 179, "keyword" : "on_light_green" }, diff --git a/rainbowstream/colorset/solarized.json b/rainbowstream/colorset/solarized.json index 7cfee1e..e9eb1e0 100644 --- a/rainbowstream/colorset/solarized.json +++ b/rainbowstream/colorset/solarized.json @@ -32,6 +32,7 @@ "rt" : 66, "link" : 23, "hashtag" : 64, + "mytweet" : 66, "keyword" : "on_light_green" }, diff --git a/rainbowstream/colorset/tomorrow_night.json b/rainbowstream/colorset/tomorrow_night.json index 32b04d1..3bd27dc 100644 --- a/rainbowstream/colorset/tomorrow_night.json +++ b/rainbowstream/colorset/tomorrow_night.json @@ -32,6 +32,7 @@ "rt" : 145, "link" : 30, "hashtag" : 67, + "mytweet" : 145, "keyword" : "on_light_blue" }, diff --git a/rainbowstream/draw.py b/rainbowstream/draw.py index 9f8a0eb..5bde76c 100644 --- a/rainbowstream/draw.py +++ b/rainbowstream/draw.py @@ -205,6 +205,7 @@ def draw(t, keyword=None, humanize=True, fil=[], ig=[]): media_url = None # Filter and ignore + mytweet = screen_name == c['original_name'] screen_name = '@' + screen_name fil = list(set((fil or []) + c['ONLY_LIST'])) ig = list(set((ig or []) + c['IGNORE_LIST'])) @@ -249,7 +250,7 @@ def draw(t, keyword=None, humanize=True, fil=[], ig=[]): # Highlight link tweet = lmap( lambda x: color_func(c['TWEET']['link'])(x) - if x[0:4] == 'http' + if x.startswith('http') else x, tweet) # Highlight hashtag @@ -258,6 +259,15 @@ def draw(t, keyword=None, humanize=True, fil=[], ig=[]): if x.startswith('#') else x, tweet) + # Highlight my tweet + if mytweet: + tweet = [color_func(c['TWEET']['mytweet'])(x) + for x in tweet + if not any([ + x == 'RT', + x.startswith('http'), + x.startswith('#')]) + ] # Highlight keyword tweet = ' '.join(tweet) if keyword: @@ -383,6 +393,7 @@ def print_right_message(m): h, w = os.popen('stty size', 'r').read().split() w = int(w) frame_width = w // 3 - dg['frame_margin'] + frame_width = max(c['THREAD_MIN_WIDTH'], frame_width) step = frame_width - 2 * dg['frame_margin'] slicing = textwrap.wrap(m['text'], step) spaces = w - frame_width - dg['frame_margin'] @@ -446,6 +457,7 @@ def print_left_message(m): h, w = os.popen('stty size', 'r').read().split() w = int(w) frame_width = w // 3 - dg['frame_margin'] + frame_width = max(c['THREAD_MIN_WIDTH'], frame_width) step = frame_width - 2 * dg['frame_margin'] slicing = textwrap.wrap(m['text'], step) spaces = dg['frame_margin'] diff --git a/rainbowstream/rainbow.py b/rainbowstream/rainbow.py index 8d93084..4b34682 100644 --- a/rainbowstream/rainbow.py +++ b/rainbowstream/rainbow.py @@ -122,7 +122,7 @@ def init(args): name = credential['name'] if not get_config('PREFIX'): set_config('PREFIX', screen_name) - g['original_name'] = screen_name[1:] + c['original_name'] = g['original_name'] = screen_name[1:] g['full_name'] = name g['decorated_name'] = lambda x: color_func( c['DECORATED_NAME'])('[' + x + ']: ') diff --git a/setup.py b/setup.py index 874893f..447c9da 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os import os.path # Bumped version -version = '0.8.8' +version = '0.8.9' # Require install_requires = [ diff --git a/theme.md b/theme.md index e5ecbab..6e27d09 100644 --- a/theme.md +++ b/theme.md @@ -143,6 +143,7 @@ Color reference can be found at * `rt`: color for `RT` word in tweet's content. * `link`: color for an url. * `hashtag`: color for a hashtag. + * `mytweet`: color for tweet's text from yourself. * `keyword`: color for highlighted keyword (in tweets search). * `MESSAGE`: colors of parts in message's output. * `partner`: color for __partner__. -- 2.25.1