mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-10-09 12:51:45 -04:00
tools: restructure browser tools and script schemas
- Replace `Action` enum with `Tool` enum using exhaustive switches - Extract `ScriptIterator` to `Iterator.zig` - Refactor `schema.zig` into `Schema.zig` - Move string substitution logic into `tools.zig` - Clean up `SlashCommand.zig` to only handle REPL meta-commands
This commit is contained in:
1 parent
6cd75c454e
commit
8fb3c7baed
13 files changed
+1691
-1420
No files matched your search
+11
-20
@@ -16,26 +16,15 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! REPL-only meta slash commands and re-exports of the PandaScript schema
|
||||
//! primitives. The actual slash-command grammar lives in `script/schema.zig`.
|
||||
//! REPL-only meta slash commands (`/help`, `/quit`, `/verbosity`). Meta
|
||||
//! commands aren't PandaScript — they're handled by `Agent.handleMeta`
|
||||
//! and never reach the recorder. PandaScript schema primitives live in
|
||||
//! `lp.script.Schema`; consumers should import that directly.
|
||||
|
||||
const std = @import("std");
|
||||
const lp = @import("lightpanda");
|
||||
const schema = lp.script.schema;
|
||||
|
||||
pub const SchemaInfo = schema.SchemaInfo;
|
||||
pub const ParseError = schema.ParseError;
|
||||
pub const Split = schema.Split;
|
||||
|
||||
pub const max_hint_slots = schema.max_hint_slots;
|
||||
|
||||
pub const globalSchemas = schema.globalSchemas;
|
||||
pub const findSchema = schema.findSchema;
|
||||
pub const splitNameRest = schema.splitNameRest;
|
||||
|
||||
/// Meta slash commands handled directly by Agent.handleMeta.
|
||||
pub const MetaCommand = struct {
|
||||
kind: Kind,
|
||||
tag: Tag,
|
||||
name: [:0]const u8,
|
||||
/// Ghost-text fragment shown after the name + space. Empty when the
|
||||
/// command takes no args (`/help`, `/quit`).
|
||||
@@ -43,13 +32,15 @@ pub const MetaCommand = struct {
|
||||
/// Tab-completion candidates for the first positional arg.
|
||||
values: []const [:0]const u8,
|
||||
|
||||
pub const Kind = enum { help, quit, verbosity };
|
||||
/// Dispatched by `Agent.handleMeta` via an exhaustive switch so adding
|
||||
/// a new meta command is a compile error until it's wired up there too.
|
||||
pub const Tag = enum { help, quit, verbosity };
|
||||
};
|
||||
|
||||
pub const meta_commands = [_]MetaCommand{
|
||||
.{ .kind = .help, .name = "help", .hint = "", .values = &.{} },
|
||||
.{ .kind = .quit, .name = "quit", .hint = "", .values = &.{} },
|
||||
.{ .kind = .verbosity, .name = "verbosity", .hint = "<low|medium|high>", .values = &.{ "low", "medium", "high" } },
|
||||
.{ .tag = .help, .name = "help", .hint = "", .values = &.{} },
|
||||
.{ .tag = .quit, .name = "quit", .hint = "", .values = &.{} },
|
||||
.{ .tag = .verbosity, .name = "verbosity", .hint = "<low|medium|high>", .values = &.{ "low", "medium", "high" } },
|
||||
};
|
||||
|
||||
pub fn findMeta(name: []const u8) ?*const MetaCommand {
|
||||
|
||||
Reference in new issue
Block a user