-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[RDY] allow external ui to draw tabline #6170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
runtime/doc/msgpack_rpc.txt
Outdated
@@ -413,5 +417,9 @@ of update. | |||
["popupmenu_hide"] | |||
The popupmenu is hidden. | |||
|
|||
["tabline", curtab, tabs] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An event is something that happens. Let's name this something more granular, e.g. "tabline_update". That follows the pattern of the existing "bg_update" and similar events.
src/nvim/window.c
Outdated
@@ -5158,6 +5160,9 @@ static void last_status_rec(frame_T *fr, int statusline) | |||
*/ | |||
int tabline_height(void) | |||
{ | |||
if (tabline_external) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this query the UI structure instead of storing extra state in window.c? E.g. ui_is_widget_external(kUITabline)
, where the parameter is a enum like:
enum {
kUITabline,
kUIStatusline,
kUICmdline,
...
}
@@ -53,6 +53,10 @@ static bool pending_cursor_update = false; | |||
static int busy = 0; | |||
static int height, width; | |||
|
|||
static bool tabline_external = false; | |||
static bool cmdline_external = false; | |||
static bool wildmenu_external = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about why this extra state is needed. Can the uis
be iterated to find the flag instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that it's because we are worried about the possibility that a UI might connect that doesn't support a externalized widget. Hmmm... ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So shall I keep these as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's fine.
src/nvim/ui.c
Outdated
case kUIWildmenu: | ||
return wildmenu_external; | ||
default: | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave out the default case. Our build settings will catch a missing case at compile-time. But for that to work, the enum needs to be typedef'd.
src/nvim/ui.h
Outdated
kUITabline = 0 | ||
, kUICmdline | ||
, kUIWildmenu | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a named type, e.g. UIWidget
typedef enum {
...
} UIWidget;
src/nvim/ui.c
Outdated
@@ -548,3 +555,31 @@ static void ui_mode_change(void) | |||
conceal_check_cursur_line(); | |||
} | |||
|
|||
bool ui_is_widget_external(int widget) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter should be UIWidget widget
@@ -6888,6 +6889,30 @@ static void draw_tabline(void) | |||
int use_sep_chars = (t_colors < 8 | |||
); | |||
|
|||
if (ui_is_widget_external(kUITabline)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's factor this out to a new function, draw_tabline_ext()
.
if (ui_is_widget_external(kUITabline)) {
draw_tabline_ext();
return;
}
If possible, try to follow a similar pattern for other externalized widgets.
The built-in tabline supports mouse-clicks which run a user-defined VimL function (see What are your thoughts about how externalized tabline widget can support that? |
The only way I can think of is that we output the raw format string to external ui and external ui can call the vimscript directly if that filed is clicked. |
put draw_tabline_ext to a function
Searching for In the "tabline_update" event, I think we need to include We don't have to do that right now. The only thing we need to do is make sure the I think that means for the
where {dict} may contain new fields in the future. |
runtime/doc/msgpack_rpc.txt
Outdated
@@ -413,5 +417,9 @@ of update. | |||
["popupmenu_hide"] | |||
The popupmenu is hidden. | |||
|
|||
["tabline_update", curtab, tabs] | |||
Nvim will send this event when drawing tabline. curtab is the tab id | |||
of the current tab. tabs is an arrays of the form [tabid, tabname]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabs is an arrays of the form [tabid, { "name": name } ].
Then we can add new fields later.
Anything else I need to improve to get this merged, cause I'm waiting to use the enum here for other external widgets. |
Part of PR #5686