diff --git a/powerline/config_files/themes/ascii.json b/powerline/config_files/themes/ascii.json index c8ff0d71..fa1927ba 100644 --- a/powerline/config_files/themes/ascii.json +++ b/powerline/config_files/themes/ascii.json @@ -77,7 +77,13 @@ "windy": "WINDY", "not_available": "NA", "unknown": "UKN" - } + }, + "temp_format": "{temp:.0f} C" + } + }, + "powerline.segments.common.fuzzy_time": { + "args": { + "unicode_text": false } }, diff --git a/powerline/config_files/themes/powerline.json b/powerline/config_files/themes/powerline.json index e076f770..7f83ec3b 100644 --- a/powerline/config_files/themes/powerline.json +++ b/powerline/config_files/themes/powerline.json @@ -79,6 +79,11 @@ } } }, + "powerline.segments.common.fuzzy_time": { + "args": { + "unicode_text": true + } + }, "powerline.segments.vim.mode": { "args": { diff --git a/powerline/config_files/themes/unicode.json b/powerline/config_files/themes/unicode.json index 9a3faf7a..78f84e0b 100644 --- a/powerline/config_files/themes/unicode.json +++ b/powerline/config_files/themes/unicode.json @@ -79,6 +79,11 @@ } } }, + "powerline.segments.common.fuzzy_time": { + "args": { + "unicode_text": true + } + }, "powerline.segments.vim.mode": { "args": { diff --git a/powerline/config_files/themes/unicode_terminus.json b/powerline/config_files/themes/unicode_terminus.json index 01b981f2..e1077d2e 100644 --- a/powerline/config_files/themes/unicode_terminus.json +++ b/powerline/config_files/themes/unicode_terminus.json @@ -79,6 +79,11 @@ } } }, + "powerline.segments.common.fuzzy_time": { + "args": { + "unicode_text": true + } + }, "powerline.segments.vim.mode": { "args": { diff --git a/powerline/config_files/themes/unicode_terminus_condensed.json b/powerline/config_files/themes/unicode_terminus_condensed.json index 15f37a1a..4b32d0ca 100644 --- a/powerline/config_files/themes/unicode_terminus_condensed.json +++ b/powerline/config_files/themes/unicode_terminus_condensed.json @@ -80,6 +80,11 @@ } } }, + "powerline.segments.common.fuzzy_time": { + "args": { + "unicode_text": true + } + }, "powerline.segments.vim.mode": { "args": { diff --git a/powerline/segments/common.py b/powerline/segments/common.py index fff542e2..ee6e0b75 100644 --- a/powerline/segments/common.py +++ b/powerline/segments/common.py @@ -116,7 +116,7 @@ class CwdSegment(Segment): dir_shorten_len=None, dir_limit_depth=None, use_path_separator=False, - ellipsis='⋯', + ellipsis='...', **kwargs): cwd = self.get_shortened_path(pl, segment_info, **kwargs) cwd_split = cwd.split(os.sep) @@ -198,7 +198,7 @@ UNICODE_TEXT_TRANSLATION = { } -def fuzzy_time(pl, unicode_text=True): +def fuzzy_time(pl, unicode_text=False): '''Display the current time as fuzzy time, e.g. "quarter past six". :param bool unicode_text: @@ -423,18 +423,18 @@ weather_conditions_codes = ( # ('sunny', (32, 36)), # ('night', (31, 33))): weather_conditions_icons = { - 'day': '〇', - 'blustery': '⚑', - 'rainy': '☔', - 'cloudy': '☁', - 'snowy': '❅', - 'stormy': '☈', - 'foggy': '〰', - 'sunny': '☼', - 'night': '☾', - 'windy': '☴', - 'not_available': '�', - 'unknown': '⚠', + 'day': 'DAY', + 'blustery': 'WIND', + 'rainy': 'RAIN', + 'cloudy': 'CLOUDS', + 'snowy': 'SNOW', + 'stormy': 'STORM', + 'foggy': 'FOG', + 'sunny': 'SUN', + 'night': 'NIGHT', + 'windy': 'WINDY', + 'not_available': 'NA', + 'unknown': 'UKN', } temp_conversions = { @@ -859,7 +859,7 @@ class NetworkLoadSegment(KwThreadedSegment): idata['last'] = (monotonic(), _get_bytes(interface)) return idata.copy() - def render_one(self, idata, recv_format='⬇ {value:>8}', sent_format='⬆ {value:>8}', suffix='B/s', si_prefix=False, **kwargs): + def render_one(self, idata, recv_format='DL {value:>8}', sent_format='UL {value:>8}', suffix='B/s', si_prefix=False, **kwargs): if not idata or 'prev' not in idata: return None @@ -1000,10 +1000,10 @@ Highlight groups used: ``email_alert_gradient`` (gradient), ``email_alert``. STATE_SYMBOLS = { - 'fallback': '♫', - 'play': '▶', - 'pause': '▮▮', - 'stop': '■', + 'fallback': '', + 'play': '>', + 'pause': '~', + 'stop': 'X', } @@ -1411,7 +1411,7 @@ def _get_capacity(pl): return _get_capacity(pl) -def battery(pl, format='{capacity:3.0%}', steps=5, gamify=False, full_heart='♥', empty_heart='♥'): +def battery(pl, format='{capacity:3.0%}', steps=5, gamify=False, full_heart='O', empty_heart='O'): '''Return battery charge status. :param str format: diff --git a/powerline/segments/vim/__init__.py b/powerline/segments/vim/__init__.py index 65118b2f..c973af1d 100644 --- a/powerline/segments/vim/__init__.py +++ b/powerline/segments/vim/__init__.py @@ -41,16 +41,16 @@ vim_funcs = { vim_modes = { 'n': 'NORMAL', - 'no': 'N·OPER', + 'no': 'N-OPER', 'v': 'VISUAL', - 'V': 'V·LINE', - '^V': 'V·BLCK', + 'V': 'V-LINE', + '^V': 'V-BLCK', 's': 'SELECT', - 'S': 'S·LINE', - '^S': 'S·BLCK', + 'S': 'S-LINE', + '^S': 'S-BLCK', 'i': 'INSERT', 'R': 'REPLACE', - 'Rv': 'V·RPLCE', + 'Rv': 'V-RPLCE', 'c': 'COMMND', 'cv': 'VIM EX', 'ce': 'EX', @@ -107,7 +107,7 @@ def mode(pl, segment_info, override=None): @window_cached @requires_segment_info -def visual_range(pl, segment_info, CTRL_V_text='{rows} × {vcols}', v_text_oneline='C:{vcols}', v_text_multiline='L:{rows}', V_text='L:{rows}'): +def visual_range(pl, segment_info, CTRL_V_text='{rows} x {vcols}', v_text_oneline='C:{vcols}', v_text_multiline='L:{rows}', V_text='L:{rows}'): '''Return the current visual selection range. :param str CTRL_V_text: @@ -197,7 +197,7 @@ def paste_indicator(pl, segment_info, text='PASTE'): @requires_segment_info -def readonly_indicator(pl, segment_info, text=''): +def readonly_indicator(pl, segment_info, text='RO'): '''Return a read-only indicator. :param string text: diff --git a/tests/test_segments.py b/tests/test_segments.py index 9320fb52..0f143bda 100644 --- a/tests/test_segments.py +++ b/tests/test_segments.py @@ -212,28 +212,28 @@ class TestShell(TestCase): {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=3, shorten_home=False), [ - {'contents': '⋯', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, + {'contents': '...', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'ghi', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'foo', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1), [ - {'contents': '⋯', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, + {'contents': '...', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) - self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, ellipsis='...'), [ - {'contents': '...', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, + self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, ellipsis='---'), [ + {'contents': '---', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, ellipsis=None), [ {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True), [ - {'contents': '⋯/', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, + {'contents': '.../', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) - self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True, ellipsis='...'), [ - {'contents': '.../', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, + self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True, ellipsis='---'), [ + {'contents': '---/', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(shell.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True, ellipsis=None), [ @@ -412,28 +412,28 @@ class TestCommon(TestCase): {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=3, shorten_home=False), [ - {'contents': '⋯', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, + {'contents': '...', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'ghi', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'foo', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1), [ - {'contents': '⋯', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, + {'contents': '...', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) - self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, ellipsis='...'), [ - {'contents': '...', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, + self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, ellipsis='---'), [ + {'contents': '---', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, ellipsis=None), [ {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': True, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True), [ - {'contents': '⋯/', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, + {'contents': '.../', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) - self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True, ellipsis='...'), [ - {'contents': '.../', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, + self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True, ellipsis='---'), [ + {'contents': '---/', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False}, {'contents': 'bar', 'divider_highlight_group': 'cwd:divider', 'draw_inner_divider': False, 'highlight_group': ['cwd:current_folder', 'cwd']} ]) self.assertEqual(common.cwd(pl=pl, segment_info=segment_info, dir_limit_depth=1, use_path_separator=True, ellipsis=None), [ @@ -491,13 +491,17 @@ class TestCommon(TestCase): time.minute = 59 self.assertEqual(common.fuzzy_time(pl=pl), 'round about midnight') time.minute = 33 - self.assertEqual(common.fuzzy_time(pl=pl), 'twenty‐five to twelve') + self.assertEqual(common.fuzzy_time(pl=pl), 'twenty-five to twelve') time.minute = 60 - self.assertEqual(common.fuzzy_time(pl=pl), 'twelve o’clock') + self.assertEqual(common.fuzzy_time(pl=pl), 'twelve o\'clock') time.minute = 33 self.assertEqual(common.fuzzy_time(pl=pl, unicode_text=False), 'twenty-five to twelve') time.minute = 60 self.assertEqual(common.fuzzy_time(pl=pl, unicode_text=False), 'twelve o\'clock') + time.minute = 33 + self.assertEqual(common.fuzzy_time(pl=pl, unicode_text=True), 'twenty‐five to twelve') + time.minute = 60 + self.assertEqual(common.fuzzy_time(pl=pl, unicode_text=True), 'twelve o’clock') def test_external_ip(self): pl = Pl() @@ -526,15 +530,15 @@ class TestCommon(TestCase): pl = Pl() with replace_attr(common, 'urllib_read', urllib_read): self.assertEqual(common.weather(pl=pl), [ - {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, + {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'CLOUDS '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0} ]) self.assertEqual(common.weather(pl=pl, temp_coldest=0, temp_hottest=100), [ - {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, + {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'CLOUDS '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 0} ]) self.assertEqual(common.weather(pl=pl, temp_coldest=-100, temp_hottest=-50), [ - {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, + {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'CLOUDS '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 100} ]) self.assertEqual(common.weather(pl=pl, icons={'cloudy': 'o'}), [ @@ -546,15 +550,15 @@ class TestCommon(TestCase): {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9°C', 'gradient_level': 30.0} ]) self.assertEqual(common.weather(pl=pl, unit='F'), [ - {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, + {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'CLOUDS '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '16°F', 'gradient_level': 30.0} ]) self.assertEqual(common.weather(pl=pl, unit='K'), [ - {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, + {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'CLOUDS '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '264K', 'gradient_level': 30.0} ]) self.assertEqual(common.weather(pl=pl, temp_format='{temp:.1e}C'), [ - {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, + {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'CLOUDS '}, {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-9.0e+00C', 'gradient_level': 30.0} ]) @@ -621,8 +625,8 @@ class TestCommon(TestCase): while not common.network_load.interfaces.get('eth0', {}).get('prev', (None, None))[1]: sleep(0.1) self.assertEqual(common.network_load(pl=pl, interface='eth0'), [ - {'divider_highlight_group': 'background:divider', 'contents': '⬇ 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']}, - {'divider_highlight_group': 'background:divider', 'contents': '⬆ 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']}, + {'divider_highlight_group': 'background:divider', 'contents': 'DL 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']}, + {'divider_highlight_group': 'background:divider', 'contents': 'UL 2 KiB/s', 'highlight_group': ['network_load_sent', 'network_load']}, ]) self.assertEqual(common.network_load(pl=pl, interface='eth0', recv_format='r {value}', sent_format='s {value}'), [ {'divider_highlight_group': 'background:divider', 'contents': 'r 1 KiB/s', 'highlight_group': ['network_load_recv', 'network_load']}, @@ -700,13 +704,13 @@ class TestCommon(TestCase): }]) self.assertEqual(common.battery(pl=pl, gamify=True), [ { - 'contents': '♥♥♥♥', + 'contents': 'OOOO', 'draw_inner_divider': False, 'highlight_group': ['battery_full', 'battery_gradient', 'battery'], 'gradient_level': 0 }, { - 'contents': '♥', + 'contents': 'O', 'draw_inner_divider': False, 'highlight_group': ['battery_empty', 'battery_gradient', 'battery'], 'gradient_level': 100 @@ -784,7 +788,7 @@ class TestVim(TestCase): with vim_module._with('mode', 'i') as segment_info: self.assertEqual(vim.mode(pl=pl, segment_info=segment_info), 'INSERT') with vim_module._with('mode', chr(ord('V') - 0x40)) as segment_info: - self.assertEqual(vim.mode(pl=pl, segment_info=segment_info), 'V·BLCK') + self.assertEqual(vim.mode(pl=pl, segment_info=segment_info), 'V-BLCK') self.assertEqual(vim.mode(pl=pl, segment_info=segment_info, override={'^V': 'VBLK'}), 'VBLK') def test_visual_range(self): @@ -795,17 +799,17 @@ class TestVim(TestCase): with vim_module._with('mode', 'i') as segment_info: self.assertEqual(vr(segment_info=segment_info), '') with vim_module._with('mode', '^V') as segment_info: - self.assertEqual(vr(segment_info=segment_info), '1 × 1') + self.assertEqual(vr(segment_info=segment_info), '1 x 1') with vim_module._with('vpos', line=5, col=5, off=0): - self.assertEqual(vr(segment_info=segment_info), '5 × 5') + self.assertEqual(vr(segment_info=segment_info), '5 x 5') with vim_module._with('vpos', line=5, col=4, off=0): - self.assertEqual(vr(segment_info=segment_info), '5 × 4') + self.assertEqual(vr(segment_info=segment_info), '5 x 4') with vim_module._with('mode', '^S') as segment_info: - self.assertEqual(vr(segment_info=segment_info), '1 × 1') + self.assertEqual(vr(segment_info=segment_info), '1 x 1') with vim_module._with('vpos', line=5, col=5, off=0): - self.assertEqual(vr(segment_info=segment_info), '5 × 5') + self.assertEqual(vr(segment_info=segment_info), '5 x 5') with vim_module._with('vpos', line=5, col=4, off=0): - self.assertEqual(vr(segment_info=segment_info), '5 × 4') + self.assertEqual(vr(segment_info=segment_info), '5 x 4') with vim_module._with('mode', 'V') as segment_info: self.assertEqual(vr(segment_info=segment_info), 'L:1') with vim_module._with('vpos', line=5, col=5, off=0): @@ -857,7 +861,7 @@ class TestVim(TestCase): segment_info = vim_module._get_segment_info() self.assertEqual(vim.readonly_indicator(pl=pl, segment_info=segment_info), None) with vim_module._with('bufoptions', readonly=1): - self.assertEqual(vim.readonly_indicator(pl=pl, segment_info=segment_info), '') + self.assertEqual(vim.readonly_indicator(pl=pl, segment_info=segment_info), 'RO') self.assertEqual(vim.readonly_indicator(pl=pl, segment_info=segment_info, text='L'), 'L') def test_file_scheme(self):