From f46d6661a8f33730c17cceb7e2885e789d6123d8 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Sun, 28 Jan 2024 01:30:55 +0100 Subject: feat: add goto (G key) command --- lib/editor.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/editor.ml') diff --git a/lib/editor.ml b/lib/editor.ml index 5a68e53..ea2e68a 100644 --- a/lib/editor.ml +++ b/lib/editor.ml @@ -244,7 +244,7 @@ module Action = struct | None -> let word = word |> Sequence.to_list |> String.of_list in set_message (Printf.sprintf "Pattern not found: %s" word) - | Some (r, c) -> Buffer.Action.goto r c |> on_focused_buffer + | Some (r, c) -> Buffer.Action.goto ~r ~c |> on_focused_buffer (* Debug *) let get_rendered e = (e.rendered, e) @@ -331,6 +331,10 @@ let handle_normal_command c = | Simple (Ctrl 'U') -> let* r, _ = get_terminal_size in Buffer.Action.move_up ~n:(r / 2) |> on_focused_buffer + | Shortcut (_, n, Goto) -> ( + match n with + | None -> Buffer.Action.eof |> on_focused_buffer + | Some n -> Buffer.Action.goto ~r:n |> on_focused_buffer) (* Yank *) | Shortcut (r, n, Yank) -> let n = Option.value ~default:1 n - 1 in -- cgit v1.2.3