diff options
Diffstat (limited to 'src/look.zig')
| -rw-r--r-- | src/look.zig | 16 |
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); |
