feat: add set_buffer_tab_width and set_session_tab_width commands
Also, fold the tab_width and set_tab_width commands into one. The default command (set_tab_width) now stores the tab_width in the persistent config.
This commit is contained in:
parent
4037d67fe9
commit
80002e4d6b
2 changed files with 34 additions and 5 deletions
|
@ -711,14 +711,14 @@ pub const Editor = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_tab_width(self: *Self, ctx: Context) Result {
|
pub fn set_editor_tab_width(self: *Self, ctx: Context) Result {
|
||||||
var tab_width: usize = 0;
|
var tab_width: usize = 0;
|
||||||
if (!try ctx.args.match(.{tp.extract(&tab_width)}))
|
if (!try ctx.args.match(.{tp.extract(&tab_width)}))
|
||||||
return error.InvalidSetTabWidthArgument;
|
return error.InvalidSetTabWidthArgument;
|
||||||
self.tab_width = tab_width;
|
self.tab_width = tab_width;
|
||||||
self.refresh_tab_width();
|
self.refresh_tab_width();
|
||||||
}
|
}
|
||||||
pub const set_tab_width_meta: Meta = .{ .arguments = &.{.integer} };
|
pub const set_editor_tab_width_meta: Meta = .{ .arguments = &.{.integer} };
|
||||||
|
|
||||||
fn close(self: *Self) !void {
|
fn close(self: *Self) !void {
|
||||||
var meta = std.ArrayListUnmanaged(u8).empty;
|
var meta = std.ArrayListUnmanaged(u8).empty;
|
||||||
|
|
|
@ -745,10 +745,39 @@ const cmds = struct {
|
||||||
}
|
}
|
||||||
pub const force_terminate_meta: Meta = .{ .description = "Force quit without saving" };
|
pub const force_terminate_meta: Meta = .{ .description = "Force quit without saving" };
|
||||||
|
|
||||||
pub fn tab_width(self: *Self, ctx: Ctx) Result {
|
pub fn set_tab_width(self: *Self, ctx: Ctx) Result {
|
||||||
return enter_mini_mode(self, @import("mode/mini/tab_width.zig"), ctx);
|
var tab_width: usize = 0;
|
||||||
|
if (!try ctx.args.match(.{tp.extract(&tab_width)}))
|
||||||
|
return enter_mini_mode(self, @import("mode/mini/tab_width.zig"), Ctx.fmt(.{"set_tab_width"}));
|
||||||
|
|
||||||
|
self.config_.tab_width = tab_width;
|
||||||
|
self.session_tab_width = null;
|
||||||
|
command.executeName("set_editor_tab_width", ctx) catch {};
|
||||||
|
try save_config();
|
||||||
|
self.logger.print("tab width {}", .{tab_width});
|
||||||
}
|
}
|
||||||
pub const tab_width_meta: Meta = .{ .description = "Set tab width" };
|
pub const set_tab_width_meta: Meta = .{ .description = "Set tab width" };
|
||||||
|
|
||||||
|
pub fn set_buffer_tab_width(self: *Self, ctx: Ctx) Result {
|
||||||
|
var tab_width: usize = 0;
|
||||||
|
if (!try ctx.args.match(.{tp.extract(&tab_width)}))
|
||||||
|
return enter_mini_mode(self, @import("mode/mini/tab_width.zig"), Ctx.fmt(.{"set_buffer_tab_width"}));
|
||||||
|
|
||||||
|
command.executeName("set_editor_tab_width", ctx) catch {};
|
||||||
|
self.logger.print("buffer tab width {}", .{tab_width});
|
||||||
|
}
|
||||||
|
pub const set_buffer_tab_width_meta: Meta = .{ .description = "Set tab width for current buffer" };
|
||||||
|
|
||||||
|
pub fn set_session_tab_width(self: *Self, ctx: Ctx) Result {
|
||||||
|
var tab_width: usize = 0;
|
||||||
|
if (!try ctx.args.match(.{tp.extract(&tab_width)}))
|
||||||
|
return enter_mini_mode(self, @import("mode/mini/tab_width.zig"), Ctx.fmt(.{"set_session_tab_width"}));
|
||||||
|
|
||||||
|
self.session_tab_width = tab_width;
|
||||||
|
command.executeName("set_editor_tab_width", ctx) catch {};
|
||||||
|
self.logger.print("session tab width {}", .{tab_width});
|
||||||
|
}
|
||||||
|
pub const set_session_tab_width_meta: Meta = .{ .description = "Set tab width for current session" };
|
||||||
|
|
||||||
pub fn set_theme(self: *Self, ctx: Ctx) Result {
|
pub fn set_theme(self: *Self, ctx: Ctx) Result {
|
||||||
var name: []const u8 = undefined;
|
var name: []const u8 = undefined;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue