mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
refactor(IWYU): move UI and LineFlags to ui_defs.h (#26318)
This commit is contained in:
parent
543e0256c1
commit
ce56e0a845
8
Makefile
8
Makefile
@ -143,14 +143,10 @@ iwyu: build/.ran-cmake
|
|||||||
cmake --build build > build/iwyu.log
|
cmake --build build > build/iwyu.log
|
||||||
iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\
|
iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\
|
||||||
|src/nvim/api/extmark.h\
|
|src/nvim/api/extmark.h\
|
||||||
|src/nvim/api/private/dispatch.h\
|
|
||||||
|src/nvim/api/private/helpers.h\
|
|src/nvim/api/private/helpers.h\
|
||||||
|src/nvim/api/private/validate.h\
|
|src/nvim/api/private/validate.h\
|
||||||
|src/nvim/api/ui.h\
|
|
||||||
|src/nvim/ascii_defs.h\
|
|
||||||
|src/nvim/assert_defs.h\
|
|src/nvim/assert_defs.h\
|
||||||
|src/nvim/autocmd.h\
|
|src/nvim/autocmd.h\
|
||||||
|src/nvim/autocmd_defs.h\
|
|
||||||
|src/nvim/buffer.h\
|
|src/nvim/buffer.h\
|
||||||
|src/nvim/buffer_defs.h\
|
|src/nvim/buffer_defs.h\
|
||||||
|src/nvim/channel.h\
|
|src/nvim/channel.h\
|
||||||
@ -178,7 +174,6 @@ iwyu: build/.ran-cmake
|
|||||||
|src/nvim/event/time.h\
|
|src/nvim/event/time.h\
|
||||||
|src/nvim/event/wstream.h\
|
|src/nvim/event/wstream.h\
|
||||||
|src/nvim/ex_cmds.h\
|
|src/nvim/ex_cmds.h\
|
||||||
|src/nvim/ex_cmds_defs.h\
|
|
||||||
|src/nvim/ex_docmd.h\
|
|src/nvim/ex_docmd.h\
|
||||||
|src/nvim/extmark.h\
|
|src/nvim/extmark.h\
|
||||||
|src/nvim/file_search.h\
|
|src/nvim/file_search.h\
|
||||||
@ -217,10 +212,7 @@ iwyu: build/.ran-cmake
|
|||||||
|src/nvim/syntax.h\
|
|src/nvim/syntax.h\
|
||||||
|src/nvim/textobject.h\
|
|src/nvim/textobject.h\
|
||||||
|src/nvim/tui/input.h\
|
|src/nvim/tui/input.h\
|
||||||
|src/nvim/tui/tui.h\
|
|
||||||
|src/nvim/ui.h\
|
|src/nvim/ui.h\
|
||||||
|src/nvim/ui_client.h\
|
|
||||||
|src/nvim/ui_compositor.h\
|
|
||||||
|src/nvim/viml/parser/expressions.h\
|
|src/nvim/viml/parser/expressions.h\
|
||||||
|src/nvim/viml/parser/parser.h\
|
|src/nvim/viml/parser/parser.h\
|
||||||
|src/nvim/window.h\
|
|src/nvim/window.h\
|
||||||
|
12
src/clint.py
12
src/clint.py
@ -898,14 +898,10 @@ def CheckIncludes(filename, lines, error):
|
|||||||
# the Makefile.
|
# the Makefile.
|
||||||
check_includes_ignore = [
|
check_includes_ignore = [
|
||||||
"src/nvim/api/extmark.h",
|
"src/nvim/api/extmark.h",
|
||||||
"src/nvim/api/private/dispatch.h",
|
|
||||||
"src/nvim/api/private/helpers.h",
|
"src/nvim/api/private/helpers.h",
|
||||||
"src/nvim/api/private/validate.h",
|
"src/nvim/api/private/validate.h",
|
||||||
"src/nvim/api/ui.h",
|
|
||||||
"src/nvim/ascii_defs.h",
|
|
||||||
"src/nvim/assert_defs.h",
|
"src/nvim/assert_defs.h",
|
||||||
"src/nvim/autocmd.h",
|
"src/nvim/autocmd.h",
|
||||||
"src/nvim/autocmd_defs.h",
|
|
||||||
"src/nvim/buffer.h",
|
"src/nvim/buffer.h",
|
||||||
"src/nvim/buffer_defs.h",
|
"src/nvim/buffer_defs.h",
|
||||||
"src/nvim/channel.h",
|
"src/nvim/channel.h",
|
||||||
@ -933,7 +929,6 @@ def CheckIncludes(filename, lines, error):
|
|||||||
"src/nvim/event/time.h",
|
"src/nvim/event/time.h",
|
||||||
"src/nvim/event/wstream.h",
|
"src/nvim/event/wstream.h",
|
||||||
"src/nvim/ex_cmds.h",
|
"src/nvim/ex_cmds.h",
|
||||||
"src/nvim/ex_cmds_defs.h",
|
|
||||||
"src/nvim/ex_docmd.h",
|
"src/nvim/ex_docmd.h",
|
||||||
"src/nvim/extmark.h",
|
"src/nvim/extmark.h",
|
||||||
"src/nvim/file_search.h",
|
"src/nvim/file_search.h",
|
||||||
@ -972,10 +967,7 @@ def CheckIncludes(filename, lines, error):
|
|||||||
"src/nvim/syntax.h",
|
"src/nvim/syntax.h",
|
||||||
"src/nvim/textobject.h",
|
"src/nvim/textobject.h",
|
||||||
"src/nvim/tui/input.h",
|
"src/nvim/tui/input.h",
|
||||||
"src/nvim/tui/tui.h",
|
|
||||||
"src/nvim/ui.h",
|
"src/nvim/ui.h",
|
||||||
"src/nvim/ui_client.h",
|
|
||||||
"src/nvim/ui_compositor.h",
|
|
||||||
"src/nvim/viml/parser/expressions.h",
|
"src/nvim/viml/parser/expressions.h",
|
||||||
"src/nvim/viml/parser/parser.h",
|
"src/nvim/viml/parser/parser.h",
|
||||||
"src/nvim/window.h",
|
"src/nvim/window.h",
|
||||||
@ -999,8 +991,10 @@ def CheckIncludes(filename, lines, error):
|
|||||||
if name in skip_headers:
|
if name in skip_headers:
|
||||||
continue
|
continue
|
||||||
if (not name.endswith('.h.generated.h') and
|
if (not name.endswith('.h.generated.h') and
|
||||||
|
not name.endswith('/defs.h') and
|
||||||
not name.endswith('_defs.h') and
|
not name.endswith('_defs.h') and
|
||||||
not name.endswith('/defs.h')):
|
not name.endswith('_defs.generated.h') and
|
||||||
|
not name.endswith('_enum.generated.h')):
|
||||||
error(filename, i, 'build/include_defs', 5,
|
error(filename, i, 'build/include_defs', 5,
|
||||||
'Headers should not include non-"_defs" headers')
|
'Headers should not include non-"_defs" headers')
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ typedef Object (*ApiDispatchWrapper)(uint64_t channel_id, Array args, Arena *are
|
|||||||
struct MsgpackRpcRequestHandler {
|
struct MsgpackRpcRequestHandler {
|
||||||
const char *name;
|
const char *name;
|
||||||
ApiDispatchWrapper fn;
|
ApiDispatchWrapper fn;
|
||||||
bool fast; // Function is safe to be executed immediately while running the
|
bool fast; ///< Function is safe to be executed immediately while running the
|
||||||
// uv loop (the loop is run very frequently due to breakcheck).
|
///< uv loop (the loop is run very frequently due to breakcheck).
|
||||||
// If "fast" is false, the function is deferred, i e the call will
|
///< If "fast" is false, the function is deferred, i e the call will
|
||||||
// be put in the event queue, for safe handling later.
|
///< be put in the event queue, for safe handling later.
|
||||||
bool arena_return; // return value is allocated in the arena (or statically)
|
bool arena_return; ///< return value is allocated in the arena (or statically)
|
||||||
// and should not be freed as such.
|
///< and should not be freed as such.
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const MsgpackRpcRequestHandler method_handlers[];
|
extern const MsgpackRpcRequestHandler method_handlers[];
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/highlight_defs.h" // IWYU pragma: keep
|
#include "nvim/highlight_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/map_defs.h"
|
|
||||||
#include "nvim/types_defs.h" // IWYU pragma: keep
|
#include "nvim/types_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui_defs.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "api/ui.h.generated.h"
|
# include "api/ui.h.generated.h"
|
||||||
|
@ -14,9 +14,11 @@
|
|||||||
|
|
||||||
// actual Decor* data is in decoration_defs.h
|
// actual Decor* data is in decoration_defs.h
|
||||||
|
|
||||||
EXTERN const char *const virt_text_pos_str[] INIT( = { "eol", "overlay", "win_col", "right_align",
|
/// Keep in sync with VirtTextPos in decoration_defs.h
|
||||||
"inline" });
|
EXTERN const char *const virt_text_pos_str[]
|
||||||
|
INIT( = { "eol", "overlay", "win_col", "right_align", "inline" });
|
||||||
|
|
||||||
|
/// Keep in sync with HlMode in decoration_defs.h
|
||||||
EXTERN const char *const hl_mode_str[] INIT( = { "", "replace", "combine", "blend" });
|
EXTERN const char *const hl_mode_str[] INIT( = { "", "replace", "combine", "blend" });
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -43,8 +45,8 @@ typedef struct {
|
|||||||
VirtTextPos pos;
|
VirtTextPos pos;
|
||||||
} ui;
|
} ui;
|
||||||
} data;
|
} data;
|
||||||
int attr_id; // cached lookup of inl.hl_id if it was a highlight
|
int attr_id; ///< cached lookup of inl.hl_id if it was a highlight
|
||||||
bool owned; // ephemeral decoration, free memory immediately
|
bool owned; ///< ephemeral decoration, free memory immediately
|
||||||
DecorPriority priority;
|
DecorPriority priority;
|
||||||
DecorRangeKind kind;
|
DecorRangeKind kind;
|
||||||
/// Screen column to draw the virtual text.
|
/// Screen column to draw the virtual text.
|
||||||
|
@ -15,6 +15,7 @@ typedef struct {
|
|||||||
typedef kvec_t(VirtTextChunk) VirtText;
|
typedef kvec_t(VirtTextChunk) VirtText;
|
||||||
#define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
|
#define VIRTTEXT_EMPTY ((VirtText)KV_INITIAL_VALUE)
|
||||||
|
|
||||||
|
/// Keep in sync with virt_text_pos_str[] in decoration.h
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kVPosEndOfLine,
|
kVPosEndOfLine,
|
||||||
kVPosOverlay,
|
kVPosOverlay,
|
||||||
@ -28,6 +29,7 @@ typedef kvec_t(struct virt_line { VirtText line; bool left_col; }) VirtLines;
|
|||||||
typedef uint16_t DecorPriority;
|
typedef uint16_t DecorPriority;
|
||||||
#define DECOR_PRIORITY_BASE 0x1000
|
#define DECOR_PRIORITY_BASE 0x1000
|
||||||
|
|
||||||
|
/// Keep in sync with hl_mode_str[] in decoration.h
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kHlModeUnknown,
|
kHlModeUnknown,
|
||||||
kHlModeReplace,
|
kHlModeReplace,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "nvim/buffer_defs.h" // IWYU pragma: keep
|
#include "nvim/buffer_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/highlight_defs.h" // IWYU pragma: export
|
#include "nvim/highlight_defs.h" // IWYU pragma: export
|
||||||
#include "nvim/option_vars.h"
|
#include "nvim/option_vars.h"
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui_defs.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "highlight.h.generated.h"
|
# include "highlight.h.generated.h"
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
#include "nvim/spell.h"
|
#include "nvim/spell.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "lua/spell.c.generated.h" // IWYU pragma: export
|
# include "lua/spell.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int nlua_spell_check(lua_State *lstate)
|
int nlua_spell_check(lua_State *lstate)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
if (lua_gettop(lstate) < 1) {
|
if (lua_gettop(lstate) < 1) {
|
||||||
return luaL_error(lstate, "Expected 1 argument");
|
return luaL_error(lstate, "Expected 1 argument");
|
||||||
@ -99,6 +100,7 @@ static const luaL_Reg spell_functions[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int luaopen_spell(lua_State *L)
|
int luaopen_spell(lua_State *L)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
luaL_register(L, NULL, spell_functions);
|
luaL_register(L, NULL, spell_functions);
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
#include "nvim/tui/tui.h"
|
#include "nvim/tui/tui.h"
|
||||||
#include "nvim/types_defs.h"
|
#include "nvim/types_defs.h"
|
||||||
#include "nvim/ugrid.h"
|
#include "nvim/ugrid.h"
|
||||||
#include "nvim/ui.h"
|
|
||||||
#include "nvim/ui_client.h"
|
#include "nvim/ui_client.h"
|
||||||
|
#include "nvim/ui_defs.h"
|
||||||
|
|
||||||
#ifdef MSWIN
|
#ifdef MSWIN
|
||||||
# include "nvim/os/os_win_console.h"
|
# include "nvim/os/os_win_console.h"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/highlight_defs.h" // IWYU pragma: keep
|
#include "nvim/highlight_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/types_defs.h" // IWYU pragma: keep
|
#include "nvim/types_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui_defs.h" // IWYU pragma: keep
|
||||||
|
|
||||||
typedef struct TUIData TUIData;
|
typedef struct TUIData TUIData;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -37,6 +36,11 @@
|
|||||||
#include "nvim/window.h"
|
#include "nvim/window.h"
|
||||||
#include "nvim/winfloat.h"
|
#include "nvim/winfloat.h"
|
||||||
|
|
||||||
|
typedef struct ui_event_callback {
|
||||||
|
LuaRef cb;
|
||||||
|
bool ext_widgets[kUIGlobalCount];
|
||||||
|
} UIEventCallback;
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "ui.c.generated.h"
|
# include "ui.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
@ -692,7 +696,7 @@ void ui_call_event(char *name, Array args)
|
|||||||
ui_log(name);
|
ui_log(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_cb_update_ext(void)
|
static void ui_cb_update_ext(void)
|
||||||
{
|
{
|
||||||
memset(ui_cb_ext, 0, ARRAY_SIZE(ui_cb_ext));
|
memset(ui_cb_ext, 0, ARRAY_SIZE(ui_cb_ext));
|
||||||
|
|
||||||
@ -708,7 +712,7 @@ void ui_cb_update_ext(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_ui_event_callback(UIEventCallback *event_cb)
|
static void free_ui_event_callback(UIEventCallback *event_cb)
|
||||||
{
|
{
|
||||||
api_free_luaref(event_cb->cb);
|
api_free_luaref(event_cb->cb);
|
||||||
xfree(event_cb);
|
xfree(event_cb);
|
||||||
|
109
src/nvim/ui.h
109
src/nvim/ui.h
@ -1,34 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdint.h> // IWYU pragma: keep
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/event/multiqueue.h"
|
#include "nvim/event/multiqueue.h"
|
||||||
#include "nvim/globals.h"
|
#include "nvim/grid_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/highlight_defs.h"
|
#include "nvim/highlight_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/macros_defs.h"
|
#include "nvim/macros_defs.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/types_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/types_defs.h"
|
#include "nvim/ui_defs.h" // IWYU pragma: export
|
||||||
|
|
||||||
struct ui_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
kUICmdline = 0,
|
|
||||||
kUIPopupmenu,
|
|
||||||
kUITabline,
|
|
||||||
kUIWildmenu,
|
|
||||||
kUIMessages,
|
|
||||||
#define kUIGlobalCount kUILinegrid
|
|
||||||
kUILinegrid,
|
|
||||||
kUIMultigrid,
|
|
||||||
kUIHlState,
|
|
||||||
kUITermColors,
|
|
||||||
kUIFloatDebug,
|
|
||||||
kUIExtCount,
|
|
||||||
} UIExtension;
|
|
||||||
|
|
||||||
|
/// Keep in sync with UIExtension in ui_defs.h
|
||||||
EXTERN const char *ui_ext_names[] INIT( = {
|
EXTERN const char *ui_ext_names[] INIT( = {
|
||||||
"ext_cmdline",
|
"ext_cmdline",
|
||||||
"ext_popupmenu",
|
"ext_popupmenu",
|
||||||
@ -42,83 +24,6 @@ EXTERN const char *ui_ext_names[] INIT( = {
|
|||||||
"_debug_float",
|
"_debug_float",
|
||||||
});
|
});
|
||||||
|
|
||||||
typedef struct ui_t UI;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
kLineFlagWrap = 1,
|
|
||||||
kLineFlagInvalid = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
size_t ncells_pending; ///< total number of cells since last buffer flush
|
|
||||||
|
|
||||||
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.
|
|
||||||
bool composed;
|
|
||||||
bool ui_ext[kUIExtCount]; ///< Externalized UI capabilities.
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int pum_nlines; /// actual nr. lines shown in PUM
|
|
||||||
bool pum_pos; /// UI reports back pum position?
|
|
||||||
double pum_row;
|
|
||||||
double pum_col;
|
|
||||||
double pum_height;
|
|
||||||
double pum_width;
|
|
||||||
|
|
||||||
// TUI fields.
|
|
||||||
char *term_name;
|
|
||||||
char *term_background; ///< Deprecated. No longer needed since background color detection happens
|
|
||||||
///< in Lua. To be removed in a future release.
|
|
||||||
int term_colors;
|
|
||||||
bool stdin_tty;
|
|
||||||
bool stdout_tty;
|
|
||||||
|
|
||||||
// TODO(bfredl): integrate into struct!
|
|
||||||
UIData data[1];
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct ui_event_callback {
|
|
||||||
LuaRef cb;
|
|
||||||
bool ext_widgets[kUIGlobalCount];
|
|
||||||
} UIEventCallback;
|
|
||||||
|
|
||||||
// uncrustify:off
|
// uncrustify:off
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "ui.h.generated.h"
|
# include "ui.h.generated.h"
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
#include "nvim/api/private/defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/event/defs.h"
|
|
||||||
#include "nvim/grid_defs.h" // IWYU pragma: keep
|
#include "nvim/grid_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/types_defs.h" // IWYU pragma: keep
|
#include "nvim/types_defs.h" // IWYU pragma: keep
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui_defs.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "ui_compositor.h.generated.h"
|
# include "ui_compositor.h.generated.h"
|
||||||
|
95
src/nvim/ui_defs.h
Normal file
95
src/nvim/ui_defs.h
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "nvim/api/private/defs.h"
|
||||||
|
|
||||||
|
/// Keep in sync with ui_ext_names[] in ui.h
|
||||||
|
typedef enum {
|
||||||
|
kUICmdline = 0,
|
||||||
|
kUIPopupmenu,
|
||||||
|
kUITabline,
|
||||||
|
kUIWildmenu,
|
||||||
|
kUIMessages,
|
||||||
|
#define kUIGlobalCount kUILinegrid
|
||||||
|
kUILinegrid,
|
||||||
|
kUIMultigrid,
|
||||||
|
kUIHlState,
|
||||||
|
kUITermColors,
|
||||||
|
kUIFloatDebug,
|
||||||
|
kUIExtCount,
|
||||||
|
} UIExtension;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kLineFlagWrap = 1,
|
||||||
|
kLineFlagInvalid = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int LineFlags;
|
||||||
|
|
||||||
|
typedef struct ui_t UI;
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
size_t ncells_pending; ///< total number of cells since last buffer flush
|
||||||
|
|
||||||
|
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.
|
||||||
|
bool composed;
|
||||||
|
bool ui_ext[kUIExtCount]; ///< Externalized UI capabilities.
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int pum_nlines; /// actual nr. lines shown in PUM
|
||||||
|
bool pum_pos; /// UI reports back pum position?
|
||||||
|
double pum_row;
|
||||||
|
double pum_col;
|
||||||
|
double pum_height;
|
||||||
|
double pum_width;
|
||||||
|
|
||||||
|
// TUI fields.
|
||||||
|
char *term_name;
|
||||||
|
char *term_background; ///< Deprecated. No longer needed since background color detection happens
|
||||||
|
///< in Lua. To be removed in a future release.
|
||||||
|
int term_colors;
|
||||||
|
bool stdin_tty;
|
||||||
|
bool stdout_tty;
|
||||||
|
|
||||||
|
// TODO(bfredl): integrate into struct!
|
||||||
|
UIData data[1];
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user