From 1564e338b3ae42c549cd8fcc9d571f056cc9980a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Silkeb=C3=A6kken?= Date: Fri, 25 Jan 2013 14:52:43 +0100 Subject: [PATCH] Remove percent placeholder from themes The vim renderer now handles searching and replacing of the percent placeholder internally so percent signs can be used directly in themes and segments instead of the percent placeholder. Refs #127. --- powerline/config_files/themes/vim/default.json | 2 +- powerline/renderers/vim.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/powerline/config_files/themes/vim/default.json b/powerline/config_files/themes/vim/default.json index dbcfdd15..e4acc695 100644 --- a/powerline/config_files/themes/vim/default.json +++ b/powerline/config_files/themes/vim/default.json @@ -69,7 +69,7 @@ "name": "line_percent", "args": { "gradient": true }, "priority": 30, - "after": "", + "after": "%", "rjust": 4 }, { diff --git a/powerline/renderers/vim.py b/powerline/renderers/vim.py index 93997a21..c15fa16a 100644 --- a/powerline/renderers/vim.py +++ b/powerline/renderers/vim.py @@ -15,7 +15,7 @@ vim_setwinvar = vim_get_func('setwinvar') class VimRenderer(Renderer): '''Powerline vim segment renderer.''' - PERCENT_PLACEHOLDER = u'' + _PERCENT_PLACEHOLDER = u'' def __init__(self, *args, **kwargs): super(VimRenderer, self).__init__(*args, **kwargs) @@ -34,13 +34,16 @@ class VimRenderer(Renderer): if current: mode = vim_mode() theme = self.get_theme() - segments = [segment for segment in theme.get_segments()] + segments = [] + for segment in theme.get_segments(): + segment['contents'] = segment['contents'].replace('%', self._PERCENT_PLACEHOLDER) + segments.append(segment) self.window_cache[window_id] = (theme, segments) else: mode = 'nc' theme, segments = self.window_cache.get(window_id, (None, None)) statusline = super(VimRenderer, self).render(mode, winwidth, theme, segments) - statusline = statusline.replace(self.PERCENT_PLACEHOLDER, '%%') + statusline = statusline.replace(self._PERCENT_PLACEHOLDER, '%%') return statusline def hl(self, fg=None, bg=None, attr=None):