robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1#pragma once 2 3#include <stdbool.h> 4#include <stdint.h> 5#include <stdio.h> 6 7#include "nvim/arglist_defs.h" 8#include "nvim/grid_defs.h" 9#include "nvim/mapping_defs.h" 10#include "nvim/marktree_defs.h" 11#include "nvim/memline_defs.h" 12#include "nvim/normal_defs.h" 13#include "nvim/option_defs.h" 14#include "nvim/os/fs_defs.h" 15#include "nvim/statusline_defs.h" 16#include "nvim/types_defs.h" 17#include "nvim/undo_defs.h" 18 19/// Reference to a buffer that stores the value of buf_free_count. 20/// bufref_valid() only needs to check "buf" when the count differs. 21typedef struct { 22buf_T * br_buf ; 23int br_fnum ; 24int br_buf_free_count ; 25}bufref_T ; 26 27#define GETFILE_SUCCESS (x ) ((x) <= 0) 28#define MODIFIABLE (buf ) (buf->b_p_ma) 29 30// Flags for w_valid. 31// These are set when something in a window structure becomes invalid, except 32// when the cursor is moved. Call check_cursor_moved() before testing one of 33// the flags. 34// These are reset when that thing has been updated and is valid again. 35// 36// Every function that invalidates one of these must call one of the 37// invalidate_* functions. 38// 39// w_valid is supposed to be used only in screen.c. From other files, use the 40// functions that set or reset the flags. 41// 42// VALID_BOTLINE VALID_BOTLINE_AP 43// on on w_botline valid 44// off on w_botline approximated 45// off off w_botline not valid 46// on off not possible 47#define VALID_WROW 0x01 // w_wrow (window row) is valid 48#define VALID_WCOL 0x02 // w_wcol (window col) is valid 49#define VALID_VIRTCOL 0x04 // w_virtcol (file col) is valid 50#define VALID_CHEIGHT 0x08 // w_cline_height and w_cline_folded valid 51#define VALID_CROW 0x10 // w_cline_row is valid 52#define VALID_BOTLINE 0x20 // w_botline and w_empty_rows are valid 53#define VALID_BOTLINE_AP 0x40 // w_botline is approximated 54#define VALID_TOPLINE 0x80 // w_topline is valid (for cursor position) 55 56// flags for b_flags 57#define BF_RECOVERED 0x01 // buffer has been recovered 58#define BF_CHECK_RO 0x02 // need to check readonly when loading file 59// into buffer (set by ":e", may be reset by 60// ":buf") 61#define BF_NEVERLOADED 0x04 // file has never been loaded into buffer, 62// many variables still need to be set 63#define BF_NOTEDITED 0x08 // Set when file name is changed after 64// starting to edit, reset when file is 65// written out. 66#define BF_NEW 0x10 // file didn't exist when editing started 67#define BF_NEW_W 0x20 // Warned for BF_NEW and file created 68#define BF_READERR 0x40 // got errors while reading the file 69#define BF_DUMMY 0x80 // Internal-only dummy buffer. 70#define BF_SYN_SET 0x200 // 'syntax' option was set 71 72// Mask to check for flags that prevent normal writing 73#define BF_WRITE_MASK (BF_NOTEDITED + BF_NEW + BF_READERR) 74 75typedef struct wininfo_S WinInfo ; 76typedef struct frame_S frame_T ; 77typedef uint64_t disptick_T ;// display tick type 78 79// The taggy struct is used to store the information about a :tag command. 80typedef struct { 81char * tagname ;// tag name 82fmark_T fmark ;// cursor position BEFORE ":tag" 83int cur_match ;// match number 84int cur_fnum ;// buffer number used for cur_match 85char * user_data ;// used with tagfunc 86}taggy_T ; 87 88// Structure that contains all options that are local to a window. 89// Used twice in a window: for the current buffer and for all buffers. 90// Also used in WinInfo. 91typedef struct { 92int wo_arab ; 93#define w_p_arab w_onebuf_opt.wo_arab // 'arabic' 94int wo_bri ; 95#define w_p_bri w_onebuf_opt.wo_bri // 'breakindent' 96char * wo_briopt ; 97#define w_p_briopt w_onebuf_opt.wo_briopt // 'breakindentopt' 98int wo_diff ; 99#define w_p_diff w_onebuf_opt.wo_diff // 'diff' 100char * wo_fdc ; 101#define w_p_eiw w_onebuf_opt.wo_eiw // 'eventignorewin' 102char * wo_eiw ; 103#define w_p_fdc w_onebuf_opt.wo_fdc // 'foldcolumn' 104char * wo_fdc_save ; 105#define w_p_fdc_save w_onebuf_opt.wo_fdc_save // 'fdc' saved for diff mode 106int wo_fen ; 107#define w_p_fen w_onebuf_opt.wo_fen // 'foldenable' 108int wo_fen_save ; 109// 'foldenable' saved for diff mode 110#define w_p_fen_save w_onebuf_opt.wo_fen_save 111char * wo_fdi ; 112#define w_p_fdi w_onebuf_opt.wo_fdi // 'foldignore' 113OptInt wo_fdl ; 114#define w_p_fdl w_onebuf_opt.wo_fdl // 'foldlevel' 115OptInt wo_fdl_save ; 116// 'foldlevel' state saved for diff mode 117#define w_p_fdl_save w_onebuf_opt.wo_fdl_save 118char * wo_fdm ; 119#define w_p_fdm w_onebuf_opt.wo_fdm // 'foldmethod' 120char * wo_fdm_save ; 121#define w_p_fdm_save w_onebuf_opt.wo_fdm_save // 'fdm' saved for diff mode 122OptInt wo_fml ; 123#define w_p_fml w_onebuf_opt.wo_fml // 'foldminlines' 124OptInt wo_fdn ; 125#define w_p_fdn w_onebuf_opt.wo_fdn // 'foldnestmax' 126Callback wo_fde ; 127#define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr' 128Callback wo_fdt ; 129#define w_p_fdt w_onebuf_opt.wo_fdt // 'foldtext' 130char * wo_fmr ; 131#define w_p_fmr w_onebuf_opt.wo_fmr // 'foldmarker' 132int wo_lbr ; 133#define w_p_lbr w_onebuf_opt.wo_lbr // 'linebreak' 134int wo_list ; 135#define w_p_list w_onebuf_opt.wo_list // 'list' 136int wo_nu ; 137#define w_p_nu w_onebuf_opt.wo_nu // 'number' 138int wo_rnu ; 139#define w_p_rnu w_onebuf_opt.wo_rnu // 'relativenumber' 140char * wo_ve ; 141#define w_p_ve w_onebuf_opt.wo_ve // 'virtualedit' 142unsigned wo_ve_flags ; 143#define w_ve_flags w_onebuf_opt.wo_ve_flags // flags for 'virtualedit' 144OptInt wo_nuw ; 145#define w_p_nuw w_onebuf_opt.wo_nuw // 'numberwidth' 146int wo_wfb ; 147#define w_p_wfb w_onebuf_opt.wo_wfb // 'winfixbuf' 148int wo_wfh ; 149#define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight' 150int wo_wfw ; 151#define w_p_wfw w_onebuf_opt.wo_wfw // 'winfixwidth' 152int wo_wp ; 153#define w_p_wp w_onebuf_opt.wo_wp // 'winpinned' 154int wo_pvw ; 155#define w_p_pvw w_onebuf_opt.wo_pvw // 'previewwindow' 156OptInt wo_lhi ; 157#define w_p_lhi w_onebuf_opt.wo_lhi // 'lhistory' 158int wo_rl ; 159#define w_p_rl w_onebuf_opt.wo_rl // 'rightleft' 160char * wo_rlc ; 161#define w_p_rlc w_onebuf_opt.wo_rlc // 'rightleftcmd' 162OptInt wo_scr ; 163#define w_p_scr w_onebuf_opt.wo_scr // 'scroll' 164int wo_sms ; 165#define w_p_sms w_onebuf_opt.wo_sms // 'smoothscroll' 166int wo_spell ; 167#define w_p_spell w_onebuf_opt.wo_spell // 'spell' 168int wo_cuc ; 169#define w_p_cuc w_onebuf_opt.wo_cuc // 'cursorcolumn' 170int wo_cul ; 171#define w_p_cul w_onebuf_opt.wo_cul // 'cursorline' 172char * wo_culopt ; 173#define w_p_culopt w_onebuf_opt.wo_culopt // 'cursorlineopt' 174char * wo_cc ; 175#define w_p_cc w_onebuf_opt.wo_cc // 'colorcolumn' 176char * wo_sbr ; 177#define w_p_sbr w_onebuf_opt.wo_sbr // 'showbreak' 178char * wo_stc ; 179#define w_p_stc w_onebuf_opt.wo_stc // 'statuscolumn' 180char * wo_stl ; 181#define w_p_stl w_onebuf_opt.wo_stl // 'statusline' 182char * wo_wbr ; 183#define w_p_wbr w_onebuf_opt.wo_wbr // 'winbar' 184int wo_scb ; 185#define w_p_scb w_onebuf_opt.wo_scb // 'scrollbind' 186int wo_diff_saved ;// options were saved for starting diff mode 187#define w_p_diff_saved w_onebuf_opt.wo_diff_saved 188int wo_scb_save ;// 'scrollbind' saved for diff mode 189#define w_p_scb_save w_onebuf_opt.wo_scb_save 190int wo_wrap ; 191#define w_p_wrap w_onebuf_opt.wo_wrap // 'wrap' 192int wo_wrap_save ;// 'wrap' state saved for diff mode 193#define w_p_wrap_save w_onebuf_opt.wo_wrap_save 194char * wo_cocu ;// 'concealcursor' 195#define w_p_cocu w_onebuf_opt.wo_cocu 196OptInt wo_cole ;// 'conceallevel' 197#define w_p_cole w_onebuf_opt.wo_cole 198int wo_crb ; 199#define w_p_crb w_onebuf_opt.wo_crb // 'cursorbind' 200int wo_crb_save ;// 'cursorbind' state saved for diff mode 201#define w_p_crb_save w_onebuf_opt.wo_crb_save 202char * wo_scl ; 203#define w_p_scl w_onebuf_opt.wo_scl // 'signcolumn' 204OptInt wo_siso ; 205#define w_p_siso w_onebuf_opt.wo_siso // 'sidescrolloff' local value 206OptInt wo_so ; 207#define w_p_so w_onebuf_opt.wo_so // 'scrolloff' local value 208OptInt wo_sop ; 209#define w_p_sop w_onebuf_opt.wo_sop // 'scrolloffpad' local value 210char * wo_winhl ; 211#define w_p_winhl w_onebuf_opt.wo_winhl // 'winhighlight' 212char * wo_lcs ; 213#define w_p_lcs w_onebuf_opt.wo_lcs // 'listchars' 214char * wo_fcs ; 215#define w_p_fcs w_onebuf_opt.wo_fcs // 'fillchars' 216OptInt wo_winbl ; 217#define w_p_winbl w_onebuf_opt.wo_winbl // 'winblend' 218 219// A few options have local flags for kOptFlagInsecure. 220uint32_t wo_wrap_flags ;// flags for 'wrap' 221#define w_p_wrap_flags w_onebuf_opt.wo_wrap_flags 222uint32_t wo_stl_flags ;// flags for 'statusline' 223#define w_p_stl_flags w_onebuf_opt.wo_stl_flags 224uint32_t wo_wbr_flags ;// flags for 'winbar' 225#define w_p_wbr_flags w_onebuf_opt.wo_wbr_flags 226uint32_t wo_fde_flags ;// flags for 'foldexpr' 227#define w_p_fde_flags w_onebuf_opt.wo_fde_flags 228uint32_t wo_fdt_flags ;// flags for 'foldtext' 229#define w_p_fdt_flags w_onebuf_opt.wo_fdt_flags 230 231sctx_T wo_script_ctx [kWinOptCount ];// SCTXs for window-local options 232#define w_p_script_ctx w_onebuf_opt.wo_script_ctx 233}winopt_T ; 234 235// Window info stored with a buffer. 236// 237// Two types of info are kept for a buffer which are associated with a 238// specific window: 239// 1. Each window can have a different line number associated with a buffer. 240// 2. The window-local options for a buffer work in a similar way. 241// The window-info is kept in a list at b_wininfo. It is kept in 242// most-recently-used order. 243struct wininfo_S { 244win_T * wi_win ;// pointer to window that did set wi_mark 245fmark_T wi_mark ;// last cursor mark in the file 246bool wi_optset ;// true when wi_opt has useful values 247winopt_T wi_opt ;// local window options 248bool wi_fold_manual ;// copy of w_fold_manual 249garray_T wi_folds ;// clone of w_folds 250int wi_changelistidx ;// copy of w_changelistidx 251}; 252 253#define ALIST (win ) (win)->w_alist 254#define GARGLIST ((aentry_T *)global_alist.al_ga.ga_data) 255#define ARGLIST ((aentry_T *)ALIST(curwin)->al_ga.ga_data) 256#define WARGLIST (wp ) ((aentry_T *)ALIST(wp)->al_ga.ga_data) 257#define AARGLIST (al ) ((aentry_T *)((al)->al_ga.ga_data)) 258#define GARGCOUNT (global_alist.al_ga.ga_len) 259#define ARGCOUNT (ALIST(curwin)->al_ga.ga_len) 260#define WARGCOUNT (wp ) (ALIST(wp)->al_ga.ga_len) 261 262// values for b_syn_spell: what to do with toplevel text 263#define SYNSPL_DEFAULT 0 // spell check if @Spell not defined 264#define SYNSPL_TOP 1 // spell check toplevel text 265#define SYNSPL_NOTOP 2 // don't spell check toplevel text 266 267// values for b_syn_foldlevel: how to compute foldlevel on a line 268#define SYNFLD_START 0 // use level of item at start of line 269#define SYNFLD_MINIMUM 1 // use lowest local minimum level on line 270 271typedef struct qf_info_S qf_info_T ; 272 273// Used for :syntime: timing of executing a syntax pattern. 274typedef struct { 275proftime_T total ;// total time used 276proftime_T slowest ;// time of slowest call 277int count ;// nr of times used 278int match ;// nr of times matched 279}syn_time_T ; 280 281// These are items normally related to a buffer. But when using ":ownsyntax" 282// a window may have its own instance. 283typedef struct { 284hashtab_T b_keywtab ;// syntax keywords hash table 285hashtab_T b_keywtab_ic ;// idem, ignore case 286bool b_syn_error ;// true when error occurred in HL 287bool b_syn_slow ;// true when 'redrawtime' reached 288int b_syn_ic ;// ignore case for :syn cmds 289int b_syn_foldlevel ;// how to compute foldlevel on a line 290int b_syn_spell ;// SYNSPL_ values 291garray_T b_syn_patterns ;// table for syntax patterns 292garray_T b_syn_clusters ;// table for syntax clusters 293int b_spell_cluster_id ;// @Spell cluster ID or 0 294int b_nospell_cluster_id ;// @NoSpell cluster ID or 0 295int b_syn_containedin ;// true when there is an item with a 296// "containedin" argument 297int b_syn_sync_flags ;// flags about how to sync 298int16_t b_syn_sync_id ;// group to sync on 299linenr_T b_syn_sync_minlines ;// minimal sync lines offset 300linenr_T b_syn_sync_maxlines ;// maximal sync lines offset 301linenr_T b_syn_sync_linebreaks ;// offset for multi-line pattern 302char * b_syn_linecont_pat ;// line continuation pattern 303regprog_T * b_syn_linecont_prog ;// line continuation program 304syn_time_T b_syn_linecont_time ; 305int b_syn_linecont_ic ;// ignore-case flag for above 306int b_syn_topgrp ;// for ":syntax include" 307int b_syn_conceal ;// auto-conceal for :syn cmds 308int b_syn_folditems ;// number of patterns with the HL_FOLD 309// flag set 310// b_sst_array[] contains the state stack for a number of lines, for the 311// start of that line (col == 0). This avoids having to recompute the 312// syntax state too often. 313// b_sst_array[] is allocated to hold the state for all displayed lines, 314// and states for 1 out of about 20 other lines. 315// b_sst_array pointer to an array of synstate_T 316// b_sst_len number of entries in b_sst_array[] 317// b_sst_first pointer to first used entry in b_sst_array[] or NULL 318// b_sst_search cached entry near the last accessed line, used as a 319// start point for forward lookups, or NULL 320// b_sst_firstfree pointer to first free entry in b_sst_array[] or NULL 321// b_sst_freecount number of free entries in b_sst_array[] 322// b_sst_check_lnum entries after this lnum need to be checked for 323// validity (MAXLNUM means no check needed) 324synstate_T * b_sst_array ; 325int b_sst_len ; 326synstate_T * b_sst_first ; 327synstate_T * b_sst_search ; 328synstate_T * b_sst_firstfree ; 329int b_sst_freecount ; 330linenr_T b_sst_check_lnum ; 331disptick_T b_sst_lasttick ;// last display tick 332 333// Cache for in_id_list(); see idl_cache_T in syntax.c. 334void * b_idlist_cache ; 335 336// for spell checking 337garray_T b_langp ;// list of pointers to slang_T, see spell.c 338bool b_spell_ismw [256 ];// flags: is midword char 339char * b_spell_ismw_mb ;// multi-byte midword chars 340char * b_p_spc ;// 'spellcapcheck' 341regprog_T * b_cap_prog ;// program for 'spellcapcheck' 342char * b_p_spf ;// 'spellfile' 343char * b_p_spl ;// 'spelllang' 344char * b_p_spo ;// 'spelloptions' 345unsigned b_p_spo_flags ;// 'spelloptions' flags 346int b_cjk ;// all CJK letters as OK 347uint64_t b_syn_chartab [4 ];// syntax iskeyword option 348char * b_syn_isk ;// iskeyword option 349}synblock_T ; 350 351/// Type used for changedtick_di member in buf_T 352/// 353/// Primary exists so that literals of relevant type can be made. 354typedef TV_DICTITEM_STRUCT (sizeof ("changedtick" ))ChangedtickDictItem ; 355 356typedef struct { 357LuaRef on_lines ; 358LuaRef on_bytes ; 359LuaRef on_changedtick ; 360LuaRef on_detach ; 361LuaRef on_reload ; 362bool utf_sizes ; 363bool preview ; 364}BufUpdateCallbacks ; 365#define BUF_UPDATE_CALLBACKS_INIT { LUA_NOREF, LUA_NOREF, LUA_NOREF, \ 366 LUA_NOREF, LUA_NOREF, false, false } 367 368#define BUF_HAS_QF_ENTRY 1 369#define BUF_HAS_LL_ENTRY 2 370 371// Maximum number of maphash blocks we will have 372#define MAX_MAPHASH 256 373 374// buffer: structure that holds information about one file 375// 376// Several windows can share a single Buffer 377// A buffer is unallocated if there is no memfile for it. 378// A buffer is new if the associated file has never been loaded yet. 379 380struct file_buffer { 381handle_T handle ;// unique id for the buffer (buffer number) 382#define b_fnum handle 383 384memline_T b_ml ;// associated memline (also contains line count 385 386buf_T * b_next ;// links in list of buffers 387buf_T * b_prev ; 388 389int b_nwindows ;// nr of windows open on this buffer 390 391int b_flags ;// various BF_ flags 392int b_locked ;// Buffer is being closed or referenced, don't 393// let autocommands wipe it out. 394int b_locked_split ;// Buffer is being closed, don't allow opening 395// it in more windows. 396int b_ro_locked ;// Non-zero when the buffer can't be changed. 397// Used for FileChangedRO 398 399// b_ffname has the full path of the file (NULL for no name). 400// b_sfname is the name as the user typed it (or NULL). 401// b_fname is the same as b_sfname, unless ":cd" has been done, 402// then it is the same as b_ffname (NULL for no name). 403char * b_ffname ;// full path file name, allocated 404char * b_sfname ;// short file name, allocated, may be equal to 405// b_ffname 406char * b_fname ;// current file name, points to b_ffname or 407// b_sfname 408 409bool file_id_valid ; 410FileID file_id ; 411 412int b_changed ;// 'modified': Set to true if something in the 413// file has been changed and not written out. 414 415/// Change-identifier incremented for each change, including undo. 416/// 417/// This is a dict item used to store b:changedtick. 418ChangedtickDictItem changedtick_di ; 419 420varnumber_T b_last_changedtick ;// b:changedtick when TextChanged was 421// last triggered. 422varnumber_T b_last_changedtick_i ;// b:changedtick for TextChangedI/T 423varnumber_T b_last_changedtick_pum ;// b:changedtick for TextChangedP 424 425bool b_saving ;// Set to true if we are in the middle of 426// saving the buffer. 427 428// Changes to a buffer require updating of the display. To minimize the 429// work, remember changes made and update everything at once. 430bool b_mod_set ;// true when there are changes since the last 431// time the display was updated 432linenr_T b_mod_top ;// topmost lnum that was changed 433linenr_T b_mod_bot ;// lnum below last changed line, AFTER the 434// change 435linenr_T b_mod_xlines ;// number of extra buffer lines inserted; 436// negative when lines were deleted 437kvec_t (WinInfo * )b_wininfo ;// list of last used info for each window 438disptick_T b_mod_tick_syn ;// last display tick syntax was updated 439disptick_T b_mod_tick_decor ;// last display tick decoration providers were invoked 440 441int64_t b_mtime ;// last change time of original file 442int64_t b_mtime_ns ;// nanoseconds of last change time 443int64_t b_mtime_read ;// last change time when reading 444int64_t b_mtime_read_ns ;// nanoseconds of last read time 445uint64_t b_orig_size ;// size of original file in bytes 446int b_orig_mode ;// mode of original file 447time_t b_last_used ;// time when the buffer was last used; used 448// for viminfo 449 450fmark_T b_namedm [NMARKS ];// current named marks (mark.c) 451 452// These variables are set when Visual.active becomes false 453visualinfo_T b_visual ; 454int b_visual_mode_eval ;// b_visual.vi_mode for visualmode() 455 456fmark_T b_last_cursor ;// cursor position when last unloading this 457// buffer 458fmark_T b_last_insert ;// where Insert mode was left 459fmark_T b_last_change ;// position of last change: '. mark 460 461// the changelist contains old change positions 462fmark_T b_changelist [JUMPLISTSIZE ]; 463int b_changelistlen ;// number of active entries 464bool b_new_change ;// set by u_savecommon() 465 466// Character table, only used in charset.c for 'iskeyword' 467// bitset with 4*64=256 bits: 1 bit per character 0-255. 468uint64_t b_chartab [4 ]; 469 470// Buffer-local mappings. 471mapblock_T * (b_maphash [MAX_MAPHASH ]); 472// Buffer-local abbreviations. 473mapblock_T * b_first_abbr ; 474// Buffer-local user commands. 475garray_T b_ucmds ; 476 477// start and end of an operator, also used for '[ and '] 478pos_T b_op_start ; 479pos_T b_op_start_orig ;// used for Ins.start_orig 480pos_T b_op_end ; 481 482bool b_marks_read ;// Have we read ShaDa marks yet? 483 484bool b_modified_was_set ;///< did ":set modified" 485bool b_did_filetype ;///< FileType event found 486bool b_keep_filetype ;///< value for did_filetype when starting 487///< to execute autocommands 488 489/// Set by the apply_autocmds_group function if the given event is equal to 490/// EVENT_FILETYPE. Used by readfile() to determine whether read autocommands 491/// triggered EVENT_FILETYPE. 492/// 493/// Relying on this value requires one to reset it prior calling 494/// apply_autocmds_group(). 495bool b_au_did_filetype ; 496 497// The following only used in undo.c. 498u_header_T * b_u_oldhead ;// pointer to oldest header 499u_header_T * b_u_newhead ;// pointer to newest header; may not be valid 500// if b_u_curhead is not NULL 501u_header_T * b_u_curhead ;// pointer to current header 502int b_u_numhead ;// current number of headers 503bool b_u_synced ;// entry lists are synced 504int b_u_seq_last ;// last used undo sequence number 505int b_u_save_nr_last ;// counter for last file write 506int b_u_seq_cur ;// uh_seq of header below which we are now 507time_t b_u_time_cur ;// uh_time of header below which we are now 508int b_u_save_nr_cur ;// file write nr after which we are now 509 510// variables for "U" command in undo.c 511char * b_u_line_ptr ;// saved line for "U" command 512linenr_T b_u_line_lnum ;// line number of line in u_line 513colnr_T b_u_line_colnr ;// optional column number 514 515bool b_scanned ;// ^N/^P have scanned this buffer 516 517// flags for use of ":lmap" and IM control 518OptInt b_p_iminsert ;// input mode for insert 519OptInt b_p_imsearch ;// input mode for search 520#define B_IMODE_USE_INSERT (-1) // Use b_p_iminsert value for search 521#define B_IMODE_NONE 0 // Input via none 522#define B_IMODE_LMAP 1 // Input via langmap 523#define B_IMODE_LAST 1 524 525int16_t b_kmap_state ;// using "lmap" mappings 526#define KEYMAP_INIT 1 // 'keymap' was set, call keymap_init() 527#define KEYMAP_LOADED 2 // 'keymap' mappings have been loaded 528garray_T b_kmap_ga ;// the keymap table 529 530// Options local to a buffer. 531// They are here because their value depends on the type of file 532// or contents of the file being edited. 533bool b_p_initialized ;// set when options initialized 534 535sctx_T b_p_script_ctx [kBufOptCount ];// SCTXs for buffer-local options 536 537int b_p_ac ;///< 'autocomplete' 538int b_p_ai ;///< 'autoindent' 539int b_p_ai_nopaste ;///< b_p_ai saved for paste mode 540char * b_p_bkc ;///< 'backupco 541unsigned b_bkc_flags ;///< flags for 'backupco 542int b_p_ci ;///< 'copyindent' 543int b_p_bin ;///< 'binary' 544int b_p_bomb ;///< 'bomb' 545char * b_p_bh ;///< 'bufhidden' 546char * b_p_bt ;///< 'buftype' 547OptInt b_p_busy ;///< 'busy' 548int b_has_qf_entry ;///< quickfix exists for buffer 549int b_p_bl ;///< 'buflisted' 550OptInt b_p_channel ;///< 'channel' 551int b_p_cin ;///< 'cindent' 552char * b_p_cino ;///< 'cinoptions' 553char * b_p_cink ;///< 'cinkeys' 554char * b_p_cinw ;///< 'cinwords' 555char * b_p_cinsd ;///< 'cinscopedecls' 556char * b_p_com ;///< 'comments' 557char * b_p_cms ;///< 'commentstring' 558char * b_p_cot ;///< 'completeopt' local value 559unsigned b_cot_flags ;///< flags for 'completeopt' 560char * b_p_cpt ;///< 'complete' 561#ifdef BACKSLASH_IN_FILENAME 562char * b_p_csl ;///< 'completeslash' 563#endif 564uint32_t b_p_cpt_flags ;///< flags for 'complete' 565Callback * b_p_cpt_cb ;///< F{func} in 'complete' callback 566int b_p_cpt_count ;///< Count of values in 'complete' 567Callback b_p_cfu ;///< 'completefunc' 568Callback b_p_ofu ;///< 'omnifunc' 569Callback b_p_tfu ;///< 'tagfunc' 570Callback b_p_ffu ;///< 'findfunc' 571int b_p_eof ;///< 'endoffile' 572int b_p_eol ;///< 'endofline' 573int b_p_fixeol ;///< 'fixendofline' 574int b_p_et ;///< 'expandtab' 575int b_p_et_nobin ;///< b_p_et saved for binary mode 576int b_p_et_nopaste ;///< b_p_et saved for paste mode 577char * b_p_fenc ;///< 'fileencoding' 578char * b_p_ff ;///< 'fileformat' 579char * b_p_ft ;///< 'filetype' 580int b_p_follow ;///< 'follow' 581char * b_p_fo ;///< 'formatoptions' 582char * b_p_flp ;///< 'formatlistpat' 583int b_p_inf ;///< 'infercase' 584char * b_p_isk ;///< 'iskeyword' 585char * b_p_def ;///< 'define' local value 586char * b_p_inc ;///< 'include' 587Callback b_p_inex ;///< 'includeexpr' 588uint32_t b_p_inex_flags ;///< flags for 'includeexpr' 589Callback b_p_inde ;///< 'indentexpr' 590uint32_t b_p_inde_flags ;///< flags for 'indentexpr' 591char * b_p_indk ;///< 'indentkeys' 592char * b_p_fp ;///< 'formatprg' 593Callback b_p_fex ;///< 'formatexpr' 594uint32_t b_p_fex_flags ;///< flags for 'formatexpr' 595int b_p_fs ;///< 'fsync' 596char * b_p_kp ;///< 'keywordprg' 597int b_p_lisp ;///< 'lisp' 598char * b_p_lop ;///< 'lispoptions' 599char * b_p_menc ;///< 'makeencoding' 600char * b_p_mps ;///< 'matchpairs' 601int b_p_ml ;///< 'modeline' 602int b_p_ml_nobin ;///< b_p_ml saved for binary mode 603int b_p_ma ;///< 'modifiable' 604char * b_p_nf ;///< 'nrformats' 605int b_p_pi ;///< 'preserveindent' 606char * b_p_qe ;///< 'quoteescape' 607int b_p_ro ;///< 'readonly' 608OptInt b_p_sw ;///< 'shiftwidth' 609OptInt b_p_scbk ;///< 'scrollback' 610int b_p_si ;///< 'smartindent' 611OptInt b_p_sts ;///< 'softtabstop' 612OptInt b_p_sts_nopaste ;///< b_p_sts saved for paste mode 613char * b_p_sua ;///< 'suffixesadd' 614int b_p_swf ;///< 'swapfile' 615OptInt b_p_smc ;///< 'synmaxcol' 616char * b_p_syn ;///< 'syntax' 617OptInt b_p_ts ;///< 'tabstop' 618OptInt b_p_tw ;///< 'textwidth' 619OptInt b_p_tw_nobin ;///< b_p_tw saved for binary mode 620OptInt b_p_tw_nopaste ;///< b_p_tw saved for paste mode 621OptInt b_p_wm ;///< 'wrapmargin' 622OptInt b_p_wm_nobin ;///< b_p_wm saved for binary mode 623OptInt b_p_wm_nopaste ;///< b_p_wm saved for paste mode 624char * b_p_vsts ;///< 'varsofttabstop' 625colnr_T * b_p_vsts_array ;///< 'varsofttabstop' in internal format 626char * b_p_vsts_nopaste ;///< b_p_vsts saved for paste mode 627char * b_p_vts ;///< 'vartabstop' 628colnr_T * b_p_vts_array ;///< 'vartabstop' in internal format 629char * b_p_keymap ;///< 'keymap' 630 631// local values for options which are normally global 632char * b_p_gefm ;///< 'grepformat' local value 633char * b_p_gp ;///< 'grepprg' local value 634char * b_p_mp ;///< 'makeprg' local value 635char * b_p_efm ;///< 'errorformat' local value 636char * b_p_ep ;///< 'equalprg' local value 637char * b_p_path ;///< 'path' local value 638int b_p_ar ;///< 'autoread' local value 639char * b_p_tags ;///< 'tags' local value 640char * b_p_tc ;///< 'tagcase' local value 641unsigned b_tc_flags ;///< flags for 'tagcase' 642char * b_p_dict ;///< 'dictionary' local value 643char * b_p_dia ;///< 'diffanchors' local value 644char * b_p_tsr ;///< 'thesaurus' local value 645Callback b_p_tsrfu ;///< 'thesaurusfunc' local value 646OptInt b_p_ul ;///< 'undolevels' local value 647int b_p_udf ;///< 'undofile' 648char * b_p_lw ;///< 'lispwords' local value 649 650// end of buffer options 651 652// values set from b_p_cino 653int b_ind_level ; 654int b_ind_open_imag ; 655int b_ind_no_brace ; 656int b_ind_first_open ; 657int b_ind_open_extra ; 658int b_ind_close_extra ; 659int b_ind_open_left_imag ; 660int b_ind_jump_label ; 661int b_ind_case ; 662int b_ind_case_code ; 663int b_ind_case_break ; 664int b_ind_param ; 665int b_ind_func_type ; 666int b_ind_comment ; 667int b_ind_in_comment ; 668int b_ind_in_comment2 ; 669int b_ind_cpp_baseclass ; 670int b_ind_continuation ; 671int b_ind_unclosed ; 672int b_ind_unclosed2 ; 673int b_ind_unclosed_noignore ; 674int b_ind_unclosed_wrapped ; 675int b_ind_unclosed_whiteok ; 676int b_ind_matching_paren ; 677int b_ind_paren_prev ; 678int b_ind_maxparen ; 679int b_ind_maxcomment ; 680int b_ind_scopedecl ; 681int b_ind_scopedecl_code ; 682int b_ind_java ; 683int b_ind_js ; 684int b_ind_keep_case_label ; 685int b_ind_hash_comment ; 686int b_ind_cpp_namespace ; 687int b_ind_if_for_while ; 688int b_ind_cpp_extern_c ; 689int b_ind_pragma ; 690 691linenr_T b_no_eol_lnum ;// non-zero lnum when last line of next binary 692// write should not have an end-of-line 693 694int b_start_eof ;// last line had eof (CTRL-Z) when it was read 695int b_start_eol ;// last line had eol when it was read 696int b_start_ffc ;// first char of 'ff' when edit started 697char * b_start_fenc ;// 'fileencoding' when edit started or NULL 698int b_bad_char ;// "++bad=" argument when edit started or 0 699int b_start_bomb ;// 'bomb' when it was read 700 701ScopeDictDictItem b_bufvar ;///< Variable for "b:" Dict. 702dict_T * b_vars ;///< b: scope Dict. 703 704// When a buffer is created, it starts without a swap file. b_may_swap is 705// then set to indicate that a swap file may be opened later. It is reset 706// if a swap file could not be opened. 707bool b_may_swap ; 708bool b_did_warn ;// Set to true if user has been warned on first 709// change of a read-only file 710 711// Two special kinds of buffers: 712// help buffer - used for help files, won't use a swap file. 713// spell buffer - used for spell info, never displayed and doesn't have a 714// file name. 715bool b_help ;// true for help file buffer (when set b_p_bt 716// is "help") 717bool b_spell ;// True for a spell file buffer, most fields 718// are not used! 719 720char * b_prompt_text ;// set by prompt_setprompt() 721Callback b_prompt_callback ;// set by prompt_setcallback() 722Callback b_prompt_interrupt ;// set by prompt_setinterrupt() 723bool b_prompt_append_new_line ;// prompt_appendlines() should start a newline 724int b_prompt_insert ;// value for restart_edit when entering 725// a prompt buffer window. 726fmark_T b_prompt_start ;// Start of the editable area of a prompt buffer. 727 728synblock_T b_s ;// Info related to syntax highlighting. w_s 729// normally points to this, but some windows 730// may use a different synblock_T. 731 732struct { 733int max ;// maximum number of signs on a single line 734int last_max ;// value of max when the buffer was last drawn 735int count [SIGN_SHOW_MAX ];// number of lines with number of signs 736bool autom ;// whether 'signcolumn' is displayed in "auto:n>1" 737// configured window. "b_signcols" calculation 738// is skipped if false. 739 }b_signcols ; 740 741Terminal * terminal ;// Terminal instance associated with the buffer 742 743AdditionalData * additional_data ;// Additional data from shada file if any. 744 745int b_mapped_ctrl_c ;// modes where CTRL-C is mapped 746 747MarkTree b_marktree [1 ]; 748Map (uint32_t ,uint32_t )b_extmark_ns [1 ];// extmark namespaces 749 750// Store the line count as it was before appending or inserting lines. 751// Used to determine a valid range before splicing marks, when the line 752// count has already changed. 753int b_prev_line_count ; 754 755// array of channel_id:s which have asked to receive updates for this 756// buffer. 757kvec_t (uint64_t )update_channels ; 758// array of lua callbacks for buffer updates. 759kvec_t (BufUpdateCallbacks )update_callbacks ; 760 761// whether an update callback has requested codepoint size of deleted regions. 762bool update_need_codepoints ; 763 764// Measurements of the deleted or replaced region since the last update 765// event. Some consumers of buffer changes need to know the byte size (like 766// treesitter) or the corresponding UTF-32/UTF-16 size (like LSP) of the 767// deleted text. 768size_t deleted_bytes ; 769size_t deleted_bytes2 ; 770size_t deleted_codepoints ; 771size_t deleted_codeunits ; 772 773// The number for times the current line has been flushed in the memline. 774int flush_count ; 775 776char * b_localdir ;///< Absolute path of local cwd or NULL. 777char * b_prevdir ;///< Previous directory. 778}; 779 780// Stuff for diff mode. 781#define DB_COUNT 8 // up to four buffers can be diff'ed 782 783/// Each diffblock defines where a block of lines starts in each of the buffers 784/// and how many lines it occupies in that buffer. When the lines are missing 785/// in the buffer the df_count[] is zero. This is all counted in 786/// buffer lines. 787/// Usually there is always at least one unchanged line in between the diffs as 788/// otherwise it would have been included in the diff above or below it. When 789/// linematch or diff anchors are used, this is no longer guaranteed, and we may 790/// have adjacent diff blocks. In all cases they will not overlap, although it 791/// is possible to have multiple 0-count diff blocks at the same line. 792/// df_lnum[] + df_count[] is the lnum below the change. When in one buffer 793/// lines have been inserted, in the other buffer df_lnum[] is the line below 794/// the insertion and df_count[] is zero. When appending lines at the end of 795/// the buffer, df_lnum[] is one beyond the end! 796/// This is using a linked list, because the number of differences is expected 797/// to be reasonable small. The list is sorted on lnum. 798/// Each diffblock also contains a cached list of inline diff of changes within 799/// the block, used for highlighting. 800typedef struct diffblock_S diff_T ; 801struct diffblock_S { 802diff_T * df_next ; 803linenr_T df_lnum [DB_COUNT ];// line number in buffer 804linenr_T df_count [DB_COUNT ];// nr of inserted/changed lines 805bool is_linematched ;// has the linematch algorithm ran on this diff hunk to divide it into 806// smaller diff hunks? 807 808bool has_changes ;///< has cached list of inline changes 809garray_T df_changes ;///< list of inline changes (diffline_change_T) 810}; 811 812/// Each entry stores a single inline change within a diff block. Line numbers 813/// are recorded as relative offsets, and columns are byte offsets, not 814/// character counts. 815/// Ranges are [start,end), with the end being exclusive. 816typedef struct diffline_change_S diffline_change_T ; 817struct diffline_change_S { 818colnr_T dc_start [DB_COUNT ];///< byte offset of start of range in the line 819colnr_T dc_end [DB_COUNT ];///< 1 past byte offset of end of range in line 820int dc_start_lnum_off [DB_COUNT ];///< starting line offset 821int dc_end_lnum_off [DB_COUNT ];///< end line offset 822}; 823 824/// Describes a single line's list of inline changes. Use diff_change_parse() to 825/// parse this. 826typedef struct diffline_S diffline_T ; 827struct diffline_S { 828diffline_change_T * changes ; 829int num_changes ; 830int bufidx ; 831int lineoff ; 832}; 833 834#define SNAP_HELP_IDX 0 835#define SNAP_AUCMD_IDX 1 836#define SNAP_QUICKFIX_IDX 2 837#define SNAP_COUNT 3 838 839/// Tab pages point to the top frame of each tab page. 840/// Note: Most values are NOT valid for the current tab page! Use "curwin", 841/// "firstwin", etc. for that. "tp_topframe" is always valid and can be 842/// compared against "topframe" to find the current tab page. 843typedef struct tabpage_S tabpage_T ; 844struct tabpage_S { 845handle_T handle ; 846tabpage_T * tp_next ;///< next tabpage or NULL 847frame_T * tp_topframe ;///< topframe for the windows 848win_T * tp_curwin ;///< current window in this Tab page 849win_T * tp_prevwin ;///< previous window in this Tab page 850win_T * tp_firstwin ;///< first window in this Tab page 851win_T * tp_lastwin ;///< last window in this Tab page 852int64_t tp_old_Rows_avail ;///< ROWS_AVAIL when Tab page was left 853int64_t tp_old_Columns ;///< Columns when Tab page was left, -1 when 854///< calling win_new_screen_cols() postponed 855OptInt tp_ch_used ;///< value of 'cmdheight' when frame size was set 856bool tp_did_tabclosedpre ;///< whether TabClosedPre was triggered 857 858diff_T * tp_first_diff ; 859buf_T * (tp_diffbuf [DB_COUNT ]); 860int tp_diff_invalid ;///< list of diffs is outdated 861int tp_diff_update ;///< update diffs before redrawing 862frame_T * (tp_snapshot [SNAP_COUNT ]);///< window layout snapshots 863ScopeDictDictItem tp_winvar ;///< Variable for "t:" Dict. 864dict_T * tp_vars ;///< Internal variables, local to tab page. 865char * tp_localdir ;///< Absolute path of local cwd or NULL. 866char * tp_prevdir ;///< Previous directory. 867}; 868 869// Structure to cache info for displayed lines in w_lines[]. 870// Each logical line has one entry. 871// The entry tells how the logical line is currently displayed in the window. 872// This is updated when displaying the window. 873// When the display is changed (e.g., when clearing the screen) w_lines_valid 874// is changed to exclude invalid entries. 875// When making changes to the buffer, wl_valid is reset to indicate wl_size 876// may not reflect what is actually in the buffer. When wl_valid is false, 877// the entries can only be used to count the number of displayed lines used. 878// wl_lnum and wl_lastlnum are invalid too. 879typedef struct { 880linenr_T wl_lnum ;// buffer line number for logical line 881uint16_t wl_size ;// height in screen lines 882bool wl_valid ;// true values are valid for text in buffer 883bool wl_folded ;// true when this is a range of folded lines 884linenr_T wl_foldend ;// last buffer line number for folded line 885linenr_T wl_lastlnum ;// last buffer line number for logical line 886}wline_T ; 887 888// Windows are kept in a tree of frames. Each frame has a column (FR_COL) 889// or row (FR_ROW) layout or is a leaf, which has a window. 890struct frame_S { 891char fr_layout ;// FR_LEAF, FR_COL or FR_ROW 892int fr_width ; 893int fr_newwidth ;// new width used in win_equal_rec() 894int fr_height ; 895int fr_newheight ;// new height used in win_equal_rec() 896frame_T * fr_parent ;// containing frame or NULL 897frame_T * fr_next ;// frame right or below in same parent, NULL 898// for last 899frame_T * fr_prev ;// frame left or above in same parent, NULL 900// for first 901// fr_child and fr_win are mutually exclusive 902frame_T * fr_child ;// first contained frame 903win_T * fr_win ;// window that fills this frame; for a snapshot 904// set to the current window 905}; 906 907#define FR_LEAF 0 // frame is a leaf 908#define FR_ROW 1 // frame with a row of windows 909#define FR_COL 2 // frame with a column of windows 910 911// Struct used for highlighting 'hlsearch' matches, matches defined by 912// ":match" and matches defined by match functions. 913// For 'hlsearch' there is one pattern for all windows. For ":match" and the 914// match functions there is a different pattern for each window. 915typedef struct { 916regmmatch_T rm ;// points to the regexp program; contains last found 917// match (may continue in next line) 918buf_T * buf ;// the buffer to search for a match 919linenr_T lnum ;// the line to search for a match 920int attr ;// attributes to be used for a match 921int attr_cur ;// attributes currently active in win_line() 922linenr_T first_lnum ;// first lnum to search for multi-line pat 923colnr_T startcol ;// in win_line() points to char where HL starts 924colnr_T endcol ;// in win_line() points to char where HL ends 925bool is_addpos ;// position specified directly by matchaddpos() 926bool has_cursor ;// true if the cursor is inside the match, used for CurSearch 927proftime_T tm ;// for a time limit 928}match_T ; 929 930/// Same as lpos_T, but with additional field len. 931typedef struct { 932linenr_T lnum ;///< line number 933colnr_T col ;///< column number 934int len ;///< length: 0 - to the end of line 935}llpos_T ; 936 937/// matchitem_T provides a linked list for storing match items for ":match", 938/// matchadd() and matchaddpos(). 939typedef struct matchitem matchitem_T ; 940struct matchitem { 941matchitem_T * mit_next ; 942int mit_id ;///< match ID 943int mit_priority ;///< match priority 944 945// Either a pattern is defined (mit_pattern is not NUL) or a list of 946// positions is given (mit_pos is not NULL and mit_pos_count > 0). 947char * mit_pattern ;///< pattern to highlight 948regmmatch_T mit_match ;///< regexp program for pattern 949 950llpos_T * mit_pos_array ;///< array of positions 951int mit_pos_count ;///< nr of entries in mit_pos 952int mit_pos_cur ;///< internal position counter 953linenr_T mit_toplnum ;///< top buffer line 954linenr_T mit_botlnum ;///< bottom buffer line 955 956match_T mit_hl ;///< struct for doing the actual highlighting 957int mit_hlg_id ;///< highlight group ID 958int mit_conceal_char ;///< cchar for Conceal highlighting 959}; 960 961typedef int FloatAnchor ; 962 963enum { 964kFloatAnchorEast = 1 , 965kFloatAnchorSouth = 2 , 966}; 967 968/// Keep in sync with float_relative_str[] in nvim_win_get_config() 969typedef enum { 970kFloatRelativeEditor = 0 , 971kFloatRelativeWindow = 1 , 972kFloatRelativeCursor = 2 , 973kFloatRelativeMouse = 3 , 974kFloatRelativeTabline = 4 , 975kFloatRelativeLaststatus = 5 , 976}FloatRelative ; 977 978typedef enum { 979kWinNormal = 0 ,///< Non-special window (split or float). 980kWinInfo ,///< Completion-menu "info" popup. 981kWinPreview ,///< 'previewpopup' window. 982}WinKind ; 983 984/// Keep in sync with win_split_str[] in nvim_win_get_config() (api/win_config.c) 985typedef enum { 986kWinSplitLeft = 0 , 987kWinSplitRight = 1 , 988kWinSplitAbove = 2 , 989kWinSplitBelow = 3 , 990}WinSplit ; 991 992typedef enum { 993kWinStyleUnused = 0 , 994kWinStyleMinimal ,///< Minimal UI: no number column, eob markers, etc 995}WinStyle ; 996 997typedef enum { 998kAlignLeft = 0 , 999kAlignCenter = 1 , 1000kAlignRight = 2 , 1001}AlignTextPos ; 1002 1003typedef enum { 1004kBorderTextTitle = 0 , 1005kBorderTextFooter = 1 , 1006}BorderTextType ; 1007 1008/// See ":help nvim_open_win()" for documentation. 1009typedef struct { 1010Window window ; 1011lpos_T bufpos ; 1012int height ,width ; 1013double row ,col ; 1014FloatAnchor anchor ; 1015FloatRelative relative ; 1016bool external ; 1017bool focusable ; 1018bool mouse ; 1019WinSplit split ; 1020int zindex ; 1021WinStyle style ; 1022bool border ; 1023bool shadow ; 1024char border_chars [8 ][MAX_SCHAR_SIZE ]; 1025int border_hl_ids [8 ]; 1026int border_attr [8 ]; 1027bool title ; 1028AlignTextPos title_pos ; 1029VirtText title_chunks ; 1030int title_width ; 1031bool footer ; 1032AlignTextPos footer_pos ; 1033VirtText footer_chunks ; 1034int footer_width ; 1035bool noautocmd ; 1036bool fixed ; 1037bool hide ; 1038int _cmdline_offset ; 1039}WinConfig ; 1040 1041#define WIN_CONFIG_INIT ((WinConfig){ .height = 0, .width = 0, \ 1042 .bufpos = { -1, 0 }, \ 1043 .row = 0, .col = 0, .anchor = 0, \ 1044 .relative = 0, .external = false, \ 1045 .focusable = true, \ 1046 .mouse = true, \ 1047 .split = 0, \ 1048 .zindex = kZIndexFloatDefault, \ 1049 .style = kWinStyleUnused, \ 1050 .noautocmd = false, \ 1051 .hide = false, \ 1052 .fixed = false, \ 1053 ._cmdline_offset = INT_MAX }) 1054 1055// Structure to store last cursor position and topline. Used by check_lnums() 1056// and reset_lnums(). 1057typedef struct { 1058int w_topline_save ;// original topline value 1059int w_topline_corr ;// corrected topline value 1060pos_T w_cursor_save ;// original cursor position 1061pos_T w_cursor_corr ;// corrected cursor position 1062}pos_save_T ; 1063 1064/// Characters from the 'listchars' option. 1065typedef struct { 1066schar_T eol ; 1067schar_T ext ; 1068schar_T prec ; 1069schar_T nbsp ; 1070schar_T space ; 1071schar_T tab1 ;///< first tab character 1072schar_T tab2 ;///< second tab character 1073schar_T tab3 ;///< third tab character 1074schar_T leadtab1 ; 1075schar_T leadtab2 ; 1076schar_T leadtab3 ; 1077schar_T lead ; 1078schar_T trail ; 1079schar_T * multispace ; 1080schar_T * leadmultispace ; 1081schar_T conceal ; 1082}lcs_chars_T ; 1083 1084/// Characters from the 'fillchars' option. 1085typedef struct { 1086schar_T stl ; 1087schar_T stlnc ; 1088schar_T wbr ; 1089schar_T horiz ; 1090schar_T horizup ; 1091schar_T horizdown ; 1092schar_T vert ; 1093schar_T vertleft ; 1094schar_T vertright ; 1095schar_T verthoriz ; 1096schar_T fold ; 1097schar_T foldopen ;///< when fold is open 1098schar_T foldclosed ;///< when fold is closed 1099schar_T foldsep ;///< continuous fold marker 1100schar_T foldinner ; 1101schar_T diff ; 1102schar_T msgsep ; 1103schar_T eob ; 1104schar_T lastline ; 1105schar_T trunc ; 1106schar_T truncrl ; 1107}fcs_chars_T ; 1108 1109/// Structure which contains all information that belongs to a window. 1110/// 1111/// All row numbers are relative to the start of the window, except w_winrow. 1112struct window_S { 1113handle_T handle ;///< unique identifier for the window 1114 1115buf_T * w_buffer ;///< buffer we are a window into (used 1116///< often, keep it the first item!) 1117 1118synblock_T * w_s ;///< for :ownsyntax 1119 1120int w_ns_hl ; 1121int w_ns_hl_winhl ; 1122int w_ns_hl_active ; 1123int * w_ns_hl_attr ; 1124 1125Set (uint32_t )w_ns_set ; 1126 1127int w_hl_id_normal ;///< 'winhighlight' normal id 1128int w_hl_attr_normal ;///< 'winhighlight' normal final attrs 1129int w_hl_attr_normalnc ;///< 'winhighlight' NormalNC final attrs 1130 1131int w_hl_needs_update ;///< attrs need to be recalculated 1132 1133win_T * w_prev ;///< link to previous window 1134win_T * w_next ;///< link to next window 1135int w_locked ;///< don't let autocommands close the window 1136 1137frame_T * w_frame ;///< frame containing this window 1138 1139pos_T w_cursor ;///< cursor position in buffer 1140 1141colnr_T w_curswant ;///< Column we want to be at. This is 1142///< used to try to stay in the same column 1143///< for up/down cursor motions. 1144 1145bool w_set_curswant ;// If set, then update w_curswant the next 1146// time through cursupdate() to the 1147// current virtual column 1148 1149linenr_T w_cursorline ;///< Where 'cursorline' should be drawn, 1150///< can be different from w_cursor.lnum 1151///< for closed folds. 1152linenr_T w_last_cursorline ;///< where last 'cursorline' was drawn 1153 1154// the next seven are used to update the visual part 1155char w_old_visual_mode ;///< last known Visual.mode 1156linenr_T w_old_cursor_lnum ;///< last known end of visual part 1157colnr_T w_old_cursor_fcol ;///< first column for block visual part 1158colnr_T w_old_cursor_lcol ;///< last column for block visual part 1159linenr_T w_old_visual_lnum ;///< last known start of visual part 1160colnr_T w_old_visual_col ;///< last known start of visual part 1161colnr_T w_old_curswant ;///< last known value of Curswant 1162 1163linenr_T w_last_cursor_lnum_rnu ;///< cursor lnum when 'rnu' was last redrawn 1164 1165/// 'listchars' characters. Defaults set in set_chars_option(). 1166lcs_chars_T w_p_lcs_chars ; 1167 1168/// 'fillchars' characters. Defaults set in set_chars_option(). 1169fcs_chars_T w_p_fcs_chars ; 1170 1171// "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for 1172// displaying the buffer. 1173linenr_T w_topline ;// buffer line number of the line at the 1174// top of the window 1175bool w_topline_was_set ;// flag set to true when topline is set, 1176// e.g. by winrestview() 1177int w_topfill ;// number of filler lines above w_topline 1178int w_old_topfill ;// w_topfill at last redraw 1179bool w_botfill ;// true when filler lines are actually 1180// below w_topline (at end of file) 1181bool w_old_botfill ;// w_botfill at last redraw 1182colnr_T w_leftcol ;// screen column number of the left most 1183// character in the window; used when 1184// 'wrap' is off 1185colnr_T w_skipcol ;// starting screen column for the first 1186// line in the window; used when 'wrap' is 1187// on; does not include win_col_off() 1188 1189// six fields that are only used when there is a WinScrolled autocommand 1190linenr_T w_last_topline ;///< last known value for w_topline 1191int w_last_topfill ;///< last known value for w_topfill 1192colnr_T w_last_leftcol ;///< last known value for w_leftcol 1193colnr_T w_last_skipcol ;///< last known value for w_skipcol 1194int w_last_width ;///< last known value for w_width 1195int w_last_height ;///< last known value for w_height 1196 1197// 1198// Layout of the window in the screen. 1199// May need to add "msg_scrolled" to "w_winrow" in rare situations. 1200// 1201int w_winrow ;// first row of window in screen 1202int w_height ;// number of rows in window, excluding 1203// status/command line(s) 1204int w_prev_winrow ;// previous winrow used for 'splitkeep' 1205int w_prev_height ;// previous height used for 'splitkeep' 1206int w_status_height ;// number of status lines (0 or 1) 1207int w_winbar_height ;// number of window bars (0 or 1) 1208int w_wincol ;// Leftmost column of window in screen. 1209int w_width ;// Width of window, excluding separation. 1210int w_hsep_height ;// Number of horizontal separator rows (0 or 1) 1211int w_vsep_width ;// Number of vertical separator columns (0 or 1). 1212pos_save_T w_save_cursor ;// backup of cursor pos and topline 1213bool w_do_win_fix_cursor ;// if true cursor may be invalid 1214 1215// Screen pos 'previewpopup' anchors to (original cursor pos). Separate from WinConfig because 1216// win_float_update_preview() re-autosizes as content updates, and re-decides the flip 1217// above/below. WinConfig.row/col hold the placed (offset, flipped, clamped) result. 1218int w_wantline ; 1219int w_wantcol ; 1220 1221int w_winrow_off ;///< offset from winrow to the inner window area 1222int w_wincol_off ;///< offset from wincol to the inner window area 1223///< this includes float border but excludes special columns 1224///< implemented in win_line() (i.e. signs, folds, numbers) 1225 1226// Size of the window viewport. This is the area usable to draw columns and buffer contents 1227int w_view_height ; 1228int w_view_width ; 1229// external UI request. If non-zero, the inner size will use this. 1230int w_height_request ; 1231int w_width_request ; 1232 1233int w_border_adj [4 ];// top, right, bottom, left 1234// outer size of window grid, including border 1235int w_height_outer ; 1236int w_width_outer ; 1237 1238// === start of cached values ==== 1239 1240// Recomputing is minimized by storing the result of computations. 1241// Use functions in screen.c to check if they are valid and to update. 1242// w_valid is a bitfield of flags, which indicate if specific values are 1243// valid or need to be recomputed. 1244int w_valid ; 1245pos_T w_valid_cursor ;// last known position of w_cursor, used to adjust w_valid 1246colnr_T w_valid_leftcol ;// last known w_leftcol 1247colnr_T w_valid_skipcol ;// last known w_skipcol 1248 1249bool w_viewport_invalid ; 1250linenr_T w_viewport_last_topline ;// topline when the viewport was last updated 1251linenr_T w_viewport_last_botline ;// botline when the viewport was last updated 1252linenr_T w_viewport_last_topfill ;// topfill when the viewport was last updated 1253linenr_T w_viewport_last_skipcol ;// skipcol when the viewport was last updated 1254 1255// w_cline_height is the number of physical lines taken by the buffer line 1256// that the cursor is on. We use this to avoid extra calls to plines_win(). 1257int w_cline_height ;// current size of cursor line 1258bool w_cline_folded ;// cursor line is folded 1259 1260int w_cline_row ;// starting row of the cursor line 1261 1262colnr_T w_virtcol ;// column number of the cursor in the 1263// buffer line, as opposed to the column 1264// number we're at on the screen. This 1265// makes a difference on lines which span 1266// more than one screen line or when 1267// w_leftcol is non-zero 1268 1269// w_wrow and w_wcol specify the cursor position in the window. 1270// This is related to positions in the window, not in the display or 1271// buffer, thus w_wrow is relative to w_winrow. 1272int w_wrow ,w_wcol ;// cursor position in window 1273int w_wcol_conceal_off ;// screen cells concealed before w_wcol on 1274// the cursor's screen line, set by win_line() 1275 1276linenr_T w_botline ;// number of the line below the bottom of 1277// the window 1278int w_empty_rows ;// number of ~ rows in window 1279int w_filler_rows ;// number of filler rows at the end of the 1280// window 1281 1282// Info about the lines currently in the window is remembered to avoid 1283// recomputing it every time. The allocated size of w_lines[] is Rows. 1284// Only the w_lines_valid entries are actually valid. 1285// When the display is up-to-date w_lines[0].wl_lnum is equal to w_topline 1286// and w_lines[w_lines_valid - 1].wl_lnum is equal to w_botline. 1287// Between changing text and updating the display w_lines[] represents 1288// what is currently displayed. wl_valid is reset to indicated this. 1289// This is used for efficient redrawing. 1290int w_lines_valid ;// number of valid entries 1291wline_T * w_lines ; 1292int w_lines_size ; 1293 1294garray_T w_folds ;// array of nested folds 1295bool w_fold_manual ;// when true: some folds are opened/closed 1296// manually 1297bool w_foldinvalid ;// when true: folding needs to be 1298// recomputed 1299int w_nrwidth ;// width of 'number' and 'relativenumber' 1300// column being used 1301int w_scwidth ;// width of 'signcolumn' 1302int w_minscwidth ;// minimum 'signcolumn' width, or SCL_NO/SCL_NUM 1303int w_maxscwidth ;// maximum 'signcolumn' width, or SCL_NO/SCL_NUM 1304 1305// === end of cached values === 1306 1307int w_redr_type ;// type of redraw to be performed on win 1308int w_upd_rows ;// number of window lines to update when 1309// w_redr_type is UPD_REDRAW_TOP 1310linenr_T w_redraw_top ;// when != 0: first line needing redraw 1311linenr_T w_redraw_bot ;// when != 0: last line needing redraw 1312bool w_redr_status ;// if true statusline/winbar must be redrawn 1313bool w_redr_border ;// if true border must be redrawn 1314bool w_redr_statuscol ;// if true 'statuscolumn' must be redrawn 1315disptick_T w_display_tick ;// when window was last drawn. 1316 1317// remember what is shown in the 'statusline'-format elements 1318pos_T w_stl_cursor ;// cursor position when last redrawn 1319colnr_T w_stl_virtcol ;// virtcol when last redrawn 1320linenr_T w_stl_topline ;// topline when last redrawn 1321linenr_T w_stl_line_count ;// line count when last redrawn 1322int w_stl_topfill ;// topfill when last redrawn 1323char w_stl_empty ;// true if elements show 0-1 (empty line) 1324int w_stl_recording ;// reg_recording when last redrawn 1325int w_stl_state ;// get_real_state() when last redrawn 1326int w_stl_visual_mode ;// Visual.mode when last redrawn 1327pos_T w_stl_visual_pos ;// Visual.start when last redrawn 1328 1329int w_alt_fnum ;// alternate file (for # and CTRL-^) 1330 1331alist_T * w_alist ;// pointer to arglist for this window 1332int w_arg_idx ;// current index in argument list (can be 1333// out of range!) 1334bool w_arg_idx_invalid ;// editing another file than w_arg_idx 1335 1336char * w_localdir ;// absolute path of local directory or NULL 1337char * w_prevdir ;// previous directory 1338// Options local to a window. 1339// They are local because they influence the layout of the window or 1340// depend on the window layout. 1341// There are two values: w_onebuf_opt is local to the buffer currently in 1342// this window, w_allbuf_opt is for all buffers in this window. 1343winopt_T w_onebuf_opt ; 1344winopt_T w_allbuf_opt ; 1345// transform a pointer to a "onebuf" option into a "allbuf" option 1346#define GLOBAL_WO (p ) ((char *)(p) + sizeof(winopt_T)) 1347 1348int * w_p_cc_cols ;// array of columns to highlight or NULL 1349uint8_t w_p_culopt_flags ;// flags for cursorline highlighting 1350 1351int w_briopt_min ;// minimum width for breakindent 1352int w_briopt_shift ;// additional shift for breakindent 1353bool w_briopt_sbr ;// sbr in 'briopt' 1354int w_briopt_list ;// additional indent for lists 1355int w_briopt_vcol ;// indent for specific column 1356 1357int w_scbind_pos ; 1358 1359ScopeDictDictItem w_winvar ;///< Variable for "w:" dict. 1360dict_T * w_vars ;///< Dict with w: variables. 1361 1362// The w_prev_pcmark field is used to check whether we really did jump to 1363// a new line after setting the w_pcmark. If not, then we revert to 1364// using the previous w_pcmark. 1365pos_T w_pcmark ;// previous context mark 1366pos_T w_prev_pcmark ;// previous w_pcmark 1367 1368// the jumplist contains old cursor positions 1369xfmark_T w_jumplist [JUMPLISTSIZE ]; 1370int w_jumplistlen ;// number of active entries 1371int w_jumplistidx ;// current position 1372 1373int w_changelistidx ;// current position in b_changelist 1374 1375matchitem_T * w_match_head ;// head of match list 1376int w_next_match_id ;// next match ID 1377 1378// the tagstack grows from 0 upwards: 1379// entry 0: older 1380// entry 1: newer 1381// entry 2: newest 1382taggy_T w_tagstack [TAGSTACKSIZE ];// the tag stack 1383int w_tagstackidx ;// idx just below active entry 1384int w_tagstacklen ;// number of tags on stack 1385 1386GridView w_grid ;// area to draw on, excluding borders and winbar 1387ScreenGrid w_grid_alloc ;// the grid specific to the window 1388bool w_pos_changed ;// true if window position changed 1389bool w_floating ;///< whether the window is floating 1390WinKind w_kind ;///< mutually-exclusive window role 1391WinConfig w_config ; 1392 1393// w_fraction is the fractional row of the cursor within the window, from 1394// 0 at the top row to FRACTION_MULT at the last row. 1395// w_prev_fraction_row was the actual cursor row when w_fraction was last 1396// calculated. 1397int w_fraction ; 1398int w_prev_fraction_row ; 1399 1400linenr_T w_nrwidth_line_count ;// line count when ml_nrwidth_width was computed. 1401linenr_T w_statuscol_line_count ;// line count when 'statuscolumn' width was computed. 1402int w_nrwidth_width ;// nr of chars to print line count. 1403 1404qf_info_T * w_llist ;// Location list for this window 1405// Location list reference used in the location list window. 1406// In a non-location list window, w_llist_ref is NULL. 1407qf_info_T * w_llist_ref ; 1408 1409StlClickDefinition * w_status_click_defs ;// Status line click definitions 1410size_t w_status_click_defs_size ;// Size of the w_status_click_defs array 1411StlClickDefinition * w_winbar_click_defs ;// Window bar click definitions 1412size_t w_winbar_click_defs_size ;// Size of the w_winbar_click_defs array 1413// Map of statuscolumn click definitions, indexed by v:lnum and v:virtnum. 1414Map (int ,StcClicks )w_statuscol_click_defs [1 ]; 1415};