mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
Merge #9992 from justinmk/ui-upgrade
UI/nvim_ui_attach(): add "override" option
This commit is contained in:
@@ -110,6 +110,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
||||
ui->width = (int)width;
|
||||
ui->height = (int)height;
|
||||
ui->rgb = true;
|
||||
ui->override = false;
|
||||
ui->grid_resize = remote_ui_grid_resize;
|
||||
ui->grid_clear = remote_ui_grid_clear;
|
||||
ui->grid_cursor_goto = remote_ui_grid_cursor_goto;
|
||||
@@ -236,6 +237,15 @@ void nvim_ui_set_option(uint64_t channel_id, String name,
|
||||
static void ui_set_option(UI *ui, bool init, String name, Object value,
|
||||
Error *error)
|
||||
{
|
||||
if (strequal(name.data, "override")) {
|
||||
if (value.type != kObjectTypeBoolean) {
|
||||
api_set_error(error, kErrorTypeValidation, "override must be a Boolean");
|
||||
return;
|
||||
}
|
||||
ui->override = value.data.boolean;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strequal(name.data, "rgb")) {
|
||||
if (value.type != kObjectTypeBoolean) {
|
||||
api_set_error(error, kErrorTypeValidation, "rgb must be a Boolean");
|
||||
|
@@ -141,6 +141,17 @@ bool ui_rgb_attached(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Returns true if any UI requested `override=true`.
|
||||
bool ui_override(void)
|
||||
{
|
||||
for (size_t i = 1; i < ui_count; i++) {
|
||||
if (uis[i]->override) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ui_active(void)
|
||||
{
|
||||
return ui_count > 1;
|
||||
@@ -173,12 +184,13 @@ void ui_refresh(void)
|
||||
ext_widgets[i] = true;
|
||||
}
|
||||
|
||||
bool inclusive = ui_override();
|
||||
for (size_t i = 0; i < ui_count; i++) {
|
||||
UI *ui = uis[i];
|
||||
width = MIN(ui->width, width);
|
||||
height = MIN(ui->height, height);
|
||||
for (UIExtension j = 0; (int)j < kUIExtCount; j++) {
|
||||
ext_widgets[j] &= ui->ui_ext[j];
|
||||
ext_widgets[j] &= (ui->ui_ext[j] || inclusive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +443,7 @@ Array ui_array(void)
|
||||
PUT(info, "width", INTEGER_OBJ(ui->width));
|
||||
PUT(info, "height", INTEGER_OBJ(ui->height));
|
||||
PUT(info, "rgb", BOOLEAN_OBJ(ui->rgb));
|
||||
PUT(info, "override", BOOLEAN_OBJ(ui->override));
|
||||
for (UIExtension j = 0; j < kUIExtCount; j++) {
|
||||
if (ui_ext_names[j][0] != '_' || ui->ui_ext[j]) {
|
||||
PUT(info, ui_ext_names[j], BOOLEAN_OBJ(ui->ui_ext[j]));
|
||||
|
@@ -48,9 +48,11 @@ typedef int LineFlags;
|
||||
|
||||
struct ui_t {
|
||||
bool rgb;
|
||||
bool override; ///< Force highest-requested UI capabilities.
|
||||
bool composed;
|
||||
bool ui_ext[kUIExtCount]; ///< Externalized widgets
|
||||
int width, height;
|
||||
bool ui_ext[kUIExtCount]; ///< Externalized UI capabilities.
|
||||
int width;
|
||||
int height;
|
||||
void *data;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
|
Reference in New Issue
Block a user