summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 00:51:40 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit4a33b8d2bd409d4a06205f28e0eb1b4cdaf49889 (patch)
tree0451135691e451216ad89167884b42b2b0a33dca /src/builtins.zig
parentdd5aa28c89e2ca31a4cd806d6087ce4ac52398fc (diff)
downloadpardes-4a33b8d2bd409d4a06205f28e0eb1b4cdaf49889.tar.gz
pardes-4a33b8d2bd409d4a06205f28e0eb1b4cdaf49889.zip
hunks: the +Diff's editor side in one place: openDiff, showDiffText and diffSource move from Output.zig, the `Diff` word's body and PaneKind.diff's test from builtins.zig, lookCommit (as lookedAtCommit) and its test from look.zig; builtins.zig's Diff is its one registration (its doc, traits and `run = hunks.word`); the three open hooks a plumber's rules would replace are a call each, look.zig's `hunks.lookedAt` (a bare look at a .diff or .patch) and `hunks.lookedAtCommit` (a commit hash) and ninep/ctl.zig's `hunks.paged` (a +Pager filled with a diff), their conditions inside them; the diff language (diff.zig, syntax.zig's highlightDiff, look's diff-line address) stays where the languages are; code locality's far share 0.575 before and after (codeloc.py --compare); goldens unchanged
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 85bb6e44..bb91d0b0 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -74,8 +74,7 @@ pub const PaneKind = enum {
.image => pane.addon != null,
.picture => pane.addon != null or pane.isTerminal(),
.program_colors => pane.isTerminal() or (pane.file != null and pane.file.?.pager),
- .diff => if (pane.file) |f| pane.colorAlgo() == .diff or
- (f.output != null and std.meta.eql(f.output.?.from, panes.Output.Origin{ .cmd = .Diff })) else false,
+ .diff => @import("hunks.zig").shows(pane),
};
}
@@ -1089,17 +1088,12 @@ pub const Filter = struct {
};
/// Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text.
+/// The diff viewer's one registration: its word and traits here, all else
+/// its own (hunks.zig).
pub const Diff = struct {
pub const needs: PaneKind = .diff;
pub const output: OutputTraits = .{ .name = config.diff_buffer, .steps = true, .locations = true };
- pub fn run(c: Ctx) void {
- const f = &c.pane.file.?;
- if (panes.Output.diffSource(c.p, f)) |source| return panes.Output.showDiffText(c.p, c.id, source);
- _ = panes.Output.openDiff(c.p, c.id, f.path, f.content) catch |err| switch (err) {
- error.NoHunks => c.p.reportFailure(c.id, "Diff: no hunk in it"),
- else => c.p.reportError(c.id, "hunks", err),
- };
- }
+ pub const run = @import("hunks.zig").word;
};
/// Cycle the pane's input modes: terminals add raw tty mode to normal/insert.