Add tab_modified_indicator to the vim segments

This indicates in the tabline that any of the open buffers in a tab
page has unsaved modifications (like the default tabline do).

Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de>
This commit is contained in:
Jan Losinski 2014-08-18 17:33:16 +02:00 committed by ZyX
parent 14a68ef8f6
commit 96e297cc6e
2 changed files with 24 additions and 0 deletions

View File

@ -30,6 +30,11 @@
},
"priority": 10
},
{
"name": "tab_modified_indicator",
"exclude_modes": ["buf", "buf_nc"],
"priority": 5
},
{
"name": "modified_indicator",
"exclude_modes": ["tab", "tab_nc"],

View File

@ -167,6 +167,25 @@ def modified_indicator(pl, segment_info, text='+'):
return text if int(vim_getbufoption(segment_info, 'modified')) else None
@requires_segment_info
def tab_modified_indicator(pl, segment_info, text='+'):
'''Return a file modified indicator for tabpages.
:param string text:
text to display if any buffer in the current tab is modified
'''
if 'tabpage' in segment_info:
buffers = [dict(buffer=w.buffer) for w in segment_info['tabpage'].windows]
modified = [int(vim_getbufoption(buf, 'modified')) != 0 for buf in buffers]
ret = text if reduce(lambda x, y: x or y, modified) else None
if ret:
return [{
'contents': ret,
'highlight_group': ['modified_indicator'],
}]
return None
@requires_segment_info
def paste_indicator(pl, segment_info, text='PASTE'):
'''Return a paste mode indicator.