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)" };
|
||||||
|
};
|
|
@ -876,6 +876,26 @@ const cmds = struct {
|
||||||
try tp.self_pid().send_raw(.{ .buf = msg_cb.items });
|
try tp.self_pid().send_raw(.{ .buf = msg_cb.items });
|
||||||
}
|
}
|
||||||
pub const run_async_meta = .{};
|
pub const run_async_meta = .{};
|
||||||
|
|
||||||
|
pub fn enter_vim_mode(_: *Self, _: Ctx) Result {
|
||||||
|
try @import("mode/vim.zig").init();
|
||||||
|
}
|
||||||
|
pub const enter_vim_mode_meta = .{};
|
||||||
|
|
||||||
|
pub fn exit_vim_mode(_: *Self, _: Ctx) Result {
|
||||||
|
@import("mode/vim.zig").deinit();
|
||||||
|
}
|
||||||
|
pub const exit_vim_mode_meta = .{};
|
||||||
|
|
||||||
|
pub fn enter_helix_mode(_: *Self, _: Ctx) Result {
|
||||||
|
try @import("mode/helix.zig").init();
|
||||||
|
}
|
||||||
|
pub const enter_helix_mode_meta = .{};
|
||||||
|
|
||||||
|
pub fn exit_helix_mode(_: *Self, _: Ctx) Result {
|
||||||
|
@import("mode/helix.zig").deinit();
|
||||||
|
}
|
||||||
|
pub const exit_helix_mode_meta = .{};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MiniMode = struct {
|
pub const MiniMode = struct {
|
||||||
|
|
Loading…
Add table
Reference in a new issue