summaryrefslogtreecommitdiff
path: root/src/edit.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 00:42:04 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit425d9beb9c977df364ed83743cb2efdef9429478 (patch)
treeeaba2e20ff041b50539d1b47fdeb498e59237cf0 /src/edit.zig
parent1912878e753ce12fdc1ac72ae2e83ddfc18df002 (diff)
downloadpardes-425d9beb9c977df364ed83743cb2efdef9429478.tar.gz
pardes-425d9beb9c977df364ed83743cb2efdef9429478.zip
File the tag code into tagline.zig and draw tags beside bodies
With tags reduced to Texts, what is left of them is the computed prefix, the default and saved tails, entering and leaving a tag and the headers: that goes to tagline.zig, as acme keeps the tag half of a window in wind.c. Tag and header drawing moves next to body drawing in body_layer.zig, and the tag hit helpers go to tag_layer.zig with the Hit they read, where sameCell now also tells the lines of a taller tag apart. The docs describe the tag as a Text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/edit.zig')
-rw-r--r--src/edit.zig14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/edit.zig b/src/edit.zig
index 36544d6b..edc86dd2 100644
--- a/src/edit.zig
+++ b/src/edit.zig
@@ -3,6 +3,7 @@
//! operations, replace, case, join, indent, comments, numbers, textobjects
//! and surround, undo, yank and paste, and the pointer selections as text.
const pardes = @import("pardes.zig");
+const tagline = @import("tagline.zig");
const mouse = @import("mouse.zig");
const normal = @import("normal.zig");
const std = @import("std");
@@ -15,7 +16,8 @@ const lsp = @import("lsp/lsp.zig");
const platform = pardes.platform;
const Pane = panes.Pane;
const Text = panes.Text;
-const TagHit = @import("tag_layer.zig").Hit;
+const tag_layer = @import("tag_layer.zig");
+const TagHit = tag_layer.Hit;
const BOX_H = pardes.BOX_H;
const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET;
const Mouse = pardes.Mouse;
@@ -72,7 +74,7 @@ pub fn typeToTty(p: *Pardes, id: usize, pane: *const Pane, text: []const u8) voi
}
pub fn applyPaste(p: *Pardes, bytes: []const u8) void {
- if (p.focusedHeader()) |t| {
+ if (tagline.focusedHeader(p)) |t| {
p.clip_pending = null;
return pasteInto(p, t, bytes);
}
@@ -132,7 +134,7 @@ pub fn clipYank(p: *Pardes, pane: *Pane, main_only: bool) void {
/// (the tag's lines first, as many as it shows)
pub fn paneText(p: *Pardes, pane: *Pane) ![]u8 {
const arena = p.scratch.allocator();
- const tag = try p.tagText(arena, pane);
+ const tag = try tagline.tagText(p, arena, pane);
const cut = modal.lineStartOffset(tag, pane.tag_rows);
const shown = if (cut < tag.len) tag[0 .. cut - 1] else tag;
return std.fmt.allocPrint(arena, "{s}\n{s}", .{ shown, try body_layer.bodyText(p, arena, pane) });
@@ -353,9 +355,9 @@ pub fn pinPaneCursor(p: *Pardes, t: *Text) void {
pub fn flatSurface(p: *Pardes, t: *Text) ![]const u8 {
switch (t.what) {
.body => {},
- .tag => return Pardes.curTail(t.pane()),
+ .tag => return tagline.curTail(t.pane()),
.input => return t.own orelse "",
- .column, .workspace => return t.own orelse p.headerDefault(t.what),
+ .column, .workspace => return t.own orelse tagline.headerDefault(p, t.what),
}
const pane = t.pane();
if (pane.file) |f| return f.content;
@@ -1617,7 +1619,7 @@ pub fn pointerTextSelection(p: *const Pardes, id: usize, col: u16, row: u16, bod
const v = @as(i32, mapped_hit.row) + pane.tag_rows;
return .{ .sel = .{ .state = .dragging, .c0 = c, .c1 = c, .r0 = v, .r1 = v }, .on_tag = false };
};
- const tag_col = if (on_tag) mouse.tagColumn(p, .pane, id, tag_hit, false, row - tag_y) else null;
+ const tag_col = if (on_tag) tag_layer.columnAt(p, .pane, id, tag_hit, false, row - tag_y) else null;
const c: i32 = (if (tag_col) |value| @as(i32, value) else @as(i32, col) - @as(i32, r.x + (if (on_tag) TAG_TEXT_INSET else config.GUTTER))) +
(if (on_tag) @as(i32, pane.tag_scroll) else 0);
const v: i32 = if (on_tag) @as(i32, row) - @as(i32, tag_y) else @as(i32, row) - @as(i32, body_y) + @as(i32, pane.tag_rows);