now to fix the toplevel library loading...
This commit is contained in:
109
oplevel.ml
109
oplevel.ml
@ -70,6 +70,7 @@ let main =
|
||||
|
||||
F.pr "oplevel.ml: Toploop.initialize_toplevel_env@.";
|
||||
Toploop.initialize_toplevel_env ();
|
||||
|
||||
let rootrepo =
|
||||
Store.init_default
|
||||
(F.str "%s/console/rootstore.git" Secrets.giturl)
|
||||
@ -98,24 +99,80 @@ let main =
|
||||
Ogui.Ui.chrcallback ui ch >>= fun _ -> Lwt.return_unit)))
|
||||
|> ignore;
|
||||
|
||||
GLFW.setWindowSizeCallback ~window
|
||||
~f:
|
||||
(Some
|
||||
Gg.(
|
||||
fun _window x y ->
|
||||
Lwd.set ui.rect
|
||||
(Box2.v V2.zero (V2.v (float x) (float y)))))
|
||||
|> ignore;
|
||||
|
||||
F.pr "oplevel.ml: building initial page@.";
|
||||
TextBuffer.of_repo
|
||||
~initial_path:[ ".config"; "init.ml" ]
|
||||
~repo:rootrepo
|
||||
>>= fun tb_init ->
|
||||
Layout.textedit (TextEdit.multiline ui tb_init) >>= fun te_init ->
|
||||
let page =
|
||||
Layout.(
|
||||
vbox
|
||||
~style:
|
||||
Style.{ default with margin = Margin.symmetric 10.0 10.0 }
|
||||
[
|
||||
te_init;
|
||||
(*textedit
|
||||
(TextEdit.multiline ui
|
||||
(TextBuffer.of_repo ~path:[ "README" ] ~repo:rootrepo)); *)
|
||||
])
|
||||
let initial_path = [ ".config"; "init.ml" ] in
|
||||
TextBuffer.of_repo ~initial_path ~repo:rootrepo >>= fun tb_init ->
|
||||
TextBuffer.of_string ~repo:rootrepo
|
||||
~path:
|
||||
(List.fold_right
|
||||
(fun a (acc : string list) ->
|
||||
match acc with
|
||||
| [] -> [ F.str "%s.output" a ]
|
||||
| a' -> a :: a')
|
||||
[] initial_path)
|
||||
(F.str "(* --- output:%s --- *)\n\n"
|
||||
(String.concat "/" initial_path))
|
||||
|> Lwt.return
|
||||
>>= fun to_init ->
|
||||
let out_ppf =
|
||||
let insert s =
|
||||
Lwt.async (fun () ->
|
||||
TextBuffer.length to_init >>= fun len ->
|
||||
(* TKTK if buffer is modified here during yield from >>= it could be weird *)
|
||||
TextBuffer.insert to_init len s)
|
||||
in
|
||||
Format.formatter_of_out_functions
|
||||
Format.
|
||||
{
|
||||
out_string = (fun s _ _ -> insert s);
|
||||
out_flush = (fun () -> ());
|
||||
out_indent = (fun n -> insert (String.make (n * 2) ' '));
|
||||
out_newline = (fun () -> insert "\n");
|
||||
out_spaces = (fun n -> insert (String.make n ' '));
|
||||
}
|
||||
in
|
||||
|
||||
ignore
|
||||
(Toploop.use_input out_ppf (String "#use \"topfind\";;\n#list;;"));
|
||||
(* toplevel execution binding *)
|
||||
Ui.(
|
||||
update_bindings ui
|
||||
Event.(
|
||||
fun a ->
|
||||
a
|
||||
|> adds
|
||||
[
|
||||
[
|
||||
Key (Press, X, [ Control ]);
|
||||
Key (Release, X, [ Control ]);
|
||||
Key (Press, E, [ Control ]);
|
||||
];
|
||||
]
|
||||
[
|
||||
Custom
|
||||
(fun () ->
|
||||
F.epr "Ctrl-X Ctrl-E@.";
|
||||
TextBuffer.peek tb_init >>= fun str ->
|
||||
Toploop.use_input out_ppf (String str)
|
||||
|> F.epr "Toploop.use_input=%b@.";
|
||||
Lwt.return_unit);
|
||||
]));
|
||||
|
||||
Layout.(
|
||||
tiling ui `Y
|
||||
~style:
|
||||
Style.{ default with margin = Margin.symmetric 10.0 10.0 }
|
||||
[ TextEdit.multiline ui tb_init; TextEdit.multiline ui to_init ])
|
||||
>>= fun page ->
|
||||
let page_root = Lwd.observe page in
|
||||
|
||||
let open GLFW in
|
||||
@ -178,25 +235,5 @@ let main =
|
||||
Printf.printf "MIN %.2f\n" !min_fps;
|
||||
Printf.printf "MAX %.2f\n%!" !max_fps;
|
||||
Lwt.return_unit
|
||||
(* let out_ppf =
|
||||
Format.formatter_of_out_functions
|
||||
Format.
|
||||
{
|
||||
out_string = (fun s _ _ -> output_buffer#insert s);
|
||||
out_flush = (fun () -> ());
|
||||
out_indent =
|
||||
(fun n ->
|
||||
for _ = 0 to n do
|
||||
output_buffer#insert " "
|
||||
done);
|
||||
out_newline = (fun () -> output_buffer#insert "\n");
|
||||
out_spaces =
|
||||
(fun n -> output_buffer#insert (String.make n ' '));
|
||||
}
|
||||
in *)
|
||||
|
||||
(* ignore
|
||||
(Toploop.use_input out_ppf
|
||||
(String "#use \"topfind\";;\n#list;;")); *)
|
||||
|
||||
let () = Lwt_main.run main
|
||||
|
||||
Reference in New Issue
Block a user