"header" parsing

This commit is contained in:
cqc
2024-02-16 18:23:15 -06:00
parent e2a574d215
commit faa945f65c
6 changed files with 89 additions and 26 deletions

View File

@ -23,7 +23,6 @@ open Js_of_ocaml_lwt
open Js_of_ocaml_tyxml
open Js_of_ocaml_toplevel
open Lwt
open Store
let compiler_name = "OCaml"
let by_id s = Dom_html.getElementById s
@ -378,11 +377,10 @@ module History = struct
textbox##.value := Js.string !data.(!idx))
end
let run setup_storeview () =
let run ~output () =
Firebug.console##log "run";
let container = by_id "toplevel-container" in
let output = by_id "output" in
let textbox : 'a Js.t =
by_id_coerce "userinput" Dom_html.CoerceTo.textarea
in
@ -390,9 +388,7 @@ let run setup_storeview () =
let sharp_ppf = Format.formatter_of_out_channel sharp_chan in
let caml_chan = open_out "/dev/null1" in
let caml_ppf = Format.formatter_of_out_channel caml_chan in
Firebug.console##log "run(Store.test_pull)";
let execute () =
let content = Js.to_string textbox##.value##trim in
let execute ?(pp_code = sharp_ppf) content () =
let content' =
let len = String.length content in
if
@ -407,8 +403,8 @@ let run setup_storeview () =
current_position := output##.childNodes##.length;
textbox##.value := Js.string "";
History.push content;
JsooTop.execute true ~pp_code:sharp_ppf ~highlight_location
caml_ppf content';
JsooTop.execute true ~pp_code ~highlight_location caml_ppf
content';
resize ~container ~textbox () >>= fun () ->
container##.scrollTop := container##.scrollHeight;
textbox##focus;
@ -456,7 +452,8 @@ let run setup_storeview () =
Dom_html.handler (fun e ->
match e##.keyCode with
| 13 when not (meta e || shift e) ->
Lwt.async execute;
Lwt.async (fun () ->
execute (Js.to_string textbox##.value##trim) ());
Js._false
| 13 ->
Lwt.async (resize ~container ~textbox);
@ -508,7 +505,6 @@ let run setup_storeview () =
setup_share_button ~output;
(* setup_examples ~container ~textbox; *)
setup_pseudo_fs ~load_cmis_from_server:false;
setup_storeview ~container ~textbox;
setup_toplevel ();
setup_js_preview ();
setup_printers ();
@ -518,7 +514,8 @@ let run setup_storeview () =
try
let code = List.assoc "code" (parse_hash ()) in
textbox##.value := Js.string (B64.decode code);
Lwt.async execute
Lwt.async (fun () ->
execute (Js.to_string textbox##.value##trim) ())
with
| Not_found -> ()
| exc ->