def tablister(pl, segment_info, **kwargs): '''List all tab pages in segment_info format Specifically generates a list of segment info dictionaries with ``window``, ``winnr``, ``window_id``, ``buffer`` and ``bufnr`` keys set to tab-local ones and additional ``tabpage`` and ``tabnr`` keys. Adds either ``tab:`` or ``tab_nc:`` prefix to all segment highlight groups. Works best with vim-7.4 or later: earlier versions miss tabpage object and thus window objects are not available as well. ''' cur_tabpage = current_tabpage() cur_tabnr = cur_tabpage.number def add_multiplier(tabpage, dct): dct['priority_multiplier'] = 1 + (0.001 * abs(tabpage.number - cur_tabnr)) return dct return ((lambda tabpage, prefix: (tabpage_updated_segment_info(segment_info, tabpage), add_multiplier( tabpage, { 'highlight_group_prefix': prefix, 'divider_highlight_group': 'tab:divider' })))(tabpage, 'tab' if tabpage == cur_tabpage else 'tab_nc') for tabpage in list_tabpages())
def tablister(pl, segment_info, **kwargs): '''List all tab pages in segment_info format Specifically generates a list of segment info dictionaries with ``window``, ``winnr``, ``window_id``, ``buffer`` and ``bufnr`` keys set to tab-local ones and additional ``tabpage`` and ``tabnr`` keys. Sets segment ``mode`` to either ``tab`` (for current tab page) or ``tab_nc`` (for all other tab pages). Works best with vim-7.4 or later: earlier versions miss tabpage object and thus window objects are not available as well. ''' cur_tabpage = current_tabpage() cur_tabnr = cur_tabpage.number def add_multiplier(tabpage, dct): dct['priority_multiplier'] = 1 + (0.001 * abs(tabpage.number - cur_tabnr)) return dct return ( (lambda tabpage, mode: ( tabpage_updated_segment_info(segment_info, tabpage, mode), add_multiplier(tabpage, {'mode': mode}) ))(tabpage, 'tab' if tabpage == cur_tabpage else 'tab_nc') for tabpage in list_tabpages() )
def tablister(pl, segment_info, **kwargs): '''List all tab pages in segment_info format Specifically generates a list of segment info dictionaries with ``window``, ``winnr``, ``window_id``, ``buffer`` and ``bufnr`` keys set to tab-local ones and additional ``tabpage`` and ``tabnr`` keys. Sets segment ``mode`` to either ``tab`` (for current tab page) or ``tab_nc`` (for all other tab pages). Works best with vim-7.4 or later: earlier versions miss tabpage object and thus window objects are not available as well. ''' cur_tabpage = current_tabpage() cur_tabnr = cur_tabpage.number def add_multiplier(tabpage, dct): dct['priority_multiplier'] = 1 + (0.001 * abs(tabpage.number - cur_tabnr)) return dct return ((lambda tabpage, mode: (tabpage_updated_segment_info(segment_info, tabpage, mode), add_multiplier(tabpage, {'mode': mode})))( tabpage, 'tab' if tabpage == cur_tabpage else 'tab_nc') for tabpage in list_tabpages())
def tablister(pl, segment_info, **kwargs): '''List all tab pages in segment_info format Specifically generates a list of segment info dictionaries with ``window``, ``winnr``, ``window_id``, ``buffer`` and ``bufnr`` keys set to tab-local ones and additional ``tabpage`` and ``tabnr`` keys. Adds either ``tab:`` or ``tab_nc:`` prefix to all segment highlight groups. Works best with vim-7.4 or later: earlier versions miss tabpage object and thus window objects are not available as well. ''' cur_tabpage = current_tabpage() cur_tabnr = cur_tabpage.number def add_multiplier(tabpage, dct): dct['priority_multiplier'] = 1 + (0.001 * abs(tabpage.number - cur_tabnr)) return dct return ( (lambda tabpage, prefix: ( tabpage_updated_segment_info(segment_info, tabpage), add_multiplier(tabpage, {'highlight_group_prefix': prefix}) ))(tabpage, 'tab' if tabpage == cur_tabpage else 'tab_nc') for tabpage in list_tabpages() )
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 Mostly useful for tabline to indicate what kind of data is shown there. :param str single_text: Text displayed when there is only one tabpage. May be None if you do not want to display anything. :param str multiple_text: Text displayed when there is more then one tabpage. May be None if you do not want to display anything. Highlight groups used: ``single_tab``, ``many_tabs``. ''' if len(list_tabpages()) == 1: return single_text and [{ 'contents': single_text, 'highlight_group': ['single_tab'], }] else: return multiple_text and [{ 'contents': multiple_text, 'highlight_group': ['many_tabs'], }]
def single_tab(pl, segment_info, mode): """Returns True if Vim has only one tab opened """ return len(list_tabpages()) == 1
def single_tab(pl, segment_info, mode): '''Returns True if Vim has only one tab opened ''' return len(list_tabpages()) == 1
def tabbuflister(**kwargs): if len(list_tabpages()) == 1: return bufferlister(**kwargs) else: return tablister(**kwargs)