From 9641927e8a4763bbcb1d4e16c3e3bcbc2a5b3e98 Mon Sep 17 00:00:00 2001 From: cqc Date: Thu, 9 May 2024 22:18:55 -0500 Subject: [PATCH] enter and repeats --- ogui.ml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/ogui.ml b/ogui.ml index 4917149..015e4fc 100644 --- a/ogui.ml +++ b/ogui.ml @@ -961,19 +961,25 @@ module TextEdit = struct |> adds [ [ Key (Press, F, [ Control ]) ]; + [ Key (Repeat, F, [ Control ]) ]; [ Key (Press, Right, []) ]; + [ Key (Repeat, Right, []) ]; ] [ Custom (fun () -> cursor_move t 1) ] |> adds [ [ Key (Press, B, [ Control ]) ]; + [ Key (Repeat, B, [ Control ]) ]; [ Key (Press, Left, []) ]; + [ Key (Repeat, Left, []) ]; ] [ Custom (fun () -> cursor_move t (-1)) ] |> adds [ [ Key (Press, N, [ Control ]) ]; + [ Key (Repeat, N, [ Control ]) ]; [ Key (Press, Down, []) ]; + [ Key (Repeat, Down, []) ]; ] [ Custom @@ -1002,7 +1008,10 @@ module TextEdit = struct ] |> adds [ - [ Key (Press, P, [ Control ]) ]; [ Key (Press, Up, []) ]; + [ Key (Press, P, [ Control ]) ]; + [ Key (Repeat, P, [ Control ]) ]; + [ Key (Press, Up, []) ]; + [ Key (Repeat, Up, []) ]; ] [ Custom @@ -1065,7 +1074,10 @@ module TextEdit = struct t.cursor.index))); ] |> adds - [ [ Key (Press, Backspace, []) ] ] + [ + [ Key (Press, Backspace, []) ]; + [ Key (Repeat, Backspace, []) ]; + ] [ Custom (fun () -> @@ -1075,6 +1087,17 @@ module TextEdit = struct t.text <- text; cursor_move t (-1)) else Lwt.return_unit); + ] + |> adds + [ [ Key (Press, Enter, []) ]; [ Key (Repeat, Enter, []) ] ] + [ + Custom + (fun () -> + TextBuffer.insert_uchar t.text t.cursor.index + (Uchar.of_char '\n') + >>= fun text -> + t.text <- text; + cursor_move t 1); ]; (* WARN XXX TKTK TODO this is probably "breaking" the lwt context and being used in other calls to Lwt_main.run *)