diff options
| author | Federico Igne <undyamon@disroot.org> | 2024-01-28 01:30:55 +0100 |
|---|---|---|
| committer | Federico Igne <undyamon@disroot.org> | 2024-01-28 01:30:55 +0100 |
| commit | f46d6661a8f33730c17cceb7e2885e789d6123d8 (patch) | |
| tree | af1dae9f7f5b7eae8a161b4ea9e4392d297676f3 /lib/editor.ml | |
| parent | 53916fc3f7dcbefd90e3d0340a2a8f32bf331d1d (diff) | |
| download | sandy-f46d6661a8f33730c17cceb7e2885e789d6123d8.tar.gz sandy-f46d6661a8f33730c17cceb7e2885e789d6123d8.zip | |
feat: add goto (G key) command
Diffstat (limited to 'lib/editor.ml')
| -rw-r--r-- | lib/editor.ml | 6 |
1 files changed, 5 insertions, 1 deletions
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 | |||
| 244 | | None -> | 244 | | None -> |
| 245 | let word = word |> Sequence.to_list |> String.of_list in | 245 | let word = word |> Sequence.to_list |> String.of_list in |
| 246 | set_message (Printf.sprintf "Pattern not found: %s" word) | 246 | set_message (Printf.sprintf "Pattern not found: %s" word) |
| 247 | | Some (r, c) -> Buffer.Action.goto r c |> on_focused_buffer | 247 | | Some (r, c) -> Buffer.Action.goto ~r ~c |> on_focused_buffer |
| 248 | 248 | ||
| 249 | (* Debug *) | 249 | (* Debug *) |
| 250 | let get_rendered e = (e.rendered, e) | 250 | let get_rendered e = (e.rendered, e) |
| @@ -331,6 +331,10 @@ let handle_normal_command c = | |||
| 331 | | Simple (Ctrl 'U') -> | 331 | | Simple (Ctrl 'U') -> |
| 332 | let* r, _ = get_terminal_size in | 332 | let* r, _ = get_terminal_size in |
| 333 | Buffer.Action.move_up ~n:(r / 2) |> on_focused_buffer | 333 | Buffer.Action.move_up ~n:(r / 2) |> on_focused_buffer |
| 334 | | Shortcut (_, n, Goto) -> ( | ||
| 335 | match n with | ||
| 336 | | None -> Buffer.Action.eof |> on_focused_buffer | ||
| 337 | | Some n -> Buffer.Action.goto ~r:n |> on_focused_buffer) | ||
| 334 | (* Yank *) | 338 | (* Yank *) |
| 335 | | Shortcut (r, n, Yank) -> | 339 | | Shortcut (r, n, Yank) -> |
| 336 | let n = Option.value ~default:1 n - 1 in | 340 | let n = Option.value ~default:1 n - 1 in |
