aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/input_cmdatom.h
blob: 500bc5b95c1f34b0acb640cd6e77a65f76cc3fae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once

#include <stdbool.h>
#include <stdint.h>

#include "nvim/buffer_defs.h"  // buf_T
#include "nvim/eval/typval_defs.h"  // varnumber_T
#include "nvim/input_cmdatom_defs.h"  // IWYU pragma: export
#include "nvim/normal_defs.h"  // VisualState, cmdarg_T
#include "nvim/pos_defs.h"
#include "nvim/register_defs.h"  // Timestamp

/// Multicursor: pending atoms; they cascade as a batch (mc_clock_edge).
extern CmdAtomVec g_atoms;

/// One `normal_execute()`: the scope of a MODE_NORMAL command (Normal/Visual/Select/Op-pending, see
/// get_real_state()). Same lifetime as `cmdarg_T`. A `composite` spans successive toplevel frames.
///
/// Entry state (`origin`, …) is diffed at `atom_cmd_end()` into the command's CmdAtom.
///
/// Insert/Cmdline modes (non-MODE_NORMAL) are "sessions", not "frames" (atom_ins_start(),
/// atom_payload_start()). Mappings initiating from non-MODE_NORMAL defer their `composite` to the
/// first frame.
typedef struct CmdFrame CmdFrame;
struct CmdFrame {
  CmdOrigin origin;     ///< State at entry.
  CmdAtom staged;       ///< Atom staged in this frame (`keys=NULL`: none).
  CmdFrame *parent;     ///< Enclosing frame (nested normal_execute()); NULL at toplevel.
  VisualState visual;   ///< Visual-mode state (active/start/mode are diffed).

  bool keytyped;        ///< KeyTyped
  unsigned keyclass;    ///< atom_key_class() of the cmd char, before its `nchar`.
  int ex_normal;        ///< If higher than `root_frame().ex_normal`, a cmd fed this (:norm, feed).
  uint64_t captures;    ///< `atom_captures` at entry.
  uint64_t global_ops;  ///< `global_ops` at entry.
  uint64_t beeps;       ///< `did_beep` at entry.
  uint64_t id;          ///< Identifies this frame (see `composite.frame`).
  bool follow;          ///< Follow-mode: updated until cursor-move happens (sticky) in this frame.
  bool consumers;       ///< Capture is skipped if there are no consumers (for performance).
  Timestamp reg_ts;     ///< Max register timestamp (to detect a per-cursor register write).
  size_t payload_start;  ///< Payload slice (SIZE_MAX: none): typed.keys[payload_start..payload_end)
  size_t payload_end;

  //
  // Toplevel command state: root_frame() only.
  //
  uint64_t redo_frame;  ///< Frame whose redobuf (potentially) defines the atom. 0: none.
  char *cmdline;        ///< The ":" payload captured at cmdline accept. NULL: none.
                        ///< Note: search payloads ("/pat<CR>") travel on `cmdarg.searchbuf`.
};

#include "input_cmdatom.h.generated.h"