mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 19:25:11 -07:00
ui: Reimplement :suspend
command for remote UIs.
- Remove suspend method from the UI protocol - Handle `:suspend` by disconnecting the last channel that sent a request to nvim.
This commit is contained in:
parent
abc147a977
commit
d992213678
@ -71,6 +71,7 @@
|
|||||||
#include "nvim/os/time.h"
|
#include "nvim/os/time.h"
|
||||||
#include "nvim/ex_cmds_defs.h"
|
#include "nvim/ex_cmds_defs.h"
|
||||||
#include "nvim/mouse.h"
|
#include "nvim/mouse.h"
|
||||||
|
#include "nvim/msgpack_rpc/channel.h"
|
||||||
|
|
||||||
static int quitmore = 0;
|
static int quitmore = 0;
|
||||||
static int ex_pressedreturn = FALSE;
|
static int ex_pressedreturn = FALSE;
|
||||||
@ -5398,10 +5399,16 @@ static void ex_stop(exarg_T *eap)
|
|||||||
/*
|
/*
|
||||||
* Disallow suspending for "rvim".
|
* Disallow suspending for "rvim".
|
||||||
*/
|
*/
|
||||||
if (!check_restricted()
|
if (!check_restricted()) {
|
||||||
) {
|
if (!eap->forceit) {
|
||||||
if (!eap->forceit)
|
|
||||||
autowrite_all();
|
autowrite_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abstract_ui) {
|
||||||
|
channel_close(last_message_source);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
windgoto((int)Rows - 1, 0);
|
windgoto((int)Rows - 1, 0);
|
||||||
out_char('\n');
|
out_char('\n');
|
||||||
out_flush();
|
out_flush();
|
||||||
|
@ -1245,6 +1245,9 @@ EXTERN int curr_tmode INIT(= TMODE_COOK); /* contains current terminal mode */
|
|||||||
EXTERN bool embedded_mode INIT(= false);
|
EXTERN bool embedded_mode INIT(= false);
|
||||||
// Using the "abstract_ui" termcap
|
// Using the "abstract_ui" termcap
|
||||||
EXTERN bool abstract_ui INIT(= false);
|
EXTERN bool abstract_ui INIT(= false);
|
||||||
|
// Id of the last channel sent a message to nvim. Used to determine the target
|
||||||
|
// of channel-specific actions such as suspending
|
||||||
|
EXTERN uint64_t last_message_source INIT(= 0);
|
||||||
|
|
||||||
/// Used to track the status of external functions.
|
/// Used to track the status of external functions.
|
||||||
/// Currently only used for iconv().
|
/// Currently only used for iconv().
|
||||||
|
@ -485,6 +485,7 @@ static void on_request_event(Event event)
|
|||||||
{
|
{
|
||||||
RequestEvent *e = event.data;
|
RequestEvent *e = event.data;
|
||||||
Channel *channel = e->channel;
|
Channel *channel = e->channel;
|
||||||
|
last_message_source = channel->id;
|
||||||
MsgpackRpcRequestHandler handler = e->handler;
|
MsgpackRpcRequestHandler handler = e->handler;
|
||||||
Array args = e->args;
|
Array args = e->args;
|
||||||
uint64_t request_id = e->request_id;
|
uint64_t request_id = e->request_id;
|
||||||
|
@ -97,7 +97,6 @@ static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
|
|||||||
ui->update_fg = remote_ui_update_fg;
|
ui->update_fg = remote_ui_update_fg;
|
||||||
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;
|
|
||||||
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;
|
||||||
@ -319,9 +318,3 @@ static void remote_ui_flush(UI *ui)
|
|||||||
channel_send_event(data->channel_id, "redraw", data->buffer);
|
channel_send_event(data->channel_id, "redraw", data->buffer);
|
||||||
data->buffer = (Array)ARRAY_DICT_INIT;
|
data->buffer = (Array)ARRAY_DICT_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remote_ui_suspend(UI *ui)
|
|
||||||
{
|
|
||||||
UIData *data = ui->data;
|
|
||||||
remote_ui_disconnect(data->channel_id);
|
|
||||||
}
|
|
||||||
|
@ -117,9 +117,7 @@ void ui_write(uint8_t *s, int len)
|
|||||||
*/
|
*/
|
||||||
void ui_suspend(void)
|
void ui_suspend(void)
|
||||||
{
|
{
|
||||||
if (abstract_ui) {
|
if (!abstract_ui) {
|
||||||
UI_CALL(suspend);
|
|
||||||
} else {
|
|
||||||
mch_suspend();
|
mch_suspend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ struct ui_t {
|
|||||||
void (*flush)(UI *ui);
|
void (*flush)(UI *ui);
|
||||||
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);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@ -99,7 +99,6 @@ function Screen.new(width, height)
|
|||||||
_mouse_enabled = true,
|
_mouse_enabled = true,
|
||||||
_bell = false,
|
_bell = false,
|
||||||
_visual_bell = false,
|
_visual_bell = false,
|
||||||
_suspended = true,
|
|
||||||
_attrs = {},
|
_attrs = {},
|
||||||
_cursor = {
|
_cursor = {
|
||||||
enabled = true, row = 1, col = 1
|
enabled = true, row = 1, col = 1
|
||||||
@ -116,12 +115,10 @@ end
|
|||||||
|
|
||||||
function Screen:attach()
|
function Screen:attach()
|
||||||
request('ui_attach', self._width, self._height, true)
|
request('ui_attach', self._width, self._height, true)
|
||||||
self._suspended = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Screen:detach()
|
function Screen:detach()
|
||||||
request('ui_detach')
|
request('ui_detach')
|
||||||
self._suspended = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Screen:expect(expected, attr_ids)
|
function Screen:expect(expected, attr_ids)
|
||||||
@ -286,10 +283,6 @@ function Screen:_handle_update_bg(bg)
|
|||||||
self._bg = bg
|
self._bg = bg
|
||||||
end
|
end
|
||||||
|
|
||||||
function Screen:_handle_suspend()
|
|
||||||
self._suspended = true
|
|
||||||
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