Add bufnr segment

Ref #705
This commit is contained in:
ZyX 2014-08-03 13:18:56 +04:00
parent 1cc46c7126
commit f877516e54
3 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,7 @@
"position": "information:additional",
"single_tab": "line_current",
"many_tabs": "line_current",
"bufnr": "information:unimportant",
"tabnr": "file_directory"
}
}

View File

@ -504,6 +504,18 @@ def tabnr(pl, segment_info, show_current=False):
return str(tabnr)
@requires_segment_info
def bufnr(pl, segment_info, show_current=False):
'''Show buffer number
:param bool show_current:
If False do not show current window number.
'''
bufnr = segment_info['bufnr']
if show_current or bufnr != vim.current.buffer.number:
return str(bufnr)
def single_tab(pl, single_text='Bufs', multiple_text='Tabs'):
'''Show one text if there is only one tab and another if there are many

View File

@ -793,6 +793,12 @@ class TestVim(TestCase):
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)
def test_bufnr(self):
pl = Pl()
segment_info = vim_module._get_segment_info()
self.assertEqual(vim.bufnr(pl=pl, segment_info=segment_info, show_current=True), str(segment_info['bufnr']))
self.assertEqual(vim.bufnr(pl=pl, segment_info=segment_info, show_current=False), None)
def test_single_tab(self):
pl = Pl()
single_tab = partial(vim.single_tab, pl=pl)