robin/laufey

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

luukvbaalfix(messages): recognize cmdline one_key/number prompt State (#34206)e876a739ee

master
1.9 KiB44 linesraw
1#pragma once
2
3typedef struct vim_state VimState;
4
5typedef int (*state_check_callback)(VimState *state);
6typedef int (*state_execute_callback)(VimState *state, int key);
7
8struct vim_state {
9  state_check_callback check;
10  state_execute_callback execute;
11};
12
13/// Values for State
14///
15/// The lower bits up to 0x80 are used to distinguish normal/visual/op_pending
16/// /cmdline/insert/replace/terminal mode.  This is used for mapping.  If none
17/// of these bits are set, no mapping is done.  See the comment above do_map().
18/// The upper bits are used to distinguish between other states and variants of
19/// the base modes.
20enum {
21  MODE_NORMAL      = 0x01,  ///< Normal mode, command expected
22  MODE_VISUAL      = 0x02,  ///< Visual mode - use get_real_state()
23  MODE_OP_PENDING  = 0x04,  ///< Normal mode, operator is pending - use get_real_state()
24  MODE_CMDLINE     = 0x08,  ///< Editing the command line
25  MODE_INSERT      = 0x10,  ///< Insert mode, also for Replace mode
26  MODE_LANGMAP     = 0x20,  ///< Language mapping, can be combined with MODE_INSERT and MODE_CMDLINE
27  MODE_SELECT      = 0x40,  ///< Select mode, use get_real_state()
28  MODE_TERMINAL    = 0x80,  ///< Terminal mode
29
30  MAP_ALL_MODES    = 0xff,  ///< all mode bits used for mapping
31
32  REPLACE_FLAG     = 0x100,  ///< Replace mode flag
33  MODE_REPLACE     = REPLACE_FLAG | MODE_INSERT,
34  VREPLACE_FLAG    = 0x200,  ///< Virtual-replace mode flag
35  MODE_VREPLACE    = REPLACE_FLAG | VREPLACE_FLAG | MODE_INSERT,
36  MODE_LREPLACE    = REPLACE_FLAG | MODE_LANGMAP,
37
38  MODE_NORMAL_BUSY = 0x1000 | MODE_NORMAL,  ///< Normal mode, busy with a command
39  MODE_HITRETURN   = 0x2000 | MODE_NORMAL,  ///< waiting for return or command
40  MODE_ASKMORE     = 0x3000,  ///< Asking if you want --more--
41  MODE_SETWSIZE    = 0x4000,  ///< window size has changed
42  MODE_EXTERNCMD   = 0x5000,  ///< executing an external command
43  MODE_SHOWMATCH   = 0x6000 | MODE_INSERT,  ///< show matching paren
44};