mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
ui: Implement set_{title,icon}
This commit is contained in:
parent
ea771ac559
commit
8596776bf6
@ -98,6 +98,8 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
|
|||||||
ui->update_bg = remote_ui_update_bg;
|
ui->update_bg = remote_ui_update_bg;
|
||||||
ui->flush = remote_ui_flush;
|
ui->flush = remote_ui_flush;
|
||||||
ui->suspend = remote_ui_suspend;
|
ui->suspend = remote_ui_suspend;
|
||||||
|
ui->set_title = remote_ui_set_title;
|
||||||
|
ui->set_icon = remote_ui_set_icon;
|
||||||
pmap_put(uint64_t)(connected_uis, channel_id, ui);
|
pmap_put(uint64_t)(connected_uis, channel_id, ui);
|
||||||
ui_attach(ui);
|
ui_attach(ui);
|
||||||
return NIL;
|
return NIL;
|
||||||
@ -325,3 +327,17 @@ static void remote_ui_suspend(UI *ui)
|
|||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
push_call(ui, "suspend", args);
|
push_call(ui, "suspend", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void remote_ui_set_title(UI *ui, char *title)
|
||||||
|
{
|
||||||
|
Array args = ARRAY_DICT_INIT;
|
||||||
|
ADD(args, STRING_OBJ(cstr_to_string(title)));
|
||||||
|
push_call(ui, "set_title", args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void remote_ui_set_icon(UI *ui, char *icon)
|
||||||
|
{
|
||||||
|
Array args = ARRAY_DICT_INIT;
|
||||||
|
ADD(args, STRING_OBJ(cstr_to_string(icon)));
|
||||||
|
push_call(ui, "set_icon", args);
|
||||||
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "nvim/syntax.h"
|
#include "nvim/syntax.h"
|
||||||
#include "nvim/tempfile.h"
|
#include "nvim/tempfile.h"
|
||||||
#include "nvim/term.h"
|
#include "nvim/term.h"
|
||||||
|
#include "nvim/ui.h"
|
||||||
#include "nvim/types.h"
|
#include "nvim/types.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/os/time.h"
|
#include "nvim/os/time.h"
|
||||||
@ -181,22 +182,26 @@ void mch_settitle(char_u *title, char_u *icon)
|
|||||||
* Note: if "t_ts" is set, title is set with escape sequence rather
|
* Note: if "t_ts" is set, title is set with escape sequence rather
|
||||||
* than x11 calls, because the x11 calls don't always work
|
* than x11 calls, because the x11 calls don't always work
|
||||||
*/
|
*/
|
||||||
if ((type || *T_TS != NUL) && title != NULL) {
|
if ((type || *T_TS != NUL || abstract_ui) && title != NULL) {
|
||||||
if (oldtitle == NULL
|
if (oldtitle == NULL
|
||||||
) /* first call but not in GUI, save title */
|
) /* first call but not in GUI, save title */
|
||||||
(void)get_x11_title(FALSE);
|
(void)get_x11_title(FALSE);
|
||||||
|
|
||||||
if (*T_TS != NUL) /* it's OK if t_fs is empty */
|
if (abstract_ui) {
|
||||||
|
ui_set_title((char *)title);
|
||||||
|
} else if (*T_TS != NUL) /* it's OK if t_fs is empty */
|
||||||
term_settitle(title);
|
term_settitle(title);
|
||||||
did_set_title = TRUE;
|
did_set_title = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((type || *T_CIS != NUL) && icon != NULL) {
|
if ((type || *T_CIS != NUL || abstract_ui) && icon != NULL) {
|
||||||
if (oldicon == NULL
|
if (oldicon == NULL
|
||||||
) /* first call, save icon */
|
) /* first call, save icon */
|
||||||
get_x11_icon(FALSE);
|
get_x11_icon(FALSE);
|
||||||
|
|
||||||
if (*T_CIS != NUL) {
|
if (abstract_ui) {
|
||||||
|
ui_set_icon((char *)icon);
|
||||||
|
} else if (*T_CIS != NUL) {
|
||||||
out_str(T_CIS); /* set icon start */
|
out_str(T_CIS); /* set icon start */
|
||||||
out_str_nf(icon);
|
out_str_nf(icon);
|
||||||
out_str(T_CIE); /* set icon end */
|
out_str(T_CIE); /* set icon end */
|
||||||
|
@ -139,6 +139,18 @@ void ui_suspend(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ui_set_title(char *title)
|
||||||
|
{
|
||||||
|
UI_CALL(set_title, title);
|
||||||
|
UI_CALL(flush);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_set_icon(char *icon)
|
||||||
|
{
|
||||||
|
UI_CALL(set_icon, icon);
|
||||||
|
UI_CALL(flush);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to get the current Vim shell size. Put the result in Rows and Columns.
|
* Try to get the current Vim shell size. Put the result in Rows and Columns.
|
||||||
* Use the new sizes as defaults for 'columns' and 'lines'.
|
* Use the new sizes as defaults for 'columns' and 'lines'.
|
||||||
|
@ -36,6 +36,8 @@ struct ui_t {
|
|||||||
void (*update_fg)(UI *ui, int fg);
|
void (*update_fg)(UI *ui, int fg);
|
||||||
void (*update_bg)(UI *ui, int bg);
|
void (*update_bg)(UI *ui, int bg);
|
||||||
void (*suspend)(UI *ui);
|
void (*suspend)(UI *ui);
|
||||||
|
void (*set_title)(UI *ui, char *title);
|
||||||
|
void (*set_icon)(UI *ui, char *icon);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@ -115,6 +115,8 @@ function Screen.new(width, height)
|
|||||||
_bell = false,
|
_bell = false,
|
||||||
_visual_bell = false,
|
_visual_bell = false,
|
||||||
_suspended = true,
|
_suspended = true,
|
||||||
|
_title = nil,
|
||||||
|
_icon = nil,
|
||||||
_attrs = {},
|
_attrs = {},
|
||||||
_cursor = {
|
_cursor = {
|
||||||
enabled = true, row = 1, col = 1
|
enabled = true, row = 1, col = 1
|
||||||
@ -306,6 +308,14 @@ function Screen:_handle_suspend()
|
|||||||
self._suspended = true
|
self._suspended = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Screen:_handle_set_title(title)
|
||||||
|
self._title = title
|
||||||
|
end
|
||||||
|
|
||||||
|
function Screen:_handle_set_icon(icon)
|
||||||
|
self._icon = icon
|
||||||
|
end
|
||||||
|
|
||||||
function Screen:_clear_block(top, lines, left, columns)
|
function Screen:_clear_block(top, lines, left, columns)
|
||||||
for i = top, top + lines - 1 do
|
for i = top, top + lines - 1 do
|
||||||
self:_clear_row_section(i, left, left + columns - 1)
|
self:_clear_row_section(i, left, left + columns - 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user