aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorYuan Fu2025-03-18 17:26:26 -0700
committerYuan Fu2025-03-19 11:59:42 -0700
commit289e1bdae28d7dbb27ae8f323b6f50f5c430a961 (patch)
treeeca2b73e0fba0d5c58e832fa80d08ce5525d1ae6 /src/buffer.h
parent72f6cf8e77f3eac8fe2e5fc6ad29c2348314b84b (diff)
downloademacs-scratch/ts-linecol.tar.gz
emacs-scratch/ts-linecol.zip
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 5c0a6ab3118..9479b141424 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -220,6 +220,23 @@ extern ptrdiff_t advance_to_char_boundary (ptrdiff_t byte_pos);
220 220
221/* Define the actual buffer data structures. */ 221/* Define the actual buffer data structures. */
222 222
223/* This data structure stores the cache of a position and its line and
224 column number. The column number is counted in bytes. The line
225 number and column number don't consider narrowing. */
226struct ts_linecol
227{
228 /* A position in the buffer. */
229 ptrdiff_t pos;
230 /* The byte position of POS. */
231 ptrdiff_t byte_pos;
232 /* The line number of this position. */
233 ptrdiff_t line;
234 /* The column number (in bytes) of this position. Unlike Emacs'
235 convention, this is 0-based (because tree-sitter column is
236 0-based). Simply the byte offset from BOL (or BOB). */
237 ptrdiff_t col;
238};
239
223/* This data structure describes the actual text contents of a buffer. 240/* This data structure describes the actual text contents of a buffer.
224 It is shared between indirect buffers and their base buffer. */ 241 It is shared between indirect buffers and their base buffer. */
225 242
@@ -700,6 +717,19 @@ struct buffer
700 /* The interval tree containing this buffer's overlays. */ 717 /* The interval tree containing this buffer's overlays. */
701 struct itree_tree *overlays; 718 struct itree_tree *overlays;
702 719
720 /* Right now only tree-sitter makes use of this, so I don't want
721 non-tree-sitter build to pay for it. If something else can make
722 use of this, we can remove the gate. */
723#ifdef HAVE_TREE_SITTER
724 /* Cache of line and column number of a position. The position cached
725 is usually near point. Tree-sitter uses this cache to calculate
726 line and column of the beginning and end of buffer edits. This
727 cache is refreshed in buffer edit functions, so it's always
728 up-to-date. Usually, the newly calculated position and line/column
729 are saved to this field. Initialized to position 1. */
730 struct ts_linecol ts_linecol_cache;
731#endif
732
703 /* Changes in the buffer are recorded here for undo, and t means 733 /* Changes in the buffer are recorded here for undo, and t means
704 don't record anything. This information belongs to the base 734 don't record anything. This information belongs to the base
705 buffer of an indirect buffer. But we can't store it in the 735 buffer of an indirect buffer. But we can't store it in the