refactor: move goto_line_vim into mode specific commands files

This commit is contained in:
CJ van den Berg 2025-11-27 18:23:23 +01:00
parent 5f242d6cf2
commit 0cba416ec4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 25 additions and 12 deletions

View file

@ -5460,18 +5460,6 @@ pub const Editor = struct {
}
pub const goto_line_meta: Meta = .{ .arguments = &.{.integer} };
pub fn goto_line_vim(self: *Self, ctx: Context) Result {
try self.send_editor_jump_source();
var line: usize = 0;
_ = ctx.args.match(.{tp.extract(&line)}) catch false;
const root = self.buf_root() catch return;
const primary = self.get_primary();
try primary.cursor.move_to(root, @intCast(if (line < 1) 0 else line - 1), primary.cursor.col, self.metrics);
self.clamp();
try self.send_editor_jump_destination();
}
pub const goto_line_vim_meta: Meta = .{ .arguments = &.{.integer} };
pub fn goto_column(self: *Self, ctx: Context) Result {
const root = self.buf_root() catch return;
const primary = self.get_primary();

View file

@ -522,6 +522,18 @@ const cmds_ = struct {
ed.need_render();
}
pub const replace_with_character_helix_meta: Meta = .{ .description = "Replace with character" };
pub fn goto_line_helix(self: *Self, ctx: Context) Result {
try self.send_editor_jump_source();
var line: usize = 0;
_ = ctx.args.match(.{tp.extract(&line)}) catch false;
const root = self.buf_root() catch return;
const primary = self.get_primary();
try primary.cursor.move_to(root, @intCast(if (line < 1) 0 else line - 1), primary.cursor.col, self.metrics);
self.clamp();
try self.send_editor_jump_destination();
}
pub const goto_line_helix_meta: Meta = .{ .arguments = &.{.integer} };
};
fn get_context() ?struct { *MainView, *Editor } {

View file

@ -1,5 +1,6 @@
const std = @import("std");
const command = @import("command");
const tp = @import("thespian");
const cmd = command.executeName;
const tui = @import("../tui.zig");
@ -209,6 +210,18 @@ const cmds_ = struct {
self.clamp();
}
pub const move_down_vim_meta: Meta = .{ .description = "Move cursor down (vim)", .arguments = &.{.integer} };
pub fn goto_line_vim(self: *Self, ctx: Context) Result {
try self.send_editor_jump_source();
var line: usize = 0;
_ = ctx.args.match(.{tp.extract(&line)}) catch false;
const root = self.buf_root() catch return;
const primary = self.get_primary();
try primary.cursor.move_to(root, @intCast(if (line < 1) 0 else line - 1), primary.cursor.col, self.metrics);
self.clamp();
try self.send_editor_jump_destination();
}
pub const goto_line_vim_meta: Meta = .{ .arguments = &.{.integer} };
};
fn is_eol_right_vim(root: Buffer.Root, cursor: *const Cursor, metrics: Buffer.Metrics) bool {