diff options
Diffstat (limited to 'src/Editor.zig')
| -rw-r--r-- | src/Editor.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Editor.zig b/src/Editor.zig index 014d1923..b7c7057d 100644 --- a/src/Editor.zig +++ b/src/Editor.zig @@ -12,9 +12,18 @@ const Registers = @import("Registers.zig"); /// on this at compile time, so the library never compiles the core. pub const lib = @import("pardes_config").lib; const Pardes = if (lib) void else @import("Core.zig"); +const Syntax = if (lib) @import("lib_editor.zig").Syntax else void; +const modal = @import("modal.zig"); const Editor = @This(); +/// A text's parse as the tree-sitter walks read it (normal.nodeTree): the +/// tree, a path its grammar's queries are found by, and helix's +/// object_selections, what Alt-o grew from for Alt-i to go back to, its +/// ranges in `gpa`. Dropped with the tree when the text changes. +pub const Tree = struct { root: *anyopaque, path: []const u8, history: *std.ArrayList(NodeStep), gpa: std.mem.Allocator }; +pub const NodeStep = struct { ranges: []modal.Selection, primary: usize }; + gpa: std.mem.Allocator, /// What an edit makes and drops: the update's scratch. scratch: std.mem.Allocator, @@ -39,6 +48,9 @@ p: if (lib) void else *Pardes, /// The library's: an edit failed (its allocator ran out) and the key is /// refused. failed: if (lib) *bool else void, +/// The library's: the parse its caller handed in, which the tree-sitter +/// walks read; null, and they are the caller's (`textRole`). +syntax: if (lib) ?*Syntax else void, pub fn of(p: *Pardes) Editor { return .{ @@ -53,6 +65,7 @@ pub fn of(p: *Pardes) Editor { .retired_edit = &p.retired_edit, .p = p, .failed = {}, + .syntax = {}, }; } |
