summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig125
1 files changed, 73 insertions, 52 deletions
diff --git a/src/config.zig b/src/config.zig
index d4efed0e..229c70ea 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -26,7 +26,7 @@ const undecided: []const u8 = "<undecided>";
// null means word/chord-only. Every enabled builtin must explicitly choose a path.
pub const leader_path = paths: {
- @setEvalBranchQuota(2000);
+ @setEvalBranchQuota(10_000); // a check per builtin, and they grow
var table = std.EnumArray(Builtin, ?[]const u8).initDefault(@as(?[]const u8, undecided), .{
.Help = &[_]u8{leader_help},
.Hover = "lk",
@@ -76,6 +76,7 @@ pub const leader_path = paths: {
.Joincol = "cj",
.Placement = "cp",
.BootShell = null,
+ .LookWord = null,
.Debug = "td",
.Msg = null,
.Colors = "tc",
@@ -350,7 +351,16 @@ test "wheel drift guard" {
try std.testing.expect(wheelTick(&g, false));
}
-pub const default_shell = "fish";
+/// The shell when no `Shell` is set: the user's login shell ($SHELL), as a
+/// terminal would start, else /bin/sh. An explicit `Shell` overrides it.
+pub fn defaultShell() []const u8 {
+ if (comptime pardes.hosted) if (std.c.getenv("SHELL")) |s| {
+ const shell = std.mem.span(s);
+ // One that is not there, or not executable, is no shell: /bin/sh.
+ if (shell.len > 0 and std.c.access(s, std.c.X_OK) == 0) return shell;
+ };
+ return "/bin/sh";
+}
// Minimum file gutter width, including the space after the line number.
pub const PREFIX_W: u16 = 5;
@@ -708,12 +718,17 @@ pub const Runtime = struct {
/// has typed into stands: `keep` leaves the shell, `replace` closes it
/// (exec.evictLonePristineTty).
boot_shell: BootShell = .keep,
+ /// A plain word looked at in a pane: `search`, acme's look3, selects its
+ /// next place in that pane, wrapping; `list`, what pardes did before,
+ /// lists every place in a +Search pane (look.zig, lookWord).
+ look_word: LookWord = .search,
pub const ShaderAnimation = enum { off, on, always };
pub const Placement = enum { acme, pardes };
pub const BootShell = enum { keep, replace };
+ pub const LookWord = enum { search, list };
/// A setting that is one of a few words, each an enum field of Runtime.
- pub const Choice = enum { placement, boot_shell };
+ pub const Choice = enum { placement, boot_shell, look_word };
/// shadow: a soft drop shadow. rim: a light hairline along the top of
/// the focused pane's tag rows. auto: a shadow on a light page; on a
@@ -912,6 +927,8 @@ pub const Runtime = struct {
pub const Setting = struct {
word: []const u8,
action: Action,
+ /// What it does, one sentence: /commands lists it after the word.
+ doc: []const u8,
availability: ?Capability = null,
pub fn enabled(setting: Setting, capabilities: Capabilities) bool {
@@ -924,51 +941,52 @@ pub const Runtime = struct {
// The builtin registry and Config report share this command table.
pub const settings = [_]Setting{
- .{ .word = "Colors", .action = .{ .toggle = .colors } },
- .{ .word = "Wrap", .action = .{ .toggle = .wrap } },
- .{ .word = "TreeContextTagStyle", .action = .{ .toggle = .tree_context_tag_style } },
- .{ .word = "Tagbottom", .action = .{ .toggle = .tag_bottom } },
- .{ .word = "Debug", .action = .{ .toggle = .debug } },
- .{ .word = "FocusTint", .action = .{ .toggle = .focus_tint } },
- .{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold } },
- .{ .word = "Verbose", .action = .{ .toggle = .verbose } },
- .{ .word = "MessageAnimation", .action = .{ .toggle = .message_animation } },
- .{ .word = "Ligatures", .action = .{ .toggle = .ligatures }, .availability = .ligatures },
- .{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .availability = .lift },
- .{ .word = "SelectionGlow", .action = .{ .toggle = .selection_glow }, .availability = .lift },
- .{ .word = "Lift", .action = .lift, .availability = .lift },
- .{ .word = "Motion", .action = .motion },
- .{ .word = "InactiveDim", .action = .inactive_dim },
- .{ .word = "GripWidth", .action = .grip_width, .availability = .lift },
- .{ .word = "MessageLinger", .action = .{ .message_ms = .linger } },
- .{ .word = "MessageFall", .action = .{ .message_ms = .fall } },
- .{ .word = "MessageDissolve", .action = .{ .message_ms = .dissolve } },
- .{ .word = "DumpDir", .action = .dump_dir },
- .{ .word = "Theme", .action = .theme },
- .{ .word = "Shell", .action = .shell },
- .{ .word = "Font", .action = .font, .availability = .font_picker },
- .{ .word = "TaglineSize", .action = .tagline_size, .availability = .font_picker },
- .{ .word = "WindowOpacity", .action = .window_opacity, .availability = .window_opacity },
- .{ .word = "WindowBlur", .action = .window_blur, .availability = .window_blur },
- .{ .word = "PanelSlide", .action = .{ .transition = .slide }, .availability = .panel_transitions },
- .{ .word = "PanelZoom", .action = .{ .transition = .zoom }, .availability = .panel_transitions },
- .{ .word = "PanelDissolve", .action = .{ .transition = .dissolve }, .availability = .panel_transitions },
- .{ .word = "PanelAscii", .action = .{ .transition = .ascii }, .availability = .panel_transitions },
- .{ .word = "PanelVertical", .action = .{ .transition = .vertical }, .availability = .panel_transitions },
- .{ .word = "PanelEdges", .action = .{ .transition = .edges }, .availability = .panel_transitions },
- .{ .word = "PanelFall", .action = .{ .transition = .fall }, .availability = .panel_transitions },
- .{ .word = "PanelWave", .action = .{ .transition = .wave }, .availability = .panel_transitions },
- .{ .word = "PanelCurtain", .action = .{ .transition = .curtain }, .availability = .panel_transitions },
- .{ .word = "PanelScramble", .action = .{ .transition = .scramble }, .availability = .panel_transitions },
- .{ .word = "PanelType", .action = .{ .transition = .typewriter }, .availability = .panel_transitions },
- .{ .word = "Crt", .action = .{ .scene = .crt }, .availability = .scene_shaders },
- .{ .word = "Bloom", .action = .{ .scene = .bloom }, .availability = .scene_shaders },
- .{ .word = "Vignette", .action = .{ .scene = .vignette }, .availability = .scene_shaders },
- .{ .word = "Grain", .action = .{ .scene = .grain }, .availability = .scene_shaders },
- .{ .word = "Shader", .action = .shader, .availability = .scene_shaders },
- .{ .word = "ShaderAnimation", .action = .shader_animation, .availability = .scene_shaders },
- .{ .word = "Placement", .action = .{ .choice = .placement } },
- .{ .word = "BootShell", .action = .{ .choice = .boot_shell } },
+ .{ .word = "Colors", .action = .{ .toggle = .colors }, .doc = "Syntax colours in text panes, on or off." },
+ .{ .word = "Wrap", .action = .{ .toggle = .wrap }, .doc = "Long lines wrap onto the next row, on or off." },
+ .{ .word = "TreeContextTagStyle", .action = .{ .toggle = .tree_context_tag_style }, .doc = "A pane's TreeContext rows draw in the tag's style, on or off." },
+ .{ .word = "Tagbottom", .action = .{ .toggle = .tag_bottom }, .doc = "Each pane's tag goes at its foot rather than its head, on or off." },
+ .{ .word = "Debug", .action = .{ .toggle = .debug }, .doc = "A small box of frame statistics at the top right, on or off." },
+ .{ .word = "FocusTint", .action = .{ .toggle = .focus_tint }, .doc = "The focused pane's and column's tags are tinted, on or off." },
+ .{ .word = "SyntaxBold", .action = .{ .toggle = .syntax_bold }, .doc = "Keywords and the like are drawn bold, on or off." },
+ .{ .word = "Verbose", .action = .{ .toggle = .verbose }, .doc = "A builtin says its own name on the message row as it runs, on or off." },
+ .{ .word = "MessageAnimation", .action = .{ .toggle = .message_animation }, .doc = "A message falls into its row and dissolves out of it, on or off." },
+ .{ .word = "Ligatures", .action = .{ .toggle = .ligatures }, .availability = .ligatures, .doc = "A font's programming ligatures draw across their cells, on or off." },
+ .{ .word = "CursorBlink", .action = .{ .toggle = .cursor_blink }, .availability = .lift, .doc = "The cursor blinks, solid while typing, on or off." },
+ .{ .word = "SelectionGlow", .action = .{ .toggle = .selection_glow }, .availability = .lift, .doc = "A soft halo of the selection's colour round it in the body, on or off." },
+ .{ .word = "Lift", .action = .lift, .availability = .lift, .doc = "How the focused pane stands off the page: off, shadow, rim or auto." },
+ .{ .word = "Motion", .action = .motion, .doc = "How animations move: off, crisp, smooth, bouncy or playful." },
+ .{ .word = "InactiveDim", .action = .inactive_dim, .doc = "Fade the unfocused panes' text by a percentage, 0 through 100, 0 off." },
+ .{ .word = "GripWidth", .action = .grip_width, .availability = .lift, .doc = "The grip and scrollbar width, as a percent of the theme's rail." },
+ .{ .word = "MessageLinger", .action = .{ .message_ms = .linger }, .doc = "How long, in milliseconds, a message stays after what dismisses it." },
+ .{ .word = "MessageFall", .action = .{ .message_ms = .fall }, .doc = "How long, in milliseconds, a message takes to fall into its row." },
+ .{ .word = "MessageDissolve", .action = .{ .message_ms = .dissolve }, .doc = "How long, in milliseconds, a message takes to dissolve." },
+ .{ .word = "DumpDir", .action = .dump_dir, .doc = "The directory Dump writes to and a relative Restore reads from; bare, the default." },
+ .{ .word = "Theme", .action = .theme, .doc = "Switch to the named theme." },
+ .{ .word = "Shell", .action = .shell, .doc = "The shell new terminals run; bare, the login shell." },
+ .{ .word = "Font", .action = .font, .availability = .font_picker, .doc = "The body font, by name or path, and its size." },
+ .{ .word = "TaglineSize", .action = .tagline_size, .availability = .font_picker, .doc = "Scale the tag font, a percentage." },
+ .{ .word = "WindowOpacity", .action = .window_opacity, .availability = .window_opacity, .doc = "The window's opacity, a percentage." },
+ .{ .word = "WindowBlur", .action = .window_blur, .availability = .window_blur, .doc = "The blur behind a translucent window, a radius." },
+ .{ .word = "PanelSlide", .action = .{ .transition = .slide }, .availability = .panel_transitions, .doc = "Panes slide in and out as they open and close, on or off." },
+ .{ .word = "PanelZoom", .action = .{ .transition = .zoom }, .availability = .panel_transitions, .doc = "Panes zoom in and out as they open and close, on or off." },
+ .{ .word = "PanelDissolve", .action = .{ .transition = .dissolve }, .availability = .panel_transitions, .doc = "Panes dissolve in and out as they open and close, on or off." },
+ .{ .word = "PanelAscii", .action = .{ .transition = .ascii }, .availability = .panel_transitions, .doc = "Panes open and close through a scatter of ASCII, on or off." },
+ .{ .word = "PanelVertical", .action = .{ .transition = .vertical }, .availability = .panel_transitions, .doc = "Panes open and close with a vertical wipe, on or off." },
+ .{ .word = "PanelEdges", .action = .{ .transition = .edges }, .availability = .panel_transitions, .doc = "Panes open and close from their edges, on or off." },
+ .{ .word = "PanelFall", .action = .{ .transition = .fall }, .availability = .panel_transitions, .doc = "Panes fall into place as they open, on or off." },
+ .{ .word = "PanelWave", .action = .{ .transition = .wave }, .availability = .panel_transitions, .doc = "Panes open and close in a wave, on or off." },
+ .{ .word = "PanelCurtain", .action = .{ .transition = .curtain }, .availability = .panel_transitions, .doc = "Panes open and close like a curtain, on or off." },
+ .{ .word = "PanelScramble", .action = .{ .transition = .scramble }, .availability = .panel_transitions, .doc = "Panes open and close through scrambled text, on or off." },
+ .{ .word = "PanelType", .action = .{ .transition = .typewriter }, .availability = .panel_transitions, .doc = "Panes type themselves in as they open, on or off." },
+ .{ .word = "Crt", .action = .{ .scene = .crt }, .availability = .scene_shaders, .doc = "The bundled CRT post pass over the window, on or off." },
+ .{ .word = "Bloom", .action = .{ .scene = .bloom }, .availability = .scene_shaders, .doc = "The brightest ink glows a little: a level, 0 (off) through 3." },
+ .{ .word = "Vignette", .action = .{ .scene = .vignette }, .availability = .scene_shaders, .doc = "The window's corners fall into shade: a level, 0 (off) through 3." },
+ .{ .word = "Grain", .action = .{ .scene = .grain }, .availability = .scene_shaders, .doc = "The page takes a fine, still grain, like paper: a level, 0 (off) through 3." },
+ .{ .word = "Shader", .action = .shader, .availability = .scene_shaders, .doc = "A Shadertoy file into the post chain, or out of it; off empties the chain." },
+ .{ .word = "ShaderAnimation", .action = .shader_animation, .availability = .scene_shaders, .doc = "When the post chain animates on its own: off, on (while focused) or always." },
+ .{ .word = "Placement", .action = .{ .choice = .placement }, .doc = "Where a new pane goes: acme, as makenewwindow does, or pardes, the older rules." },
+ .{ .word = "BootShell", .action = .{ .choice = .boot_shell }, .doc = "A document dropped where a lone untouched shell stands: keep the shell, or replace it." },
+ .{ .word = "LookWord", .action = .{ .choice = .look_word }, .doc = "A plain word looked at: search selects its next place in the pane, list lists every place in a +Search." },
};
pub fn find(name: []const u8) ?Setting {
@@ -1052,8 +1070,9 @@ pub const Runtime = struct {
}
},
.shell => {
- const value = std.mem.trim(u8, argument orelse return false, " \t\r\n");
- if (value.len == 0 or !state.shell.requested.set(value)) return false;
+ // Bare, the default again ($SHELL, else /bin/sh).
+ const value = std.mem.trim(u8, argument orelse "", " \t\r\n");
+ if (!state.shell.requested.set(value)) return false;
state.shell.pending = true;
},
.tagline_size => {
@@ -1379,7 +1398,7 @@ pub const Runtime = struct {
try out.writeAll("Startup config: no per-user config path\n");
try out.print(
"Platform: {s}\n" ++
- "Compiled default shell: {s}\n",
+ "Default shell ($SHELL, else /bin/sh): {s}\n",
.{ context.platform, context.compiled_default_shell },
);
if (context.gui_shader_source_mode) |mode|
@@ -1641,6 +1660,7 @@ pub const Runtime = struct {
.choice => |which| switch (which) {
.placement => "pardes",
.boot_shell => "replace",
+ .look_word => "list",
},
.lift => "rim",
.motion => "playful",
@@ -1703,6 +1723,7 @@ pub const Runtime = struct {
.choice => |which| switch (which) {
.placement => "Placement pardes\n",
.boot_shell => "BootShell replace\n",
+ .look_word => "LookWord list\n",
},
.lift => "Lift rim\n",
.motion => "Motion playful\n",
@@ -1738,7 +1759,7 @@ pub const Runtime = struct {
"TaglineSize 82\n",
"Startup config: /tmp/pardes/init\n",
"Platform: gui\n",
- "Compiled default shell: /bin/sh\n",
+ "Default shell ($SHELL, else /bin/sh): /bin/sh\n",
"GUI shader source: live GLSL compiled during this build\n",
"Look hover delay: 18 frames\n",
"Native images: on\n",