pretty good

This commit is contained in:
cqc
2021-08-10 23:31:52 -05:00
parent a4c10bbf57
commit 2e1c66f7b6
4 changed files with 38 additions and 23 deletions

42
main.ml
View File

@ -106,6 +106,8 @@ module Display = struct
(the Wall.image extents) *)
type pane = state -> state * image
type panebox = pane list -> state -> state * image
type panedom = Empty | Pane of pane | Box of (panebox * panedom list)
type frame = {
sdl_win : Sdl.window;
@ -204,6 +206,9 @@ module Display = struct
done;
print_endline "quit";
Sdl.hide_window frame.sdl_win;
Sdl.gl_delete_context frame.gl;
Sdl.destroy_window frame.sdl_win;
Sdl.quit ();
()
let gray ?(a = 1.0) v = Color.v v v v a
@ -564,8 +569,8 @@ let make_top storepath ?(branch = "current") () =
storeview = make_storeview storepath branch ();
}
in
(* Topinf.ppf := Format.formatter_of_symbolic_output_buffer t.res;
Format.pp_set_formatter_out_functions Format.std_formatter (out_funs_of_sob t.res);*)
Topinf.ppf := Format.formatter_of_symbolic_output_buffer t.res;
Format.pp_set_formatter_out_functions Format.std_formatter (out_funs_of_sob t.res);
let zctx = Zed_edit.context t.te.ze t.te.zc in
Zed_edit.insert zctx
(Zed_rope.of_string
@ -590,17 +595,19 @@ let draw_top (t : top) height (s : Display.state) =
(* HACK overwriting stdout formatter because fucking ocaml/toplevel/topdirs.ml hardcodes it *)
Format.pp_set_formatter_out_functions Format.std_formatter (out_funs_of_sob t.res);
let b = Buffer.create 69 in
format_symbolic_output_buffer (Format.formatter_of_buffer b) (Format.flush_symbolic_output_buffer t.res);
ignore (Lwt_main.run (Store.tree t.storeview.s >>= fun tree ->
Store.Tree.add tree (t.histpath @ ["output"]) (Buffer.contents b)));
Store.Tree.add tree (t.histpath @ ["input"]) (str_of_textedit t.te) ));
ignore (Format.flush_symbolic_output_buffer t.res);
eval ppf (str_of_textedit t.te ^ ";;"); (*HACK to prevent getting stuck in parser*)
let b = Buffer.create 69 in
format_symbolic_output_buffer (Format.formatter_of_buffer b) (Format.get_symbolic_output_buffer t.res);
ignore (Lwt_main.run (Store.tree t.storeview.s >>= fun tree ->
Store.Tree.add tree (t.histpath @ ["output"]) (Buffer.contents b)));
ignore (Lwt_main.run (Store.set_exn t.storeview.s ~info:(Irmin_unix.info "history")
t.path (str_of_textedit t.te)));
eval ppf (str_of_textedit t.te ^ ";;"); (*HACK to prevent getting stuck in parser*)
ignore
(Lwt_main.run
( Store.tree t.storeview.s >>= fun tree ->
Store.Tree.add tree (t.histpath @ ["input"]) (str_of_textedit t.te) ))
Zed_edit.clear_data t.te.ze;
| _ -> ());
pane_vbox
[
@ -617,24 +624,21 @@ let draw_top (t : top) height (s : Display.state) =
let top_1 = make_top "../rootstore" ()
let draw_komm (s : Display.state) =
let draw_komm_default (s : Display.state) =
let node, state, box = (ref I.empty, ref s, ref s.box) in
let push (s, (b, i)) =
node := I.stack !node i;
state := s;
box := b
in
push @@ fill_box (Display.gray 0.125) s.box !state;
(* gray bg *)
push @@ fill_box (Display.gray 0.125) s.box !state; (* gray bg *)
push @@ draw_top top_1 30. { s with box = !state.box };
(!state, (Box2.of_pts (Box2.o s.box) (Box2.max !box), !node))
let () = while true do
Display.(run (make_frame ~title:"hi" ~w:1440 ~h:900 ()) draw_komm) ()
done
let draw_komm = ref draw_komm_default
let () = Display.(run (make_frame ~title:"hi" ~w:1440 ~h:900 ()) !draw_komm) ()
(* Implement the "window management" as just toplevel defined functions that manipulate the window tree *)
(* also, i'm tired *)