···10921092 term
10931093 root
10941094 =
10951095+ Printf.eprintf "running step\n";
10951096 let size = Term.size term in
10961097 let image =
10971098 if (not (Lwd.is_damaged root)) && !cache |> Option.is_some
···11041105 (* If we are already damaged then we should re-calculate*)
11051106 if Lwd.is_damaged root then stabilize () else image
11061107 in
11071107- stabilize ())
11081108+ stabilize ()
11091109+11101110+ )
11081111 in
11091112 cache := Some image;
11101113 Term.image term image;
···11221125 (* let has_event =Term.pending term in *)
11231126 if wait_for_event ()
11241127 then (
11251125- Printf.eprintf "getting term event\n";
11261128 match Term.event term with
11271129 | `End -> ()
11281130 | `Resize _ -> ()
···11841186 ?term
11851187 ?(renderer = Renderer.make ())
11861188 ?quit
11871187- ?(quit_on_escape = true)
11891189+ ?(quit_on_escape = false)
11881190 ?(quit_on_ctrl_q = true)
11891191 t
11901192 =
+7-20
forks/nottui/lib/nottui_picos/nottui_picos.ml
···1010 let step computation in_fd =
1111 Ui_loop.Internal.step ~await_read:(fun _ timeout ->
1212 let rec select () =
1313- Printf.eprintf "waiting on events\n";
1414- computation := Ivar.create ();
1515- let cancelEvent = Ivar.read_evt !computation in
1613 let ret =
1714 Event.select
1815 [ Picos_io_select.on in_fd `R |> Event.map (fun x -> `Ready)
1919- ; Picos_io_select.on in_fd `W |> Event.map (fun _ -> `Ready)
2020- ; cancelEvent
2121- |> Event.map (fun x ->
2222- Printf.eprintf "rerun-invalidation\n";
2323- `LwdStateUpdate)
2424- ; Picos_io_select.timeout ~seconds:10.0
2525- |> Event.map (fun x -> `NotReady)
1616+ (* This doesn't seem to be needed *)
1717+ (* ; Picos_io_select.on in_fd `W |> Event.map (fun _ -> `Ready) *)
1818+ ; Event.from_computation !computation |> Event.map (fun _ -> `LwdStateUpdate)
2619 ]
2720 in
2828- Printf.eprintf "finished waiting\n";
2121+ Printf.eprintf "done waiting\n";
2922 ret
3030- (* match Picos_io.Unix.select [ in_fd ] [] [ in_fd ] timeout with *)
3131- (* | [], [], [] -> `NotReady *)
3232- (* | _ -> `Ready *)
3333- (* | exception Unix.Unix_error (Unix.EINTR, _, _) -> select () *)
3423 in
3524 select ())
3625 ;;
···4534 then Picos_io.Unix.stdin
4635 else Picos_io_fd.create ~dispose:false in_fd
4736 in
4848- let trigger = ref (Ivar.create ()) in
3737+ let trigger = ref (Computation.create ()) in
4938 let step = step trigger in_picos_fd in
5039 a := !a + 1;
5140 Ui_loop.Internal.run_with_term
5252- ~on_invalidate:(fun _ ->
5353- Printf.eprintf "invalidated\n";
5454- Ivar.fill !trigger ())
4141+ ~on_invalidate:(fun _ -> Computation.finish !trigger;)
5542 ~step
5643 term
5744 ;;
58455959- let run = Ui_loop.Internal.run ~run_with_term
4646+ let run = Ui_loop.Internal.run ~run_with_term ~tick_period:100.0
6047end
···2121- This allows for way less idle usage
2222- This allows us to support selection
2323 - Currently we cannot select becasue the terminal is constatnly re-rendering, I could fix that now probably, but the picos change would also fix it
2424+2525+2626+## Allow single threading support to also behave the same way
2727+I can make this work single threaded as well.
2828+Instead of using async await.
2929+1. use a very small timeout in unix.select/ polling
3030+2. on_invalidate set the invalidate flag true
3131+3. Re-render when it's been set to true
3232+3333+3434+## locking issues
3535+Currently we have an issue with lwd and locking.
3636+Basically we want to observe all invalidation that isn't processed already
3737+- Nottui will reprocess the node before rendering if it's already invalid
3838+- Lwd has oninvalidate but it runs event lwd.set that is being delayed because we are during recomputation.
3939+I want to capture all invalidation between the last call to stabalize in nottui and the next event whether that be a invalidation event or a keypress