mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 19:48:32 +00:00
api/ui: externalize tabline
This commit is contained in:

committed by
Justin M. Keyes

parent
7e571bca5d
commit
88023d5123
@@ -132,6 +132,7 @@
|
||||
#include "nvim/version.h"
|
||||
#include "nvim/window.h"
|
||||
#include "nvim/os/time.h"
|
||||
#include "nvim/api/private/helpers.h"
|
||||
|
||||
#define MB_FILLER_CHAR '<' /* character used when a double-width character
|
||||
* doesn't fit. */
|
||||
@@ -6885,8 +6886,13 @@ static void draw_tabline(void)
|
||||
if (ScreenLines == NULL) {
|
||||
return;
|
||||
}
|
||||
redraw_tabline = false;
|
||||
|
||||
if (ui_is_widget_external(kUITabline)) {
|
||||
draw_tabline_ext();
|
||||
return;
|
||||
}
|
||||
|
||||
redraw_tabline = false;
|
||||
|
||||
if (tabline_height() < 1)
|
||||
return;
|
||||
@@ -7027,6 +7033,34 @@ static void draw_tabline(void)
|
||||
redraw_tabline = FALSE;
|
||||
}
|
||||
|
||||
// send tabline update to external ui
|
||||
void draw_tabline_ext(void)
|
||||
{
|
||||
win_T *cwp;
|
||||
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
ADD(args, INTEGER_OBJ(curtab->handle));
|
||||
Array tabs = ARRAY_DICT_INIT;
|
||||
FOR_ALL_TABS(tp) {
|
||||
if (tp == curtab) {
|
||||
cwp = curwin;
|
||||
} else {
|
||||
cwp = tp->tp_curwin;
|
||||
}
|
||||
get_trans_bufname(cwp->w_buffer);
|
||||
Array tab = ARRAY_DICT_INIT;
|
||||
ADD(tab, INTEGER_OBJ(tp->handle));
|
||||
|
||||
Dictionary tab_info = ARRAY_DICT_INIT;
|
||||
PUT(tab_info, "name", STRING_OBJ(cstr_to_string((char *)NameBuff)));
|
||||
ADD(tab, DICTIONARY_OBJ(tab_info));
|
||||
ADD(tabs, ARRAY_OBJ(tab));
|
||||
}
|
||||
ADD(args, ARRAY_OBJ(tabs));
|
||||
|
||||
ui_event("tabline_update", args);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get buffer name for "buf" into NameBuff[].
|
||||
* Takes care of special buffer names and translates special characters.
|
||||
|
Reference in New Issue
Block a user