Add `use_non_breaking_spaces` theme option, use it in ascii theme
This commit is contained in:
parent
7e7803f680
commit
d32b798c11
|
@ -287,6 +287,19 @@ ascii Theme without any unicode characters at all
|
|||
after it (on the left side). These spaces will not be added if divider is
|
||||
not drawn.
|
||||
|
||||
``use_non_breaking_spaces``
|
||||
Determines whether non-breaking spaces should be used in place of the
|
||||
regular ones. This option is needed because regular spaces are not displayed
|
||||
properly when using powerline with some font configuration. Defaults to
|
||||
``True``.
|
||||
|
||||
.. note::
|
||||
Unlike all other options this one is only checked once at startup using
|
||||
whatever theme is :ref:`the default <config-ext-theme>`. If this option
|
||||
is set in the local themes it will be ignored. This option may also be
|
||||
ignored in some bindings.
|
||||
|
||||
|
||||
``dividers``
|
||||
Defines the dividers used in all Powerline extensions. This option
|
||||
should usually only be changed if you don't have a patched font, or if
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"use_non_breaking_spaces": false,
|
||||
"dividers": {
|
||||
"left": {
|
||||
"hard": " ",
|
||||
|
|
|
@ -1388,6 +1388,7 @@ common_theme_spec = Spec(
|
|||
top_theme_spec = common_theme_spec().update(
|
||||
dividers=dividers_spec(),
|
||||
spaces=spaces_spec(),
|
||||
use_non_breaking_spaces=Spec().type(bool).optional(),
|
||||
segment_data=Spec().unknown_spec(
|
||||
Spec().func(check_segment_data_key),
|
||||
segment_data_value_spec(),
|
||||
|
|
|
@ -73,7 +73,7 @@ class Renderer(object):
|
|||
python-2) regular string or ``None``.
|
||||
'''
|
||||
|
||||
character_translations = {ord(' '): NBSP}
|
||||
character_translations = {}
|
||||
'''Character translations for use in escape() function.
|
||||
|
||||
See documentation of ``unicode.translate`` for details.
|
||||
|
@ -101,6 +101,9 @@ class Renderer(object):
|
|||
self.theme_config = theme_config
|
||||
theme_kwargs['pl'] = pl
|
||||
self.pl = pl
|
||||
if theme_config.get('use_non_breaking_spaces', True):
|
||||
self.character_translations = self.character_translations.copy()
|
||||
self.character_translations[ord(' ')] = NBSP
|
||||
self.theme = Theme(theme_config=theme_config, **theme_kwargs)
|
||||
self.local_themes = local_themes
|
||||
self.theme_kwargs = theme_kwargs
|
||||
|
@ -442,11 +445,10 @@ class Renderer(object):
|
|||
segment['_rendered_hl'] = contents_highlighted
|
||||
yield segment
|
||||
|
||||
@classmethod
|
||||
def escape(cls, string):
|
||||
def escape(self, string):
|
||||
'''Method that escapes segment contents.
|
||||
'''
|
||||
return string.translate(cls.character_translations)
|
||||
return string.translate(self.character_translations)
|
||||
|
||||
def hlstyle(fg=None, bg=None, attr=None):
|
||||
'''Output highlight style string.
|
||||
|
|
|
@ -30,7 +30,7 @@ catch
|
|||
cquit
|
||||
endtry
|
||||
|
||||
if result isnot# '%#Pl_22_24320_148_11523840_bold# NORMAL %#Pl_148_11523840_236_3158064_NONE# %#Pl_231_16777215_236_3158064_NONE# %#Pl_247_10395294_236_3158064_NONE#unix%#Pl_240_5789784_236_3158064_NONE# %#Pl_247_10329757_240_5789784_NONE# 100%%%#Pl_252_13684944_240_5789784_NONE# %#Pl_235_2500134_252_13684944_NONE# LN %#Pl_235_2500134_252_13684944_bold# 1%#Pl_22_24576_252_13684944_NONE#:1 '
|
||||
if result isnot# '%#Pl_22_24320_148_11523840_bold# NORMAL %#Pl_148_11523840_236_3158064_NONE# %#Pl_231_16777215_236_3158064_NONE# %#Pl_247_10395294_236_3158064_NONE#unix%#Pl_240_5789784_236_3158064_NONE# %#Pl_247_10329757_240_5789784_NONE# 100%%%#Pl_252_13684944_240_5789784_NONE# %#Pl_235_2500134_252_13684944_NONE# LN %#Pl_235_2500134_252_13684944_bold# 1%#Pl_22_24576_252_13684944_NONE#:1 '
|
||||
call writefile(['Unexpected result', result], 'message.fail')
|
||||
cquit
|
||||
endif
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m2[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mbool 42
|
||||
[0;38;5;250;48;5;240m [0;38;5;231;48;5;240m2[0;38;5;250;48;5;240m> [0;38;5;240;49;22m [0mbool(42)
|
||||
[0;38;5;250;48;5;240m Out[[0;38;5;231;48;5;240m2[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mTrue
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m2[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mbool 42
|
||||
[0;38;5;250;48;5;240m [0;38;5;231;48;5;240m2[0;38;5;250;48;5;240m> [0;38;5;240;49;22m [0mbool(42)
|
||||
[0;38;5;250;48;5;240m Out[[0;38;5;231;48;5;240m2[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mTrue
|
||||
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m3[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mbool 44
|
||||
[0;38;5;250;48;5;240m [0;38;5;231;48;5;240m3[0;38;5;250;48;5;240m> [0;38;5;240;49;22m [0mbool(44)
|
||||
[0;38;5;250;48;5;240m Out[[0;38;5;231;48;5;240m3[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mTrue
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m3[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mbool 44
|
||||
[0;38;5;250;48;5;240m [0;38;5;231;48;5;240m3[0;38;5;250;48;5;240m> [0;38;5;240;49;22m [0mbool(44)
|
||||
[0;38;5;250;48;5;240m Out[[0;38;5;231;48;5;240m3[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mTrue
|
||||
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m4[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mclass Test(object):
|
||||
[0;38;5;250;48;5;240m [0;38;5;240;49;22m [0m pass
|
||||
[0;38;5;250;48;5;240m [0;38;5;240;49;22m [0m
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m4[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mclass Test(object):
|
||||
[0;38;5;250;48;5;240m [0;38;5;240;49;22m [0m pass
|
||||
[0;38;5;250;48;5;240m [0;38;5;240;49;22m [0m
|
||||
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m5[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mexit
|
||||
[0;38;5;250;48;5;240m In [[0;38;5;231;48;5;240m5[0;38;5;250;48;5;240m] [0;38;5;240;49;22m [0mexit
|
||||
|
|
Loading…
Reference in New Issue