parent
89204d2a7b
commit
6f3703e312
|
@ -120,6 +120,25 @@ Common configuration is a subdictionary that is a value of ``common`` key in
|
|||
to the terminal emulator. See the :ref:`term-feature-support-matrix` for
|
||||
information on whether your terminal emulator supports 24-bit colors.
|
||||
|
||||
.. _config-common-ambiwidth:
|
||||
|
||||
``ambiwidth``
|
||||
Tells powerline what to do with characters with East Asian Width Class
|
||||
Ambigious (such as Euro, Registered Sign, Copyright Sign, Greek
|
||||
letters, Cyrillic letters). Valid values: any positive integer; it is
|
||||
suggested that you only set it to 1 (default) or 2.
|
||||
|
||||
.. _config-common-additional_escapes:
|
||||
|
||||
``additional_escapes``
|
||||
Valid for shell extensions, makes sense only if :ref:`term_truecolor
|
||||
<config-common-term_truecolor>` is enabled. Is to be set from command-line
|
||||
(unless you are sure you always need it). Controls additional escaping that
|
||||
is needed for tmux/screen to work with terminal true color escape codes:
|
||||
normally tmux/screen prevent terminal emulator from receiving these control
|
||||
codes thus rendering powerline prompt colorless. Valid values: ``"tmux"``,
|
||||
``"screen"``, ``null`` (default).
|
||||
|
||||
``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
|
||||
|
|
|
@ -90,7 +90,8 @@ Statusline is getting wrapped to the next line in iTerm2
|
|||
|
||||
* Turn off “Treat ambigious-width characters as double width” in `Preferences
|
||||
--> Text`.
|
||||
* Alternative: remove fancy dividers and other fancy symbols from configuration.
|
||||
* Alternative: remove fancy dividers (they suck in this case), set
|
||||
:ref:`ambiwidth <config-common-ambiwidth>` to 2.
|
||||
|
||||
I receive a ``NameError`` when trying to use Powerline with MacVim!
|
||||
-------------------------------------------------------------------
|
||||
|
|
|
@ -10,6 +10,15 @@ I'm using tmux and Powerline looks like crap, what's wrong?
|
|||
:guilabel:`Set locale variables automatically` in :menuselection:`Profiles
|
||||
--> Terminal --> Environment`.
|
||||
|
||||
I’m using tmux/screen and Powerline is colorless
|
||||
------------------------------------------------
|
||||
|
||||
* If the above advices do not help, then you need to disable
|
||||
:ref:`term_truecolor <config-common-term_truecolor>`.
|
||||
* Alternative: set :ref:`additional_escapes <config-common-additional_escapes>`
|
||||
to ``"tmux"`` or ``"screen"``. Note that it is known to work perfectly in
|
||||
screen, but in tmux it may produce ugly spaces.
|
||||
|
||||
My vim statusline has strange characters like ``^B`` in it!
|
||||
-----------------------------------------------------------
|
||||
|
||||
|
@ -49,4 +58,5 @@ My vim statusline is not displayed completely and has too much spaces
|
|||
---------------------------------------------------------------------
|
||||
|
||||
* Be sure you have ``ambiwidth`` option set to ``single``.
|
||||
* Alternative: remove fancy dividers and other fancy symbols from configuration.
|
||||
* Alternative: set :ref:`ambiwidth <config-common-ambiwidth>` to 2, remove fancy
|
||||
dividers (they suck when ``ambiwidth`` is set to double).
|
||||
|
|
|
@ -71,7 +71,11 @@ class Powerline(object):
|
|||
except ImportError as e:
|
||||
sys.stderr.write('Error while importing renderer module: {0}\n'.format(e))
|
||||
sys.exit(1)
|
||||
options = {'term_truecolor': common_config.get('term_truecolor', False)}
|
||||
options = {'term_truecolor': common_config.get('term_truecolor', False),
|
||||
'ambiwidth': common_config.get('ambiwidth', 1),
|
||||
'tmux_escape': common_config.get('additional_escapes') == 'tmux',
|
||||
'screen_escape': common_config.get('additional_escapes') == 'screen',
|
||||
}
|
||||
self.renderer = Renderer(theme_config, local_themes, theme_kwargs, colorscheme, **options)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from powerline.theme import Theme
|
||||
from powerline.theme import Theme, u
|
||||
from unicodedata import east_asian_width, combining
|
||||
|
||||
|
||||
try:
|
||||
|
@ -17,6 +18,17 @@ class Renderer(object):
|
|||
self.local_themes = local_themes
|
||||
self.theme_kwargs = theme_kwargs
|
||||
self.colorscheme = colorscheme
|
||||
self.width_data = {
|
||||
'N': 1, # Neutral
|
||||
'Na': 1, # Narrow
|
||||
'A': getattr(self, 'ambiwidth', 1), # Ambigious
|
||||
'H': 1, # Half-width
|
||||
'W': 2, # Wide
|
||||
'F': 2, # Fullwidth
|
||||
}
|
||||
|
||||
def strwidth(self, string):
|
||||
return sum((0 if combining(symbol) else self.width_data[east_asian_width(symbol)] for symbol in string))
|
||||
|
||||
def get_theme(self, matcher_info):
|
||||
return self.theme
|
||||
|
@ -151,7 +163,7 @@ class Renderer(object):
|
|||
else:
|
||||
segment['_rendered_raw'] += contents_raw
|
||||
segment['_rendered_hl'] += contents_highlighted
|
||||
segment['_len'] = len(segment['_rendered_raw'])
|
||||
segment['_len'] = self.strwidth(segment['_rendered_raw'])
|
||||
yield segment
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -22,6 +22,11 @@ class VimRenderer(Renderer):
|
|||
'''Powerline vim segment renderer.'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
if not hasattr(vim, 'strwidth'):
|
||||
# Hope nobody want to change this at runtime
|
||||
if vim.eval('&ambiwidth') == 'double':
|
||||
kwargs = dict(**kwargs)
|
||||
kwargs['ambigious'] = 2
|
||||
super(VimRenderer, self).__init__(*args, **kwargs)
|
||||
self.hl_groups = {}
|
||||
|
||||
|
@ -40,6 +45,13 @@ class VimRenderer(Renderer):
|
|||
else:
|
||||
return self.theme
|
||||
|
||||
if hasattr(vim, 'strwidth'):
|
||||
@staticmethod
|
||||
def strwidth(string):
|
||||
# Does not work with tabs, but neither is strwidth from default
|
||||
# renderer
|
||||
return vim.strwidth(string.encode('utf-8'))
|
||||
|
||||
def render(self, window_id, winidx, current):
|
||||
'''Render all segments.
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ _mode = 'n'
|
|||
_buf_purge_events = set()
|
||||
_options = {
|
||||
'paste': 0,
|
||||
'ambiwidth': 'single',
|
||||
}
|
||||
_last_bufnr = 0
|
||||
_highlights = {}
|
||||
|
|
Loading…
Reference in New Issue