Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nottui_widgets.edit_field's swallowing of keyboard shortcuts #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/nottui/nottui_widgets.ml
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ let edit_field ?(focus=Focus.make()) state ~on_change ~on_submit =
let handler = function
| `ASCII 'U', [`Ctrl] -> on_change ("", 0); `Handled (* clear *)
| `Escape, [] -> Focus.release focus_h; `Handled
| `ASCII k, _ ->
| `ASCII k, [] ->
let text =
if pos < String.length text then (
String.sub text 0 pos ^ String.make 1 k ^
Expand All @@ -395,7 +395,7 @@ let edit_field ?(focus=Focus.make()) state ~on_change ~on_submit =
in
on_change (text, (pos + 1));
`Handled
| `Backspace, _ ->
| `Backspace, [] ->
let text =
if pos > 0 then (
if pos < String.length text then (
Expand All @@ -409,7 +409,7 @@ let edit_field ?(focus=Focus.make()) state ~on_change ~on_submit =
let pos = maxi 0 (pos - 1) in
on_change (text, pos);
`Handled
| `Enter, _ -> on_submit (text, pos); `Handled
| `Enter, [] -> on_submit (text, pos); `Handled
| `Arrow `Left, [] ->
let pos = mini (String.length text) pos in
if pos > 0 then (
Expand Down