-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
structs.h
5099 lines (4562 loc) · 164 KB
/
structs.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
*/
/*
* This file contains various definitions of structures that are used by Vim
*/
/*
* There is something wrong in the SAS compiler that makes typedefs not
* valid in include files. Has been fixed in version 6.58.
*/
#if defined(SASC) && SASC < 658
typedef long linenr_T;
typedef int colnr_T;
typedef unsigned short short_u;
#endif
// structure to store a string (including it's length)
typedef struct
{
char_u *string; // the string
size_t length; // length of the string (excluding the NUL)
} string_T;
/*
* Position in file or buffer.
*/
typedef struct
{
linenr_T lnum; // line number
colnr_T col; // column number
colnr_T coladd; // extra virtual column
} pos_T;
/*
* Same, but without coladd.
*/
typedef struct
{
linenr_T lnum; // line number
colnr_T col; // column number
} lpos_T;
/*
* Structure used for growing arrays.
* This is used to store information that only grows, is deleted all at
* once, and needs to be accessed by index. See ga_clear() and ga_grow().
*/
typedef struct growarray
{
int ga_len; // current number of items used
int ga_maxlen; // maximum number of items possible
int ga_itemsize; // sizeof(item)
int ga_growsize; // number of items to grow each time
void *ga_data; // pointer to the first item
} garray_T;
#define GA_EMPTY {0, 0, 0, 0, NULL}
typedef struct window_S win_T;
typedef struct wininfo_S wininfo_T;
typedef struct frame_S frame_T;
typedef int scid_T; // script ID
typedef struct file_buffer buf_T; // forward declaration
typedef struct terminal_S term_T;
#ifdef FEAT_MENU
typedef struct VimMenu vimmenu_T;
#endif
// maximum value for sc_version
#define SCRIPT_VERSION_MAX 4
// value for sc_version in a Vim9 script file
#define SCRIPT_VERSION_VIM9 999999
/*
* SCript ConteXt (SCTX): identifies a script line.
* When sourcing a script "sc_lnum" is zero, "sourcing_lnum" is the current
* line number. When executing a user function "sc_lnum" is the line where the
* function was defined, "sourcing_lnum" is the line number inside the
* function. When stored with a function, mapping, option, etc. "sc_lnum" is
* the line number in the script "sc_sid".
*
* sc_version is also here, for convenience.
*/
typedef struct {
#ifdef FEAT_EVAL
scid_T sc_sid; // script ID
int sc_seq; // sourcing sequence number
linenr_T sc_lnum; // line number
#endif
int sc_version; // :scriptversion
} sctx_T;
/*
* Reference to a buffer that stores the value of buf_free_count.
* bufref_valid() only needs to check "buf" when the count differs.
*/
typedef struct {
buf_T *br_buf;
int br_fnum;
int br_buf_free_count;
} bufref_T;
/*
* This is here because regexp.h needs pos_T and below regprog_T is used.
*/
#include "regexp.h"
/*
* This is here because gui.h needs the pos_T and win_T, and win_T needs gui.h
* for scrollbar_T.
*/
#ifdef FEAT_GUI
# include "gui.h"
#else
# ifdef FEAT_XCLIPBOARD
# include <X11/Intrinsic.h>
# endif
# define guicolor_T long
# define INVALCOLOR ((guicolor_T)0x1ffffff)
// only used for cterm.bg_rgb and cterm.fg_rgb: use cterm color
# define CTERMCOLOR ((guicolor_T)0x1fffffe)
#endif
#define COLOR_INVALID(x) ((x) == INVALCOLOR || (x) == CTERMCOLOR)
#ifdef FEAT_TERMINAL
# include "libvterm/include/vterm.h"
typedef struct {
VTermColor fg;
VTermColor bg;
} termcellcolor_T;
#endif
/*
* marks: positions in a file
* (a normal mark is a lnum/col pair, the same as a file position)
*/
#define NMARKS ('z' - 'a' + 1) // max. # of named marks
#define EXTRA_MARKS 10 // marks 0-9
#define JUMPLISTSIZE 100 // max. # of marks in jump list
#define TAGSTACKSIZE 20 // max. # of tags in tag stack
typedef struct filemark
{
pos_T mark; // cursor position
int fnum; // file number
} fmark_T;
// Xtended file mark: also has a file name
typedef struct xfilemark
{
fmark_T fmark;
char_u *fname; // file name, used when fnum == 0
#ifdef FEAT_VIMINFO
time_T time_set;
#endif
} xfmark_T;
/*
* The taggy struct is used to store the information about a :tag command.
*/
typedef struct taggy
{
char_u *tagname; // tag name
fmark_T fmark; // cursor position BEFORE ":tag"
int cur_match; // match number
int cur_fnum; // buffer number used for cur_match
char_u *user_data; // used with tagfunc
} taggy_T;
/*
* Structure that contains all options that are local to a window.
* Used twice in a window: for the current buffer and for all buffers.
* Also used in wininfo_T.
*/
typedef struct
{
#ifdef FEAT_ARABIC
int wo_arab;
# define w_p_arab w_onebuf_opt.wo_arab // 'arabic'
#endif
#ifdef FEAT_LINEBREAK
int wo_bri;
# define w_p_bri w_onebuf_opt.wo_bri // 'breakindent'
char_u *wo_briopt;
# define w_p_briopt w_onebuf_opt.wo_briopt // 'breakindentopt'
#endif
char_u *wo_wcr;
# define w_p_wcr w_onebuf_opt.wo_wcr // 'wincolor'
#ifdef FEAT_DIFF
int wo_diff;
# define w_p_diff w_onebuf_opt.wo_diff // 'diff'
#endif
#ifdef FEAT_FOLDING
long wo_fdc;
# define w_p_fdc w_onebuf_opt.wo_fdc // 'foldcolumn'
int wo_fdc_save;
# define w_p_fdc_save w_onebuf_opt.wo_fdc_save // 'foldenable' saved for diff mode
int wo_fen;
# define w_p_fen w_onebuf_opt.wo_fen // 'foldenable'
int wo_fen_save;
# define w_p_fen_save w_onebuf_opt.wo_fen_save // 'foldenable' saved for diff mode
char_u *wo_fdi;
# define w_p_fdi w_onebuf_opt.wo_fdi // 'foldignore'
long wo_fdl;
# define w_p_fdl w_onebuf_opt.wo_fdl // 'foldlevel'
int wo_fdl_save;
# define w_p_fdl_save w_onebuf_opt.wo_fdl_save // 'foldlevel' state saved for diff mode
char_u *wo_fdm;
# define w_p_fdm w_onebuf_opt.wo_fdm // 'foldmethod'
char_u *wo_fdm_save;
# define w_p_fdm_save w_onebuf_opt.wo_fdm_save // 'fdm' saved for diff mode
long wo_fml;
# define w_p_fml w_onebuf_opt.wo_fml // 'foldminlines'
long wo_fdn;
# define w_p_fdn w_onebuf_opt.wo_fdn // 'foldnestmax'
# ifdef FEAT_EVAL
char_u *wo_fde;
# define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr'
char_u *wo_fdt;
# define w_p_fdt w_onebuf_opt.wo_fdt // 'foldtext'
# endif
char_u *wo_fmr;
# define w_p_fmr w_onebuf_opt.wo_fmr // 'foldmarker'
#endif
#ifdef FEAT_LINEBREAK
int wo_lbr;
# define w_p_lbr w_onebuf_opt.wo_lbr // 'linebreak'
#endif
int wo_list;
#define w_p_list w_onebuf_opt.wo_list // 'list'
char_u *wo_lcs;
#define w_p_lcs w_onebuf_opt.wo_lcs // 'listchars'
char_u *wo_fcs;
#define w_p_fcs w_onebuf_opt.wo_fcs // 'fillchars'
int wo_nu;
#define w_p_nu w_onebuf_opt.wo_nu // 'number'
int wo_rnu;
#define w_p_rnu w_onebuf_opt.wo_rnu // 'relativenumber'
char_u *wo_ve;
#define w_p_ve w_onebuf_opt.wo_ve // 'virtualedit'
unsigned wo_ve_flags;
#define w_ve_flags w_onebuf_opt.wo_ve_flags // flags for 'virtualedit'
#ifdef FEAT_LINEBREAK
long wo_nuw;
# define w_p_nuw w_onebuf_opt.wo_nuw // 'numberwidth'
#endif
int wo_wfb;
#define w_p_wfb w_onebuf_opt.wo_wfb // 'winfixbuf'
int wo_wfh;
# define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight'
int wo_wfw;
# define w_p_wfw w_onebuf_opt.wo_wfw // 'winfixwidth'
#if defined(FEAT_QUICKFIX)
int wo_pvw;
# define w_p_pvw w_onebuf_opt.wo_pvw // 'previewwindow'
#endif
#ifdef FEAT_RIGHTLEFT
int wo_rl;
# define w_p_rl w_onebuf_opt.wo_rl // 'rightleft'
char_u *wo_rlc;
# define w_p_rlc w_onebuf_opt.wo_rlc // 'rightleftcmd'
#endif
long wo_scr;
#define w_p_scr w_onebuf_opt.wo_scr // 'scroll'
int wo_sms;
#define w_p_sms w_onebuf_opt.wo_sms // 'smoothscroll'
#ifdef FEAT_SPELL
int wo_spell;
# define w_p_spell w_onebuf_opt.wo_spell // 'spell'
#endif
#if defined(FEAT_SYN_HL) || defined(FEAT_FOLDING) || defined(FEAT_DIFF)
int wo_cuc;
# define w_p_cuc w_onebuf_opt.wo_cuc // 'cursorcolumn'
int wo_cul;
# define w_p_cul w_onebuf_opt.wo_cul // 'cursorline'
char_u *wo_culopt;
# define w_p_culopt w_onebuf_opt.wo_culopt // 'cursorlineopt'
char_u *wo_cc;
# define w_p_cc w_onebuf_opt.wo_cc // 'colorcolumn'
#endif
#ifdef FEAT_LINEBREAK
char_u *wo_sbr;
#define w_p_sbr w_onebuf_opt.wo_sbr // 'showbreak'
#endif
#ifdef FEAT_STL_OPT
char_u *wo_stl;
#define w_p_stl w_onebuf_opt.wo_stl // 'statusline'
#endif
int wo_scb;
#define w_p_scb w_onebuf_opt.wo_scb // 'scrollbind'
int wo_diff_saved; // options were saved for starting diff mode
#define w_p_diff_saved w_onebuf_opt.wo_diff_saved
int wo_scb_save; // 'scrollbind' saved for diff mode
#define w_p_scb_save w_onebuf_opt.wo_scb_save
int wo_wrap;
#define w_p_wrap w_onebuf_opt.wo_wrap // 'wrap'
#ifdef FEAT_DIFF
int wo_wrap_save; // 'wrap' state saved for diff mode
# define w_p_wrap_save w_onebuf_opt.wo_wrap_save
#endif
#ifdef FEAT_CONCEAL
char_u *wo_cocu; // 'concealcursor'
# define w_p_cocu w_onebuf_opt.wo_cocu
long wo_cole; // 'conceallevel'
# define w_p_cole w_onebuf_opt.wo_cole
#endif
int wo_crb;
#define w_p_crb w_onebuf_opt.wo_crb // 'cursorbind'
int wo_crb_save; // 'cursorbind' state saved for diff mode
#define w_p_crb_save w_onebuf_opt.wo_crb_save
#ifdef FEAT_SIGNS
char_u *wo_scl;
# define w_p_scl w_onebuf_opt.wo_scl // 'signcolumn'
#endif
long wo_siso;
# define w_p_siso w_onebuf_opt.wo_siso // 'sidescrolloff' local value
long wo_so;
# define w_p_so w_onebuf_opt.wo_so // 'scrolloff' local value
#ifdef FEAT_TERMINAL
char_u *wo_twk;
# define w_p_twk w_onebuf_opt.wo_twk // 'termwinkey'
char_u *wo_tws;
# define w_p_tws w_onebuf_opt.wo_tws // 'termwinsize'
#endif
#ifdef FEAT_EVAL
sctx_T wo_script_ctx[WV_COUNT]; // SCTXs for window-local options
# define w_p_script_ctx w_onebuf_opt.wo_script_ctx
#endif
} winopt_T;
/*
* Window info stored with a buffer.
*
* Two types of info are kept for a buffer which are associated with a
* specific window:
* 1. Each window can have a different line number associated with a buffer.
* 2. The window-local options for a buffer work in a similar way.
* The window-info is kept in a list at b_wininfo. It is kept in
* most-recently-used order.
*/
struct wininfo_S
{
wininfo_T *wi_next; // next entry or NULL for last entry
wininfo_T *wi_prev; // previous entry or NULL for first entry
win_T *wi_win; // pointer to window that did set wi_fpos
pos_T wi_fpos; // last cursor position in the file
winopt_T wi_opt; // local window options
int wi_optset; // TRUE when wi_opt has useful values
#ifdef FEAT_FOLDING
int wi_fold_manual; // copy of w_fold_manual
garray_T wi_folds; // clone of w_folds
#endif
int wi_changelistidx; // copy of w_changelistidx
};
/*
* Info used to pass info about a fold from the fold-detection code to the
* code that displays the foldcolumn.
*/
typedef struct foldinfo
{
int fi_level; // level of the fold; when this is zero the
// other fields are invalid
int fi_lnum; // line number where fold starts
int fi_low_level; // lowest fold level that starts in the same
// line
} foldinfo_T;
/*
* Structure to store info about the Visual area.
*/
typedef struct
{
pos_T vi_start; // start pos of last VIsual
pos_T vi_end; // end position of last VIsual
int vi_mode; // VIsual_mode of last VIsual
colnr_T vi_curswant; // MAXCOL from w_curswant
} visualinfo_T;
/*
* structures used for undo
*/
// One line saved for undo. After the NUL terminated text there might be text
// properties, thus ul_len can be larger than STRLEN(ul_line) + 1.
typedef struct {
char_u *ul_line; // text of the line
long ul_len; // length of the line including NUL, plus text
// properties
} undoline_T;
typedef struct u_entry u_entry_T;
typedef struct u_header u_header_T;
struct u_entry
{
u_entry_T *ue_next; // pointer to next entry in list
linenr_T ue_top; // number of line above undo block
linenr_T ue_bot; // number of line below undo block
linenr_T ue_lcount; // linecount when u_save called
undoline_T *ue_array; // array of lines in undo block
long ue_size; // number of lines in ue_array
#ifdef U_DEBUG
int ue_magic; // magic number to check allocation
#endif
};
struct u_header
{
// The following have a pointer and a number. The number is used when
// reading the undo file in u_read_undo()
union {
u_header_T *ptr; // pointer to next undo header in list
long seq;
} uh_next;
union {
u_header_T *ptr; // pointer to previous header in list
long seq;
} uh_prev;
union {
u_header_T *ptr; // pointer to next header for alt. redo
long seq;
} uh_alt_next;
union {
u_header_T *ptr; // pointer to previous header for alt. redo
long seq;
} uh_alt_prev;
long uh_seq; // sequence number, higher == newer undo
int uh_walk; // used by undo_time()
u_entry_T *uh_entry; // pointer to first entry
u_entry_T *uh_getbot_entry; // pointer to where ue_bot must be set
pos_T uh_cursor; // cursor position before saving
long uh_cursor_vcol;
int uh_flags; // see below
pos_T uh_namedm[NMARKS]; // marks before undo/after redo
visualinfo_T uh_visual; // Visual areas before undo/after redo
time_T uh_time; // timestamp when the change was made
long uh_save_nr; // set when the file was saved after the
// changes in this block
#ifdef U_DEBUG
int uh_magic; // magic number to check allocation
#endif
};
// values for uh_flags
#define UH_CHANGED 0x01 // b_changed flag before undo/after redo
#define UH_EMPTYBUF 0x02 // buffer was empty
/*
* structures used in undo.c
*/
#define ALIGN_LONG // longword alignment and use filler byte
#define ALIGN_SIZE (sizeof(long))
#define ALIGN_MASK (ALIGN_SIZE - 1)
typedef struct m_info minfo_T;
/*
* structure used to link chunks in one of the free chunk lists.
*/
struct m_info
{
#ifdef ALIGN_LONG
long_u m_size; // size of the chunk (including m_info)
#else
short_u m_size; // size of the chunk (including m_info)
#endif
minfo_T *m_next; // pointer to next free chunk in the list
};
/*
* things used in memfile.c
*/
typedef struct block_hdr bhdr_T;
typedef struct memfile memfile_T;
typedef long blocknr_T;
/*
* mf_hashtab_T is a chained hashtable with blocknr_T key and arbitrary
* structures as items. This is an intrusive data structure: we require
* that items begin with mf_hashitem_T which contains the key and linked
* list pointers. List of items in each bucket is doubly-linked.
*/
typedef struct mf_hashitem_S mf_hashitem_T;
struct mf_hashitem_S
{
mf_hashitem_T *mhi_next;
mf_hashitem_T *mhi_prev;
blocknr_T mhi_key;
};
#define MHT_INIT_SIZE 64
typedef struct mf_hashtab_S
{
long_u mht_mask; // mask used for hash value (nr of items
// in array is "mht_mask" + 1)
long_u mht_count; // nr of items inserted into hashtable
mf_hashitem_T **mht_buckets; // points to mht_small_buckets or
//dynamically allocated array
mf_hashitem_T *mht_small_buckets[MHT_INIT_SIZE]; // initial buckets
char mht_fixed; // non-zero value forbids growth
} mf_hashtab_T;
/*
* for each (previously) used block in the memfile there is one block header.
*
* The block may be linked in the used list OR in the free list.
* The used blocks are also kept in hash lists.
*
* The used list is a doubly linked list, most recently used block first.
* The blocks in the used list have a block of memory allocated.
* mf_used_count is the number of pages in the used list.
* The hash lists are used to quickly find a block in the used list.
* The free list is a single linked list, not sorted.
* The blocks in the free list have no block of memory allocated and
* the contents of the block in the file (if any) is irrelevant.
*/
struct block_hdr
{
mf_hashitem_T bh_hashitem; // header for hash table and key
#define bh_bnum bh_hashitem.mhi_key // block number, part of bh_hashitem
bhdr_T *bh_next; // next block_hdr in free or used list
bhdr_T *bh_prev; // previous block_hdr in used list
char_u *bh_data; // pointer to memory (for used block)
int bh_page_count; // number of pages in this block
#define BH_DIRTY 1
#define BH_LOCKED 2
char bh_flags; // BH_DIRTY or BH_LOCKED
};
/*
* when a block with a negative number is flushed to the file, it gets
* a positive number. Because the reference to the block is still the negative
* number, we remember the translation to the new positive number in the
* double linked trans lists. The structure is the same as the hash lists.
*/
typedef struct nr_trans NR_TRANS;
struct nr_trans
{
mf_hashitem_T nt_hashitem; // header for hash table and key
#define nt_old_bnum nt_hashitem.mhi_key // old, negative, number
blocknr_T nt_new_bnum; // new, positive, number
};
typedef struct buffblock buffblock_T;
typedef struct buffheader buffheader_T;
/*
* structure used to store one block of the stuff/redo/recording buffers
*/
struct buffblock
{
buffblock_T *b_next; // pointer to next buffblock
char_u b_str[1]; // contents (actually longer)
};
/*
* header used for the stuff buffer and the redo buffer
*/
struct buffheader
{
buffblock_T bh_first; // first (dummy) block of list
buffblock_T *bh_curr; // buffblock for appending
int bh_index; // index for reading
int bh_space; // space in bh_curr for appending
};
typedef struct
{
buffheader_T sr_redobuff;
buffheader_T sr_old_redobuff;
} save_redo_T;
typedef enum {
XP_PREFIX_NONE, // prefix not used
XP_PREFIX_NO, // "no" prefix for bool option
XP_PREFIX_INV, // "inv" prefix for bool option
} xp_prefix_T;
/*
* :set operator types
*/
typedef enum {
OP_NONE = 0,
OP_ADDING, // "opt+=arg"
OP_PREPENDING, // "opt^=arg"
OP_REMOVING, // "opt-=arg"
} set_op_T;
/*
* used for completion on the command line
*/
typedef struct expand
{
char_u *xp_pattern; // start of item to expand, guaranteed
// to be part of xp_line
int xp_context; // type of expansion
int xp_pattern_len; // bytes in xp_pattern before cursor
xp_prefix_T xp_prefix;
#if defined(FEAT_EVAL)
char_u *xp_arg; // completion function
sctx_T xp_script_ctx; // SCTX for completion function
#endif
int xp_backslash; // one of the XP_BS_ values
#ifndef BACKSLASH_IN_FILENAME
int xp_shell; // TRUE for a shell command, more
// characters need to be escaped
#endif
int xp_numfiles; // number of files found by
// file name completion
int xp_col; // cursor position in line
int xp_selected; // selected index in completion
char_u *xp_orig; // originally expanded string
char_u **xp_files; // list of files
char_u *xp_line; // text being completed
#define EXPAND_BUF_LEN 256
char_u xp_buf[EXPAND_BUF_LEN]; // buffer for returned match
} expand_T;
/*
* values for xp_backslash
*/
#define XP_BS_NONE 0 // nothing special for backslashes
#define XP_BS_ONE 0x1 // uses one backslash before a space
#define XP_BS_THREE 0x2 // uses three backslashes before a space
#define XP_BS_COMMA 0x4 // commas need to be escaped with a backslash
/*
* Variables shared between getcmdline(), redrawcmdline() and others.
* These need to be saved when using CTRL-R |, that's why they are in a
* structure.
*/
typedef struct
{
char_u *cmdbuff; // pointer to command line buffer
int cmdbufflen; // length of cmdbuff
int cmdlen; // number of chars in command line
int cmdpos; // current cursor position
int cmdspos; // cursor column on screen
int cmdfirstc; // ':', '/', '?', '=', '>' or NUL
int cmdindent; // number of spaces before cmdline
char_u *cmdprompt; // message in front of cmdline
int cmdattr; // attributes for prompt
int overstrike; // Typing mode on the command line. Shared by
// getcmdline() and put_on_cmdline().
expand_T *xpc; // struct being used for expansion, xp_pattern
// may point into cmdbuff
int xp_context; // type of expansion
# ifdef FEAT_EVAL
char_u *xp_arg; // user-defined expansion arg
int input_fn; // when TRUE Invoked for input() function
# endif
} cmdline_info_T;
/*
* Command modifiers ":vertical", ":browse", ":confirm" and ":hide" set a flag.
* This needs to be saved for recursive commands, put them in a structure for
* easy manipulation.
*/
typedef struct
{
int cmod_flags; // CMOD_ flags
#define CMOD_SANDBOX 0x0001 // ":sandbox"
#define CMOD_SILENT 0x0002 // ":silent"
#define CMOD_ERRSILENT 0x0004 // ":silent!"
#define CMOD_UNSILENT 0x0008 // ":unsilent"
#define CMOD_NOAUTOCMD 0x0010 // ":noautocmd"
#define CMOD_HIDE 0x0020 // ":hide"
#define CMOD_BROWSE 0x0040 // ":browse" - invoke file dialog
#define CMOD_CONFIRM 0x0080 // ":confirm" - invoke yes/no dialog
#define CMOD_KEEPALT 0x0100 // ":keepalt"
#define CMOD_KEEPMARKS 0x0200 // ":keepmarks"
#define CMOD_KEEPJUMPS 0x0400 // ":keepjumps"
#define CMOD_LOCKMARKS 0x0800 // ":lockmarks"
#define CMOD_KEEPPATTERNS 0x1000 // ":keeppatterns"
#define CMOD_NOSWAPFILE 0x2000 // ":noswapfile"
#define CMOD_VIM9CMD 0x4000 // ":vim9cmd"
#define CMOD_LEGACY 0x8000 // ":legacy"
int cmod_split; // flags for win_split()
int cmod_tab; // > 0 when ":tab" was used
regmatch_T cmod_filter_regmatch; // set by :filter /pat/
int cmod_filter_force; // set for :filter!
int cmod_verbose; // 0 if not set, > 0 to set 'verbose'
// to cmod_verbose - 1
// values for undo_cmdmod()
char_u *cmod_save_ei; // saved value of 'eventignore'
#ifdef HAVE_SANDBOX
int cmod_did_sandbox; // set when "sandbox" was incremented
#endif
long cmod_verbose_save; // if 'verbose' was set: value of
// p_verbose plus one
int cmod_save_msg_silent; // if non-zero: saved value of
// msg_silent + 1
int cmod_save_msg_scroll; // for restoring msg_scroll
int cmod_did_esilent; // incremented when emsg_silent is
} cmdmod_T;
typedef enum {
MF_DIRTY_NO = 0, // no dirty blocks
MF_DIRTY_YES, // there are dirty blocks
MF_DIRTY_YES_NOSYNC, // there are dirty blocks, do not sync yet
} mfdirty_T;
#define MF_SEED_LEN 8
struct memfile
{
char_u *mf_fname; // name of the file
char_u *mf_ffname; // idem, full path
int mf_fd; // file descriptor
int mf_flags; // flags used when opening this memfile
int mf_reopen; // mf_fd was closed, retry opening
bhdr_T *mf_free_first; // first block_hdr in free list
bhdr_T *mf_used_first; // mru block_hdr in used list
bhdr_T *mf_used_last; // lru block_hdr in used list
unsigned mf_used_count; // number of pages in used list
unsigned mf_used_count_max; // maximum number of pages in memory
mf_hashtab_T mf_hash; // hash lists
mf_hashtab_T mf_trans; // trans lists
blocknr_T mf_blocknr_max; // highest positive block number + 1
blocknr_T mf_blocknr_min; // lowest negative block number - 1
blocknr_T mf_neg_count; // number of negative blocks numbers
blocknr_T mf_infile_count; // number of pages in the file
unsigned mf_page_size; // number of bytes in a page
mfdirty_T mf_dirty;
#ifdef FEAT_CRYPT
buf_T *mf_buffer; // buffer this memfile is for
char_u mf_seed[MF_SEED_LEN]; // seed for encryption
// Values for key, method and seed used for reading data blocks when
// updating for a newly set key or method. Only when mf_old_key != NULL.
char_u *mf_old_key;
int mf_old_cm;
char_u mf_old_seed[MF_SEED_LEN];
#endif
};
/*
* things used in memline.c
*/
/*
* When searching for a specific line, we remember what blocks in the tree
* are the branches leading to that block. This is stored in ml_stack. Each
* entry is a pointer to info in a block (may be data block or pointer block)
*/
typedef struct info_pointer
{
blocknr_T ip_bnum; // block number
linenr_T ip_low; // lowest lnum in this block
linenr_T ip_high; // highest lnum in this block
int ip_index; // index for block with current lnum
} infoptr_T; // block/index pair
#ifdef FEAT_BYTEOFF
typedef struct ml_chunksize
{
int mlcs_numlines;
long mlcs_totalsize;
} chunksize_T;
/*
* Flags when calling ml_updatechunk()
*/
# define ML_CHNK_ADDLINE 1
# define ML_CHNK_DELLINE 2
# define ML_CHNK_UPDLINE 3
#endif
/*
* the memline structure holds all the information about a memline
*/
typedef struct memline
{
linenr_T ml_line_count; // number of lines in the buffer
memfile_T *ml_mfp; // pointer to associated memfile
infoptr_T *ml_stack; // stack of pointer blocks (array of IPTRs)
int ml_stack_top; // current top of ml_stack
int ml_stack_size; // total number of entries in ml_stack
#define ML_EMPTY 0x01 // empty buffer
#define ML_LINE_DIRTY 0x02 // cached line was changed and allocated
#define ML_LOCKED_DIRTY 0x04 // ml_locked was changed
#define ML_LOCKED_POS 0x08 // ml_locked needs positive block number
#define ML_ALLOCATED 0x10 // ml_line_ptr is an allocated copy
int ml_flags;
colnr_T ml_line_len; // length of the cached line + NUL + text properties
colnr_T ml_line_textlen;// length of the cached line + NUL, 0 if not known yet
linenr_T ml_line_lnum; // line number of cached line, 0 if not valid
char_u *ml_line_ptr; // pointer to cached line
bhdr_T *ml_locked; // block used by last ml_get
linenr_T ml_locked_low; // first line in ml_locked
linenr_T ml_locked_high; // last line in ml_locked
int ml_locked_lineadd; // number of lines inserted in ml_locked
#ifdef FEAT_BYTEOFF
chunksize_T *ml_chunksize;
int ml_numchunks;
int ml_usedchunks;
#endif
} memline_T;
// Values for the flags argument of ml_delete_flags().
#define ML_DEL_MESSAGE 1 // may give a "No lines in buffer" message
#define ML_DEL_UNDO 2 // called from undo, do not update textprops
#define ML_DEL_NOPROP 4 // splitting data block, do not update textprops
// Values for the flags argument of ml_append_int().
#define ML_APPEND_NEW 1 // starting to edit a new file
#define ML_APPEND_MARK 2 // mark the new line
#define ML_APPEND_UNDO 4 // called from undo
#define ML_APPEND_NOPROP 8 // do not continue textprop from previous line
/*
* Structure defining text properties. These stick with the text.
* When stored in memline they are after the text, ml_line_len is larger than
* STRLEN(ml_line_ptr) + 1.
*/
typedef struct textprop_S
{
colnr_T tp_col; // start column (one based, in bytes)
colnr_T tp_len; // length in bytes, when tp_id is negative used
// for left padding plus one
int tp_id; // identifier
int tp_type; // property type
int tp_flags; // TP_FLAG_ values
int tp_padleft; // left padding between text line and virtual
// text
} textprop_T;
#define TP_FLAG_CONT_NEXT 0x1 // property continues in next line
#define TP_FLAG_CONT_PREV 0x2 // property was continued from prev line
// without these text is placed after the end of the line
#define TP_FLAG_ALIGN_RIGHT 0x010 // virtual text is right-aligned
#define TP_FLAG_ALIGN_ABOVE 0x020 // virtual text above the line
#define TP_FLAG_ALIGN_BELOW 0x040 // virtual text on next screen line
#define TP_FLAG_WRAP 0x080 // virtual text wraps - when missing
// text is truncated
#define TP_FLAG_START_INCL 0x100 // "start_incl" copied from proptype
#define PROP_TEXT_MIN_CELLS 4 // minimum number of cells to use for
// the text, even when truncating
/*
* Structure defining a property type.
*/
typedef struct proptype_S
{
int pt_id; // value used for tp_id
int pt_type; // number used for tp_type
int pt_hl_id; // highlighting
int pt_priority; // priority
int pt_flags; // PT_FLAG_ values
char_u pt_name[1]; // property type name, actually longer
} proptype_T;
#define PT_FLAG_INS_START_INCL 1 // insert at start included in property
#define PT_FLAG_INS_END_INCL 2 // insert at end included in property
#define PT_FLAG_COMBINE 4 // combine with syntax highlight
#define PT_FLAG_OVERRIDE 8 // override any highlight
// Sign group
typedef struct signgroup_S
{
int sg_next_sign_id; // next sign id for this group
short_u sg_refcount; // number of signs in this group
char_u sg_name[1]; // sign group name, actually longer
} signgroup_T;
typedef struct sign_entry sign_entry_T;
struct sign_entry
{
int se_id; // unique identifier for each placed sign
int se_typenr; // typenr of sign
int se_priority; // priority for highlighting
linenr_T se_lnum; // line number which has this sign
signgroup_T *se_group; // sign group
sign_entry_T *se_next; // next entry in a list of signs
sign_entry_T *se_prev; // previous entry -- for easy reordering
};
/*
* Sign attributes. Used by the screen refresh routines.
*/
typedef struct sign_attrs_S {
int sat_typenr;
void *sat_icon;
char_u *sat_text;
int sat_texthl;
int sat_linehl;
int sat_culhl;
int sat_numhl;
int sat_priority;
} sign_attrs_T;
#if defined(FEAT_SIGNS) || defined(PROTO)
// Macros to get the sign group structure from the group name
#define SGN_KEY_OFF offsetof(signgroup_T, sg_name)
#define HI2SG(hi) ((signgroup_T *)((hi)->hi_key - SGN_KEY_OFF))
// Default sign priority for highlighting
#define SIGN_DEF_PRIO 10
#endif
/*
* Argument list: Array of file names.
* Used for the global argument list and the argument lists local to a window.
*/
typedef struct arglist
{
garray_T al_ga; // growarray with the array of file names
int al_refcount; // number of windows using this arglist
int id; // id of this arglist
} alist_T;
/*
* For each argument remember the file name as it was given, and the buffer
* number that contains the expanded file name (required for when ":cd" is
* used).
*/
typedef struct argentry
{
char_u *ae_fname; // file name as specified
int ae_fnum; // buffer number with expanded file name
} aentry_T;
#define ALIST(win) (win)->w_alist
#define GARGLIST ((aentry_T *)global_alist.al_ga.ga_data)
#define ARGLIST ((aentry_T *)ALIST(curwin)->al_ga.ga_data)
#define WARGLIST(wp) ((aentry_T *)ALIST(wp)->al_ga.ga_data)
#define AARGLIST(al) ((aentry_T *)((al)->al_ga.ga_data))
#define GARGCOUNT (global_alist.al_ga.ga_len)
#define ARGCOUNT (ALIST(curwin)->al_ga.ga_len)
#define WARGCOUNT(wp) (ALIST(wp)->al_ga.ga_len)
/*
* A list used for saving values of "emsg_silent". Used by ex_try() to save the
* value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT
* flag below is set.
*/
typedef struct eslist_elem eslist_T;
struct eslist_elem
{
int saved_emsg_silent; // saved value of "emsg_silent"
eslist_T *next; // next element on the list
};
/*
* For conditional commands a stack is kept of nested conditionals.
* When cs_idx < 0, there is no conditional command.
*/
#define CSTACK_LEN 50
typedef struct {
short cs_flags[CSTACK_LEN]; // CSF_ flags
char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally"
union {
void *csp_rv[CSTACK_LEN]; // return typeval for pending return
void *csp_ex[CSTACK_LEN]; // exception for pending throw
} cs_pend;
void *cs_forinfo[CSTACK_LEN]; // info used by ":for"
int cs_line[CSTACK_LEN]; // line nr of ":while"/":for" line
int cs_block_id[CSTACK_LEN]; // block ID stack
int cs_script_var_len[CSTACK_LEN]; // value of sn_var_vals.ga_len
// when entering the block
int cs_idx; // current entry, or -1 if none
int cs_looplevel; // nr of nested ":while"s and ":for"s
int cs_trylevel; // nr of nested ":try"s
eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent"
char cs_lflags; // loop flags: CSL_ flags