summaryrefslogtreecommitdiff
path: root/core/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/builtins.zig')
-rw-r--r--core/builtins.zig729
1 files changed, 563 insertions, 166 deletions
diff --git a/core/builtins.zig b/core/builtins.zig
index 9649d7b8..a236b0d6 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -1,4 +1,15 @@
//! Command structs and runtime settings form the builtin registry; bindings live in config.zig.
+//!
+//! THE CONVENTION: the `///` block right above a builtin's `pub const
+//! <Word> = struct` is what a USER reads, in Help, `pardes help`, /commands,
+//! `pardes words` and the manual's glossary (`registry.doc`): what the word
+//! does, its argument's forms as typed, what it does bare, where its answer
+//! goes, an example where the forms are not obvious. No file names, no
+//! "registration", no history: notes for whoever reads the code are `//`
+//! lines inside the struct. Its first sentence (to the first `. `) is the
+//! summary, at most `summary_max` bytes; a blank `///` starts a paragraph.
+//! The compiler holds it: a builtin with no `///`, a summary past the bound
+//! or a `///` naming a .zig file fails the build, naming the builtin.
const std = @import("std");
const pardes = @import("root.zig");
const tagline = @import("tagline.zig");
@@ -152,6 +163,46 @@ pub fn word(comptime T: type) []const u8 {
return n[dot + 1 ..];
}
+/// A builtin's documentation (THE CONVENTION, at the top of this file).
+pub const Doc = struct {
+ /// Its first sentence: a line of /commands and of `pardes words`.
+ summary: []const u8,
+ /// All of it, a line a paragraph, the summary first.
+ text: []const u8,
+};
+
+/// The longest summary, in bytes: a line's worth after its word.
+pub const summary_max = 100;
+
+/// `text`'s first sentence: to the first `.` a blank or a line's end
+/// follows (`a.zig@main` and `from..to` go on).
+fn docOf(comptime text: []const u8) Doc {
+ for (text, 0..) |c, i| {
+ if (c == '\n') return .{ .summary = text[0..i], .text = text };
+ if (c == '.' and (i + 1 == text.len or text[i + 1] == ' ' or text[i + 1] == '\n')) return .{ .summary = text[0 .. i + 1], .text = text };
+ }
+ return .{ .summary = text, .text = text };
+}
+
+/// The `///` lines from `from` to `to` in `source` as paragraphs: each
+/// line's text after `///` joined to the next by a blank, a blank `///` a
+/// line break.
+fn paragraphs(comptime source: []const u8, comptime from: usize, comptime to: usize) []const u8 {
+ var text: []const u8 = "";
+ var lines = std.mem.splitScalar(u8, source[from..to], '\n');
+ var gap: []const u8 = "";
+ while (lines.next()) |line| {
+ const said = std.mem.trim(u8, line["///".len..], " ");
+ if (said.len == 0) {
+ if (text.len > 0) gap = "\n";
+ continue;
+ }
+ text = text ++ (if (text.len == 0) "" else if (gap.len > 0) gap else " ") ++ said;
+ gap = "";
+ }
+ return text;
+}
+
pub const OutputTraits = struct {
name: []const u8,
steps: bool = false,
@@ -204,6 +255,63 @@ pub const registry = struct {
return setting;
}
+ /// What a user reads of builtin `b` (THE CONVENTION, at the top).
+ pub fn doc(b: Builtin()) Doc {
+ return docs[@backingInt(b)];
+ }
+
+ /// Each builtin's documentation, by its number: a hand-written one's
+ /// the `///` block above it, read off this file at compile time; a
+ /// setting's its `doc`.
+ const docs = docs: {
+ const manual = manualBuiltinList();
+ const generated = settingList();
+ var table: [manual.len + generated.len]Doc = undefined;
+ var found: [manual.len]bool = @splat(false);
+ // a few branches a byte of the source, once
+ @setEvalBranchQuota(4_000_000);
+ const source = @embedFile("builtins.zig");
+ var block: ?usize = null; // where the `///` lines above this one start
+ var block_end: usize = 0;
+ var at: usize = 0;
+ while (at < source.len) {
+ const end = std.mem.indexOfScalarPos(u8, source, at, '\n') orelse source.len;
+ const line = source[at..end];
+ if (std.mem.startsWith(u8, line, "///")) {
+ if (block == null) block = at;
+ block_end = end;
+ } else {
+ if (block) |from| if (std.mem.startsWith(u8, line, "pub const ")) {
+ const rest = line["pub const ".len..];
+ if (std.mem.indexOf(u8, rest, " = struct")) |name_end| for (manual, 0..) |T, i| {
+ if (!std.mem.eql(u8, word(T), rest[0..name_end])) continue;
+ table[i] = docOf(paragraphs(source, from, block_end));
+ found[i] = true;
+ };
+ };
+ block = null;
+ }
+ at = end + 1;
+ }
+ for (manual, 0..) |T, i| {
+ if (!found[i]) @compileError("builtin " ++ word(T) ++ " has no documentation: a `///` block right above `pub const " ++ word(T) ++ " = struct`");
+ held(word(T), table[i]);
+ }
+ for (generated, manual.len..) |setting, i| {
+ table[i] = docOf(setting.doc);
+ held(setting.word, table[i]);
+ }
+ break :docs table;
+ };
+
+ /// THE CONVENTION's two rules the compiler can read.
+ fn held(comptime name: []const u8, comptime d: Doc) void {
+ if (d.summary.len > summary_max)
+ @compileError(std.fmt.comptimePrint("builtin {s}: its first sentence is {d} bytes, over {d}: \"{s}\"", .{ name, d.summary.len, summary_max, d.summary }));
+ if (std.mem.indexOf(u8, d.text, ".zig") != null)
+ @compileError("builtin " ++ name ++ ": its documentation names a source file; a note for the code's reader is a `//` line inside the struct");
+ }
+
pub fn takesArg(b: Builtin()) bool {
// Every setting takes its value, and a switch flips when bare.
return declOr(b, "takes_arg", false, true);
@@ -267,7 +375,14 @@ pub const registry = struct {
// ---- the two acme verbs ----
-/// Look at its argument: open the file or address it names, else find the word, as a right click does.
+/// Look at its argument as B3 does: open the file or address it names, else
+/// find the word.
+///
+/// `Look notes.txt:12` opens the file at line 12, or goes to the pane already
+/// showing it; an address may be a line, `:12:5`, `/re/`, a directory (a pane
+/// listing it) or a URL (the browser, by a plumbing rule). A relative path is
+/// found in the directory of the pane looked from, then of each pane on the
+/// jump list. Bare (Enter): the selection, else what is under the cursor.
pub const Look = struct {
pub const takes_arg = true;
pub const requires_arg = true;
@@ -282,7 +397,13 @@ pub const Look = struct {
}
};
-/// Execute its argument as a middle click on it would, a builtin or a shell command.
+/// Run its argument as B2 on it would: a builtin, else a shell command.
+///
+/// `Exec Newcol` runs the builtin. `Exec make test` runs the line: from a
+/// terminal at an idle, empty prompt, typed into its shell; from anywhere
+/// else, in a command pane (a terminal running `$SHELL -c` the line, which
+/// shows its output and `exit N` when it ends; Kill stops it). Run by name, a
+/// line is never a REPL's.
pub const Exec = struct {
pub const takes_arg = true;
pub const requires_arg = true;
@@ -394,10 +515,14 @@ pub fn warnModifiedIn(c: Ctx, asking: Pane.Discarding, which: Asked) bool {
return count > 0;
}
-/// Quit the editor, refusing once while a pane holds unsaved text: an Exit
-/// with nothing edited since discards it (acme's Exit, editors/acme/exec.c:892,
-/// asking warnModified first).
+/// Quit the editor; refused once while a pane holds unsaved text.
+///
+/// Each pane with unsaved text is listed in +Unsaved and the notice counts
+/// them; Exit again, nothing edited since, quits and discards it. On the way
+/// out the session's panes are kept in the state file, for History and
+/// Restore.
pub const Exit = struct {
+ // acme's Exit (editors/acme/exec.c:892), asking warnModifiedIn first.
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
if (warnModifiedIn(c, .Exit, .all)) return;
@@ -406,14 +531,16 @@ pub const Exit = struct {
}
};
-/// acme's Kill (exec.c, `kill`; acme.c's WKill): stop the commands pardes
-/// started -- the lines it typed into a terminal, from an exec, a middle
-/// click or a pty/run, while their shell says they run (C mark to D).
-/// Bare, every one; `Kill make ls`, those whose line starts with one of
-/// the words. acme posts the "kill" note, which ends a process; here that
-/// is SIGTERM to the terminal's foreground job, and never to the shell,
-/// which is its own job and stays.
+/// Stop the commands pardes started that are still running.
+///
+/// They are the lines pardes typed into a terminal (from an exec, a middle
+/// click, a pty/run) and its command panes. Bare, every one; `Kill make ls`,
+/// those whose line starts with one of the words. Each gets SIGTERM: a
+/// command pane's whole command, a terminal's foreground job, never its
+/// shell, which stays.
pub const Kill = struct {
+ // acme's Kill (exec.c, `kill`; acme.c's WKill) posts the "kill" note,
+ // which ends a process; here a terminal's job between its C and D marks.
pub const scope: Scope = .session;
pub const takes_arg = true;
pub fn run(c: Ctx) void {
@@ -462,8 +589,11 @@ pub const Kill = struct {
}
};
-/// Write the session's panes and layout to the state file, for Restore;
-/// `Dump export <path>` writes them to a file of their own instead.
+/// Write the session's panes and layout to the state file, for Restore.
+///
+/// `Dump export <path>` writes them to a file of their own instead (`~` the
+/// home directory). The workspace tag then holds a `Restore <path>` word that
+/// brings them back.
pub const Dump = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -481,8 +611,13 @@ pub const Dump = struct {
}
};
-/// Replace every pane with those of a dump: the state file's of that label,
-/// or a file's; bare, the last one this session made, else the newest.
+/// Replace every pane with those of a dump.
+///
+/// `Restore <label>`: the state file's dump of that label (History lists
+/// them); `Restore <file>`: a dump file's, a path, or the name of a file in
+/// the DumpDir or the directory pardes runs in. Bare: the last one this
+/// session made, else the newest. A file that is not a dump is said first;
+/// then, as Exit, it is refused once while a pane holds unsaved text.
pub const Restore = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -532,7 +667,9 @@ pub const Restore = struct {
};
/// Detach this pardes from its terminal or window, leaving the session
-/// running: `pardes attach` (or `pardes-gui attach`) shows it as a client.
+/// running.
+///
+/// `pardes attach` (or `pardes-gui attach`) shows it again, as a client.
pub const Detach = struct {
pub const scope: Scope = .session;
pub const enabled = pardes.can_attach;
@@ -541,8 +678,11 @@ pub const Detach = struct {
}
};
-/// Take in the shells of a session that died holding them, each as a
-/// terminal pane here: the pardes daemon kept their terminals open.
+/// Take in the shells of a session that died holding them, each as a terminal
+/// here.
+///
+/// The pardes daemon kept their terminals open; with none kept for this
+/// session, it says so.
pub const Adopt = struct {
pub const scope: Scope = .session;
pub const enabled = pardes.can_attach;
@@ -551,9 +691,11 @@ pub const Adopt = struct {
}
};
-/// Move this session onto the pardes installed since it started, in place:
-/// its text, undo, views, terminals with their running shells, and its
-/// terminals and windows come along. The pardes daemon moves too.
+/// Move this session onto the pardes installed since it started, in place.
+///
+/// Its text, undo, views, terminals with their running shells, and its
+/// terminals and windows come along; the pardes daemon moves too. A pardes
+/// that cannot move to another build in place says so.
pub const Upgrade = struct {
pub const scope: Scope = .session;
pub const enabled = pardes.can_attach;
@@ -563,6 +705,10 @@ pub const Upgrade = struct {
};
/// Mount another pardes's 9P tree under /n/<name>, given its dial address.
+///
+/// `Mount <name> <dial>`, the dial `unix!/path`, a socket's path,
+/// `tcp!<numeric-ip>!<port>` or a session's name. One that cannot be reached
+/// is said at once, and not kept.
pub const Mount = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -603,7 +749,7 @@ pub const Mount = struct {
}
};
-/// Unmount the 9P tree mounted under /n/<name>.
+/// Unmount the 9P tree mounted under /n/<name>: `Unmount <name>`.
pub const Unmount = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -625,7 +771,7 @@ pub const Unmount = struct {
// ---- the message row ----
-/// Show its argument on this pane's message row.
+/// Show its argument on this pane's message row: `Msg built`.
pub const Msg = struct {
pub const takes_arg = true;
pub const requires_arg = true;
@@ -646,7 +792,7 @@ pub const NextColor = struct {
}
};
-/// List the themes in a pane, each a word to click.
+/// List the bundled themes in a +Themes, each a `Theme <name>` line to run.
pub const Themes = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.themes_buffer, .steps = true, .commands = true };
@@ -655,7 +801,9 @@ pub const Themes = struct {
}
};
-/// Load a theme from a file.
+/// Load a theme from a .zon file: `ThemeFile ~/themes/mine.zon`.
+///
+/// DumpThemes writes the bundled ones out to start from.
pub const ThemeFile = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -672,7 +820,10 @@ pub const ThemeFile = struct {
}
};
-/// Write the bundled themes into the config directory's themes, to edit.
+/// Write the bundled themes into the configuration directory's themes, to
+/// edit.
+///
+/// ThemeFile loads one back.
pub const DumpThemes = struct {
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
@@ -684,7 +835,7 @@ pub const DumpThemes = struct {
}
};
-/// List the fonts in a pane, each a word to click.
+/// List this machine's fonts in a +Fonts, each a `Font <name>` line to run.
pub const Fonts = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.fonts_buffer, .steps = true, .commands = true };
@@ -696,7 +847,10 @@ pub const Fonts = struct {
}
};
-/// Show the declarations enclosing the top row at the pane's head, on or off.
+/// Show, at the pane's head, the declarations its top row is in.
+///
+/// `TreeContext on` or `off` sets it; bare, it flips. Only a source file the
+/// parser knows has them.
pub const TreeContext = struct {
pub const takes_arg = true;
@@ -728,8 +882,10 @@ fn stateArg(c: Ctx, comptime T: type, comptime builtin_word: []const u8, comptim
const OnOff = enum { on, off };
-/// Addons, the libraries that bring kinds of pane: `Addon load <path>`,
-/// `Addon unload <name>`, `Addon reload <name>`; bare, the kinds here.
+/// Load, unload or reload an addon, a library that brings a kind of pane.
+///
+/// `Addon load <path>`, `Addon unload <name>`, `Addon reload <name>`; bare,
+/// the kinds here.
pub const Addon = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -738,8 +894,11 @@ pub const Addon = struct {
}
};
-/// glyph art over the host's pixels: an image pane's picture, or the
-/// kitty graphics a terminal's program placed (yazi's previews)
+/// Draw an image pane's picture, or a terminal's kitty graphics, as glyph
+/// art.
+///
+/// `Petscii on` or `Petscii off` sets it; bare, it flips. A terminal's kitty
+/// graphics are the pictures its program placed (yazi's previews).
pub const Petscii = struct {
pub const needs: PaneKind = .picture;
pub const takes_arg = true;
@@ -755,7 +914,10 @@ pub const Petscii = struct {
}
};
-/// the C64 palette or the terminal's own 16
+/// Draw an image pane's glyph art in the C64 palette, or in the terminal's
+/// own 16 colours.
+///
+/// `Palette commodore` or `Palette terminal` sets it; bare, it flips.
pub const Palette = struct {
pub const needs: PaneKind = .image;
pub const takes_arg = true;
@@ -769,7 +931,10 @@ pub const Palette = struct {
}
};
-/// add the printable ASCII bitmaps to the matcher's glyph set
+/// Add the printable ASCII glyphs to those an image pane's glyph art is made
+/// of, or take them out.
+///
+/// `Ascii on` or `off` sets it; bare, it flips.
pub const Ascii = struct {
pub const needs: PaneKind = .image;
pub const takes_arg = true;
@@ -786,14 +951,19 @@ pub const Ascii = struct {
// ---- the system clipboard ----
/// Copy the selection to the system clipboard.
+///
+/// Every cursor's selection, joined; in an image or a PDF's pane, what it has
+/// selected.
pub const ClipYank = struct {
pub fn run(c: Ctx) void {
edit.clipYank(c.p, c.pane, false);
}
};
-/// helix `<space>Y`: the PRIMARY selection alone, where `SPC y` joins every
-/// cursor's. One cursor makes them the same word.
+/// Copy the primary selection alone to the system clipboard.
+///
+/// ClipYank (`SPC y`) copies every cursor's selection, joined; with one
+/// cursor the two are the same.
pub const ClipYankMain = struct {
pub fn run(c: Ctx) void {
edit.clipYank(c.p, c.pane, true);
@@ -823,9 +993,11 @@ pub const ClipReplace = struct {
// ---- panes and columns ----
-/// acme's Get: the pane's file read again, its unsaved edits refused once
-/// as Del refuses them. `Get file` loads that file into the pane instead,
-/// the pane taking its name.
+/// Read this pane's file again from disk; refused once over unsaved edits, as
+/// Del is.
+///
+/// `Get <file>` loads that file into the pane instead, the pane taking its
+/// name. In a directory's pane, it reads the directory again.
pub const Get = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
@@ -861,10 +1033,12 @@ pub const Get = struct {
}
};
-/// acme's Putall: every pane holding unsaved edits to a file is saved, each
-/// as its own Save; one that is refused (changed on disk since, a write
-/// that fails) says so and the rest are saved all the same.
+/// Save every pane holding unsaved edits to a file, each as its own Save.
+///
+/// One that is refused (changed on disk since, a write that fails) says so,
+/// and the rest are saved all the same.
pub const Putall = struct {
+ // acme's Putall.
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
for (c.p.panes, 0..) |slot, id| {
@@ -880,10 +1054,13 @@ pub const Putall = struct {
}
};
-/// acme's Incl, for the session: `Incl dir ...` adds directories a look at a
-/// name found nowhere else is tried in (`stdio.h`, `<foo.h>`), bare lists
-/// them, `Incl -` empties the list.
+/// Add directories where a Look tries a name it finds nowhere else
+/// (`stdio.h`, `<foo.h>`).
+///
+/// `Incl <dir> ...` adds them, each absolute or from `~`; bare, it lists
+/// them; `Incl -` empties the list. The list is the session's.
pub const Incl = struct {
+ // acme's Incl, for the session.
pub const scope: Scope = .session;
pub const takes_arg = true;
pub fn run(c: Ctx) void {
@@ -935,9 +1112,11 @@ pub const Incl = struct {
}
};
-/// Open the plumbing file, the plumber's rules (plumb(6)'s rule sets) in
-/// the configuration directory beside `init`: saved, they are the rules in
-/// force. Not there yet, it holds `include basic`, the default rules.
+/// Open the plumbing file, the plumber's rules, in the configuration
+/// directory beside `init`.
+///
+/// Saved, they are the rules in force (plumb(6)'s rule sets). Not there yet,
+/// it holds `include basic`, the default rules.
pub const Plumb = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -950,9 +1129,13 @@ pub const Plumb = struct {
}
};
-/// acme's Zerox: a second pane on this pane's file, the same text, undo and
-/// unsaved state, with a scroll and a cursor of its own (File.zerox).
+/// Open a second pane on this pane's file: the same text, undo and unsaved
+/// state.
+///
+/// Each pane keeps a scroll and a cursor of its own. Only a file's pane takes
+/// it.
pub const Zerox = struct {
+ // acme's Zerox (File.zerox).
pub fn run(c: Ctx) void {
if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Zerox: " ++ @import("edit_cmd.zig").e_busy);
const f = c.pane.file orelse return c.p.reportFailure(c.id, "Zerox: only a file pane takes it");
@@ -964,6 +1147,11 @@ pub const Zerox = struct {
};
/// Write the pane's text to its file, or to the file its argument names.
+///
+/// `Save <path>` writes it there. Bare, a pane with no file of its own (a
+/// +New, a list, a terminal) asks for a path; a file at a revision is
+/// read-only, written only to a path. Over a file changed on disk since it
+/// was read, it warns once.
pub const Save = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
@@ -995,7 +1183,10 @@ pub const Save = struct {
}
};
-/// Open an empty scratch pane, <dir>/+New, in this pane's directory.
+/// Open an empty scratch pane, +New, in this pane's directory.
+///
+/// It takes the keyboard. Save asks it for a path to write to; past 100
+/// bytes, Exit, Del and Restore ask about its text as about a file's.
pub const New = struct {
pub const output: OutputTraits = .{ .name = config.scratch_buffer, .doc = true, .saves = true };
pub fn run(c: Ctx) void {
@@ -1003,7 +1194,10 @@ pub const New = struct {
}
};
-/// An empty column right of the keyboard's, its tag taking the keyboard.
+/// Make an empty column right of the keyboard's, its tag taking the keyboard.
+///
+/// The next pane made from there goes in it. Refused, saying why, when no
+/// column fits.
pub const Newcol = struct {
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
@@ -1011,9 +1205,13 @@ pub const Newcol = struct {
}
};
-/// Close the pane. `Del k` gives its rows to the open pane above it and
-/// `Del j` to the one below, each falling back to the other side. Focus on
-/// it goes with its rows.
+/// Close the pane.
+///
+/// `Del k` gives its rows to the pane above it, `Del j` to the one below,
+/// each falling back to the other side; bare, from the keyboard between two
+/// panes, it asks k or j on the pane's notice band. A docked pane's rows go
+/// back to the pane it answers for. Refused once while the pane holds unsaved
+/// text (listed in +Unsaved); Del again, nothing edited since, closes it.
pub const Del = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
@@ -1057,7 +1255,10 @@ pub const Del = struct {
}
};
-/// Recolour a terminal's or a +Pager's program colours to the theme, or show them as sent, flipping between them.
+/// Recolour a terminal's or a +Pager's program colours to the theme, or show
+/// them as sent.
+///
+/// Each Filter flips between the two.
pub const Filter = struct {
pub const needs: PaneKind = .program_colors;
pub fn run(c: Ctx) void {
@@ -1065,49 +1266,103 @@ pub const Filter = struct {
}
};
-/// Turn a text's syntax colours off in this view, or on again.
-/// The ink layer (File.Layers).
+/// Turn this text's syntax colours off in this view, or on again.
pub const Syntax = struct {
+ // The ink layer (File.Layers).
pub fn run(c: Ctx) void {
if (c.pane.file == null) return c.p.reportFailure(c.id, "Syntax: only a text pane has it");
c.pane.layers.ink = !c.pane.layers.ink;
}
};
-/// Show a file as it was at revision `rev` (jj), read-only, beside its pane; in such a pane, that file at another revision in its place, or bare, the file.
+/// Show this file as it was at a jj revision, read-only, beside its pane.
+///
+/// `At <rev>` (`At main`, `At @-`) opens `path@rev`, as a Look at that name
+/// does. In such a pane, `At <rev>` turns it to that revision, the cursor's
+/// line kept, and bare `At` opens the file itself. What jj refuses is said in
+/// jj's words.
pub const At = struct {
pub const takes_arg = true;
pub const run = @import("jj.zig").word;
};
-/// Pin the changes `revset` names (jj) on a file's pane and show them in every view of it: a lane each after the line number, a line one added whole green, what the file no longer has as lines of its text where it stood, read-only (a line taken away whole red, each change's description after its last line); bare, shown or not (none pinned yet: `@`).
+/// Draw jj's changes to this file on its own pane: a lane each, and what they
+/// took away.
+///
+/// `Changes <revset>` pins the revset's changes that touched the file on its
+/// pane, or a revision's (`notes.md@main`), and shows them in every view of
+/// it: `Changes @-::@`, `Changes trunk()..@`. One set a pane: a later Changes
+/// or Compare replaces it. Bare: hidden, or shown again; with none pinned
+/// yet, `@`.
+///
+/// Each change gets a lane after the line number. What the file no longer has
+/// stands where it stood as lines of the pane's text with no number,
+/// read-only: the cursor, a selection, a search, B2 and B3 work there, and an
+/// edit that touches one is refused. After a change's last line comes its
+/// description, `id title author age`, its lane ending in an arrow at it; a
+/// long one wraps. `] g` and `[ g` step through the changes; B3 on a
+/// description's id opens that change's patch at that line
+/// (`Diff <id> <path>:<line>`).
pub const Changes = struct {
pub const takes_arg = true;
pub const run = @import("jj.zig").changesWord;
};
-/// Pin on a file's pane the file's whole difference between each two of `points` (jj revisions, a blank between, two or more) as one change, however many changes lie between them, and show them in every view of it as `Changes` shows a change: a lane each, the lines it wrote and took away, its row `from..to N changes dates` after its last line; bare, as bare `Changes`.
+/// Draw the file's difference between each two jj revisions as one change, as
+/// Changes draws one.
+///
+/// `Compare <rev> <rev> [<rev> ...]`: two points or more in their order, each
+/// one revision (a commit or change id, a bookmark, `master@origin`, `@`):
+/// `Compare 9ef6312813 ea63317630 master@origin`. A pair is drawn as one
+/// change however many lie between its points; after its last line, its row:
+/// the two points, how many changes lie between them, their first and last
+/// days. One set a pane: a later Changes or Compare replaces it. Bare: as
+/// bare Changes.
pub const Compare = struct {
pub const takes_arg = true;
pub const run = @import("jj.zig").compareWord;
};
-/// Count, for each declaration of a file's pane, the changes in `window` (jj) that touched it, and show it in this view: a heat lane after the line number and a strip by the scroll thumb, the line numbers' grey to the theme's red on a log scale; `window` a revset or a span of time (`3d`, `2w`, `6m`, `1y`); bare, shown here or not (none counted yet: the file's whole history).
+/// Show how many changes touched each declaration of this file, as a heat
+/// lane.
+///
+/// `Churn <window>`: a revset, or a span of time back from now (`3d`, `2w`,
+/// `6m`, `1y`). In this view a cell after the line number, from the line
+/// numbers' grey to the theme's red on a log scale, and a strip by the scroll
+/// thumb. Bare: hidden in this view or shown again; with none counted yet,
+/// the file's whole history.
pub const Churn = struct {
pub const takes_arg = true;
pub const run = @import("jj.zig").churnWord;
};
-/// 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. `Diff <file>` stacks that diff's, `Diff <revision>` git show's.
-/// The diff viewer's one registration: its word and traits here, all else
-/// its own (hunks.zig).
+/// Show a diff's hunks stacked in a +Diff, each under its place, as a diff
+/// viewer shows them.
+///
+/// Bare, on a diff (a .diff, a .patch, a +Pager holding one): its hunks
+/// stacked; on a +Diff: the diff itself, as text. `Diff <file>`: that .diff's
+/// or .patch's hunks. `Diff <hash>` (7 to 40 hex digits): `git show` of that
+/// commit, in its own `+Diff-<hash>`. `Diff <change> [path[:line]]` (a jj
+/// change id): its patch, its header and whole message on top, the cursor at
+/// that place. `Diff <from>..<to> [path[:line]]`: the difference between two
+/// points, the changes between them on top.
+///
+/// Each hunk stands under its `path:line` and the declarations around it, a +
+/// or - before each line, the words a changed line changed tinted. `SPC j n`
+/// and `SPC j p` step through the hunks; B3 on a place opens it.
pub const Diff = struct {
+ // The diff viewer's one registration: its word and traits here, all else
+ // its own (hunks.zig).
pub const takes_arg = true;
pub const output: OutputTraits = .{ .name = config.diff_buffer, .steps = true, .locations = true };
pub const run = @import("hunks.zig").word;
};
-/// Cycle the pane's input modes: terminals add raw tty mode to normal/insert.
+/// Step this pane to its next input mode: normal, insert, and in a terminal
+/// raw.
+///
+/// From the last it goes back to normal. The keyboard goes to the pane's
+/// text.
pub const Mode = struct {
pub fn run(c: Ctx) void {
if (c.pane.file == null and !c.pane.isTerminal()) return c.p.reportFailure(c.id, "Mode: only a text or terminal pane has modes");
@@ -1115,7 +1370,8 @@ pub const Mode = struct {
}
};
-/// Switch this terminal between raw program input and normal editor mode.
+/// Switch this terminal between raw mode, its keys the program's, and normal
+/// mode.
pub const Togglettymode = struct {
pub const needs: PaneKind = .terminal;
pub fn run(c: Ctx) void {
@@ -1123,12 +1379,16 @@ pub const Togglettymode = struct {
}
};
-/// acme's Edit (exec.c `edit`, edit.c): sam's command language over the
-/// open text panes, from a tag, a pane ctl or exec, starting in the pane's
-/// body. One undo step in each file it changes; a failure changes nothing
-/// and says why. core/edit_cmd.zig runs it; core/sam_edit.zig has what is
-/// left out.
+/// Run a command of sam's language over the open text panes, starting in this
+/// pane's body.
+///
+/// `Edit ,s/old/new/g` changes every old to new in this pane's text. As
+/// acme's Edit: from a tag, a pane's ctl or an exec; one undo step in each
+/// file it changes; a failure changes nothing and says why. Left out of
+/// sam's: the `'` address, `B <cmd` and `D <cmd`, and `\1` to `\9` in `s`.
pub const Edit = struct {
+ // acme's Edit (exec.c `edit`, edit.c). core/edit_cmd.zig runs it;
+ // core/sam_edit.zig has what is left out.
pub const takes_arg = true;
pub const requires_arg = true;
pub fn run(c: Ctx) void {
@@ -1136,12 +1396,12 @@ pub const Edit = struct {
}
};
-/// acme's Undo and Redo (exec.c `undo`): step the pane's body back or
-/// forward through its edits, from a tag, a pane ctl or exec.
-/// With no step left, Undo and Redo say so and change nothing; a ctl write
-/// of them still succeeds, as acme's Undo is silent there. A file keeps
-/// limits.undo_max steps (256).
+/// Step the pane's text back one edit.
+///
+/// With no step left, it says so and changes nothing (a ctl write of it still
+/// succeeds, as acme's Undo is silent there). A file keeps 256 steps.
pub const Undo = struct {
+ // acme's Undo and Redo (exec.c `undo`); limits.undo_max steps.
pub fn run(c: Ctx) void {
if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Undo: " ++ @import("edit_cmd.zig").e_busy);
if (c.pane.file) |f| if (f.history.journal.done == 0) return c.p.setMessage(.at(c.id), "Undo: nothing to undo");
@@ -1149,7 +1409,9 @@ pub const Undo = struct {
}
};
-/// Redo the last undone edit.
+/// Step the pane's text forward again, one edit Undo took back.
+///
+/// With none left, it says so and changes nothing.
pub const Redo = struct {
pub fn run(c: Ctx) void {
if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Redo: " ++ @import("edit_cmd.zig").e_busy);
@@ -1158,16 +1420,17 @@ pub const Redo = struct {
}
};
-/// Fold a pane to its tag, or restore its share of the column.
+/// Fold this pane to its tag, or give it its share of the column again.
pub const Collapse = struct {
pub fn run(c: Ctx) void {
layout.toggleCollapse(c.p, c.id);
}
};
-/// Undock a pane from the pane it answers for: it stays where it is, a
-/// pane of its own, and the next search from that pane opens another
-/// under it.
+/// Undock a pane from the pane it answers for: it stays where it is, a pane
+/// of its own.
+///
+/// The next search from that pane opens another under it.
pub const Undock = struct {
pub fn run(c: Ctx) void {
if (c.pane.docked_to == null) return c.p.reportFailure(c.id, "Undock: not docked to a pane");
@@ -1175,7 +1438,11 @@ pub const Undock = struct {
}
};
-/// Close this column and its panes, refusing once over unsaved text.
+/// Close this column and its panes.
+///
+/// The column is the one whose tag it ran from, else the pane's. Refused once
+/// while a pane in it holds unsaved text, the notice saying how many; Delcol
+/// again, nothing edited since, closes them.
pub const Delcol = struct {
pub fn run(c: Ctx) void {
// The column of the tag it came from, else the pane's: a pane ctl's
@@ -1188,24 +1455,26 @@ pub const Delcol = struct {
}
};
-/// Close the pane, giving its rows to the pane above it.
+/// Close the pane, giving its rows to the pane above it, as `Del k` does.
pub const DelAbove = struct {
pub fn run(c: Ctx) void {
Del.run(.{ .p = c.p, .pane = c.pane, .id = c.id, .txt = c.txt, .arg = "k" });
}
};
-/// Close the pane, giving its rows to the pane below it.
+/// Close the pane, giving its rows to the pane below it, as `Del j` does.
pub const DelBelow = struct {
pub fn run(c: Ctx) void {
Del.run(.{ .p = c.p, .pane = c.pane, .id = c.id, .txt = c.txt, .arg = "j" });
}
};
-/// A shell in the calling pane's directory, raw from the first frame. On every
-/// pane's tagline: the fast path from wherever you are to a prompt there.
-/// A terminal below the caller in its directory: the configured shell, or
-/// the one named, `Term fish`, as a terminal's own tag word `Term+fish` says.
+/// Open a terminal below this pane, in its directory, raw: its keys the
+/// shell's at once.
+///
+/// `Term fish` runs that shell instead of the Shell setting's, as a
+/// terminal's own tag word `Term+fish` says; a shell that is not there is
+/// said. A directory that is not there makes no terminal.
pub const Term = struct {
pub const takes_arg = true;
pub const plus_arg = true;
@@ -1226,18 +1495,19 @@ pub const Term = struct {
}
};
-/// Binds this terminal as a language's REPL, so an exec on that language's
-/// files is typed into it instead of run. The language is named as the
-/// syntax table has it: an exec made on the body of a file in that
-/// language -- a middle click, the execute key, a single word like `ls`
-/// as much as a selection -- and one made on this terminal's own body, is
-/// typed into it (bracketed paste if its program asked for that, else line
-/// by line, then Enter) instead of run. `Repl python` binds (again, it is
-/// already); `Repl -` unbinds; `Repl` bare says what it is bound as. With
-/// several bound for a language, the exec asks which.
-/// Still commands, whatever is bound: a word in a tag, `Exec <text>` run by
-/// name (typed, a 2-1 chord onto Exec, a ctl line), and a command word
-/// @`cmd` in the text, looked at or clicked.
+/// Bind this terminal as a language's REPL: an exec on that language's files
+/// is typed into it.
+///
+/// `Repl python` binds it (the language named as a code fence names it: `py`,
+/// `Python`, `sh`); `Repl -` unbinds it; bare, it says what it is bound as.
+/// An exec made on the body of a file in that language (a middle click, the
+/// execute key, a single word like `ls` as much as a selection), and one made
+/// on this terminal's own body, is typed into it (bracketed paste if its
+/// program asked for that, else line by line, then Enter) instead of run.
+/// With several bound for a language, the exec asks which.
+///
+/// Still commands, whatever is bound: a word in a tag, `Exec <text>`, a ctl
+/// line, and a command word @`cmd` in the text, looked at or clicked.
pub const Repl = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
@@ -1304,8 +1574,10 @@ pub const Repl = struct {
}
};
-/// Fold the active pane's column into the one on its right, keeping its panes.
-/// The horizontal mirror of the vertical stacking `New` does.
+/// Fold the keyboard's column into the one on its right, keeping its panes.
+///
+/// Refused for the last column, and where the joined column could not give
+/// each pane its tag and 2 rows.
pub const Joincol = struct {
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
@@ -1329,17 +1601,31 @@ pub const Tutor = struct {
}
};
-/// Open the help: every key and every builtin.
+/// Show every builtin with its keys and documentation, or one builtin's alone.
+///
+/// `Help <name>`: that builtin alone, its keys spelled out, what it acts on
+/// and its line for a shell (`Help Diff`); a setting or an addon's word the
+/// same. `Help <keys>`: the builtins under SPC and those keys (`Help l`, as
+/// `SPC l ?` shows them). Each fills the one +Help: a second Help replaces
+/// its text.
pub const Help = struct {
pub const scope: Scope = .session;
+ pub const takes_arg = true;
pub const output: OutputTraits = .{ .name = config.help_buffer };
pub fn run(c: Ctx) void {
- panes.Output.openHelp(c.p, c.id, "") catch |err| c.p.reportError(.at(c.id), "help", err);
+ const what = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
+ if (what.len == 0) return panes.Output.openHelp(c.p, c.id, "") catch |err| c.p.reportError(.at(c.id), "help", err);
+ const found = panes.Output.openHelpOn(c.p, c.id, what) catch |err| return c.p.reportError(.at(c.id), "help", err);
+ if (found) return;
+ var said: pardes.Kind.Buf(128) = .{};
+ c.p.reportFailure(c.id, said.print("Help: {s}: no such builtin, nor SPC keys", .{what[0..@min(what.len, 64)]}));
}
};
-/// Open the startup file, `init`, in a pane: its pane when it is open, else
-/// the file, else a pane of that name for Save to make it and its directory.
+/// Open the startup file, `init` in the configuration directory, in a pane.
+///
+/// Its pane when it is open, else the file; not there yet, a pane of that
+/// name, which Save makes, its directory too.
pub const Config = struct {
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
@@ -1375,8 +1661,10 @@ fn openConfigFile(c: Ctx, name: []const u8, path: []const u8, initial: []const u
c.p.view().active = free;
}
-/// Open the settings in effect, each a word to click, and the startup
-/// file's path.
+/// Show the settings in effect in a +DumpConfig, as lines the startup file
+/// takes.
+///
+/// The startup file's path with them; a line run there is that setting.
pub const DumpConfig = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.dump_config_buffer };
@@ -1385,7 +1673,12 @@ pub const DumpConfig = struct {
}
};
-/// Set how location rows are drawn, or show how they are when bare.
+/// Set how a list's location rows are drawn: `LocationsConfig layout:inline
+/// context:2`.
+///
+/// Its fields: `context:<lines>` around each, `tscontext:on|off`,
+/// `tslocations:on|off`, `layout:inline|stacked`; those not given stay. Bare,
+/// it shows them in a +LocationsConfig.
pub const LocationsConfig = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -1416,7 +1709,7 @@ pub const LocationsConfig = struct {
}
};
-/// Open the messages shown so far.
+/// Show the messages said so far in a +Messages.
pub const Messages = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.messages_buffer };
@@ -1425,10 +1718,12 @@ pub const Messages = struct {
}
};
-/// This build: its version, commit, jj change and build time (a stamped
-/// build's: a release or the ~/.local install), the zig that built it, its
-/// optimize mode, target, platform, grammars, whether the addons are compiled
-/// in, and its dependencies, printed into an output buffer.
+/// Show this build in a +Build: its version, compiler, optimize mode, target
+/// and dependencies.
+///
+/// A stamped build's (a release, or the ~/.local install) commit, jj change
+/// and build time too, its platform, its grammars, and whether the addons are
+/// compiled in.
pub const Build = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.build_buffer };
@@ -1437,8 +1732,7 @@ pub const Build = struct {
}
};
-/// This build's version and what changed to reach it, printed into an output
-/// buffer the same way Config prints the live settings.
+/// Show this build's version and what changed to reach it, in a +Changelog.
pub const Changelog = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.changelog_buffer };
@@ -1447,7 +1741,10 @@ pub const Changelog = struct {
}
};
-/// Open a minimap of the file in braille dots.
+/// Map a file of this pane's directory in braille dots: `Mini notes.txt`.
+///
+/// A pane of its own, drawn once: a Mini of the same file again draws it
+/// anew.
pub const Mini = struct {
pub const takes_arg = true;
pub const requires_arg = true; // a file to map: bare, wrong #args (EINVAL)
@@ -1466,7 +1763,12 @@ pub const Mini = struct {
const e_search_miss_find = "Find: name not found";
const e_search_miss_grep = "Grep: text not found";
-/// List the files below this pane's directory whose names hold its argument, in a +Search.
+/// List the files below this pane's directory whose names match its argument.
+///
+/// A query pane under this pane, its line 1 `Find <name>`, the files under it
+/// by a fuzzy match of their names: with a word, listed, the keyboard left
+/// where it was; bare (`SPC f f`), typed into. Enter or B3 on a row opens
+/// that file. A script's Find that finds nothing fails, `not found`.
pub const Find = struct {
pub const takes_arg = true;
// A script's Find names what to find (bare, it is a key's prompt).
@@ -1476,8 +1778,13 @@ pub const Find = struct {
}
};
-/// Find's sibling: Find matches file NAMES under this pane's directory, Grep
-/// matches the LINES of those files, on the disk engine's worker.
+/// List the lines of the files below this pane's directory that hold its
+/// argument.
+///
+/// The text is matched as it is, not as a pattern, in a query pane under this
+/// pane, its line 1 `Grep <text>`: with a word, listed, the keyboard left
+/// where it was; bare (`SPC f g`), typed into. Past 2000 lines it stops, and
+/// More goes on. A script's Grep that finds nothing fails, `not found`.
pub const Grep = struct {
pub const takes_arg = true;
pub const requires_arg = true;
@@ -1503,8 +1810,13 @@ fn search(c: Ctx, source: panes.Query.Source, miss: []const u8) void {
c.p.reportFailure(c.id, miss);
}
-/// Search in a query pane under this pane, line 1 the argument (`Panes`,
-/// `Symbols lay`, `All needle`, `/re`, any of its words); bare, `/`.
+/// Search in a query pane under this pane, its line 1 the argument.
+///
+/// Line 1's first word names what it searches: `/re` this pane's text,
+/// `Find`, `Grep`, `Recent`, `Panes`, `Symbols`, `All` (every open pane's
+/// text), `Refs`, `Def`, `Impl`, `Diagnostics`; a line with none of them is a
+/// `/`: `Search lay` is `/lay`. Bare, `/`, typed into. `SPC b b`, `SPC s s`
+/// and `SPC /` open it with Panes, Symbols and All.
pub const Search = struct {
pub const takes_arg = true;
pub const quiet = true;
@@ -1515,7 +1827,7 @@ pub const Search = struct {
}
};
-/// A query pane's Grep stopped at its 2000 lines goes on for 2000 more.
+/// Let a query pane's Grep stopped at its 2000 lines go on for 2000 more.
pub const More = struct {
pub const quiet = true;
pub fn run(c: Ctx) void {
@@ -1523,7 +1835,11 @@ pub const More = struct {
}
};
-/// Pick an open pane by its name in a query pane under this one (SPC b b).
+/// Pick a pane by its name, in a query pane under this one.
+///
+/// The open panes, then those closed this session, `(closed)`: Enter on one
+/// goes to it, or brings a closed one back where it was, its text with it.
+/// `Panes <name>` narrows them; `SPC b b` opens the same query.
pub const Panes = struct {
pub const takes_arg = true;
pub const quiet = true;
@@ -1549,7 +1865,7 @@ pub const Left = struct {
}
};
-/// Move the keyboard to the pane below, off a tag onto the pane under it.
+/// Move the keyboard to the pane below, or off a tag onto the pane under it.
pub const Down = struct {
pub fn run(c: Ctx) void {
if (c.p.view().header != null) {
@@ -1568,7 +1884,8 @@ pub const Down = struct {
}
};
-/// Move the keyboard to the pane above, and from a column's top pane to its tag.
+/// Move the keyboard to the pane above, and from a column's top pane to its
+/// tag.
pub const Up = struct {
pub fn run(c: Ctx) void {
if (c.p.view().header != null) {
@@ -1593,10 +1910,12 @@ pub const Right = struct {
}
};
-/// Emacs's follow-mode: one text across a chain of panes as consecutive
-/// pages, each going on where the one before ends, scrolled as one. Adds a
-/// page, a Zerox twin, at the end of the column right of the chain's last,
-/// or in a new column there; its tag has Unfollow.
+/// Show one text across a chain of panes as consecutive pages, scrolled as
+/// one.
+///
+/// As Emacs's follow-mode: each page goes on where the one before ends. Each
+/// Follow adds a page, a Zerox of the text, at the end of the column right of
+/// the chain's last, or in a new column there; its tag has Unfollow.
pub const Follow = struct {
pub fn run(c: Ctx) void {
if (@import("edit_cmd.zig").busyOn(c.p, c.id)) return c.p.reportFailure(c.id, "Follow: " ++ @import("edit_cmd.zig").e_busy);
@@ -1634,8 +1953,10 @@ pub const Follow = struct {
}
};
-/// Take this pane out of its Follow chain: it stays, a Zerox twin with the
-/// scroll it has, and the chain closes up behind it.
+/// Take this pane out of its Follow chain.
+///
+/// It stays, a Zerox twin with the scroll it has, and the chain closes up
+/// behind it.
pub const Unfollow = struct {
pub fn run(c: Ctx) void {
const f = if (c.pane.file) |*file| file else return c.p.reportFailure(c.id, "Unfollow: this pane is in no Follow chain");
@@ -1644,8 +1965,12 @@ pub const Unfollow = struct {
}
};
-/// Window mode: h/j/k/l move an outline between the panes; Enter or Esc
-/// focuses the outlined pane, `:` its tag, the letter shown on a pane that one; d is Del on it (then k or j between two), c Collapse.
+/// Window mode: move an outline between the panes and act on the one
+/// outlined.
+///
+/// h/j/k/l move the outline; Enter or Esc focuses the outlined pane, `:` its
+/// tag, the letter shown on a pane that one; d is Del on it (then k or j
+/// between two), c Collapse.
pub const Window = struct {
pub fn run(c: Ctx) void {
tagline.exitHeader(c.p);
@@ -1655,7 +1980,9 @@ pub const Window = struct {
// ---- the jump group ----
-/// Ctrl-o: one step back into the history.
+/// Go one step back in the jump history.
+///
+/// A place in a file closed since opens the file again.
pub const Back = struct {
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
@@ -1663,7 +1990,7 @@ pub const Back = struct {
}
};
-/// Ctrl-i: one step forward again, up to wherever Back started.
+/// Go one step forward again in the jump history, up to where Back started.
pub const Forward = struct {
pub const scope: Scope = .session;
pub fn run(c: Ctx) void {
@@ -1671,7 +1998,11 @@ pub const Forward = struct {
}
};
-/// Select the next Look location across panes; Enter opens it.
+/// Select the next thing a Look would open: a place in a list, a word that
+/// names a file.
+///
+/// The walk goes on through the panes in order, the keyboard with it; Enter
+/// opens what it selected.
pub const LookNext = struct {
pub const quiet = true;
pub fn run(c: Ctx) void {
@@ -1679,7 +2010,9 @@ pub const LookNext = struct {
}
};
-/// Select the previous Look location across panes; Enter opens it.
+/// Select the previous thing a Look would open, as LookNext walks forward.
+///
+/// Enter opens what it selected.
pub const LookPrev = struct {
pub const quiet = true;
pub fn run(c: Ctx) void {
@@ -1688,6 +2021,8 @@ pub const LookPrev = struct {
};
/// Go back to the last place jumped from in another pane.
+///
+/// With none, to the pane beside this one.
pub const Last = struct {
pub fn run(c: Ctx) void {
var i = c.p.view().jumps.n;
@@ -1704,7 +2039,11 @@ pub const Last = struct {
}
};
-/// List the files opened lately, closed ones too, each a place to open again.
+/// List the files opened lately, closed ones too, in a query pane under this
+/// one.
+///
+/// `Recent <name>` narrows them by name; bare (`SPC f r`), typed into. Enter
+/// opens the current one; B3 on a row, that one.
pub const Recent = struct {
pub const scope: Scope = .session;
pub const takes_arg = true;
@@ -1716,12 +2055,15 @@ pub const Recent = struct {
}
};
-/// List the state file's dumps, those Dump made and those every session's
-/// end left (dump.dumpExit), the newest first, each as the command that
-/// brings it back, `Restore <label>` on a line of its own, its date, size,
-/// pane count and the panes' names indented under it; a click on the
-/// Restore (an exec, or a look at the line) is that Restore.
+/// List the state file's dumps, newest first, each with the Restore that
+/// brings it back.
+///
+/// Those Dump made and those every session's end left, in a +History: each a
+/// `Restore <label>` line, its date, size and pane count, the panes' names
+/// indented under it. B2 on the Restore, or a Look at its line, is that
+/// Restore.
pub const History = struct {
+ // A session's end dumps it (dump.dumpExit).
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.history_buffer };
pub fn run(c: Ctx) void {
@@ -1733,7 +2075,7 @@ pub const History = struct {
}
};
-/// List the places jumped from, each a place to go.
+/// List the places jumped from in a +Jumps, each a place to go.
pub const Jumplist = struct {
pub const scope: Scope = .session;
pub const output: OutputTraits = .{ .name = config.jumps_buffer, .steps = true, .locations = true };
@@ -1744,8 +2086,11 @@ pub const Jumplist = struct {
// ---- the language group ----
-/// Go to the definition of the symbol under the cursor; with an argument
-/// (a 2-1 chord's selection), of that symbol, where it is nearest.
+/// Go to the definition of the symbol under the cursor.
+///
+/// With an argument (a 2-1 chord's selection), of that symbol, asked at its
+/// occurrence nearest the cursor. One answer is a jump; several open a list,
+/// the keyboard on its current row; none says so. `g d` does the same.
pub const Def = struct {
pub const takes_arg = true;
/// Its answer says what it found, a jump or a list or why not; its
@@ -1756,8 +2101,11 @@ pub const Def = struct {
}
};
-/// List the references to the symbol under the cursor; with an argument
-/// (a 2-1 chord's selection), to that symbol, where it is nearest.
+/// List the references to the symbol under the cursor.
+///
+/// With an argument (a 2-1 chord's selection), to that symbol, asked at its
+/// occurrence nearest the cursor; a single reference is a jump. `g r` does
+/// the same.
pub const Refs = struct {
pub const takes_arg = true;
pub const quiet = true; // as Def
@@ -1766,14 +2114,15 @@ pub const Refs = struct {
}
};
-/// Ask the language server about the symbol under the cursor.
+/// Ask the language server about the symbol under the cursor, its answer in a
+/// +Hover.
pub const Hover = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .hover, "");
}
};
-/// List the language server's code actions for the cursor.
+/// List the language server's code actions for the cursor, in a +Lsp.
pub const CodeAction = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .code_action, "");
@@ -1787,70 +2136,93 @@ pub const SelectRefs = struct {
}
};
-/// List the file's symbols from the language server.
+/// List this file's symbols in a +Search.
pub const Symbols = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .document_symbols, "");
}
};
-/// List the file's diagnostics from the language server.
+/// List this file's diagnostics in a +Search.
+///
+/// `] d` and `[ d` step through them in the text, `] D` and `[ D` to the last
+/// and the first.
pub const Diagnostics = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .diagnostics, "");
}
};
-/// List the workspace's diagnostics from the language server.
+/// List the diagnostics of the whole workspace in a +Search.
pub const WsDiagnostics = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .workspace_diagnostics, "");
}
};
-/// Run the file's language indexer at its project root, writing the index.scip the language words ask first.
+/// Run the file's language indexer at its project root, writing its
+/// index.scip.
+///
+/// The language words ask the nearest index.scip above a file first, and its
+/// language server only when the index has nothing to say; an index older
+/// than the file still answers, and says so once.
pub const Index = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .index, "");
}
};
-/// Show outermost callers first, with signatures and call sites (gc).
+/// Show the callers of the function under the cursor as a tree, outermost
+/// first, in a +Callstack.
+///
+/// Each caller with its place to open and its signature, the line of each
+/// call under it; callers named for tests after the rest, a recursion marked
+/// `↻`. CallstackDepth sets how many levels (8 by default); a deeper tree
+/// says where to go on from. `g c` does the same.
pub const Callstack = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .callstack, "");
}
};
-/// List the callers of the function under the cursor.
+/// List the functions that call the one under the cursor, one level up; a
+/// single one is a jump.
pub const Callers = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .incoming_calls, "");
}
};
-/// List the functions the function under the cursor calls.
+/// List the functions the one under the cursor calls, one level down; a
+/// single one is a jump.
pub const Callees = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .outgoing_calls, "");
}
};
-/// List the supertypes of the type under the cursor.
+/// List the supertypes of the type under the cursor in a +Search; a single
+/// one is a jump.
pub const Supertypes = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .supertypes, "");
}
};
-/// List the subtypes of the type under the cursor.
+/// List the subtypes of the type under the cursor in a +Search; a single one
+/// is a jump.
pub const Subtypes = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .subtypes, "");
}
};
-/// Rename the symbol under the cursor everywhere, to its argument.
+/// Rename the symbol under the cursor to its argument, wherever the language
+/// server finds it.
+///
+/// Bare, it asks for the new name. Within this file it is done at once,
+/// saying how many places changed; one that reaches other files changes
+/// nothing and lists its edits in a +Search to look over.
pub const Rename = struct {
pub const takes_arg = true;
pub const requires_arg = true;
@@ -1861,7 +2233,8 @@ pub const Rename = struct {
}
};
-/// Search the workspace's symbols for its argument.
+/// Search the workspace's symbols for its argument, in a +Search; bare, it
+/// asks for the name.
pub const WsSymbols = struct {
pub const takes_arg = true;
pub const requires_arg = true;
@@ -1872,14 +2245,20 @@ pub const WsSymbols = struct {
}
};
-/// Show which language servers serve this file and their state.
+/// Show which index and language server serve this file, and their state, in
+/// a +Lsp.
+///
+/// The index.scip it asks (or the Index that would write one), its server and
+/// the server's state (not started yet, failed and waiting to retry), and
+/// what answered each query lately.
pub const Lspinfo = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .status, "");
}
};
-/// Explain how the last language server request was answered, step by step.
+/// Explain, step by step in a +Lsp, how the last language server request was
+/// answered.
pub const Lspwhy = struct {
pub fn run(c: Ctx) void {
c.p.lspRequest(c.id, .explain, "");
@@ -1905,6 +2284,24 @@ fn testDump(buf: []u8) ![]const u8 {
return std.fmt.bufPrint(buf, "Restore {s}/d.zon", .{at});
}
+test "a builtin's documentation is the whole `///` block above it, a line a paragraph, its summary first" {
+ const Builtin = registry.Builtin();
+ const diff = registry.doc(Builtin.Diff);
+ try std.testing.expect(std.mem.startsWith(u8, diff.text, diff.summary));
+ try std.testing.expect(std.mem.endsWith(u8, diff.summary, "."));
+ // Its paragraphs, each its `///` lines joined: the forms in the second.
+ var paras = std.mem.splitScalar(u8, diff.text, '\n');
+ _ = paras.next();
+ try std.testing.expect(std.mem.indexOf(u8, paras.next().?, "`Diff <hash>` (7 to 40 hex digits)") != null);
+ try std.testing.expect(paras.next() != null);
+ // No note for the code's reader: those are `//` lines in the struct.
+ try std.testing.expect(std.mem.indexOf(u8, diff.text, "registration") == null);
+ // A setting's is its own doc.
+ try std.testing.expectEqualStrings(config.Settings.find("Wrap").?.doc, registry.doc(Builtin.Wrap).text);
+ // Every builtin has one, its summary a line (the compiler holds both).
+ for (std.enums.values(Builtin)) |b| try std.testing.expect(registry.doc(b).summary.len > 0);
+}
+
test "capabilities exactly gate setting builtins" {
const Builtin = registry.Builtin();
for (config.Settings.settings) |setting| {