Add virtcol_current textwidth-based gradient

This commit is contained in:
ZyX 2013-04-13 19:28:34 +04:00
parent cce79fda0e
commit bd0546d688
4 changed files with 47 additions and 33 deletions

View File

@ -26,6 +26,7 @@
"line_percent_gradient": { "fg": "green_yellow_red", "bg": "gray4" }, "line_percent_gradient": { "fg": "green_yellow_red", "bg": "gray4" },
"line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] }, "line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray1", "bg": "gray10" }, "line_current_symbol": { "fg": "gray1", "bg": "gray10" },
"virtcol_current_gradient": { "fg": "dark_GREEN_Orange_red", "bg": "gray10" },
"col_current": { "fg": "gray6", "bg": "gray10" }, "col_current": { "fg": "gray6", "bg": "gray10" },
"modified_buffers": { "fg": "brightyellow", "bg": "gray2" } "modified_buffers": { "fg": "brightyellow", "bg": "gray2" }
}, },

View File

@ -1,32 +1,33 @@
{ {
"name": "Solarized Dark", "name": "Solarized Dark",
"groups": { "groups": {
"background": { "fg": "oldlace", "bg": "royalblue5" }, "background": { "fg": "oldlace", "bg": "royalblue5" },
"background:divider": { "fg": "lightskyblue4", "bg": "royalblue5" }, "background:divider": { "fg": "lightskyblue4", "bg": "royalblue5" },
"mode": { "fg": "oldlace", "bg": "green", "attr": ["bold"] }, "mode": { "fg": "oldlace", "bg": "green", "attr": ["bold"] },
"modified_indicator": { "fg": "yellow", "bg": "darkgreencopper", "attr": ["bold"] }, "modified_indicator": { "fg": "yellow", "bg": "darkgreencopper", "attr": ["bold"] },
"paste_indicator": { "fg": "oldlace", "bg": "orange", "attr": ["bold"] }, "paste_indicator": { "fg": "oldlace", "bg": "orange", "attr": ["bold"] },
"readonly_indicator": { "fg": "red", "bg": "darkgreencopper" }, "readonly_indicator": { "fg": "red", "bg": "darkgreencopper" },
"branch": { "fg": "lightyellow", "bg": "darkgreencopper" }, "branch": { "fg": "lightyellow", "bg": "darkgreencopper" },
"branch_dirty": { "fg": "yellow", "bg": "darkgreencopper" }, "branch_dirty": { "fg": "yellow", "bg": "darkgreencopper" },
"branch_clean": { "fg": "lightyellow", "bg": "darkgreencopper" }, "branch_clean": { "fg": "lightyellow", "bg": "darkgreencopper" },
"branch:divider": { "fg": "gray61", "bg": "darkgreencopper" }, "branch:divider": { "fg": "gray61", "bg": "darkgreencopper" },
"file_directory": { "fg": "lightyellow", "bg": "darkgreencopper" }, "file_directory": { "fg": "lightyellow", "bg": "darkgreencopper" },
"file_name": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] }, "file_name": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
"file_size": { "fg": "oldlace", "bg": "darkgreencopper" }, "file_size": { "fg": "oldlace", "bg": "darkgreencopper" },
"file_name_no_file": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] }, "file_name_no_file": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
"file_name_empty": { "fg": "oldlace", "bg": "darkgreencopper" }, "file_name_empty": { "fg": "oldlace", "bg": "darkgreencopper" },
"file_format": { "fg": "gray61", "bg": "royalblue5" }, "file_format": { "fg": "gray61", "bg": "royalblue5" },
"file_encoding": { "fg": "gray61", "bg": "royalblue5" }, "file_encoding": { "fg": "gray61", "bg": "royalblue5" },
"file_type": { "fg": "gray61", "bg": "royalblue5" }, "file_type": { "fg": "gray61", "bg": "royalblue5" },
"file_vcs_status": { "fg": "red", "bg": "darkgreencopper" }, "file_vcs_status": { "fg": "red", "bg": "darkgreencopper" },
"file_vcs_status_M": { "fg": "yellow", "bg": "darkgreencopper" }, "file_vcs_status_M": { "fg": "yellow", "bg": "darkgreencopper" },
"file_vcs_status_A": { "fg": "green", "bg": "darkgreencopper" }, "file_vcs_status_A": { "fg": "green", "bg": "darkgreencopper" },
"line_percent": { "fg": "oldlace", "bg": "lightskyblue4" }, "line_percent": { "fg": "oldlace", "bg": "lightskyblue4" },
"line_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "lightskyblue4" }, "line_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "lightskyblue4" },
"line_current": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] }, "line_current": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray13", "bg": "lightyellow" }, "line_current_symbol": { "fg": "gray13", "bg": "lightyellow" },
"col_current": { "fg": "azure4", "bg": "lightyellow" } "virtcol_current_gradient": { "fg": "GREEN_Orange_red", "bg": "gray10" },
"col_current": { "fg": "azure4", "bg": "lightyellow" }
}, },
"mode_translations": { "mode_translations": {
"nc": { "nc": {

View File

@ -1,6 +1,6 @@
# vim:fileencoding=utf-8:noet # vim:fileencoding=utf-8:noet
from __future__ import absolute_import from __future__ import absolute_import, division
import os import os
try: try:
@ -275,13 +275,21 @@ def col_current(pl, segment_info):
@window_cached @window_cached
def virtcol_current(pl): def virtcol_current(pl, gradient=True):
'''Return current visual column with concealed characters ingored '''Return current visual column with concealed characters ingored
Highlight groups used: ``virtcol_current`` or ``col_current``. :param bool gradient:
Determines whether it should show textwidth-based gradient (gradient level is ``virtcol * 100 / textwidth``).
Highlight groups used: ``virtcol_current_gradient`` (gradient), ``virtcol_current`` or ``col_current``.
''' '''
return [{'contents': str(vim_funcs['virtcol']('.')), col = vim_funcs['virtcol']('.')
'highlight_group': ['virtcol_current', 'col_current']}] r = [{'contents': str(col), 'highlight_group': ['virtcol_current', 'col_current']}]
if gradient:
textwidth = getbufvar('%', '&textwidth')
r[-1]['gradient_level'] = min(col * 100 / textwidth, 100) if textwidth else 0
r[-1]['highlight_group'].insert(0, 'virtcol_current_gradient')
return r
def modified_buffers(pl, text='+ ', join_str=','): def modified_buffers(pl, text='+ ', join_str=','):

View File

@ -436,8 +436,12 @@ class TestVim(TestCase):
segment_info = vim_module._get_segment_info() segment_info = vim_module._get_segment_info()
self.assertEqual(vim.line_current(pl=pl, segment_info=segment_info), '1') self.assertEqual(vim.line_current(pl=pl, segment_info=segment_info), '1')
self.assertEqual(vim.col_current(pl=pl, segment_info=segment_info), '1') self.assertEqual(vim.col_current(pl=pl, segment_info=segment_info), '1')
self.assertEqual(vim.virtcol_current(pl=pl, segment_info=segment_info), self.assertEqual(vim.virtcol_current(pl=pl, segment_info=segment_info), [{
[{'highlight_group': ['virtcol_current', 'col_current'], 'contents': '1'}]) 'highlight_group': ['virtcol_current_gradient', 'virtcol_current', 'col_current'], 'contents': '1', 'gradient_level': 100.0 / 80,
}])
self.assertEqual(vim.virtcol_current(pl=pl, segment_info=segment_info, gradient=False), [{
'highlight_group': ['virtcol_current', 'col_current'], 'contents': '1',
}])
def test_modified_buffers(self): def test_modified_buffers(self):
pl = Pl() pl = Pl()