Add virtcol parameter for col_current segment

The virtual column number is also default. I doubt anybody here ever
wanted to see byte offset. When it comes to a questions like alignment,
forced text width and so on only virtual columns matter. It would be
good to optionally take concealed characters into account, but vim does
not provide a way to do so (well, except recent screencol() added solely
for testing which would be hard, but not impossible, to adapt to such
needs).

Closes #25.
This commit is contained in:
ZyX 2013-01-03 01:22:53 +04:00 committed by Kim Silkebækken
parent f67a004548
commit ca1225b864
1 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,7 @@ from powerline.lib.memoize import memoize
vim_funcs = {
'col': vim_get_func('col', rettype=int),
'virtcol': vim_get_func('virtcol', rettype=int),
'expand': vim_get_func('expand'),
'line': vim_get_func('line', rettype=int),
'mode': vim_get_func('mode'),
@ -163,7 +164,10 @@ def line_current():
return vim_funcs['line']('.')
def col_current():
def col_current(virtcol=True):
'''Return the current cursor column.
If the optional argument is True then returns visual column with concealed
characters ignored (default), else returns byte offset.
'''
return vim_funcs['col']('.')
return vim_funcs['virtcol' if virtcol else 'col']('.')