summaryrefslogtreecommitdiff
path: root/src/output_pane.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-31 19:02:04 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:08 -0300
commit005178177a1ddb2eb2f1af5fad36e2717758ee8e (patch)
tree6e974c12def02fd855446d84db25232c1f3b4fd2 /src/output_pane.zig
parent41847fce244fdd0d01971c302b89d1252f6497ed (diff)
downloadpardes-005178177a1ddb2eb2f1af5fad36e2717758ee8e.tar.gz
pardes-005178177a1ddb2eb2f1af5fad36e2717758ee8e.zip
the gui wears any monospace font on the machine
Diffstat (limited to 'src/output_pane.zig')
-rw-r--r--src/output_pane.zig37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/output_pane.zig b/src/output_pane.zig
index 9c004dff..3308e22a 100644
--- a/src/output_pane.zig
+++ b/src/output_pane.zig
@@ -25,6 +25,9 @@ const builtins = @import("builtins.zig");
const Builtin = builtins.Builtin();
const config = @import("config.zig");
const lsp = @import("lsp/lsp.zig");
+/// the installed fonts, for openFonts. GUI only, behind the same comptime
+/// branch builtins.zig imports it through — see the note there.
+const fonts = if (pardes.platform == .gui) @import("gui/fonts.zig") else struct {};
/// What opened this buffer — THE field, and the only input to `traits`.
///
@@ -139,10 +142,21 @@ pub fn traits(o: Origin) Traits {
// rows are COMMANDS rather than locations, so n/N execute them:
// walking the list wears each theme, and stopping is picking one.
.ThemeSel => .{ .name = config.themes_buffer, .steps = true, .executes = true },
+ // the font picker, the theme picker one layer down: same rows,
+ // same verb, its own name. It is a BRANCH and not a prong because
+ // FontSel only exists in a gui build (see builtins.zig) — a prong
+ // naming an enum field the tty fold does not have is a compile
+ // error, and a comptime-false `if` is the one form that is not
+ // even analysed there.
+ //
// Find (file names) and Grep (file contents) both list locations;
// no other builtin opens a buffer, and the day one does it lands
// here rather than in a call site.
- else => .{ .name = config.search_buffer, .steps = true },
+ else => blk: {
+ if (pardes.platform == .gui) if (b == .FontSel)
+ break :blk .{ .name = config.fonts_buffer, .steps = true, .executes = true };
+ break :blk .{ .name = config.search_buffer, .steps = true };
+ },
},
.query => |k| switch (k) {
.hover => .{ .name = config.hover_buffer },
@@ -287,6 +301,27 @@ pub fn openThemes(p: *Pardes, id: usize) void {
openStepped(p, id, .{ .cmd = .ThemeSel }, out.items);
}
+/// The FontSel builtin: openThemes over the fonts installed on the machine
+/// instead of the themes compiled into the binary — one `Font <name>` row
+/// each, in a buffer whose rows n/N RUN, so walking it wears the fonts and
+/// stopping picks one. Everything that makes that work is already above; this
+/// is the same eight lines pointed at a different list.
+///
+/// GUI only, and the body says so rather than the signature: fonts.list and
+/// the FontSel origin both exist only there, and a comptime-false `if` is what
+/// keeps the tty build from analysing either. The dead parameters on that
+/// build are the honest shape of "this platform cannot open one".
+pub fn openFonts(p: *Pardes, id: usize) void {
+ if (pardes.platform == .gui) {
+ const arena = p.scratch.allocator();
+ var out: std.ArrayList(u8) = .empty;
+ for (fonts.list(arena, null)) |f| {
+ out.print(arena, comptime builtins.word(builtins.Font) ++ " {s}\n", .{f.name}) catch return;
+ }
+ openStepped(p, id, .{ .cmd = .FontSel }, out.items);
+ }
+}
+
/// Open a buffer n/N will walk, and arm them on it: the shared tail of every
/// builtin that answers with a list. `text` is borrowed (the callers build it
/// in the scratch arena) and copied into a gpa buffer the pane adopts.