mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Merge pull request #17747 from bfredl/ui_input
feat(ui_client): input and resize
This commit is contained in:
commit
09a3b33d36
@ -19,6 +19,7 @@
|
||||
# include "nvim/os/os_win_console.h"
|
||||
#endif
|
||||
#include "nvim/event/rstream.h"
|
||||
#include "nvim/msgpack_rpc/channel.h"
|
||||
|
||||
#define KEY_BUFFER_SIZE 0xfff
|
||||
|
||||
@ -125,8 +126,16 @@ static void tinput_wait_enqueue(void **argv)
|
||||
const String keys = { .data = buf, .size = len };
|
||||
if (input->paste) {
|
||||
String copy = copy_string(keys);
|
||||
multiqueue_put(main_loop.events, tinput_paste_event, 3,
|
||||
copy.data, copy.size, (intptr_t)input->paste);
|
||||
if (ui_client_channel_id) {
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
ADD(args, STRING_OBJ(copy_string(keys))); // 'data'
|
||||
ADD(args, BOOLEAN_OBJ(true)); // 'crlf'
|
||||
ADD(args, INTEGER_OBJ(input->paste)); // 'phase'
|
||||
rpc_send_event(ui_client_channel_id, "nvim_paste", args);
|
||||
} else {
|
||||
multiqueue_put(main_loop.events, tinput_paste_event, 3,
|
||||
copy.data, copy.size, (intptr_t)input->paste);
|
||||
}
|
||||
if (input->paste == 1) {
|
||||
// Paste phase: "continue"
|
||||
input->paste = 2;
|
||||
@ -134,7 +143,17 @@ static void tinput_wait_enqueue(void **argv)
|
||||
rbuffer_consumed(input->key_buffer, len);
|
||||
rbuffer_reset(input->key_buffer);
|
||||
} else {
|
||||
const size_t consumed = input_enqueue(keys);
|
||||
size_t consumed;
|
||||
if (ui_client_channel_id) {
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
Error err = ERROR_INIT;
|
||||
ADD(args, STRING_OBJ(copy_string(keys)));
|
||||
// TODO(bfredl): could be non-blocking now with paste?
|
||||
Object result = rpc_send_call(ui_client_channel_id, "nvim_input", args, &err);
|
||||
consumed = result.type == kObjectTypeInteger ? (size_t)result.data.integer : 0;
|
||||
} else {
|
||||
consumed = input_enqueue(keys);
|
||||
}
|
||||
if (consumed) {
|
||||
rbuffer_consumed(input->key_buffer, consumed);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/cursor.h"
|
||||
#include "nvim/cursor_shape.h"
|
||||
#include "nvim/msgpack_rpc/channel.h"
|
||||
#include "nvim/diff.h"
|
||||
#include "nvim/event/loop.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
@ -224,7 +225,21 @@ void ui_refresh(void)
|
||||
|
||||
int save_p_lz = p_lz;
|
||||
p_lz = false; // convince redrawing() to return true ...
|
||||
screen_resize(width, height);
|
||||
if (!ui_client_channel_id) {
|
||||
screen_resize(width, height);
|
||||
} else {
|
||||
Array args = ARRAY_DICT_INIT;
|
||||
Error err = ERROR_INIT;
|
||||
ADD(args, INTEGER_OBJ((int)width));
|
||||
ADD(args, INTEGER_OBJ((int)height));
|
||||
rpc_send_call(ui_client_channel_id, "nvim_ui_try_resize", args, &err);
|
||||
|
||||
if (ERROR_SET(&err)) {
|
||||
ELOG("ui_client resize: %s", err.msg);
|
||||
}
|
||||
api_clear_error(&err);
|
||||
}
|
||||
|
||||
p_lz = save_p_lz;
|
||||
|
||||
if (ext_widgets[kUIMessages]) {
|
||||
|
@ -52,8 +52,6 @@ void ui_client_init(uint64_t chan)
|
||||
|
||||
/// Handler for "redraw" events sent by the NVIM server
|
||||
///
|
||||
/// This is just a stub. The mentioned functionality will be implemented.
|
||||
///
|
||||
/// This function will be called by handle_request (in msgpack_rpc/channel.c)
|
||||
/// The individual ui_events sent by the server are individually handled
|
||||
/// by their respective handlers defined in ui_events_client.generated.h
|
||||
@ -92,6 +90,7 @@ void ui_client_execute(uint64_t chan)
|
||||
{
|
||||
while (true) {
|
||||
loop_poll_events(&main_loop, -1);
|
||||
multiqueue_process_events(resize_events);
|
||||
}
|
||||
|
||||
getout(0);
|
||||
|
Loading…
Reference in New Issue
Block a user