refactor: move goto_line_vim into mode specific commands files
This commit is contained in:
parent
5f242d6cf2
commit
0cba416ec4
3 changed files with 25 additions and 12 deletions
|
|
@ -5460,18 +5460,6 @@ pub const Editor = struct {
|
||||||
}
|
}
|
||||||
pub const goto_line_meta: Meta = .{ .arguments = &.{.integer} };
|
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 {
|
pub fn goto_column(self: *Self, ctx: Context) Result {
|
||||||
const root = self.buf_root() catch return;
|
const root = self.buf_root() catch return;
|
||||||
const primary = self.get_primary();
|
const primary = self.get_primary();
|
||||||
|
|
|
||||||
|
|
@ -522,6 +522,18 @@ const cmds_ = struct {
|
||||||
ed.need_render();
|
ed.need_render();
|
||||||
}
|
}
|
||||||
pub const replace_with_character_helix_meta: Meta = .{ .description = "Replace with character" };
|
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 } {
|
fn get_context() ?struct { *MainView, *Editor } {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const command = @import("command");
|
const command = @import("command");
|
||||||
|
const tp = @import("thespian");
|
||||||
const cmd = command.executeName;
|
const cmd = command.executeName;
|
||||||
|
|
||||||
const tui = @import("../tui.zig");
|
const tui = @import("../tui.zig");
|
||||||
|
|
@ -209,6 +210,18 @@ const cmds_ = struct {
|
||||||
self.clamp();
|
self.clamp();
|
||||||
}
|
}
|
||||||
pub const move_down_vim_meta: Meta = .{ .description = "Move cursor down (vim)", .arguments = &.{.integer} };
|
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 {
|
fn is_eol_right_vim(root: Buffer.Root, cursor: *const Cursor, metrics: Buffer.Metrics) bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue