aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui.h
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-12-30 22:17:01 +0100
committerbfredl <bjorn.linse@gmail.com>2023-01-05 09:48:26 +0100
commit47ba78f89a1f0bba8168b4408bc55a3024d5ab97 (patch)
tree79a1d81956d87986467e4da70b4f9ad53b079040 /src/nvim/ui.h
parentae64772a88125153a438a0e9e43d5f6bcb4eeb28 (diff)
downloadrneovim-47ba78f89a1f0bba8168b4408bc55a3024d5ab97.tar.gz
rneovim-47ba78f89a1f0bba8168b4408bc55a3024d5ab97.tar.bz2
rneovim-47ba78f89a1f0bba8168b4408bc55a3024d5ab97.zip
refactor(ui): devirtualize the ui layer
- The defined interface for the UI is only the RPC protocol. The original UI interface as an array of function pointers fill no function. - On the server, all the UI:s are all RPC channels. - ui.c is only used on the server. - The compositor is a preprocessing step for single-grid UI:s - on the client, ui_client and tui talk directly to each other - we still do module separation, as ui_client.c could form the basis of a libnvim client module later. Items for later PR:s - vim.ui_attach is still an unhappy child, reconsider based on plugin experience. - the flags in ui_events.in.h are still a mess. Can be simplified now. - UX for remote attachment needs more work. - startup for client can be simplified further (think of the millisecs we can save)
Diffstat (limited to 'src/nvim/ui.h')
-rw-r--r--src/nvim/ui.h43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index c28393476e..9140a9f1f3 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -52,6 +52,41 @@ enum {
typedef int LineFlags;
+typedef struct {
+ uint64_t channel_id;
+
+#define UI_BUF_SIZE 4096 ///< total buffer size for pending msgpack data.
+ /// guaranteed size available for each new event (so packing of simple events
+ /// and the header of grid_line will never fail)
+#define EVENT_BUF_SIZE 256
+ char buf[UI_BUF_SIZE]; ///< buffer of packed but not yet sent msgpack data
+ char *buf_wptr; ///< write head of buffer
+ const char *cur_event; ///< name of current event (might get multiple arglists)
+ Array call_buf; ///< buffer for constructing a single arg list (max 16 elements!)
+
+ // state for write_cb, while packing a single arglist to msgpack. This
+ // might fail due to buffer overflow.
+ size_t pack_totlen;
+ bool buf_overflow;
+ char *temp_buf;
+
+ // We start packing the two outermost msgpack arrays before knowing the total
+ // number of elements. Thus track the location where array size will need
+ // to be written in the msgpack buffer, once the specific array is finished.
+ char *nevents_pos;
+ char *ncalls_pos;
+ uint32_t nevents; ///< number of distinct events (top-level args to "redraw"
+ uint32_t ncalls; ///< number of calls made to the current event (plus one for the name!)
+ bool flushed_events; ///< events where sent to client without "flush" event
+
+ int hl_id; // Current highlight for legacy put event.
+ Integer cursor_row, cursor_col; // Intended visible cursor position.
+
+ // Position of legacy cursor, used both for drawing and visible user cursor.
+ Integer client_row, client_col;
+ bool wildmenu_active;
+} UIData;
+
struct ui_t {
bool rgb;
bool override; ///< Force highest-requested UI capabilities.
@@ -65,13 +100,9 @@ struct ui_t {
double pum_col;
double pum_height;
double pum_width;
- void *data;
-
-#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "ui_events.generated.h"
-#endif
- void (*inspect)(UI *ui, Dictionary *info);
+ // TODO(bfredl): integrate into struct!
+ UIData data[1];
};
typedef struct ui_event_callback {