Merge remote-tracking branch 'zyx-i/virtcol-current-gradient' into develop

Conflicts:
	tests/vim.py
This commit is contained in:
Kim Silkebækken 2013-04-20 16:57:37 +02:00
commit 02eee6f54e
6 changed files with 58 additions and 33 deletions

View File

@ -74,6 +74,14 @@
"khaki1": 228
},
"gradients": {
"dark_GREEN_Orange_red": [
[22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, 94, 94, 94, 94, 94, 94, 52],
["005f00", "015f00", "025f00", "035f00", "045f00", "055f00", "065f00", "075f00", "085f00", "095f00", "0b5f00", "0c5f00", "0d5f00", "0e5f00", "0f5f00", "105f00", "115f00", "125f00", "135f00", "145f00", "165f00", "175f00", "185f00", "195f00", "1a5f00", "1b5f00", "1c5f00", "1d5f00", "1e5f00", "1f5f00", "215f00", "225f00", "235f00", "245f00", "255f00", "265f00", "275f00", "285f00", "295f00", "2a5f00", "2c5f00", "2d5f00", "2e5f00", "2f5f00", "305f00", "315f00", "325f00", "335f00", "345f00", "355f00", "375f00", "385f00", "395f00", "3a5f00", "3b5f00", "3c5f00", "3d5f00", "3e5f00", "3f5f00", "415f00", "425f00", "435f00", "445f00", "455f00", "465f00", "475f00", "485f00", "495f00", "4a5f00", "4c5f00", "4d5f00", "4e5f00", "4f5f00", "505f00", "515f00", "525f00", "535f00", "545f00", "555f00", "575f00", "585f00", "595f00", "5a5f00", "5b5f00", "5c5f00", "5d5f00", "5e5f00", "615f00", "655f00", "685f00", "6c5f00", "6f5f00", "735f00", "765f00", "7a5f00", "7d5f00", "815f00", "845f00", "815200", "702900"]
],
"GREEN_Orange_red": [
[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1],
["005f00", "015f00", "025f00", "035f00", "045f00", "055f00", "065f00", "075f00", "085f00", "095f00", "0b5f00", "0c5f00", "0d5f00", "0e5f00", "0f5f00", "105f00", "115f00", "125f00", "135f00", "145f00", "165f00", "175f00", "185f00", "195f00", "1a5f00", "1b5f00", "1c5f00", "1d5f00", "1e5f00", "1f5f00", "215f00", "225f00", "235f00", "245f00", "255f00", "265f00", "275f00", "285f00", "295f00", "2a5f00", "2c5f00", "2d5f00", "2e5f00", "2f5f00", "305f00", "315f00", "325f00", "335f00", "345f00", "355f00", "375f00", "385f00", "395f00", "3a5f00", "3b5f00", "3c5f00", "3d5f00", "3e5f00", "3f5f00", "415f00", "425f00", "435f00", "445f00", "455f00", "465f00", "475f00", "485f00", "495f00", "4a5f00", "4c5f00", "4d5f00", "4e5f00", "4f5f00", "505f00", "515f00", "525f00", "535f00", "545f00", "555f00", "575f00", "585f00", "595f00", "5a5f00", "5b5f00", "5c5f00", "5d5f00", "5e5f00", "615f00", "655f00", "685f00", "6c5f00", "6f5f00", "735f00", "765f00", "7a5f00", "7d5f00", "815f00", "845f00", "815200", "702900"]
],
"green_yellow_red": [
[190, 184, 178, 172, 166, 160],
["8ae71c", "8ce71c", "8fe71c", "92e71c", "95e71d", "98e71d", "9ae71d", "9de71d", "a0e71e", "a3e71e", "a6e71e", "a8e71e", "abe71f", "aee71f", "b1e71f", "b4e71f", "b6e720", "b9e720", "bce720", "bfe720", "c2e821", "c3e721", "c5e621", "c7e521", "c9e522", "cbe422", "cde322", "cfe222", "d1e223", "d3e123", "d5e023", "d7df23", "d9df24", "dbde24", "dddd24", "dfdc24", "e1dc25", "e3db25", "e5da25", "e7d925", "e9d926", "e9d626", "e9d426", "e9d126", "e9cf27", "e9cc27", "e9ca27", "e9c727", "e9c528", "e9c228", "e9c028", "e9bd28", "e9bb29", "e9b829", "e9b629", "e9b329", "e9b12a", "e9ae2a", "e9ac2a", "e9a92a", "eaa72b", "eaa42b", "eaa22b", "ea9f2b", "ea9d2c", "ea9b2c", "ea982c", "ea962c", "ea942d", "ea912d", "ea8f2d", "ea8d2d", "ea8a2e", "ea882e", "ea862e", "ea832e", "ea812f", "ea7f2f", "ea7c2f", "ea7a2f", "eb7830", "eb7530", "eb7330", "eb7130", "eb6f31", "eb6c31", "eb6a31", "eb6831", "eb6632", "eb6332", "eb6132", "eb5f32", "eb5d33", "eb5a33", "eb5833", "eb5633", "eb5434", "eb5134", "eb4f34", "eb4d34", "ec4b35"]

View File

@ -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" }
},

View File

@ -1,32 +1,33 @@
{
"name": "Solarized Dark",
"groups": {
"background": { "fg": "oldlace", "bg": "royalblue5" },
"background:divider": { "fg": "lightskyblue4", "bg": "royalblue5" },
"mode": { "fg": "oldlace", "bg": "green", "attr": ["bold"] },
"modified_indicator": { "fg": "yellow", "bg": "darkgreencopper", "attr": ["bold"] },
"paste_indicator": { "fg": "oldlace", "bg": "orange", "attr": ["bold"] },
"readonly_indicator": { "fg": "red", "bg": "darkgreencopper" },
"branch": { "fg": "lightyellow", "bg": "darkgreencopper" },
"branch_dirty": { "fg": "yellow", "bg": "darkgreencopper" },
"branch_clean": { "fg": "lightyellow", "bg": "darkgreencopper" },
"branch:divider": { "fg": "gray61", "bg": "darkgreencopper" },
"file_directory": { "fg": "lightyellow", "bg": "darkgreencopper" },
"file_name": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
"file_size": { "fg": "oldlace", "bg": "darkgreencopper" },
"file_name_no_file": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
"file_name_empty": { "fg": "oldlace", "bg": "darkgreencopper" },
"file_format": { "fg": "gray61", "bg": "royalblue5" },
"file_encoding": { "fg": "gray61", "bg": "royalblue5" },
"file_type": { "fg": "gray61", "bg": "royalblue5" },
"file_vcs_status": { "fg": "red", "bg": "darkgreencopper" },
"file_vcs_status_M": { "fg": "yellow", "bg": "darkgreencopper" },
"file_vcs_status_A": { "fg": "green", "bg": "darkgreencopper" },
"line_percent": { "fg": "oldlace", "bg": "lightskyblue4" },
"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" },
"col_current": { "fg": "azure4", "bg": "lightyellow" }
"background": { "fg": "oldlace", "bg": "royalblue5" },
"background:divider": { "fg": "lightskyblue4", "bg": "royalblue5" },
"mode": { "fg": "oldlace", "bg": "green", "attr": ["bold"] },
"modified_indicator": { "fg": "yellow", "bg": "darkgreencopper", "attr": ["bold"] },
"paste_indicator": { "fg": "oldlace", "bg": "orange", "attr": ["bold"] },
"readonly_indicator": { "fg": "red", "bg": "darkgreencopper" },
"branch": { "fg": "lightyellow", "bg": "darkgreencopper" },
"branch_dirty": { "fg": "yellow", "bg": "darkgreencopper" },
"branch_clean": { "fg": "lightyellow", "bg": "darkgreencopper" },
"branch:divider": { "fg": "gray61", "bg": "darkgreencopper" },
"file_directory": { "fg": "lightyellow", "bg": "darkgreencopper" },
"file_name": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
"file_size": { "fg": "oldlace", "bg": "darkgreencopper" },
"file_name_no_file": { "fg": "oldlace", "bg": "darkgreencopper", "attr": ["bold"] },
"file_name_empty": { "fg": "oldlace", "bg": "darkgreencopper" },
"file_format": { "fg": "gray61", "bg": "royalblue5" },
"file_encoding": { "fg": "gray61", "bg": "royalblue5" },
"file_type": { "fg": "gray61", "bg": "royalblue5" },
"file_vcs_status": { "fg": "red", "bg": "darkgreencopper" },
"file_vcs_status_M": { "fg": "yellow", "bg": "darkgreencopper" },
"file_vcs_status_A": { "fg": "green", "bg": "darkgreencopper" },
"line_percent": { "fg": "oldlace", "bg": "lightskyblue4" },
"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": {
"nc": {

View File

@ -1,6 +1,6 @@
# vim:fileencoding=utf-8:noet
from __future__ import absolute_import
from __future__ import absolute_import, division
import os
try:
@ -276,13 +276,21 @@ def col_current(pl, segment_info):
# TODO Add &textwidth-based gradient
@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 = int(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=','):

View File

@ -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()

View File

@ -196,6 +196,8 @@ def _emul_mode(*args):
@_str_func
def _emul_getbufvar(bufnr, varname):
if varname[0] == '&':
if bufnr == '%':
bufnr = buffers[_buffer()].number
if bufnr not in buffers:
return ''
try:
@ -322,6 +324,7 @@ class _Buffer(object):
'filetype': '',
'buftype': '',
'fileencoding': 'utf-8',
'textwidth': 80,
}
_buf_lines[bufnr] = ['']
from copy import copy