mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
api/ui: externalize tabline
- Work with a bool[] array parallel to the UIWidget enum. - Rename some functions. - Documentation.
This commit is contained in:
parent
88023d5123
commit
00843902d3
@ -251,9 +251,9 @@ connect to another with different type codes.
|
|||||||
6. Remote UIs *rpc-remote-ui*
|
6. Remote UIs *rpc-remote-ui*
|
||||||
|
|
||||||
GUIs can be implemented as external processes communicating with Nvim over the
|
GUIs can be implemented as external processes communicating with Nvim over the
|
||||||
RPC API. Currently the UI model consists of a terminal-like grid with one
|
RPC API. The UI model consists of a terminal-like grid with a single,
|
||||||
single, monospace font size. Some elements (UI "widgets") can be drawn
|
monospace font size. Some elements (UI "widgets") can be drawn separately from
|
||||||
separately from the grid.
|
the grid ("externalized").
|
||||||
|
|
||||||
After connecting to Nvim (usually a spawned, embedded instance) use the
|
After connecting to Nvim (usually a spawned, embedded instance) use the
|
||||||
|nvim_ui_attach| API method to tell Nvim that your program wants to draw the
|
|nvim_ui_attach| API method to tell Nvim that your program wants to draw the
|
||||||
@ -264,14 +264,13 @@ a dictionary with these (optional) keys:
|
|||||||
colors.
|
colors.
|
||||||
Set to false to use terminal color codes (at
|
Set to false to use terminal color codes (at
|
||||||
most 256 different colors).
|
most 256 different colors).
|
||||||
`popupmenu_external` Instead of drawing the completion popupmenu on
|
`ui_ext` String array of "externalized" widgets.
|
||||||
the grid, Nvim will send higher-level events to
|
Widgets in this list will not be drawn by
|
||||||
the UI and let it draw the popupmenu.
|
Nvim; only high-level data will be published
|
||||||
Defaults to false.
|
in new UI event kinds. Valid names:
|
||||||
`tabline_external` Instead of drawing the tabline on the grid,
|
popupmenu |ui-ext-popupmenu|
|
||||||
Nvim will send higher-level events to
|
tabline |ui-ext-tabline|
|
||||||
the UI and let it draw the tabline.
|
Defaults to empty.
|
||||||
Defaults to false.
|
|
||||||
|
|
||||||
Nvim will then send msgpack-rpc notifications, with the method name "redraw"
|
Nvim will then send msgpack-rpc notifications, with the method name "redraw"
|
||||||
and a single argument, an array of screen updates (described below). These
|
and a single argument, an array of screen updates (described below). These
|
||||||
@ -421,6 +420,7 @@ properties specified in the corresponding item. The set of modes reported will
|
|||||||
change in new versions of Nvim, for instance more submodes and temporary
|
change in new versions of Nvim, for instance more submodes and temporary
|
||||||
states might be represented as separate modes.
|
states might be represented as separate modes.
|
||||||
|
|
||||||
|
*ui-ext-popupmenu*
|
||||||
["popupmenu_show", items, selected, row, col]
|
["popupmenu_show", items, selected, row, col]
|
||||||
When `popupmenu_external` is set to true, nvim will not draw the
|
When `popupmenu_external` is set to true, nvim will not draw the
|
||||||
popupmenu on the grid, instead when the popupmenu is to be displayed
|
popupmenu on the grid, instead when the popupmenu is to be displayed
|
||||||
@ -440,9 +440,10 @@ states might be represented as separate modes.
|
|||||||
["popupmenu_hide"]
|
["popupmenu_hide"]
|
||||||
The popupmenu is hidden.
|
The popupmenu is hidden.
|
||||||
|
|
||||||
|
*ui-ext-tabline*
|
||||||
["tabline_update", curtab, tabs]
|
["tabline_update", curtab, tabs]
|
||||||
Nvim will send this event when drawing tabline. curtab is the tab id
|
Nvim will send this event when drawing tabline. curtab is the tab id
|
||||||
of the current tab. tabs is an arrays of the form:
|
of the current tab. tabs is an array of the form:
|
||||||
[tabid, { "name": name }]
|
[tabid, { "name": name }]
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
@ -68,8 +68,6 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
|||||||
ui->width = (int)width;
|
ui->width = (int)width;
|
||||||
ui->height = (int)height;
|
ui->height = (int)height;
|
||||||
ui->rgb = true;
|
ui->rgb = true;
|
||||||
ui->pum_external = false;
|
|
||||||
ui->tabline_external = false;
|
|
||||||
ui->resize = remote_ui_resize;
|
ui->resize = remote_ui_resize;
|
||||||
ui->clear = remote_ui_clear;
|
ui->clear = remote_ui_clear;
|
||||||
ui->eol_clear = remote_ui_eol_clear;
|
ui->eol_clear = remote_ui_eol_clear;
|
||||||
@ -96,6 +94,8 @@ 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->event = remote_ui_event;
|
ui->event = remote_ui_event;
|
||||||
|
|
||||||
|
memset(ui->ui_ext, 0, sizeof(ui->ui_ext));
|
||||||
|
|
||||||
for (size_t i = 0; i < options.size; i++) {
|
for (size_t i = 0; i < options.size; i++) {
|
||||||
ui_set_option(ui, options.items[i].key, options.items[i].value, err);
|
ui_set_option(ui, options.items[i].key, options.items[i].value, err);
|
||||||
if (ERROR_SET(err)) {
|
if (ERROR_SET(err)) {
|
||||||
@ -171,7 +171,8 @@ void nvim_ui_set_option(uint64_t channel_id, String name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ui_set_option(UI *ui, String name, Object value, Error *error) {
|
static void ui_set_option(UI *ui, String name, Object value, Error *error)
|
||||||
|
{
|
||||||
if (strequal(name.data, "rgb")) {
|
if (strequal(name.data, "rgb")) {
|
||||||
if (value.type != kObjectTypeBoolean) {
|
if (value.type != kObjectTypeBoolean) {
|
||||||
api_set_error(error, kErrorTypeValidation, "rgb must be a Boolean");
|
api_set_error(error, kErrorTypeValidation, "rgb must be a Boolean");
|
||||||
@ -179,19 +180,42 @@ static void ui_set_option(UI *ui, String name, Object value, Error *error) {
|
|||||||
}
|
}
|
||||||
ui->rgb = value.data.boolean;
|
ui->rgb = value.data.boolean;
|
||||||
} else if (strequal(name.data, "popupmenu_external")) {
|
} else if (strequal(name.data, "popupmenu_external")) {
|
||||||
|
// LEGACY: Deprecated option, use `ui_ext` instead.
|
||||||
if (value.type != kObjectTypeBoolean) {
|
if (value.type != kObjectTypeBoolean) {
|
||||||
api_set_error(error, kErrorTypeValidation,
|
api_set_error(error, kErrorTypeValidation,
|
||||||
"popupmenu_external must be a Boolean");
|
"popupmenu_external must be a Boolean");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui->pum_external = value.data.boolean;
|
ui->ui_ext[kUIPopupmenu] = value.data.boolean;
|
||||||
} else if (strequal(name.data, "tabline_external")) {
|
} else if (strequal(name.data, "ui_ext")) {
|
||||||
if (value.type != kObjectTypeBoolean) {
|
if (value.type != kObjectTypeArray) {
|
||||||
api_set_error(error, kErrorTypeValidation,
|
api_set_error(error, kErrorTypeValidation,
|
||||||
"tabline_external must be a Boolean");
|
"ui_ext must be an Array");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui->tabline_external = value.data.boolean;
|
|
||||||
|
for (size_t i = 0; i < value.data.array.size; i++) {
|
||||||
|
Object item = value.data.array.items[i];
|
||||||
|
if (item.type != kObjectTypeString) {
|
||||||
|
api_set_error(error, kErrorTypeValidation,
|
||||||
|
"ui_ext: item must be a String");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
char *name = item.data.string.data;
|
||||||
|
if (strequal(name, "cmdline")) {
|
||||||
|
ui->ui_ext[kUICmdline] = true;
|
||||||
|
} else if (strequal(name, "popupmenu")) {
|
||||||
|
ui->ui_ext[kUIPopupmenu] = true;
|
||||||
|
} else if (strequal(name, "tabline")) {
|
||||||
|
ui->ui_ext[kUITabline] = true;
|
||||||
|
} else if (strequal(name, "wildmenu")) {
|
||||||
|
ui->ui_ext[kUIWildmenu] = true;
|
||||||
|
} else {
|
||||||
|
api_set_error(error, kErrorTypeValidation,
|
||||||
|
"ui_ext: unknown widget: %s", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
api_set_error(error, kErrorTypeValidation, "No such ui option");
|
api_set_error(error, kErrorTypeValidation, "No such ui option");
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,7 @@ static int pum_row; // top row of pum
|
|||||||
static int pum_col; // left column of pum
|
static int pum_col; // left column of pum
|
||||||
|
|
||||||
static bool pum_is_visible = false;
|
static bool pum_is_visible = false;
|
||||||
|
|
||||||
static bool pum_external = false;
|
static bool pum_external = false;
|
||||||
static bool pum_wants_external = false;
|
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "popupmnu.c.generated.h"
|
# include "popupmnu.c.generated.h"
|
||||||
@ -80,7 +78,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed)
|
|||||||
if (!pum_is_visible) {
|
if (!pum_is_visible) {
|
||||||
// To keep the code simple, we only allow changing the
|
// To keep the code simple, we only allow changing the
|
||||||
// draw mode when the popup menu is not being displayed
|
// draw mode when the popup menu is not being displayed
|
||||||
pum_external = pum_wants_external;
|
pum_external = ui_is_external(kUIPopupmenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
redo:
|
redo:
|
||||||
@ -751,8 +749,3 @@ int pum_get_height(void)
|
|||||||
{
|
{
|
||||||
return pum_height;
|
return pum_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pum_set_external(bool external)
|
|
||||||
{
|
|
||||||
pum_wants_external = external;
|
|
||||||
}
|
|
||||||
|
@ -6886,14 +6886,13 @@ static void draw_tabline(void)
|
|||||||
if (ScreenLines == NULL) {
|
if (ScreenLines == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
redraw_tabline = false;
|
||||||
|
|
||||||
if (ui_is_widget_external(kUITabline)) {
|
if (ui_is_external(kUITabline)) {
|
||||||
draw_tabline_ext();
|
ui_ext_tabline_update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw_tabline = false;
|
|
||||||
|
|
||||||
if (tabline_height() < 1)
|
if (tabline_height() < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -7033,20 +7032,13 @@ static void draw_tabline(void)
|
|||||||
redraw_tabline = FALSE;
|
redraw_tabline = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send tabline update to external ui
|
void ui_ext_tabline_update(void)
|
||||||
void draw_tabline_ext(void)
|
|
||||||
{
|
{
|
||||||
win_T *cwp;
|
|
||||||
|
|
||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
ADD(args, INTEGER_OBJ(curtab->handle));
|
ADD(args, INTEGER_OBJ(curtab->handle));
|
||||||
Array tabs = ARRAY_DICT_INIT;
|
Array tabs = ARRAY_DICT_INIT;
|
||||||
FOR_ALL_TABS(tp) {
|
FOR_ALL_TABS(tp) {
|
||||||
if (tp == curtab) {
|
win_T *cwp = (tp == curtab) ? curwin : tp->tp_curwin;
|
||||||
cwp = curwin;
|
|
||||||
} else {
|
|
||||||
cwp = tp->tp_curwin;
|
|
||||||
}
|
|
||||||
get_trans_bufname(cwp->w_buffer);
|
get_trans_bufname(cwp->w_buffer);
|
||||||
Array tab = ARRAY_DICT_INIT;
|
Array tab = ARRAY_DICT_INIT;
|
||||||
ADD(tab, INTEGER_OBJ(tp->handle));
|
ADD(tab, INTEGER_OBJ(tp->handle));
|
||||||
|
@ -109,8 +109,6 @@ UI *tui_start(void)
|
|||||||
UI *ui = xcalloc(1, sizeof(UI));
|
UI *ui = xcalloc(1, sizeof(UI));
|
||||||
ui->stop = tui_stop;
|
ui->stop = tui_stop;
|
||||||
ui->rgb = p_tgc;
|
ui->rgb = p_tgc;
|
||||||
ui->pum_external = false;
|
|
||||||
ui->tabline_external = false;
|
|
||||||
ui->resize = tui_resize;
|
ui->resize = tui_resize;
|
||||||
ui->clear = tui_clear;
|
ui->clear = tui_clear;
|
||||||
ui->eol_clear = tui_eol_clear;
|
ui->eol_clear = tui_eol_clear;
|
||||||
@ -136,6 +134,9 @@ UI *tui_start(void)
|
|||||||
ui->set_title = tui_set_title;
|
ui->set_title = tui_set_title;
|
||||||
ui->set_icon = tui_set_icon;
|
ui->set_icon = tui_set_icon;
|
||||||
ui->event = tui_event;
|
ui->event = tui_event;
|
||||||
|
|
||||||
|
memset(ui->ui_ext, 0, sizeof(ui->ui_ext));
|
||||||
|
|
||||||
return ui_bridge_attach(ui, tui_main, tui_scheduler);
|
return ui_bridge_attach(ui, tui_main, tui_scheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#define MAX_UI_COUNT 16
|
#define MAX_UI_COUNT 16
|
||||||
|
|
||||||
static UI *uis[MAX_UI_COUNT];
|
static UI *uis[MAX_UI_COUNT];
|
||||||
|
static bool ui_ext[UI_WIDGETS] = { 0 };
|
||||||
static size_t ui_count = 0;
|
static size_t ui_count = 0;
|
||||||
static int row = 0, col = 0;
|
static int row = 0, col = 0;
|
||||||
static struct {
|
static struct {
|
||||||
@ -58,10 +59,6 @@ static int busy = 0;
|
|||||||
static int height, width;
|
static int height, width;
|
||||||
static int old_mode_idx = -1;
|
static int old_mode_idx = -1;
|
||||||
|
|
||||||
static bool tabline_external = false;
|
|
||||||
static bool cmdline_external = false;
|
|
||||||
static bool wildmenu_external = false;
|
|
||||||
|
|
||||||
// UI_CALL invokes a function on all registered UI instances. The functions can
|
// UI_CALL invokes a function on all registered UI instances. The functions can
|
||||||
// have 0-5 arguments (configurable by SELECT_NTH).
|
// have 0-5 arguments (configurable by SELECT_NTH).
|
||||||
//
|
//
|
||||||
@ -170,21 +167,25 @@ void ui_refresh(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int width = INT_MAX, height = INT_MAX;
|
int width = INT_MAX, height = INT_MAX;
|
||||||
bool pum_external = true;
|
bool ext_widgets[UI_WIDGETS];
|
||||||
bool tabline_external = true;
|
for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) {
|
||||||
|
ext_widgets[i] = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < ui_count; i++) {
|
for (size_t i = 0; i < ui_count; i++) {
|
||||||
UI *ui = uis[i];
|
UI *ui = uis[i];
|
||||||
width = MIN(ui->width, width);
|
width = MIN(ui->width, width);
|
||||||
height = MIN(ui->height, height);
|
height = MIN(ui->height, height);
|
||||||
pum_external &= ui->pum_external;
|
for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) {
|
||||||
tabline_external &= ui->tabline_external;
|
ext_widgets[i] &= ui->ui_ext[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
row = col = 0;
|
row = col = 0;
|
||||||
screen_resize(width, height);
|
screen_resize(width, height);
|
||||||
pum_set_external(pum_external);
|
for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) {
|
||||||
ui_set_widget_external(kUITabline, tabline_external);
|
ui_set_external(i, ext_widgets[i]);
|
||||||
|
}
|
||||||
ui_mode_info_set();
|
ui_mode_info_set();
|
||||||
old_mode_idx = -1;
|
old_mode_idx = -1;
|
||||||
ui_cursor_shape();
|
ui_cursor_shape();
|
||||||
@ -564,30 +565,16 @@ void ui_cursor_shape(void)
|
|||||||
conceal_check_cursur_line();
|
conceal_check_cursur_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ui_is_widget_external(UIWidget widget)
|
/// Returns true if `widget` is externalized.
|
||||||
|
bool ui_is_external(UIWidget widget)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
return ui_ext[widget];
|
||||||
case kUITabline:
|
|
||||||
return tabline_external;
|
|
||||||
case kUICmdline:
|
|
||||||
return cmdline_external;
|
|
||||||
case kUIWildmenu:
|
|
||||||
return wildmenu_external;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_set_widget_external(UIWidget widget, bool external)
|
/// Sets `widget` as "external".
|
||||||
|
/// Such widgets are not drawn by Nvim; external UIs are expected to handle
|
||||||
|
/// higher-level UI events and present the data.
|
||||||
|
void ui_set_external(UIWidget widget, bool external)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
ui_ext[widget] = external;
|
||||||
case kUITabline:
|
|
||||||
tabline_external = external;
|
|
||||||
break;
|
|
||||||
case kUICmdline:
|
|
||||||
cmdline_external = external;
|
|
||||||
break;
|
|
||||||
case kUIWildmenu:
|
|
||||||
wildmenu_external = external;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,13 @@
|
|||||||
#include "api/private/defs.h"
|
#include "api/private/defs.h"
|
||||||
#include "nvim/buffer_defs.h"
|
#include "nvim/buffer_defs.h"
|
||||||
|
|
||||||
// values for externalized widgets
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
kUICmdline = 0,
|
||||||
|
kUIPopupmenu,
|
||||||
kUITabline,
|
kUITabline,
|
||||||
kUICmdline,
|
kUIWildmenu,
|
||||||
kUIWildmenu
|
|
||||||
} UIWidget;
|
} UIWidget;
|
||||||
|
#define UI_WIDGETS (kUIWildmenu + 1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool bold, underline, undercurl, italic, reverse;
|
bool bold, underline, undercurl, italic, reverse;
|
||||||
@ -23,7 +24,8 @@ typedef struct {
|
|||||||
typedef struct ui_t UI;
|
typedef struct ui_t UI;
|
||||||
|
|
||||||
struct ui_t {
|
struct ui_t {
|
||||||
bool rgb, pum_external, tabline_external;
|
bool rgb;
|
||||||
|
bool ui_ext[UI_WIDGETS]; ///< Externalized widgets
|
||||||
int width, height;
|
int width, height;
|
||||||
void *data;
|
void *data;
|
||||||
void (*resize)(UI *ui, int rows, int columns);
|
void (*resize)(UI *ui, int rows, int columns);
|
||||||
|
@ -57,8 +57,6 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler)
|
|||||||
UIBridgeData *rv = xcalloc(1, sizeof(UIBridgeData));
|
UIBridgeData *rv = xcalloc(1, sizeof(UIBridgeData));
|
||||||
rv->ui = ui;
|
rv->ui = ui;
|
||||||
rv->bridge.rgb = ui->rgb;
|
rv->bridge.rgb = ui->rgb;
|
||||||
rv->bridge.pum_external = ui->pum_external;
|
|
||||||
rv->bridge.tabline_external = ui->tabline_external;
|
|
||||||
rv->bridge.stop = ui_bridge_stop;
|
rv->bridge.stop = ui_bridge_stop;
|
||||||
rv->bridge.resize = ui_bridge_resize;
|
rv->bridge.resize = ui_bridge_resize;
|
||||||
rv->bridge.clear = ui_bridge_clear;
|
rv->bridge.clear = ui_bridge_clear;
|
||||||
@ -86,6 +84,10 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler)
|
|||||||
rv->bridge.set_icon = ui_bridge_set_icon;
|
rv->bridge.set_icon = ui_bridge_set_icon;
|
||||||
rv->scheduler = scheduler;
|
rv->scheduler = scheduler;
|
||||||
|
|
||||||
|
for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) {
|
||||||
|
rv->bridge.ui_ext[i] = ui->ui_ext[i];
|
||||||
|
}
|
||||||
|
|
||||||
rv->ui_main = ui_main;
|
rv->ui_main = ui_main;
|
||||||
uv_mutex_init(&rv->mutex);
|
uv_mutex_init(&rv->mutex);
|
||||||
uv_cond_init(&rv->cond);
|
uv_cond_init(&rv->cond);
|
||||||
|
@ -5224,8 +5224,8 @@ static void last_status_rec(frame_T *fr, int statusline)
|
|||||||
*/
|
*/
|
||||||
int tabline_height(void)
|
int tabline_height(void)
|
||||||
{
|
{
|
||||||
if (ui_is_widget_external(kUITabline)) {
|
if (ui_is_external(kUITabline)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
assert(first_tabpage);
|
assert(first_tabpage);
|
||||||
switch (p_stal) {
|
switch (p_stal) {
|
||||||
|
@ -6,7 +6,7 @@ local insert = helpers.insert
|
|||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
|
|
||||||
describe('Initial screen', function()
|
describe('screen', function()
|
||||||
local screen
|
local screen
|
||||||
local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
|
||||||
'--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
|
'--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
|
||||||
@ -27,7 +27,7 @@ describe('Initial screen', function()
|
|||||||
screen:detach()
|
screen:detach()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is the default initial screen', function()
|
it('default initial screen', function()
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^ |
|
^ |
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
@ -565,12 +565,40 @@ describe('Screen', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
it('nvim_ui_attach() handles very large width/height #2180', function()
|
describe('nvim_ui_attach()', function()
|
||||||
screen:detach()
|
before_each(function()
|
||||||
screen = Screen.new(999, 999)
|
clear()
|
||||||
|
end)
|
||||||
|
it('handles very large width/height #2180', function()
|
||||||
|
local screen = Screen.new(999, 999)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
eq(999, eval('&lines'))
|
eq(999, eval('&lines'))
|
||||||
eq(999, eval('&columns'))
|
eq(999, eval('&columns'))
|
||||||
end)
|
end)
|
||||||
|
it('"ui_ext" widgets', function()
|
||||||
|
local screen = Screen.new()
|
||||||
|
screen:attach({ui_ext={
|
||||||
|
'cmdline',
|
||||||
|
'popupmenu',
|
||||||
|
'tabline',
|
||||||
|
'wildmenu',
|
||||||
|
}})
|
||||||
|
end)
|
||||||
|
it('invalid "ui_ext" returns error', function()
|
||||||
|
local screen = Screen.new()
|
||||||
|
|
||||||
|
local status, rv = pcall(function() screen:attach({ui_ext={'foo'}}) end)
|
||||||
|
eq(false, status)
|
||||||
|
eq('ui_ext: unknown widget: foo', rv:match("ui_ext:.*"))
|
||||||
|
|
||||||
|
status, rv = pcall(function() screen:attach({ui_ext={'cmdline','foo'}}) end)
|
||||||
|
eq(false, status)
|
||||||
|
eq('ui_ext: unknown widget: foo', rv:match("ui_ext:.*"))
|
||||||
|
|
||||||
|
status, rv = pcall(function() screen:attach({ui_ext={'cmdline',1}}) end)
|
||||||
|
eq(false, status)
|
||||||
|
eq('ui_ext: item must be a String', rv:match("ui_ext:.*"))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -2,16 +2,14 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq
|
local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
describe('ui/tabline', function()
|
||||||
|
|
||||||
describe('External tab line', function()
|
|
||||||
local screen
|
local screen
|
||||||
local tabs, curtab
|
local tabs, curtab
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = Screen.new(25, 5)
|
screen = Screen.new(25, 5)
|
||||||
screen:attach({rgb=true, tabline_external=true})
|
screen:attach({rgb=true, ui_ext={'tabline'}})
|
||||||
screen:set_on_event_handler(function(name, data)
|
screen:set_on_event_handler(function(name, data)
|
||||||
if name == "tabline_update" then
|
if name == "tabline_update" then
|
||||||
curtab, tabs = unpack(data)
|
curtab, tabs = unpack(data)
|
||||||
@ -23,8 +21,8 @@ describe('External tab line', function()
|
|||||||
screen:detach()
|
screen:detach()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe("'tabline'", function()
|
describe('externalized', function()
|
||||||
it('tabline', function()
|
it('publishes UI events', function()
|
||||||
local expected = {
|
local expected = {
|
||||||
{1, {['name'] = '[No Name]'}},
|
{1, {['name'] = '[No Name]'}},
|
||||||
{2, {['name'] = '[No Name]'}},
|
{2, {['name'] = '[No Name]'}},
|
||||||
|
@ -868,13 +868,13 @@ describe('completion', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('External completion popupmenu', function()
|
describe('ui/externalized/popupmenu', function()
|
||||||
local screen
|
local screen
|
||||||
local items, selected, anchor
|
local items, selected, anchor
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = Screen.new(60, 8)
|
screen = Screen.new(60, 8)
|
||||||
screen:attach({rgb=true, popupmenu_external=true})
|
screen:attach({rgb=true, ui_ext={'popupmenu'}})
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
[1] = {bold=true, foreground=Screen.colors.Blue},
|
[1] = {bold=true, foreground=Screen.colors.Blue},
|
||||||
[2] = {bold = true},
|
[2] = {bold = true},
|
||||||
|
Loading…
Reference in New Issue
Block a user