mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #8456 'API: nvim_list_uis: include channel id'
This commit is contained in:
commit
402a797d08
@ -97,6 +97,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
|||||||
ui->set_icon = remote_ui_set_icon;
|
ui->set_icon = remote_ui_set_icon;
|
||||||
ui->option_set = remote_ui_option_set;
|
ui->option_set = remote_ui_option_set;
|
||||||
ui->event = remote_ui_event;
|
ui->event = remote_ui_event;
|
||||||
|
ui->inspect = remote_ui_inspect;
|
||||||
|
|
||||||
memset(ui->ui_ext, 0, sizeof(ui->ui_ext));
|
memset(ui->ui_ext, 0, sizeof(ui->ui_ext));
|
||||||
|
|
||||||
@ -275,3 +276,9 @@ static void remote_ui_event(UI *ui, char *name, Array args, bool *args_consumed)
|
|||||||
}
|
}
|
||||||
push_call(ui, name, my_args);
|
push_call(ui, name, my_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void remote_ui_inspect(UI *ui, Dictionary *info)
|
||||||
|
{
|
||||||
|
UIData *data = ui->data;
|
||||||
|
PUT(*info, "chan", INTEGER_OBJ((Integer)data->channel_id));
|
||||||
|
}
|
||||||
|
@ -62,7 +62,7 @@ void set_title(String title)
|
|||||||
void set_icon(String icon)
|
void set_icon(String icon)
|
||||||
FUNC_API_SINCE(3);
|
FUNC_API_SINCE(3);
|
||||||
void option_set(String name, Object value)
|
void option_set(String name, Object value)
|
||||||
FUNC_API_SINCE(4);
|
FUNC_API_SINCE(4) FUNC_API_BRIDGE_IMPL;
|
||||||
|
|
||||||
void popupmenu_show(Array items, Integer selected, Integer row, Integer col)
|
void popupmenu_show(Array items, Integer selected, Integer row, Integer col)
|
||||||
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
|
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
|
||||||
|
@ -1747,6 +1747,14 @@ Dictionary nvim__stats(void)
|
|||||||
/// Gets a list of dictionaries representing attached UIs.
|
/// Gets a list of dictionaries representing attached UIs.
|
||||||
///
|
///
|
||||||
/// @return Array of UI dictionaries
|
/// @return Array of UI dictionaries
|
||||||
|
///
|
||||||
|
/// Each dictionary has the following keys:
|
||||||
|
/// - "height" requested height of the UI
|
||||||
|
/// - "width" requested width of the UI
|
||||||
|
/// - "rgb" whether the UI uses rgb colors (false implies cterm colors)
|
||||||
|
/// - "ext_..." Requested UI extensions, see |ui-options|
|
||||||
|
/// - "chan" Channel id of remote UI (not present for TUI)
|
||||||
|
///
|
||||||
Array nvim_list_uis(void)
|
Array nvim_list_uis(void)
|
||||||
FUNC_API_SINCE(4)
|
FUNC_API_SINCE(4)
|
||||||
{
|
{
|
||||||
|
@ -535,14 +535,18 @@ Array ui_array(void)
|
|||||||
{
|
{
|
||||||
Array all_uis = ARRAY_DICT_INIT;
|
Array all_uis = ARRAY_DICT_INIT;
|
||||||
for (size_t i = 0; i < ui_count; i++) {
|
for (size_t i = 0; i < ui_count; i++) {
|
||||||
Dictionary dic = ARRAY_DICT_INIT;
|
UI *ui = uis[i];
|
||||||
PUT(dic, "width", INTEGER_OBJ(uis[i]->width));
|
Dictionary info = ARRAY_DICT_INIT;
|
||||||
PUT(dic, "height", INTEGER_OBJ(uis[i]->height));
|
PUT(info, "width", INTEGER_OBJ(ui->width));
|
||||||
PUT(dic, "rgb", BOOLEAN_OBJ(uis[i]->rgb));
|
PUT(info, "height", INTEGER_OBJ(ui->height));
|
||||||
|
PUT(info, "rgb", BOOLEAN_OBJ(ui->rgb));
|
||||||
for (UIExtension j = 0; j < kUIExtCount; j++) {
|
for (UIExtension j = 0; j < kUIExtCount; j++) {
|
||||||
PUT(dic, ui_ext_names[j], BOOLEAN_OBJ(uis[i]->ui_ext[j]));
|
PUT(info, ui_ext_names[j], BOOLEAN_OBJ(ui->ui_ext[j]));
|
||||||
}
|
}
|
||||||
ADD(all_uis, DICTIONARY_OBJ(dic));
|
if (ui->inspect) {
|
||||||
|
ui->inspect(ui, &info);
|
||||||
|
}
|
||||||
|
ADD(all_uis, DICTIONARY_OBJ(info));
|
||||||
}
|
}
|
||||||
return all_uis;
|
return all_uis;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ struct ui_t {
|
|||||||
#endif
|
#endif
|
||||||
void (*event)(UI *ui, char *name, Array args, bool *args_consumed);
|
void (*event)(UI *ui, char *name, Array args, bool *args_consumed);
|
||||||
void (*stop)(UI *ui);
|
void (*stop)(UI *ui);
|
||||||
|
void (*inspect)(UI *ui, Dictionary *info);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@ -163,3 +163,28 @@ static void ui_bridge_suspend_event(void **argv)
|
|||||||
UI *ui = UI(argv[0]);
|
UI *ui = UI(argv[0]);
|
||||||
ui->suspend(ui);
|
ui->suspend(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ui_bridge_option_set(UI *ui, String name, Object value)
|
||||||
|
{
|
||||||
|
String copy_name = copy_string(name);
|
||||||
|
Object *copy_value = xmalloc(sizeof(Object));
|
||||||
|
*copy_value = copy_object(value);
|
||||||
|
UI_BRIDGE_CALL(ui, option_set, 4, ui, copy_name.data,
|
||||||
|
INT2PTR(copy_name.size), copy_value);
|
||||||
|
// TODO(bfredl): when/if TUI/bridge teardown is refactored to use events, the
|
||||||
|
// commit that introduced this special case can be reverted.
|
||||||
|
// For now this is needed for nvim_list_uis().
|
||||||
|
if (strequal(name.data, "termguicolors")) {
|
||||||
|
ui->rgb = value.data.boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void ui_bridge_option_set_event(void **argv)
|
||||||
|
{
|
||||||
|
UI *ui = UI(argv[0]);
|
||||||
|
String name = (String){ .data = argv[1], .size = (size_t)argv[2] };
|
||||||
|
Object value = *(Object *)argv[3];
|
||||||
|
ui->option_set(ui, name, value);
|
||||||
|
api_free_string(name);
|
||||||
|
api_free_object(value);
|
||||||
|
xfree(argv[3]);
|
||||||
|
}
|
||||||
|
@ -1226,6 +1226,7 @@ describe('api', function()
|
|||||||
screen:attach()
|
screen:attach()
|
||||||
local expected = {
|
local expected = {
|
||||||
{
|
{
|
||||||
|
chan = 1,
|
||||||
ext_cmdline = false,
|
ext_cmdline = false,
|
||||||
ext_popupmenu = false,
|
ext_popupmenu = false,
|
||||||
ext_tabline = false,
|
ext_tabline = false,
|
||||||
@ -1242,6 +1243,7 @@ describe('api', function()
|
|||||||
screen:attach({ rgb = false })
|
screen:attach({ rgb = false })
|
||||||
expected = {
|
expected = {
|
||||||
{
|
{
|
||||||
|
chan = 1,
|
||||||
ext_cmdline = false,
|
ext_cmdline = false,
|
||||||
ext_popupmenu = false,
|
ext_popupmenu = false,
|
||||||
ext_tabline = false,
|
ext_tabline = false,
|
||||||
|
@ -253,6 +253,19 @@ describe('tui', function()
|
|||||||
{4:-- TERMINAL --} |
|
{4:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('shows up in nvim_list_uis', function()
|
||||||
|
feed_data(':echo map(nvim_list_uis(), {k,v -> sort(items(v))})\013')
|
||||||
|
screen:expect([=[
|
||||||
|
{5: }|
|
||||||
|
[[['ext_cmdline', v:false], ['ext_popupmenu', v:fa|
|
||||||
|
lse], ['ext_tabline', v:false], ['ext_wildmenu', v|
|
||||||
|
:false], ['height', 6], ['rgb', v:false], ['width'|
|
||||||
|
, 50]]] |
|
||||||
|
{10:Press ENTER or type command to continue}{1: } |
|
||||||
|
{3:-- TERMINAL --} |
|
||||||
|
]=])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('tui with non-tty file descriptors', function()
|
describe('tui with non-tty file descriptors', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user