summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 02:04:25 -0300
committerGabriel Schneider <[email protected]>2026-11-09 02:14:10 -0300
commitc78d362fa20393621ac198861f891439f9d832e9 (patch)
tree7ba6d82f7dca1926abf7a985cf3830c69d21c90c /src
parent69b993d585cfb14c607f46aba500b141b85516ff (diff)
downloadpardes-c78d362fa20393621ac198861f891439f9d832e9.tar.gz
pardes-c78d362fa20393621ac198861f891439f9d832e9.zip
locality: caller-led moves: MAX_JUMPS into Jump.zig (Core's unused alias goes), RasterPolicy and rasterPolicy beside Kind.viewOf, Names.relative beside Query.startSource, fs.find_skip beside Stream's max_walk_depth, File.drawGutter and drawWrapMarkers beside body_layer.renderBody; each unit's only users are in its new file
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
-rw-r--r--src/Core.zig1
-rw-r--r--src/File.zig60
-rw-r--r--src/Jump.zig2
-rw-r--r--src/Kind.zig12
-rw-r--r--src/Names.zig6
-rw-r--r--src/Query.zig16
-rw-r--r--src/Stream.zig7
-rw-r--r--src/body_layer.zig64
-rw-r--r--src/fs.zig5
-rw-r--r--src/pardes.zig11
10 files changed, 91 insertions, 93 deletions
diff --git a/src/Core.zig b/src/Core.zig
index d09c1188..67667695 100644
--- a/src/Core.zig
+++ b/src/Core.zig
@@ -27,7 +27,6 @@ const Ask = pardes.lsp.Ask;
const Key = pardes.Key;
const Loc = Jump.Loc;
const MAX_COLS = pardes.MAX_COLS;
-const MAX_JUMPS = pardes.MAX_JUMPS;
const MAX_PANES = pardes.MAX_PANES;
const MAX_TAG_ROWS = pardes.MAX_TAG_ROWS;
const Macro = pardes.Macro;
diff --git a/src/File.zig b/src/File.zig
index d5438704..fc50051c 100644
--- a/src/File.zig
+++ b/src/File.zig
@@ -1763,43 +1763,6 @@ fn fillBody(dst: ?[]u8, pane: *Pane, f: *State, width: usize, record_wrap: bool)
return written;
}
-pub fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16, active: bool) void {
- const prefix_width = gutterWidth(pane);
- const goff = pane.scroll();
- const gcur = terminal.gridCursor(pane);
- const gcrow = if (pane.body.cur_pinned) pane.body.cur_row else @as(i32, gcur.y) + goff;
- const typing_body = pane.focus == .body and (pane.prompt == .none or pane.prompt == .del_side or pane.prompt == .repl_choice);
- const cur_line: i32 = if (active and typing_body) gcrow else std.math.minInt(i32);
- // the body's first row, the way renderPane derives it
- const body_y = p.bodyTop(pane, r);
- const context_bg = p.theme().tag_bg;
- for (0..@min(pane.context_rows, body_h)) |context_row| {
- for (0..tw) |col| {
- const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(context_row)));
- cell.default = false;
- cell.style.bg = .{ .rgb = context_bg };
- cell.style.font_role = .tagline;
- }
- }
- var vr: u16 = 0;
- while (vr < body_h) : (vr += 1) {
- const row_line: i32 = if (pane.wrap_n == 0)
- goff + @as(i32, vr)
- else if (vr < pane.wrap_n) pane.wrap_line[vr] else std.math.maxInt(i32);
- const on_cursor = row_line == cur_line;
- var c: u16 = 0;
- while (c < prefix_width and c < tw) : (c += 1) {
- const cell = s.at(tx + c, body_y + vr);
- cell.default = false; // paints blank gutter rows too
- cell.style.fg = .{ .rgb = if (on_cursor)
- p.theme().lineno_active orelse p.theme().lineno
- else
- p.theme().lineno };
- cell.style.bold = on_cursor;
- }
- }
-}
-
const SynStyle = struct { fg: [3]u8, bold: bool };
/// How added and removed diff lines are told apart in every theme: a row
@@ -2191,29 +2154,6 @@ pub fn recolorDiffOutput(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, t
}
}
-pub fn drawWrapMarkers(
- p: *Pardes,
- s: *Surface,
- pane: *const Pane,
- r: pardes.Rect,
- tx: u16,
- tw: u16,
- body_h: u16,
- pane_bg: pardes.Color,
-) void {
- if (tw <= gutterWidth(pane) + 1) return;
- const body_y = p.bodyTop(pane, r);
- const marker_fg = p.chromeTheme().lineno;
- var row: u16 = 0;
- while (row + 1 < pane.wrap_n and row + 1 < body_h) : (row += 1) {
- if (pane.wrap_line[row + 1] != pane.wrap_line[row]) continue;
- s.set(tx + tw - 1, body_y + row, config.wrap_marker, .{
- .fg = .{ .rgb = marker_fg },
- .bg = pane_bg,
- });
- }
-}
-
pub fn paintWordSelection(
p: *Pardes,
s: *Surface,
diff --git a/src/Jump.zig b/src/Jump.zig
index 9f40343a..11c7da6e 100644
--- a/src/Jump.zig
+++ b/src/Jump.zig
@@ -13,7 +13,7 @@ const limits = @import("memory.zig").limits;
const Pardes = pardes.Pardes;
const Pane = panes.Pane;
const MAX_PANES = pardes.MAX_PANES;
-const MAX_JUMPS = pardes.MAX_JUMPS;
+const MAX_JUMPS = 64;
const BOX_H = pardes.BOX_H;
const Jump = @This();
diff --git a/src/Kind.zig b/src/Kind.zig
index bdbfeb2e..806e9558 100644
--- a/src/Kind.zig
+++ b/src/Kind.zig
@@ -677,6 +677,16 @@ fn seen(v: *const c.pa_view) u64 {
return if (v.cols == 0) 0 else std.hash.Wyhash.hash(0, std.mem.asBytes(v));
}
+/// The raster a frontend wants a kind's picture at (Kind.viewOf, a
+/// `pa_view`): a terminal's kitty images go down a wire, so smaller; a
+/// window rasterizes for its display.
+const RasterPolicy = struct { dpi: u16, max_dimension: u16, match_viewport: bool };
+/// A view's: a window's denser than a terminal's. By the view's frontend,
+/// never the build's, so every core of a session asks a kind alike.
+fn rasterPolicy(windowed: bool) RasterPolicy {
+ return if (windowed) .{ .dpi = 192, .max_dimension = 4096, .match_viewport = true } else .{ .dpi = 96, .max_dimension = 1200, .match_viewport = false };
+}
+
/// Pane `id` as view `k` shows it (its id k + 1): its body below its
/// notices, as draw.zig paints it, a cell's pixels, the theme's colours and
/// the raster that view's frontend wants a picture at; no cells when the
@@ -696,7 +706,7 @@ pub fn viewOf(p: *const Pardes, k: u8, id: usize) c.pa_view {
return @as(u32, x[0]) << 16 | @as(u32, x[1]) << 8 | x[2];
}
}.f;
- const policy = pardes.rasterPolicy(v.frontend.windowed);
+ const policy = rasterPolicy(v.frontend.windowed);
return .{
.cols = r.w -| pardes.config.GUTTER,
.rows = (r.h -| tag_rows) -| notices,
diff --git a/src/Names.zig b/src/Names.zig
index d9597994..af1d5c2d 100644
--- a/src/Names.zig
+++ b/src/Names.zig
@@ -100,12 +100,6 @@ pub fn add(n: *Names, gpa: std.mem.Allocator, row_in: []const u8, key: usize, ke
for (text) |c| n.lower.appendAssumeCapacity(std.ascii.toLower(c));
}
-pub fn relative(path: []const u8, dir: []const u8) []const u8 {
- const d = std.mem.trimEnd(u8, dir, "/");
- if (d.len > 0 and path.len > d.len + 1 and std.mem.startsWith(u8, path, d) and path[d.len] == '/') return path[d.len + 1 ..];
- return path;
-}
-
pub fn baseOf(path: []const u8) u16 {
const slash = std.mem.lastIndexOfScalar(u8, std.mem.trimEnd(u8, path, "/"), '/') orelse return 0;
return @intCast(@min(slash + 1, max_text));
diff --git a/src/Query.zig b/src/Query.zig
index 1bb5792a..77119ca9 100644
--- a/src/Query.zig
+++ b/src/Query.zig
@@ -542,6 +542,12 @@ fn searchable(tp: *const Pane) bool {
return true;
}
+fn relative(path: []const u8, dir: []const u8) []const u8 {
+ const d = std.mem.trimEnd(u8, dir, "/");
+ if (d.len > 0 and path.len > d.len + 1 and std.mem.startsWith(u8, path, d) and path[d.len] == '/') return path[d.len + 1 ..];
+ return path;
+}
+
/// A source begun: its candidates gathered (names), its walk started.
fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usize) void {
const rp = p.panes[id].?;
@@ -563,7 +569,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
var lines = std.mem.splitScalar(u8, pardes.tape.authority(recentRows, .{ p, &out }), '\n');
while (lines.next()) |ln| {
if (ln.len == 0) continue;
- const rel = Names.relative(ln, dir);
+ const rel = relative(ln, dir);
const path_end = std.mem.indexOfAny(u8, rel, ": ") orelse rel.len;
q.names.add(gpa, rel, 0, path_end, Names.baseOf(rel[0..path_end]), 0) catch break;
}
@@ -574,7 +580,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
if (other == rp or other.query != null) continue;
var buf: [4096 + 32]u8 = undefined;
const what: []const u8 = if (other.file) |f| f.path else if (other.command) |c| c else other.cwdSlice();
- const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}", .{ other.serial, Names.relative(what, dir) }) catch continue;
+ const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}", .{ other.serial, relative(what, dir) }) catch continue;
const key_at = std.mem.indexOfScalar(u8, row, ' ').? + 1;
const ln = row[0 .. std.mem.indexOfAny(u8, row, "\r\n") orelse row.len];
q.names.add(gpa, ln, key_at, ln.len -| key_at, Names.baseOf(ln[@min(key_at, ln.len)..]), other.serial) catch break;
@@ -585,7 +591,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz
// session's, which a replica has from the authority.
for (pardes.tape.authority(Store.closedNames, .{p})) |c| {
var buf: [4096 + 48]u8 = undefined;
- const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}" ++ closed_word, .{ c.serial, Names.relative(c.name, dir) }) catch continue;
+ const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}" ++ closed_word, .{ c.serial, relative(c.name, dir) }) catch continue;
const key_at = std.mem.indexOfScalar(u8, row, ' ').? + 1;
const key_len = row.len - closed_word.len - key_at;
q.names.add(gpa, row, key_at, key_len, Names.baseOf(row[key_at..][0..key_len]), c.serial) catch break;
@@ -871,7 +877,7 @@ fn addressOf(arena: std.mem.Allocator, tp: *const Pane) []const u8 {
/// relative one that climbs.
pub fn lookPath(buf: []u8, path: []const u8, dir: []const u8) []const u8 {
// a relative pane's (a test's): its directory's prefix off, as ever
- if (path.len == 0 or path[0] != '/' or dir.len == 0 or dir[0] != '/') return Names.relative(path, dir);
+ if (path.len == 0 or path[0] != '/' or dir.len == 0 or dir[0] != '/') return relative(path, dir);
const d = std.mem.trimEnd(u8, dir, "/");
// the last slash both share, ending a whole component of `dir`
var k: usize = 0;
@@ -1055,7 +1061,7 @@ fn makeAllRows(p: *Pardes, id: usize) !void {
q.total += set.hits.items.len;
q.more = q.more or !set.complete();
var hb: pardes.Kind.Buf(600) = .{};
- const name = if (tp.file) |f| Names.relative(f.path, std.Io.Dir.path.dirname(rp.file.?.path) orelse "") else "";
+ const name = if (tp.file) |f| relative(f.path, std.Io.Dir.path.dirname(rp.file.?.path) orelse "") else "";
const head = hb.print(config.pane_addr ++ "{d} {s} ({d})", .{ tp.serial, name[0..@min(name.len, 500)], set.hits.items.len });
try q.items.append(p.gpa, .{ .kind = .header, .serial = tp.serial });
try writeRow(p, &out, &rows, head, .{ .kind = .context, .declaration = true, .path = @constCast(addressOf(p.scratch.allocator(), tp)), .at = .{}, .location_end = 0, .code_start = 0 });
diff --git a/src/Stream.zig b/src/Stream.zig
index 2641fc73..11fa7a31 100644
--- a/src/Stream.zig
+++ b/src/Stream.zig
@@ -46,6 +46,11 @@ const batch_bytes = 256 * 1024;
const max_file_bytes = 16 << 20;
/// The walk goes no deeper than this many directories below its root.
const max_walk_depth = 16;
+/// Directories the walk never enters.
+const find_skip = [_][]const u8{
+ ".git", ".jj", "target", "node_modules",
+ ".venv", "__pycache__", ".zig-cache", "zig-out",
+};
/// What a worker sends: rows as fs.zig wrote them (`path:line:col-end
/// text`, a listing's `path`), relative to the search's directory. Owned by
@@ -886,7 +891,7 @@ const Worker = struct {
switch (e.kind) {
.directory => {
if (depth + 1 >= max_walk_depth or e.name[0] == '.') continue;
- if (for (filesystem.find_skip) |skip| {
+ if (for (find_skip) |skip| {
if (std.mem.eql(u8, e.name, skip)) break true;
} else false) continue;
var sub = dir.openDir(w.io, e.name, .{ .iterate = true }) catch |err| switch (err) {
diff --git a/src/body_layer.zig b/src/body_layer.zig
index 56c4bc79..76aec179 100644
--- a/src/body_layer.zig
+++ b/src/body_layer.zig
@@ -227,6 +227,66 @@ pub fn joinBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
}
}
+fn drawGutter(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, tx: u16, tw: u16, body_h: u16, active: bool) void {
+ const prefix_width = panes.File.gutterWidth(pane);
+ const goff = pane.scroll();
+ const gcur = panes.terminal.gridCursor(pane);
+ const gcrow = if (pane.body.cur_pinned) pane.body.cur_row else @as(i32, gcur.y) + goff;
+ const typing_body = pane.focus == .body and (pane.prompt == .none or pane.prompt == .del_side or pane.prompt == .repl_choice);
+ const cur_line: i32 = if (active and typing_body) gcrow else std.math.minInt(i32);
+ // the body's first row, the way renderPane derives it
+ const body_y = p.bodyTop(pane, r);
+ const context_bg = p.theme().tag_bg;
+ for (0..@min(pane.context_rows, body_h)) |context_row| {
+ for (0..tw) |col| {
+ const cell = s.at(tx + @as(u16, @intCast(col)), body_y + @as(u16, @intCast(context_row)));
+ cell.default = false;
+ cell.style.bg = .{ .rgb = context_bg };
+ cell.style.font_role = .tagline;
+ }
+ }
+ var vr: u16 = 0;
+ while (vr < body_h) : (vr += 1) {
+ const row_line: i32 = if (pane.wrap_n == 0)
+ goff + @as(i32, vr)
+ else if (vr < pane.wrap_n) pane.wrap_line[vr] else std.math.maxInt(i32);
+ const on_cursor = row_line == cur_line;
+ var c: u16 = 0;
+ while (c < prefix_width and c < tw) : (c += 1) {
+ const cell = s.at(tx + c, body_y + vr);
+ cell.default = false; // paints blank gutter rows too
+ cell.style.fg = .{ .rgb = if (on_cursor)
+ p.theme().lineno_active orelse p.theme().lineno
+ else
+ p.theme().lineno };
+ cell.style.bold = on_cursor;
+ }
+ }
+}
+
+fn drawWrapMarkers(
+ p: *Pardes,
+ s: *Surface,
+ pane: *const Pane,
+ r: pardes.Rect,
+ tx: u16,
+ tw: u16,
+ body_h: u16,
+ pane_bg: pardes.Color,
+) void {
+ if (tw <= panes.File.gutterWidth(pane) + 1) return;
+ const body_y = p.bodyTop(pane, r);
+ const marker_fg = p.chromeTheme().lineno;
+ var row: u16 = 0;
+ while (row + 1 < pane.wrap_n and row + 1 < body_h) : (row += 1) {
+ if (pane.wrap_line[row + 1] != pane.wrap_line[row]) continue;
+ s.set(tx + tw - 1, body_y + row, config.wrap_marker, .{
+ .fg = .{ .rgb = marker_fg },
+ .bg = pane_bg,
+ });
+ }
+}
+
pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: Rect, id: usize, active: bool, rail: ?pardes.Region) !void {
const th = p.theme();
const chrome = p.chromeTheme();
@@ -276,12 +336,12 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
defer p.frames.zone(.body_color, probe_color);
// File layout is independent of whether its producer requests colors.
if (pane.file) |*f| {
- panes.File.drawGutter(p, s, pane, r, tx, tw, body_h, active);
+ drawGutter(p, s, pane, r, tx, tw, body_h, active);
panes.Query.paintMark(p, s, pane, r, body_h);
if (pane.colorAlgo() != .none)
panes.File.recolorSyntax(p, s, pane, f, r, tx, tw, body_h);
panes.Tables.paint(p, s, pane, r, tx, tw, body_h);
- panes.File.drawWrapMarkers(p, s, pane, r, tx, tw, body_h, pane_bg);
+ drawWrapMarkers(p, s, pane, r, tx, tw, body_h, pane_bg);
pane.places.paint(p, s, pane, r, body_h);
panes.Query.paint(p, s, pane, r, body_h);
} else if (pane.isTerminal()) {
diff --git a/src/fs.zig b/src/fs.zig
index 5e4f181a..8e7ec346 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -664,11 +664,6 @@ fn findEmbeddedSource(path: []const u8, allow_root_suffix: bool) ?Source {
pub const platform_has_fs = !pardes.isolated;
-pub const find_skip = [_][]const u8{
- ".git", ".jj", "target", "node_modules",
- ".venv", "__pycache__", ".zig-cache", "zig-out",
-};
-
fn isDir(path: [*:0]const u8) bool {
const fd = libc.open(path, .{ .ACCMODE = .RDONLY, .DIRECTORY = true, .CLOEXEC = true });
if (fd < 0) return false;
diff --git a/src/pardes.zig b/src/pardes.zig
index e9d38ad2..298822bc 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -110,16 +110,6 @@ pub const can_attach = platform == .tui or platform == .gui;
pub const fonts = if (font_picker) @import("fonts.zig") else struct {};
-/// The raster a frontend wants a kind's picture at (Kind.viewOf, a
-/// `pa_view`): a terminal's kitty images go down a wire, so smaller; a
-/// window rasterizes for its display.
-pub const RasterPolicy = struct { dpi: u16, max_dimension: u16, match_viewport: bool };
-/// A view's: a window's denser than a terminal's. By the view's frontend,
-/// never the build's, so every core of a session asks a kind alike.
-pub fn rasterPolicy(windowed: bool) RasterPolicy {
- return if (windowed) .{ .dpi = 192, .max_dimension = 4096, .match_viewport = true } else .{ .dpi = 96, .max_dimension = 1200, .match_viewport = false };
-}
-
pub const Pane = panes.Pane;
const Text = panes.Text;
@@ -143,7 +133,6 @@ pub const NOTICE_LAYER_BASE = MAX_PANES + MAX_COLS + 1;
/// being most of it).
pub const MAX_COLS = 16;
const column_weight_unit = layout.column_weight_unit;
-pub const MAX_JUMPS = 64;
pub const TOPBAR_H: u16 = 1;
pub const COLBAR_H: u16 = 1;
pub const BOX_H: u16 = 1;