robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #35655 docs05a511996f

master
2.5 KiB90 linesraw
1#pragma once
2
3#include <stdbool.h>
4#include <stddef.h>
5#include <stdint.h>
6
7#include "nvim/api/private/defs.h"
8#include "nvim/msgpack_rpc/packer_defs.h"
9
10/// Keep in sync with ui_ext_names[] in ui.h
11typedef enum {
12  kUICmdline = 0,
13  kUIPopupmenu,
14  kUITabline,
15  kUIWildmenu,
16  kUIMessages,
17#define kUIGlobalCount kUILinegrid
18  kUILinegrid,
19  kUIMultigrid,
20  kUIHlState,
21  kUITermColors,
22  kUIFloatDebug,
23  kUIExtCount,
24} UIExtension;
25
26enum {
27  kLineFlagWrap = 1,
28  kLineFlagInvalid = 2,
29};
30
31typedef int LineFlags;
32
33typedef struct {
34  bool rgb;
35  bool override;  ///< Force highest-requested UI capabilities.
36  bool composed;
37  bool ui_ext[kUIExtCount];  ///< UI capabilities/extensions.
38  int width;
39  int height;
40  int pum_nlines;  ///< actual nr. lines shown in PUM
41  bool pum_pos;  ///< UI reports back pum position?
42  double pum_row;
43  double pum_col;
44  double pum_height;
45  double pum_width;
46
47  // TUI fields.
48  char *term_name;
49  char *term_background;  ///< Deprecated. No longer needed since background color detection happens
50                          ///< in Lua. To be removed in a future release.
51  int term_colors;
52  bool stdin_tty;
53  bool stdout_tty;
54
55  uint64_t channel_id;
56
57#define UI_BUF_SIZE ARENA_BLOCK_SIZE  ///< total buffer size for pending msgpack data.
58  /// guaranteed size available for each new event (so packing of simple events
59  /// and the header of grid_line will never fail)
60#define EVENT_BUF_SIZE 256
61
62// Fields related to packing
63  PackerBuffer packer;
64
65  const char *cur_event;  ///< name of current event (might get multiple arglists)
66
67  // We start packing the two outermost msgpack arrays before knowing the total
68  // number of elements. Thus track the location where array size will need
69  // to be written in the msgpack buffer, once the specific array is finished.
70  char *nevents_pos;
71  char *ncalls_pos;
72  uint32_t nevents;  ///< number of distinct events (top-level args to "redraw"
73  uint32_t ncalls;  ///< number of calls made to the current event (plus one for the name!)
74  bool flushed_events;  ///< events where sent to client without "flush" event
75  bool incomplete_event;  ///< incomplete event might be pending
76
77  size_t ncells_pending;  ///< total number of cells since last buffer flush
78
79  int hl_id;  // Current highlight for legacy put event.
80  Integer cursor_row, cursor_col;  // Intended visible cursor position.
81
82  // Position of legacy cursor, used both for drawing and visible user cursor.
83  Integer client_row, client_col;
84  bool wildmenu_active;
85} RemoteUI;
86
87typedef struct {
88  const char *name;
89  void (*fn)(Array args);
90} UIClientHandler;