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 =
|
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
|
||||||
|
| 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) -> (
|
| Some (`Char cc) -> (
|
||||||
match res with
|
match res with
|
||||||
| Accepted _ | Continue _ ->
|
| Accepted _ | Continue _ ->
|
||||||
F.epr
|
F.epr
|
||||||
"Ui.process_events Lwt_stream.junk events@.";
|
"Ui.process_events Lwt_stream.junk events@.";
|
||||||
proc ~skip:(`Char cc) res
|
proc ~skip:(`Char cc) res
|
||||||
| Rejected -> proc res)
|
| Rejected -> )
|
||||||
| Some (`Key _) | None -> proc res)
|
| Some (`Key _) | None -> proc res *)
|
||||||
| `Char char -> (
|
>>=
|
||||||
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user