robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
60a0e3d0a0
master
1#pragma once 2 3#include "nvim/memfile_defs.h" 4#include "nvim/pos_defs.h" 5 6/// 7/// When searching for a specific line, we remember what blocks in the tree 8/// are the branches leading to that block. This is stored in ml_stack. Each 9/// entry is a pointer to info in a block (may be data block or pointer block) 10/// 11typedef struct { 12blocknr_T ip_bnum ;// block number 13linenr_T ip_low ;// lowest lnum in this block 14linenr_T ip_high ;// highest lnum in this block 15int ip_index ;// index for block with current lnum 16}infoptr_T ;// block/index pair 17 18typedef struct { 19int mlcs_numlines ; 20int mlcs_totalsize ; 21}chunksize_T ; 22 23// Flags when calling ml_updatechunk() 24#define ML_CHNK_ADDLINE 1 25#define ML_CHNK_DELLINE 2 26#define ML_CHNK_UPDLINE 3 27 28/// memline structure: the contents of a buffer. 29/// Essentially a tree with a branch factor of 128. 30/// Lines are stored at leaf nodes. 31/// Nodes are stored on ml_mfp (memfile_T): 32/// pointer_block: internal nodes 33/// data_block: leaf nodes 34/// 35/// Memline also has "chunks" of 800 lines that are separate from the 128-tree 36/// structure, primarily used to speed up line2byte() and byte2line(). 37/// 38/// Motivation: If you have a file that is 10000 lines long, and you insert 39/// a line at linenr 1000, you don't want to move 9000 lines in 40/// memory. With this structure it is roughly (N * 128) pointer 41/// moves, where N is the height (typically 1-3). 42/// 43typedef struct { 44linenr_T ml_line_count ;// number of lines in the buffer 45 46memfile_T * ml_mfp ;// pointer to associated memfile 47 48infoptr_T * ml_stack ;// stack of pointer blocks (array of IPTRs) 49int ml_stack_top ;// current top of ml_stack 50int ml_stack_size ;// total number of entries in ml_stack 51 52#define ML_EMPTY 0x01 // empty buffer 53#define ML_LINE_DIRTY 0x02 // cached line was changed and allocated 54#define ML_LOCKED_DIRTY 0x04 // ml_locked was changed 55#define ML_LOCKED_POS 0x08 // ml_locked needs positive block number 56#define ML_ALLOCATED 0x10 // ml_line_ptr is an allocated copy 57int ml_flags ; 58 59// colnr_T ml_line_len; 60colnr_T ml_line_textlen ;// length of the cached line + NUL 61linenr_T ml_line_lnum ;// line number of cached line, 0 if not valid 62char * ml_line_ptr ;// pointer to cached line 63size_t ml_line_offset ;// cached byte offset of ml_line_lnum 64int ml_line_offset_ff ;// fileformat of cached line 65 66bhdr_T * ml_locked ;// block used by last ml_get 67linenr_T ml_locked_low ;// first line in ml_locked 68linenr_T ml_locked_high ;// last line in ml_locked 69int ml_locked_lineadd ;// number of lines inserted in ml_locked 70chunksize_T * ml_chunksize ; 71int ml_numchunks ; 72int ml_usedchunks ; 73}memline_T ;