aboutsummaryrefslogtreecommitdiff
path: root/lib/input_screen.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-15 10:45:54 -0500
committerMarc Coquand <marc@mccd.space>2024-05-15 10:45:54 -0500
commit47892663040f7e295cc4052438cf804b040f0389 (patch)
treed299cb4f0741904b1a8d484a6fba365b41592bf5 /lib/input_screen.ml
parent7038e0073e7f7f672644ca949eeda399d6a533fb (diff)
downloadstitch-47892663040f7e295cc4052438cf804b040f0389.tar.gz
stitch-47892663040f7e295cc4052438cf804b040f0389.tar.bz2
stitch-47892663040f7e295cc4052438cf804b040f0389.zip
Add TODOs, update help, rebind keys
Diffstat (limited to 'lib/input_screen.ml')
-rw-r--r--lib/input_screen.ml15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/input_screen.ml b/lib/input_screen.ml
index 3fae53c..45979aa 100644
--- a/lib/input_screen.ml
+++ b/lib/input_screen.ml
@@ -22,12 +22,15 @@ let rec render t ({ user_input; on_enter; on_cancel; screen; prompt } as state)
| `End | `Key (`ASCII 'G', [ `Ctrl ]) | `Key (`ASCII 'C', [ `Ctrl ]) -> on_cancel ()
| `Key (`Enter, []) -> on_enter user_input
| `Key (`Backspace, []) ->
- let state =
- { state with
- user_input = String.sub user_input 0 (max (String.length user_input - 1) 0)
- }
- in
- render t state
+ if String.equal "" user_input
+ then on_cancel ()
+ else (
+ let state =
+ { state with
+ user_input = String.sub user_input 0 (max (String.length user_input - 1) 0)
+ }
+ in
+ render t state)
| `Resize _ -> render t state
| `Key (`ASCII c, []) ->
let state = { state with user_input = user_input ^ String.make 1 c } in