feat: add place_next_tab and swap_tabs commands

This commit is contained in:
CJ van den Berg 2025-10-24 12:21:48 +02:00
parent 91b54d6842
commit 2704c7be07
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 92 additions and 7 deletions

View file

@ -1192,6 +1192,28 @@ const cmds = struct {
_ = try self.widgets_widget.msg(.{"move_tab_previous"});
}
pub const move_tab_previous_meta: Meta = .{ .description = "Move tab to previous position" };
pub fn swap_tabs(self: *Self, ctx: Ctx) Result {
var buffer_ref_a: usize = undefined;
var buffer_ref_b: usize = undefined;
if (!try ctx.args.match(.{
tp.extract(&buffer_ref_a),
tp.extract(&buffer_ref_b),
})) return error.InvalidSwapTabsArgument;
_ = try self.widgets_widget.msg(.{ "swap_tabs", buffer_ref_a, buffer_ref_b });
}
pub const swap_tabs_meta: Meta = .{ .arguments = &.{ .integer, .integer } };
pub fn place_next_tab(self: *Self, ctx: Ctx) Result {
var pos: enum { before, after } = undefined;
var buffer_ref: usize = undefined;
if (try ctx.args.match(.{ tp.extract(&pos), tp.extract(&buffer_ref) })) {
_ = try self.widgets_widget.msg(.{ "place_next_tab", pos, buffer_ref });
} else if (try ctx.args.match(.{"atend"})) {
_ = try self.widgets_widget.msg(.{ "place_next_tab", "atend" });
} else return error.InvalidSwapTabsArgument;
}
pub const place_next_tab_meta: Meta = .{ .arguments = &.{ .string, .integer } };
};
pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {