diff options
Diffstat (limited to 'core/Command.zig')
| -rw-r--r-- | core/Command.zig | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/core/Command.zig b/core/Command.zig index bb42bbbd..ce4dd132 100644 --- a/core/Command.zig +++ b/core/Command.zig @@ -19,7 +19,9 @@ //! pipes typed last. Enter runs the line as B2 runs a word: a command as //! its pardes word (`:theme`'s the theme the window wears), anything else //! Exec'd. `:` on the empty field gives the keyboard to the tag's own text, -//! as `:` did before there was a field; `:` there gives it back. +//! as `:` did before there was a field; `:` there gives it back. `SPC :` +//! (Root bare) is its twin at the project's root: Enter runs the line as +//! Root, head `: root`. //! //! A view's own, as its prompt is (TagState.prompt.command): which rows //! the hits (TagState.hits) are of, and where in the field Tab writes. @@ -69,6 +71,9 @@ from: u16 = 0, /// Tab (or a click) wrote the current row into the field: the rows are /// the line's from before it, which Tab steps on through. completed: bool = false, +/// `SPC :` (Root bare): the line runs at the project's root, its head +/// `: root`. +root: bool = false, /// A command typed after `:`, its short name, what it takes, and what it /// does: the pardes word it is. @@ -97,10 +102,12 @@ const row_max = 96; /// A doc's rows, the fewest the names' band has. const doc_rows = 4; -/// `:` in pane `pane`'s body: the field empty in its tag, every row. -pub fn open(p: *Pardes, pane: *Pane) void { +/// `:` in pane `pane`'s body: the field empty in its tag, every row; its +/// line run by Root, at the project's root, when `root`. +pub fn open(p: *Pardes, pane: *Pane, root: bool) void { Prompt.open(p, pane, .command); if (p.view().tag_state.kind != .prompt) return; + p.view().tag_state.prompt.command.root = root; filter(p, pane); } @@ -166,8 +173,9 @@ pub fn filter(p: *Pardes, pane: *Pane) void { var buf: [Field.max + 8]u8 = undefined; const word = std.fmt.bufPrint(&buf, "Find {s}", .{arg}) catch return; const id = TagState.hostOf(p) orelse return; + const root = c.root; TagState.toRest(p); - return exec.runBuiltin(p, config.exec_cmd, id, "", word); + return exec.runBuiltin(p, if (root) .Root else config.exec_cmd, id, "", word); } c.rows = typed[i].rows; c.from = @intCast(l.name.len + 1); @@ -508,13 +516,14 @@ fn run(p: *Pardes, id: usize, pane: *Pane) void { // What it runs, read while the rows are there (the theme worn). var buf: [Field.max + 16]u8 = undefined; const r = plan(p, line, &buf); + const root = s.prompt.command.root; TagState.toRest(p); if (std.mem.trim(u8, line, " ").len == 0) return; p.prompt_history.command.add(line); p.registers.put(p.gpa, ':', line, 0, 1, true) catch |err| return p.reportError(.at(id), "command", err); if (r.said) |why| return p.setMessage(.at(id), why); switch (r.verb) { - .exec => exec.runBuiltin(p, config.exec_cmd, id, "", r.word), + .exec => exec.runBuiltin(p, if (root) .Root else config.exec_cmd, id, "", r.word), .look => exec.runBuiltin(p, config.look_cmd, id, "", r.word), .pipe => { const f = pane.file orelse return p.setMessage(.at(id), "only a file's text is piped"); @@ -537,6 +546,7 @@ pub fn plainWord(p: *Pardes, w: *std.Io.Writer, line: []const u8) ?[]const u8 { .look => w.writeAll(r.word) catch return null, .pipe => w.print("Edit |{s}", .{r.word}) catch return null, } + if (r.verb == .exec and p.view().tag_state.prompt.command.root) return "Root"; return if (r.verb == .look) "Look" else "Exec"; } |
