summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 05:49:29 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit2b04f877c29cf1e95c2fc8154de1da322c7299a3 (patch)
tree1430ca4deb53e0fae0b24238af543a13cf2125e1 /src/look.zig
parent779ff8cc27014b8c2f2f078985ab2ca9cf285740 (diff)
downloadpardes-2b04f877c29cf1e95c2fc8154de1da322c7299a3.tar.gz
pardes-2b04f877c29cf1e95c2fc8154de1da322c7299a3.zip
edit: the routing of a text's characters takes the editing context (docs/next-editor.md, R2, first slice): flatSurface, editText, editTextEol, setEditText, setEditTextEnd, setEditTextSpan, paneCursorLines, paneByteAtDisplay, pinPaneCursor, paneWrapWidth, treeIndent, pushUndo, undoStep, stepOwn, selText and vselText take `e: Editor` where they took `*Pardes`, the pane they route to reached through `e.p`; 149 calls in 16 files hand `p.editor()`, nothing else changes; core-test 810 of 949, shell-test 989 of 992, hxdiff 658 / parity 738 / hxgolf 124 with 0 mismatches, replicas pass
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/look.zig b/src/look.zig
index 136a7a9c..62f6a7da 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -296,7 +296,7 @@ pub fn cursorWordSel(p: *Pardes, pane: *Pane) Pane.Sel {
const vcol = if (pane.file != null)
w.pad + panes.File.displayOffset(pane, pane.body.cur_row, w.at, pane.body.cur_col) + @as(i32, panes.File.gutterWidth(pane))
else blk: {
- const lines = edit.paneCursorLines(p, &pane.body) catch break :blk pane.body.cur_col;
+ const lines = edit.paneCursorLines(p.editor(), &pane.body) catch break :blk pane.body.cur_col;
const local = pane.body.cur_row;
if (local < 0 or @as(usize, @intCast(local)) >= lines.len) break :blk pane.body.cur_col;
break :blk panes.File.lineDisplayOffset(lines[@intCast(local)], @intCast(@max(0, w.at)), @intCast(@max(0, pane.body.cur_col)));
@@ -372,7 +372,7 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, start: SearchStart,
@memcpy(out[0..out_len], rows[0..out_len]);
nrows = std.mem.count(u8, rows, "\n");
} else {
- const lines = try edit.paneCursorLines(p, &pane.body);
+ const lines = try edit.paneCursorLines(p.editor(), &pane.body);
// a real file names itself; a terminal or an output buffer has no path
const has_path = if (pane.file) |f| f.output == null else false;
var idbuf: [16]u8 = undefined;
@@ -547,7 +547,7 @@ pub fn wordSpan(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, realbuf:
}
fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usize) ?Pane.LookSpot {
- const lines = edit.paneCursorLines(p, &pane.body) catch return null;
+ const lines = edit.paneCursorLines(p.editor(), &pane.body) catch return null;
const nrows: i32 = @intCast(lines.len);
if (nrows == 0) return null;
const grain: panes.Output.Grain = if (pane.file) |*f| panes.Output.grain(f.output) else .word;
@@ -636,7 +636,7 @@ pub fn lookWalk(p: *Pardes, delta: i32) void {
}
fn landLookSpot(p: *Pardes, id: usize, pane: *Pane, spot: Pane.LookSpot) void {
- edit.pinPaneCursor(p, &pane.body); // fresh out of tty mode the cursor still tracks the shell
+ edit.pinPaneCursor(p.editor(), &pane.body); // fresh out of tty mode the cursor still tracks the shell
pane.body.vsel = .{ .active = true, .row = spot.row, .col = spot.col1, .explicit = true };
pane.body.nsel = 0;
pane.body.cur_row = spot.row;
@@ -751,7 +751,7 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at: Spot, landing: enum { center, ke
}
fn selectSpan(p: *Pardes, pane: *Pane, at: Spot) void {
- const text = edit.flatSurface(p, &pane.body) catch |err| return p.reportError(p.view().active, "look", err);
+ const text = edit.flatSurface(p.editor(), &pane.body) catch |err| return p.reportError(p.view().active, "look", err);
// saturating, not `- 1`: `f.zig:0-5` is a legal thing to type and a
// 1-based zero is the same nothing an absent number is
const acol: i32 = @intCast(at.col -| 1);
@@ -1185,7 +1185,7 @@ fn closeAndMiss(p: *Pardes, id: usize, opened: usize, name: []const u8, why: []c
fn lookTerminalAddress(p: *Pardes, id: usize, target: usize, expr: []const u8) void {
const Addr = @import("ninep/addr.zig").Addr;
const pane = p.panes[target].?;
- const lines = edit.paneCursorLines(p, &pane.body) catch return missed(p, id, "{s}", .{"out of memory"});
+ const lines = edit.paneCursorLines(p.editor(), &pane.body) catch return missed(p, id, "{s}", .{"out of memory"});
var text: std.ArrayList(u8) = .empty;
const arena = p.scratch.allocator();
const row: usize = @intCast(@max(0, pane.body.cur_row));
@@ -1490,7 +1490,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
if (found == .pane and found.pane.id < MAX_PANES) if (p.panes[found.pane.id]) |shown| {
// A terminal's lines are its logical lines, as a +Search lists them.
const n = if (shown.file) |*f| panes.File.nlines(p.gpa, f) else if (shown.isTerminal())
- if (edit.paneCursorLines(p, &shown.body)) |ls| ls.len else |_| std.math.maxInt(usize)
+ if (edit.paneCursorLines(p.editor(), &shown.body)) |ls| ls.len else |_| std.math.maxInt(usize)
else
std.math.maxInt(usize);
if (pl.at.line > n) return missedLine(p, id, trimmed, pl.at.line);
@@ -2515,7 +2515,7 @@ test "LookNext in a command pane walks its own file:line places, whoever walked
exec.runBuiltin(p, .LookNext, p.view().active, "", null);
try std.testing.expectEqual(dst, p.view().active);
const first = cmd.look_at orelse return error.NoSpot;
- const lines = try edit.paneCursorLines(p, &cmd.body);
+ const lines = try edit.paneCursorLines(p.editor(), &cmd.body);
try std.testing.expect(std.mem.startsWith(u8, lines[@intCast(first.row)][@intCast(first.col0)..], "x.c:3:1"));
exec.runBuiltin(p, .LookNext, p.view().active, "", null);
try std.testing.expectEqual(dst, p.view().active);