From d78fa4f9d90437dac60d9150e3a6eca868895856 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 12:56:32 -0300 Subject: idioms #18, std.Io's names and fewer forms: the core's path functions are std.Io.Dir.path's and max_path_bytes std.Io.Dir's (std.fs's are deprecated aliases), pinOf takes the *const PageList it is always given, normal's @hasDecl guard goes (@field says the same), deleteSelection returns edit.Error, and a Look miss too long for its buffer is said cut where it said `no match` Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/Core.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Core.zig') diff --git a/src/Core.zig b/src/Core.zig index c7d2fd48..413de233 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -551,7 +551,7 @@ fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes { }; const content = try std.fmt.allocPrint(gpa, "cannot open\n\n\t{s}\n\n{s}\n", .{ path, why }); errdefer gpa.free(content); - _ = try pardes.panes.Output.open(p, 0, std.fs.path.dirname(path) orelse "/", .errors, "", content); + _ = try pardes.panes.Output.open(p, 0, std.Io.Dir.path.dirname(path) orelse "/", .errors, "", content); } p.oneColumn(); }, @@ -574,7 +574,7 @@ fn initSession(gpa: std.mem.Allocator, opts: Options) !*Pardes { const dir = p.sessionDir(); const shown = try pardes.panes.Output.open(p, 0, dir, .{ .cmd = .New }, "", content); // Named +Pager, as `pardes -` inside a session names its pane. - const named = try std.fs.path.join(gpa, &.{ dir, "+Pager" }); + const named = try std.Io.Dir.path.join(gpa, &.{ dir, "+Pager" }); gpa.free(shown.file.?.path); shown.file.?.path = named; shown.file.?.pager = true; @@ -981,7 +981,7 @@ pub fn acknowledgeShell(p: *Pardes, id: usize, executable: []const u8, prompt_ma if (pane.command == null) { // A shell given as a path keeps it: its bare name would find // nothing, or another program, on the usual paths. - const base = if (pane.shell) |given| (if (std.mem.indexOfScalar(u8, given, '/') != null) given else std.fs.path.basename(executable)) else std.fs.path.basename(executable); + const base = if (pane.shell) |given| (if (std.mem.indexOfScalar(u8, given, '/') != null) given else std.Io.Dir.path.basename(executable)) else std.Io.Dir.path.basename(executable); const rest = tagline.terminal_pane_tail[" Term".len..]; if (std.fmt.bufPrint(&pane.shell_tail, " Term+{s}{s}", .{ base, rest })) |tail| { pane.shell_tail_len = @intCast(tail.len); @@ -1311,7 +1311,7 @@ fn sayShellFailure(p: *Pardes, id: u8, err: anyerror) void { /// The program the shell's `#!` names that is not there, in `out`. fn missingInterpreter(bin: []const u8, out: []u8) ?[]const u8 { const Shell = @import("host_io.zig").Shell; - var buf: [std.fs.max_path_bytes]u8 = undefined; + var buf: [std.Io.Dir.max_path_bytes]u8 = undefined; return Shell.missingInterpreter(Shell.find(bin, &buf) orelse return null, out); } @@ -1319,7 +1319,7 @@ fn missingInterpreter(bin: []const u8, out: []u8) ?[]const u8 { /// what is there (a directory when it is no local path), whether it is /// missing, and whether that is because one above refuses (EACCES). fn parentTrouble(path: []const u8, err: anyerror) struct { dir: []const u8, kind: ?std.Io.File.Kind, missing: bool, denied: bool } { - const dir = std.fs.path.dirname(path) orelse "/"; + const dir = std.Io.Dir.path.dirname(path) orelse "/"; const local = filesystem.localPath(dir); const kind: ?std.Io.File.Kind = if (local) |l| exec.kindOf(l) else .directory; const missing = err == error.FileNotFound or err == error.NotDir or kind != .directory; -- cgit v1.3