From 46169ec3eb38e177cafd7faf6338d36c6a9e3971 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Thu, 27 Nov 2025 23:35:08 +0100 Subject: Whatever all of this is --- bin/dune | 2 +- bin/main.ml | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 106 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/dune b/bin/dune index 34c3866..64e7c56 100644 --- a/bin/dune +++ b/bin/dune @@ -3,4 +3,4 @@ (name main) (preprocess (pps ppx_jane)) - (libraries rdcapsis)) + (libraries rdcapsis imguiml lwd nottui nottui-unix notty notty.unix)) diff --git a/bin/main.ml b/bin/main.ml index 8b1be23..b3f4ec9 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -1,3 +1,106 @@ +open Nottui +module W = Nottui_widgets + +let f_to_c x = (x -. 32.0) *. 5.0 /. 9.0 +let c_to_f x = (x *. 9.0 /. 5.0) +. 32.0 +let degrees = Lwd.var 0.0 +let farenheit = Lwd.var (nan, ("", 0)) + +let farenheit_text = + Lwd.map2 (Lwd.get degrees) (Lwd.get farenheit) ~f:(fun d (d', f) -> + if d = d' then f else (string_of_float (c_to_f d), 0)) + +let farenheit_edit = + W.edit_field farenheit_text + ~on_change:(fun ((text, _) as state) -> + let d = + match float_of_string_opt text with + | None -> Lwd.peek degrees + | Some d -> + let d = f_to_c d in + Lwd.set degrees d; + d + in + Lwd.set farenheit (d, state)) + ~on_submit:ignore + +let celsius = Lwd.var (nan, ("", 0)) + +let celsius_text = + Lwd.map2 (Lwd.get degrees) (Lwd.get celsius) ~f:(fun d (d', f) -> + if d = d' then f else (string_of_float d, 0)) + +let celsius_edit = + W.edit_field celsius_text + ~on_change:(fun ((text, _) as state) -> + let d = + match float_of_string_opt text with + | None -> Lwd.peek degrees + | Some d -> + Lwd.set degrees d; + d + in + Lwd.set celsius (d, state)) + ~on_submit:ignore + +let root = + Lwd_utils.pack Ui.pack_y + [ + Lwd.pure (W.string "Celsius:"); + celsius_edit; + Lwd.pure (W.string "Farenheight:"); + farenheit_edit; + ] + +let root = + Lwd_utils.pack Ui.pack_y + [ + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + ] + +let root = + Lwd_utils.pack Ui.pack_x + [ + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + root; + ] + +let root = W.scrollbox root +let () = Nottui_unix.run ~tick_period:0.2 root + open Rdcapsis.Prelude let () = @@ -7,9 +110,9 @@ let () = ~f:(Rdcapsis.Ingcsv.read_channel ~ams_tz) |> Result.unwrap in - let euc_id = "EUC" in + let euc_id = "EUR/C" in let ledger = List.map_result ~f:(Rdcapsis.Convert.les_from_current_acc euc_id) prim_txs - |> Result.unwrap |> List.concat + |> Result.unwrap |> List.concat |> Rdcapsis.Ledger.make in print_endline (Sexp.to_string_hum ([%sexp_of: Rdcapsis.Ledger.t] ledger)) -- cgit v1.2.3