tried to resolve the duplicate Key problems but it's probably not perfect

This commit is contained in:
cqc
2024-06-29 20:20:22 -05:00
parent 1e3b9da1ed
commit 023495b3b0

43
ogui.ml
View File

@ -696,11 +696,10 @@ module Ui = struct
let process_events (ui : t) (events : event Lwt_stream.t) : unit = let process_events (ui : t) (events : event Lwt_stream.t) : unit =
Lwt.async (fun () -> Lwt.async (fun () ->
let rec proc ?(skip : event option) let rec proc (r : action list Event.result) :
(r : action list Event.result) :
action list Event.result Lwt.t = action list Event.result Lwt.t =
Lwt_stream.last_new events >>= function Lwt_stream.last_new events >>= function
| `Key (state, key, mods) -> ( | `Key (state, key, mods) ->
process_key ui r state key mods process_key ui r state key mods
>>= fun (res : action list Event.result) -> >>= fun (res : action list Event.result) ->
Event.( Event.(
@ -710,25 +709,29 @@ module Ui = struct
| Accepted _ -> "Accepted" | Accepted _ -> "Accepted"
| Continue _ -> "Continue" | Continue _ -> "Continue"
| Rejected -> "Rejected")); | Rejected -> "Rejected"));
Lwt_stream.peek events >>= function (match res with
| Some (`Char cc) -> ( | Accepted _ when mods = [] || mods == [ Shift ] -> (
match res with (* junk the `Char that is sent with a `Key that has no mods *)
| Accepted _ | Continue _ -> Lwt_stream.peek events
F.epr >>= function
"Ui.process_events Lwt_stream.junk events@."; | Some (`Char _) -> Lwt_stream.junk events
proc ~skip:(`Char cc) res | _ -> Lwt.return_unit)
| Rejected -> proc res) | Accepted _ | Continue _ | Rejected -> Lwt.return_unit)
| Some (`Key _) | None -> proc res) (*Lwt_stream.peek events >>= function
| `Char char -> ( | Some (`Char cc) -> (
match res with
| Accepted _ | Continue _ ->
F.epr
"Ui.process_events Lwt_stream.junk events@.";
proc ~skip:(`Char cc) res
| Rejected -> )
| Some (`Key _) | None -> proc res *)
>>=
fun () -> proc res
| `Char char ->
F.epr "Ui.process_events `Char '%a'@." pp_uchar F.epr "Ui.process_events `Char '%a'@." pp_uchar
(Uchar.of_int char); (Uchar.of_int char);
match skip with process_char char >>= fun () -> proc (Event.Accepted [])
| Some (`Char c) when c == char ->
F.epr "Ui.process_events skip match@.";
Lwt.return (Event.Accepted [])
| Some _ | None ->
process_char char >>= fun () ->
proc (Event.Accepted []))
in in
proc Event.Rejected >>= fun _ -> Lwt.return_unit) proc Event.Rejected >>= fun _ -> Lwt.return_unit)