robin/laufey

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

robinmerge: 9a29622b3b00ddb601

master
3.6 KiB55 linesraw
1#pragma once
2
3#include <stdbool.h>
4
5#include "nvim/pos_defs.h"
6#include "nvim/types_defs.h"
7
8/// Change-delimiting cursor-move in insert-mode (start_arrow()): undo, Ins.start and last_insert
9/// (the ". register) restart at next edit (stop_arrow()); typed keys sync undo (may_sync_undo()).
10typedef enum {
11  kInsNone = 0,  ///< No cursor-move since last edit: contiguous insert-session.
12  kInsArrow,     ///< Cursor-move captured in the atom.
13  kInsJump,      ///< Non-replayable jump (mouse, <PageUp>, …): atom terminated (<Esc>).
14} InsArrow;
15
16/// Insert-mode session state: the in-progress insert session, as one global "group" (Ins), so it
17/// can be saved/restored around nested edit() sessions (mc_ins_save_state).
18typedef struct {
19  pos_T start;               ///< Start of current INSERTION: from here to cursor is the unit that
20                             ///< undo, '[ and ". treat as one. Reanchored after cursor-move, C-G u.
21  pos_T start_orig;          ///< Where insert by the user started (for op_insert): follows `start`
22                             ///< until insertion starts right of it; <bs> before it pulls back.
23  colnr_T start_textlen;     ///< length of line when insert started
24  colnr_T start_blank_vcol;  ///< vcol for first inserted blank
25  InsArrow moved;            ///< Cursor moved since the last edit; see InsArrow.
26  bool stop_insert_mode;     ///< for ":stopinsert"
27  bool can_cindent;          ///< may do cindenting on this line
28  bool need_undo;            ///< call u_save() before inserting a char. Set when edit() is
29                             ///< called; after that `moved` is used.
30  bool did_ai;               ///< Makes auto-indent work right on lines where only a <CR> or
31                             ///< <Esc> is typed: set when an auto-indent is done, reset when any
32                             ///< other editing is done on the line. If an <Esc> or <CR> is
33                             ///< received and did_ai is true, the line is truncated.
34  colnr_T ai_col;            ///< Column of first char after autoindent. 0 when no autoindent
35                             ///< done. Used when 'backspace' is 0, to avoid backspacing over
36                             ///< autoindent.
37  int end_comment_pending;   ///< A character which will end a start-middle-end comment when
38                             ///< typed as the first character on a new line. Taken from the last
39                             ///< character of the "end" comment leader when the COM_AUTO_END
40                             ///< flag is given for that comment end in 'comments'. Only valid
41                             ///< when did_ai is true.
42  bool did_si;               ///< Set when a smart indent has been performed: when the next
43                             ///< typed character is a '{' the inserted tab will be deleted again.
44  bool can_si;               ///< after an auto indent: a typed '}' removes one indent
45  bool can_si_back;          ///< after an "O" command: a typed '{' removes one indent
46  bool update_start_orig;    ///< set start_orig to start
47  int new_insert_skip;       ///< number of chars in front of the current insert
48  int did_restart_edit;      ///< "restart_edit" when edit() was called
49  bool revins_on;            ///< reverse insert mode on
50  int revins_chars;          ///< how much to skip after edit
51  int revins_legal;          ///< was the last char "legal"?
52  int revins_scol;           ///< start column of revins session
53  TriState dont_sync_undo;   ///< CTRL-G U prevents syncing undo for the next left/right cursor key
54  linenr_T o_lnum;           ///< "o" command's line, for "CTRL-O ." that adds a line (ins_at_eol)
55} InsState;