Merge branch 'master' into zig-0.14

This commit is contained in:
CJ van den Berg 2025-02-19 21:36:09 +01:00
commit 90bacba8d5
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 19 additions and 12 deletions

View file

@ -30,8 +30,8 @@
["ctrl+l", "scroll_view_center_cycle"], ["ctrl+l", "scroll_view_center_cycle"],
["ctrl+n", "goto_next_match"], ["ctrl+n", "goto_next_match"],
["ctrl+p", "goto_prev_match"], ["ctrl+p", "goto_prev_match"],
["ctrl+b", "move_to_char", false], ["ctrl+b", "move_to_char", "left"],
["ctrl+t", "move_to_char", true], ["ctrl+t", "move_to_char", "right"],
["ctrl+x", "cut"], ["ctrl+x", "cut"],
["ctrl+c", "copy"], ["ctrl+c", "copy"],
["ctrl+v", "system_paste"], ["ctrl+v", "system_paste"],

View file

@ -85,6 +85,9 @@
["<C-k>", "TODO"], ["<C-k>", "TODO"],
["F", "move_to_char", "left"],
["f", "move_to_char", "right"],
["<C-CR>", ["move_down"], ["move_begin"]], ["<C-CR>", ["move_down"], ["move_begin"]],
["<CR>", ["move_down"], ["move_begin"]] ["<CR>", ["move_down"], ["move_begin"]]
] ]

View file

@ -2084,21 +2084,25 @@ pub const Editor = struct {
} }
fn move_cursor_up(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { fn move_cursor_up(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void {
try cursor.move_up(root, metrics); cursor.move_up(root, metrics) catch |e| switch (e) {
error.Stop => cursor.move_begin(),
};
} }
fn move_cursor_up_vim(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { fn move_cursor_up_vim(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void {
try cursor.move_up(root, metrics); try cursor.move_up(root, metrics);
if(is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics); if (is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics);
} }
fn move_cursor_down(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { fn move_cursor_down(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void {
try cursor.move_down(root, metrics); cursor.move_down(root, metrics) catch |e| switch (e) {
error.Stop => cursor.move_end(root, metrics),
};
} }
fn move_cursor_down_vim(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void { fn move_cursor_down_vim(root: Buffer.Root, cursor: *Cursor, metrics: Buffer.Metrics) !void {
try cursor.move_down(root, metrics); try cursor.move_down(root, metrics);
if(is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics); if (is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics);
} }
fn move_cursor_buffer_begin(_: Buffer.Root, cursor: *Cursor, _: Buffer.Metrics) !void { fn move_cursor_buffer_begin(_: Buffer.Root, cursor: *Cursor, _: Buffer.Metrics) !void {
@ -2123,7 +2127,7 @@ pub const Editor = struct {
fn move_cursor_half_page_up_vim(root: Buffer.Root, cursor: *Cursor, view: *const View, metrics: Buffer.Metrics) !void { fn move_cursor_half_page_up_vim(root: Buffer.Root, cursor: *Cursor, view: *const View, metrics: Buffer.Metrics) !void {
cursor.move_half_page_up(root, view, metrics); cursor.move_half_page_up(root, view, metrics);
if(is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics); if (is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics);
} }
fn move_cursor_half_page_down(root: Buffer.Root, cursor: *Cursor, view: *const View, metrics: Buffer.Metrics) !void { fn move_cursor_half_page_down(root: Buffer.Root, cursor: *Cursor, view: *const View, metrics: Buffer.Metrics) !void {
@ -2132,7 +2136,7 @@ pub const Editor = struct {
fn move_cursor_half_page_down_vim(root: Buffer.Root, cursor: *Cursor, view: *const View, metrics: Buffer.Metrics) !void { fn move_cursor_half_page_down_vim(root: Buffer.Root, cursor: *Cursor, view: *const View, metrics: Buffer.Metrics) !void {
cursor.move_half_page_down(root, view, metrics); cursor.move_half_page_down(root, view, metrics);
if(is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics); if (is_eol_vim(root, cursor, metrics)) try move_cursor_left_vim(root, cursor, metrics);
} }
pub fn primary_click(self: *Self, y: c_int, x: c_int) !void { pub fn primary_click(self: *Self, y: c_int, x: c_int) !void {

View file

@ -30,13 +30,13 @@ const Operation = enum {
}; };
pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tui.MiniMode } { pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tui.MiniMode } {
var right: bool = true; var direction: Direction = undefined;
const select = if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| true else false else false; const select = if (tui.get_active_editor()) |editor| if (editor.get_primary().selection) |_| true else false else false;
_ = ctx.args.match(.{tp.extract(&right)}) catch return error.InvalidMoveToCharArgument; _ = ctx.args.match(.{tp.extract(&direction)}) catch return error.InvalidMoveToCharArgument;
const self: *Self = try allocator.create(Self); const self: *Self = try allocator.create(Self);
self.* = .{ self.* = .{
.allocator = allocator, .allocator = allocator,
.direction = if (right) .right else .left, .direction = direction,
.operation = if (select) .select else .move, .operation = if (select) .select else .move,
}; };
try self.commands.init(self); try self.commands.init(self);