robin/laufey

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

robinmerge: 1dc9728daa1d8a2702

master
2.5 KiB52 linesraw
1#pragma once
2
3#include <stdbool.h>
4#include <stdint.h>
5
6#include "nvim/buffer_defs.h"  // buf_T
7#include "nvim/eval/typval_defs.h"  // varnumber_T
8#include "nvim/input_cmdatom_defs.h"  // IWYU pragma: export
9#include "nvim/normal_defs.h"  // VisualState, cmdarg_T
10#include "nvim/pos_defs.h"
11#include "nvim/register_defs.h"  // Timestamp
12
13/// Multicursor: pending atoms; they cascade as a batch (mc_clock_edge).
14extern CmdAtomVec g_atoms;
15
16/// One `normal_execute()`: the scope of a MODE_NORMAL command (Normal/Visual/Select/Op-pending, see
17/// get_real_state()). Same lifetime as `cmdarg_T`. A `composite` spans successive toplevel frames.
18///
19/// Entry state (`origin`, …) is diffed at `atom_cmd_end()` into the command's CmdAtom.
20///
21/// Insert/Cmdline modes (non-MODE_NORMAL) are "sessions", not "frames" (atom_ins_start(),
22/// atom_payload_start()). Mappings initiating from non-MODE_NORMAL defer their `composite` to the
23/// first frame.
24typedef struct CmdFrame CmdFrame;
25struct CmdFrame {
26  CmdOrigin origin;     ///< State at entry.
27  CmdAtom staged;       ///< Atom staged in this frame (`keys=NULL`: none).
28  CmdFrame *parent;     ///< Enclosing frame (nested normal_execute()); NULL at toplevel.
29  VisualState visual;   ///< Visual-mode state (active/start/mode are diffed).
30
31  bool keytyped;        ///< KeyTyped
32  unsigned keyclass;    ///< atom_key_class() of the cmd char, before its `nchar`.
33  int ex_normal;        ///< If higher than `root_frame().ex_normal`, a cmd fed this (:norm, feed).
34  uint64_t captures;    ///< `atom_captures` at entry.
35  uint64_t global_ops;  ///< `global_ops` at entry.
36  uint64_t beeps;       ///< `did_beep` at entry.
37  uint64_t id;          ///< Identifies this frame (see `composite.frame`).
38  bool follow;          ///< Follow-mode: updated until cursor-move happens (sticky) in this frame.
39  bool consumers;       ///< Capture is skipped if there are no consumers (for performance).
40  Timestamp reg_ts;     ///< Max register timestamp (to detect a per-cursor register write).
41  size_t payload_start;  ///< Payload slice (SIZE_MAX: none): typed.keys[payload_start..payload_end)
42  size_t payload_end;
43
44  //
45  // Toplevel command state: root_frame() only.
46  //
47  uint64_t redo_frame;  ///< Frame whose redobuf (potentially) defines the atom. 0: none.
48  char *cmdline;        ///< The ":" payload captured at cmdline accept. NULL: none.
49                        ///< Note: search payloads ("/pat<CR>") travel on `cmdarg.searchbuf`.
50};
51
52#include "input_cmdatom.h.generated.h"