Add tabnr segment
This commit is contained in:
parent
f02399b617
commit
85f252652e
|
@ -11,6 +11,7 @@
|
||||||
"file_name_empty": "file_directory",
|
"file_name_empty": "file_directory",
|
||||||
"line_percent": "information:additional",
|
"line_percent": "information:additional",
|
||||||
"line_count": "line_current",
|
"line_count": "line_current",
|
||||||
"position": "information:additional"
|
"position": "information:additional",
|
||||||
|
"tabnr": "file_directory"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
"type": "segment_list",
|
"type": "segment_list",
|
||||||
"name": "tablister",
|
"name": "tablister",
|
||||||
"segments": [
|
"segments": [
|
||||||
|
{
|
||||||
|
"name": "tabnr",
|
||||||
|
"after": " ",
|
||||||
|
"draw_soft_divider": false,
|
||||||
|
"priority": 5
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "file_directory",
|
"name": "file_directory",
|
||||||
"draw_soft_divider": false,
|
"draw_soft_divider": false,
|
||||||
|
|
|
@ -488,6 +488,22 @@ def trailing_whitespace(pl, segment_info):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@requires_segment_info
|
||||||
|
def tabnr(pl, segment_info, show_current=False):
|
||||||
|
'''Show tabpage number
|
||||||
|
|
||||||
|
:param bool show_current:
|
||||||
|
If False do not show current tabpage number. This is default because
|
||||||
|
tabnr is by default only present in tabline.
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
tabnr = segment_info['tabnr']
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
if show_current or tabnr != current_tabpage().number:
|
||||||
|
return str(tabnr)
|
||||||
|
|
||||||
|
|
||||||
def tabpage_updated_segment_info(segment_info, tabpage):
|
def tabpage_updated_segment_info(segment_info, tabpage):
|
||||||
segment_info = segment_info.copy()
|
segment_info = segment_info.copy()
|
||||||
window = tabpage.window
|
window = tabpage.window
|
||||||
|
|
|
@ -787,6 +787,12 @@ class TestVim(TestCase):
|
||||||
self.assertEqual(trailing_whitespace(), None)
|
self.assertEqual(trailing_whitespace(), None)
|
||||||
self.assertEqual(trailing_whitespace(), None)
|
self.assertEqual(trailing_whitespace(), None)
|
||||||
|
|
||||||
|
def test_tabnr(self):
|
||||||
|
pl = Pl()
|
||||||
|
segment_info = vim_module._get_segment_info()
|
||||||
|
self.assertEqual(vim.tabnr(pl=pl, segment_info=segment_info, show_current=True), '1')
|
||||||
|
self.assertEqual(vim.tabnr(pl=pl, segment_info=segment_info, show_current=False), None)
|
||||||
|
|
||||||
|
|
||||||
old_cwd = None
|
old_cwd = None
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ catch
|
||||||
cquit
|
cquit
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
if result isnot# '%#Pl_240_5789784_235_2500134_NONE# ./%#Pl_244_8421504_235_2500134_bold#abc %#Pl_244_8421504_235_2500134_NONE# %#Pl_240_5789784_235_2500134_NONE#./%#Pl_244_8421504_235_2500134_bold#def %#Pl_235_2500134_240_5789784_NONE# %#Pl_250_12369084_240_5789784_NONE#./%#Pl_231_16777215_240_5789784_bold#ghi %#Pl_240_5789784_236_3158064_NONE# %#Pl_231_16777215_236_3158064_NONE# '
|
if result isnot# '%#Pl_240_5789784_235_2500134_NONE# 1 %#Pl_240_5789784_235_2500134_NONE#./%#Pl_244_8421504_235_2500134_bold#abc %#Pl_244_8421504_235_2500134_NONE# %#Pl_240_5789784_235_2500134_NONE#2 %#Pl_240_5789784_235_2500134_NONE#./%#Pl_244_8421504_235_2500134_bold#def %#Pl_235_2500134_240_5789784_NONE# %#Pl_250_12369084_240_5789784_NONE#./%#Pl_231_16777215_240_5789784_bold#ghi %#Pl_240_5789784_236_3158064_NONE# %#Pl_231_16777215_236_3158064_NONE# %#Pl_252_13684944_236_3158064_NONE# %#Pl_235_2500134_252_13684944_bold# Tabs '
|
||||||
call writefile(['Unexpected result', result], 'message.fail')
|
call writefile(['Unexpected result', result], 'message.fail')
|
||||||
cquit
|
cquit
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -609,11 +609,14 @@ def _get_segment_info():
|
||||||
mode = mode_translations.get(mode, mode)
|
mode = mode_translations.get(mode, mode)
|
||||||
window = current.window
|
window = current.window
|
||||||
buffer = current.buffer
|
buffer = current.buffer
|
||||||
|
tabpage = current.tabpage
|
||||||
return {
|
return {
|
||||||
'window': window,
|
'window': window,
|
||||||
'winnr': window.number,
|
'winnr': window.number,
|
||||||
'buffer': buffer,
|
'buffer': buffer,
|
||||||
'bufnr': buffer.number,
|
'bufnr': buffer.number,
|
||||||
|
'tabpage': tabpage,
|
||||||
|
'tabnr': tabpage.number,
|
||||||
'window_id': window._window_id,
|
'window_id': window._window_id,
|
||||||
'mode': mode,
|
'mode': mode,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue