feat: add metadata to all commands

This commit is contained in:
CJ van den Berg 2024-09-17 22:58:35 +02:00
parent bdd16f43fb
commit d75dcd7b84
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
13 changed files with 221 additions and 6 deletions

View file

@ -310,22 +310,27 @@ const cmds_ = struct {
pub fn w(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
}
pub const w_meta = .{ .description = "w (write file)" };
pub fn q(self: *Self, _: Ctx) Result {
try self.cmd("quit", .{});
}
pub const q_meta = .{ .description = "w (quit)" };
pub fn @"q!"(self: *Self, _: Ctx) Result {
try self.cmd("quit_without_saving", .{});
}
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
pub fn wq(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
try self.cmd("quit", .{});
}
pub const wq_meta = .{ .description = "wq (write file and quit)" };
pub fn @"wq!"(self: *Self, _: Ctx) Result {
self.cmd("save_file", .{}) catch {};
try self.cmd("quit_without_saving", .{});
}
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
};

View file

@ -662,26 +662,32 @@ const cmds_ = struct {
pub fn w(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
}
pub const w_meta = .{ .description = "w (write file)" };
pub fn q(self: *Self, _: Ctx) Result {
try self.cmd("quit", .{});
}
pub const q_meta = .{ .description = "w (quit)" };
pub fn @"q!"(self: *Self, _: Ctx) Result {
try self.cmd("quit_without_saving", .{});
}
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
pub fn wq(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
try self.cmd("quit", .{});
}
pub const wq_meta = .{ .description = "wq (write file and quit)" };
pub fn o(self: *Self, _: Ctx) Result {
try self.cmd("open_file", .{});
}
pub const o_meta = .{ .description = "o (open file)" };
pub fn @"wq!"(self: *Self, _: Ctx) Result {
self.cmd("save_file", .{}) catch {};
try self.cmd("quit_without_saving", .{});
}
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
};

View file

@ -662,26 +662,32 @@ const cmds_ = struct {
pub fn w(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
}
pub const w_meta = .{ .description = "w (write file)" };
pub fn q(self: *Self, _: Ctx) Result {
try self.cmd("quit", .{});
}
pub const q_meta = .{ .description = "w (quit)" };
pub fn @"q!"(self: *Self, _: Ctx) Result {
try self.cmd("quit_without_saving", .{});
}
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
pub fn wq(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
try self.cmd("quit", .{});
}
pub const wq_meta = .{ .description = "wq (write file and quit)" };
pub fn o(self: *Self, _: Ctx) Result {
try self.cmd("open_file", .{});
}
pub const o_meta = .{ .description = "o (open file)" };
pub fn @"wq!"(self: *Self, _: Ctx) Result {
self.cmd("save_file", .{}) catch {};
try self.cmd("quit_without_saving", .{});
}
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
};

View file

@ -310,22 +310,27 @@ const cmds_ = struct {
pub fn w(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
}
pub const w_meta = .{ .description = "w (write file)" };
pub fn q(self: *Self, _: Ctx) Result {
try self.cmd("quit", .{});
}
pub const q_meta = .{ .description = "w (quit)" };
pub fn @"q!"(self: *Self, _: Ctx) Result {
try self.cmd("quit_without_saving", .{});
}
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
pub fn wq(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
try self.cmd("quit", .{});
}
pub const wq_meta = .{ .description = "wq (write file and quit)" };
pub fn @"wq!"(self: *Self, _: Ctx) Result {
self.cmd("save_file", .{}) catch {};
try self.cmd("quit_without_saving", .{});
}
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
};

View file

@ -626,22 +626,27 @@ const cmds_ = struct {
pub fn w(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
}
pub const w_meta = .{ .description = "w (write file)" };
pub fn q(self: *Self, _: Ctx) Result {
try self.cmd("quit", .{});
}
pub const q_meta = .{ .description = "w (quit)" };
pub fn @"q!"(self: *Self, _: Ctx) Result {
try self.cmd("quit_without_saving", .{});
}
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
pub fn wq(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
try self.cmd("quit", .{});
}
pub const wq_meta = .{ .description = "wq (write file and quit)" };
pub fn @"wq!"(self: *Self, _: Ctx) Result {
self.cmd("save_file", .{}) catch {};
try self.cmd("quit_without_saving", .{});
}
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
};

View file

@ -572,25 +572,30 @@ const cmds_ = struct {
const Ctx = command.Context;
const Result = command.Result;
pub fn @"w"(self: *Self, _: Ctx) Result {
pub fn w(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
}
pub const w_meta = .{ .description = "w (write file)" };
pub fn @"q"(self: *Self, _: Ctx) Result {
pub fn q(self: *Self, _: Ctx) Result {
try self.cmd("quit", .{});
}
pub const q_meta = .{ .description = "w (quit)" };
pub fn @"q!"(self: *Self, _: Ctx) Result {
try self.cmd("quit_without_saving", .{});
}
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
pub fn @"wq"(self: *Self, _: Ctx) Result {
pub fn wq(self: *Self, _: Ctx) Result {
try self.cmd("save_file", .{});
try self.cmd("quit", .{});
}
pub const wq_meta = .{ .description = "wq (write file and quit)" };
pub fn @"wq!"(self: *Self, _: Ctx) Result {
self.cmd("save_file", .{}) catch {};
try self.cmd("quit_without_saving", .{});
}
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
};

View file

@ -342,12 +342,15 @@ const cmds = struct {
pub fn open_recent_menu_down(self: *Self, _: Ctx) Result {
self.menu.select_down();
}
pub const open_recent_menu_down_meta = .{ .interactive = false };
pub fn open_recent_menu_up(self: *Self, _: Ctx) Result {
self.menu.select_up();
}
pub const open_recent_menu_up_meta = .{ .interactive = false };
pub fn open_recent_menu_activate(self: *Self, _: Ctx) Result {
self.menu.activate_selected();
}
pub const open_recent_menu_activate_meta = .{ .interactive = false };
};

View file

@ -439,6 +439,7 @@ pub fn Create(options: type) type {
self.menu.select_down();
self.selection_updated();
}
pub const palette_menu_down_meta = .{ .interactive = false };
pub fn palette_menu_up(self: *Self, _: Ctx) Result {
if (self.menu.selected) |selected| {
@ -452,6 +453,7 @@ pub fn Create(options: type) type {
self.menu.select_up();
self.selection_updated();
}
pub const palette_menu_up_meta = .{ .interactive = false };
pub fn palette_menu_pagedown(self: *Self, _: Ctx) Result {
if (self.total_items > self.view_rows) {
@ -463,6 +465,7 @@ pub fn Create(options: type) type {
self.menu.select_last();
self.selection_updated();
}
pub const palette_menu_pagedown_meta = .{ .interactive = false };
pub fn palette_menu_pageup(self: *Self, _: Ctx) Result {
if (self.view_pos > self.view_rows)
@ -473,15 +476,18 @@ pub fn Create(options: type) type {
self.menu.select_first();
self.selection_updated();
}
pub const palette_menu_pageup_meta = .{ .interactive = false };
pub fn palette_menu_activate(self: *Self, _: Ctx) Result {
self.menu.activate_selected();
}
pub const palette_menu_activate_meta = .{ .interactive = false };
pub fn palette_menu_cancel(self: *Self, _: Ctx) Result {
if (@hasDecl(options, "cancel")) try options.cancel(self);
try self.cmd("exit_overlay_mode", .{});
}
pub const palette_menu_cancel_meta = .{ .interactive = false };
};
};
}