tried to resolve the duplicate Key problems but it's probably not perfect
This commit is contained in:
31
ogui.ml
31
ogui.ml
@ -696,11 +696,10 @@ module Ui = struct
|
||||
|
||||
let process_events (ui : t) (events : event Lwt_stream.t) : unit =
|
||||
Lwt.async (fun () ->
|
||||
let rec proc ?(skip : event option)
|
||||
(r : action list Event.result) :
|
||||
let rec proc (r : action list Event.result) :
|
||||
action list Event.result Lwt.t =
|
||||
Lwt_stream.last_new events >>= function
|
||||
| `Key (state, key, mods) -> (
|
||||
| `Key (state, key, mods) ->
|
||||
process_key ui r state key mods
|
||||
>>= fun (res : action list Event.result) ->
|
||||
Event.(
|
||||
@ -710,25 +709,29 @@ module Ui = struct
|
||||
| Accepted _ -> "Accepted"
|
||||
| Continue _ -> "Continue"
|
||||
| Rejected -> "Rejected"));
|
||||
Lwt_stream.peek events >>= function
|
||||
(match res with
|
||||
| Accepted _ when mods = [] || mods == [ Shift ] -> (
|
||||
(* junk the `Char that is sent with a `Key that has no mods *)
|
||||
Lwt_stream.peek events
|
||||
>>= function
|
||||
| Some (`Char _) -> Lwt_stream.junk events
|
||||
| _ -> Lwt.return_unit)
|
||||
| Accepted _ | Continue _ | Rejected -> Lwt.return_unit)
|
||||
(*Lwt_stream.peek events >>= function
|
||||
| Some (`Char cc) -> (
|
||||
match res with
|
||||
| Accepted _ | Continue _ ->
|
||||
F.epr
|
||||
"Ui.process_events Lwt_stream.junk events@.";
|
||||
proc ~skip:(`Char cc) res
|
||||
| Rejected -> proc res)
|
||||
| Some (`Key _) | None -> proc res)
|
||||
| `Char char -> (
|
||||
| Rejected -> )
|
||||
| Some (`Key _) | None -> proc res *)
|
||||
>>=
|
||||
fun () -> proc res
|
||||
| `Char char ->
|
||||
F.epr "Ui.process_events `Char '%a'@." pp_uchar
|
||||
(Uchar.of_int char);
|
||||
match skip with
|
||||
| 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 []))
|
||||
process_char char >>= fun () -> proc (Event.Accepted [])
|
||||
in
|
||||
|
||||
proc Event.Rejected >>= fun _ -> Lwt.return_unit)
|
||||
|
||||
Reference in New Issue
Block a user