feat: add back vim/helix mode specific commands
This commit is contained in:
parent
480487414e
commit
85b8ff8bea
3 changed files with 119 additions and 0 deletions
52
src/tui/mode/helix.zig
Normal file
52
src/tui/mode/helix.zig
Normal file
|
@ -0,0 +1,52 @@
|
|||
const std = @import("std");
|
||||
const command = @import("command");
|
||||
const cmd = command.executeName;
|
||||
|
||||
var commands: Commands = undefined;
|
||||
|
||||
pub fn init() !void {
|
||||
var v: void = {};
|
||||
try commands.init(&v);
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
commands.deinit();
|
||||
}
|
||||
|
||||
const Commands = command.Collection(cmds_);
|
||||
const cmds_ = struct {
|
||||
pub const Target = void;
|
||||
const Ctx = command.Context;
|
||||
const Result = command.Result;
|
||||
|
||||
pub fn w(_: *void, _: Ctx) Result {
|
||||
try cmd("save_file", .{});
|
||||
}
|
||||
pub const w_meta = .{ .description = "w (write file)" };
|
||||
|
||||
pub fn q(_: *void, _: Ctx) Result {
|
||||
try cmd("quit", .{});
|
||||
}
|
||||
pub const q_meta = .{ .description = "q (quit)" };
|
||||
|
||||
pub fn @"q!"(_: *void, _: Ctx) Result {
|
||||
try cmd("quit_without_saving", .{});
|
||||
}
|
||||
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
|
||||
|
||||
pub fn wq(_: *void, _: Ctx) Result {
|
||||
try cmd("save_file", command.fmt(.{ "then", .{ "quit", .{} } }));
|
||||
}
|
||||
pub const wq_meta = .{ .description = "wq (write file and quit)" };
|
||||
|
||||
pub fn o(_: *void, _: Ctx) Result {
|
||||
try cmd("open_file", .{});
|
||||
}
|
||||
pub const o_meta = .{ .description = "o (open file)" };
|
||||
|
||||
pub fn @"wq!"(_: *void, _: Ctx) Result {
|
||||
cmd("save_file", .{}) catch {};
|
||||
try cmd("quit_without_saving", .{});
|
||||
}
|
||||
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
|
||||
};
|
47
src/tui/mode/vim.zig
Normal file
47
src/tui/mode/vim.zig
Normal file
|
@ -0,0 +1,47 @@
|
|||
const std = @import("std");
|
||||
const command = @import("command");
|
||||
const cmd = command.executeName;
|
||||
|
||||
var commands: Commands = undefined;
|
||||
|
||||
pub fn init() !void {
|
||||
var v: void = {};
|
||||
try commands.init(&v);
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
commands.deinit();
|
||||
}
|
||||
|
||||
const Commands = command.Collection(cmds_);
|
||||
const cmds_ = struct {
|
||||
pub const Target = void;
|
||||
const Ctx = command.Context;
|
||||
const Result = command.Result;
|
||||
|
||||
pub fn w(_: *void, _: Ctx) Result {
|
||||
try cmd("save_file", .{});
|
||||
}
|
||||
pub const w_meta = .{ .description = "w (write file)" };
|
||||
|
||||
pub fn q(_: *void, _: Ctx) Result {
|
||||
try cmd("quit", .{});
|
||||
}
|
||||
pub const q_meta = .{ .description = "q (quit)" };
|
||||
|
||||
pub fn @"q!"(_: *void, _: Ctx) Result {
|
||||
try cmd("quit_without_saving", .{});
|
||||
}
|
||||
pub const @"q!_meta" = .{ .description = "q! (quit without saving)" };
|
||||
|
||||
pub fn wq(_: *void, _: Ctx) Result {
|
||||
try cmd("save_file", command.fmt(.{ "then", .{ "quit", .{} } }));
|
||||
}
|
||||
pub const wq_meta = .{ .description = "wq (write file and quit)" };
|
||||
|
||||
pub fn @"wq!"(_: *void, _: Ctx) Result {
|
||||
cmd("save_file", .{}) catch {};
|
||||
try cmd("quit_without_saving", .{});
|
||||
}
|
||||
pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue