Add virtcol_current textwidth-based gradient
This commit is contained in:
parent
cce79fda0e
commit
bd0546d688
|
@ -26,6 +26,7 @@
|
|||
"line_percent_gradient": { "fg": "green_yellow_red", "bg": "gray4" },
|
||||
"line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] },
|
||||
"line_current_symbol": { "fg": "gray1", "bg": "gray10" },
|
||||
"virtcol_current_gradient": { "fg": "dark_GREEN_Orange_red", "bg": "gray10" },
|
||||
"col_current": { "fg": "gray6", "bg": "gray10" },
|
||||
"modified_buffers": { "fg": "brightyellow", "bg": "gray2" }
|
||||
},
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"line_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "lightskyblue4" },
|
||||
"line_current": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
|
||||
"line_current_symbol": { "fg": "gray13", "bg": "lightyellow" },
|
||||
"virtcol_current_gradient": { "fg": "GREEN_Orange_red", "bg": "gray10" },
|
||||
"col_current": { "fg": "azure4", "bg": "lightyellow" }
|
||||
},
|
||||
"mode_translations": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, division
|
||||
|
||||
import os
|
||||
try:
|
||||
|
@ -275,13 +275,21 @@ def col_current(pl, segment_info):
|
|||
|
||||
|
||||
@window_cached
|
||||
def virtcol_current(pl):
|
||||
def virtcol_current(pl, gradient=True):
|
||||
'''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']('.')),
|
||||
'highlight_group': ['virtcol_current', 'col_current']}]
|
||||
col = vim_funcs['virtcol']('.')
|
||||
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=','):
|
||||
|
|
|
@ -436,8 +436,12 @@ class TestVim(TestCase):
|
|||
segment_info = vim_module._get_segment_info()
|
||||
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.virtcol_current(pl=pl, segment_info=segment_info),
|
||||
[{'highlight_group': ['virtcol_current', 'col_current'], 'contents': '1'}])
|
||||
self.assertEqual(vim.virtcol_current(pl=pl, segment_info=segment_info), [{
|
||||
'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):
|
||||
pl = Pl()
|
||||
|
|
Loading…
Reference in New Issue