this repo has no description

add X_ocaml_lib.output_html

ArthurW 889cd800 09ae6b5a

+57 -21
+1 -1
bin/x_ocaml.ml
··· 152 152 | [] -> targets 153 153 | _ -> targets @ ppxs @ [ "ppxlib_register" ] 154 154 in 155 - let env = Env.empty in 155 + let env = Env.singleton "x-ocaml.lib" in 156 156 let env, all_ppxs = dependencies ~ppx:true ppxs env in 157 157 let _env, all_libs = dependencies ~ppx:false targets env in 158 158 let all = all_ppxs @ all_libs in
+1
protocol/dune
··· 1 1 (library 2 + (public_name x-ocaml.protocol) 2 3 (name x_protocol) 3 4 (libraries merlin-js.protocol))
+5 -1
protocol/x_protocol.ml
··· 8 8 | Format of id * string 9 9 | Setup 10 10 11 - type output = Stdout of string | Stderr of string | Meta of string 11 + type output = 12 + | Stdout of string 13 + | Stderr of string 14 + | Meta of string 15 + | Html of string 12 16 13 17 type response = 14 18 | Merlin_response of id * Merlin_protocol.answer
+11 -6
src/cell.ml
··· 158 158 refresh_lines_from ~editor 159 159 160 160 let render_message msg = 161 + let raw_html s = 162 + let el = El.div [] in 163 + let el_t = El.to_jv el in 164 + Jv.set el_t "innerHTML" (Jv.of_jstr @@ Jstr.of_string s); 165 + el 166 + in 161 167 let kind, text = 162 168 match msg with 163 - | X_protocol.Stdout str -> ("stdout", str) 164 - | Stderr str -> ("stderr", str) 165 - | Meta str -> ("meta", str) 169 + | X_protocol.Stdout str -> ("stdout", El.txt' str) 170 + | Stderr str -> ("stderr", El.txt' str) 171 + | Meta str -> ("meta", El.txt' str) 172 + | Html str -> ("html", raw_html str) 166 173 in 167 - El.pre 168 - ~at:[ At.class' (Jstr.of_string ("caml_" ^ kind)) ] 169 - [ El.txt (Jstr.of_string text) ] 174 + El.pre ~at:[ At.class' (Jstr.of_string ("caml_" ^ kind)) ] [ text ] 170 175 171 176 let add_message t loc msg = 172 177 Editor.add_message t.cm loc (List.map render_message msg)
+1 -2
src/editor.ml
··· 39 39 let refresh_messages ed = 40 40 Code_mirror.Editor.View.dispatch ed.view 41 41 (Code_mirror.Compartment.reconfigure ed.messages_comp 42 - [ render_messages ed ]); 43 - Code_mirror.Editor.View.request_measure ed.view 42 + [ render_messages ed ]) 44 43 45 44 let custom_ln editor = 46 45 Code_mirror.Editor.View.line_numbers (fun x ->
+13
src/style.css
··· 74 74 padding-bottom: 0.5em; 75 75 background: #eee; 76 76 } 77 + .caml_html { 78 + margin: 0; 79 + padding: 0.2em 0.5em; 80 + color: black; 81 + border: 1px solid transparent; 82 + white-space: collapse; 83 + } 84 + 85 + table, tr, td, th { 86 + border: 1px solid black; 87 + border-collapse: collapse; 88 + padding: 0.2em; 89 + }
+4
worker-lib/dune
··· 1 + (library 2 + (public_name x-ocaml.lib) 3 + (name x_ocaml_lib) 4 + (libraries x-ocaml.protocol js_of_ocaml))
+8
worker-lib/x_ocaml_lib.ml
··· 1 + let id = ref (0, 0) 2 + 3 + let output_html m = 4 + let id, loc = !id in 5 + Js_of_ocaml.Worker.post_message 6 + (X_protocol.resp_to_bytes 7 + (X_protocol.Top_response_at (id, loc, [ Html m ]))); 8 + ()
+5
worker-lib/x_ocaml_lib.mli
··· 1 + val output_html : string -> unit 2 + 3 + (**/**) 4 + 5 + val id : (int * int) ref
+6 -10
worker/dune
··· 1 1 (library 2 2 (name x_worker) 3 - (libraries 4 - brr 5 - js_of_ocaml 6 - js_of_ocaml-toplevel 7 - x_protocol 8 - merlin-js.worker 9 - ocamlformat-lib 10 - ocamlformat-lib.parser_extended 3 + (libraries brr js_of_ocaml js_of_ocaml-toplevel x-ocaml.protocol x-ocaml.lib 4 + merlin-js.worker ocamlformat-lib ocamlformat-lib.parser_extended 11 5 ocamlformat-lib.format_)) 12 6 13 7 (rule ··· 18 12 %{targets} 19 13 (progn 20 14 (cat %{deps}) 21 - (echo "Ast_mapper\n"))))) 15 + (echo "Ast_mapper\n") 16 + (echo "X_ocaml_lib\n"))))) 22 17 23 18 (rule 24 19 (target export-stdlib.txt) 25 20 (action 26 - (run jsoo_listunits -o %{target} stdlib))) 21 + (run jsoo_listunits -o %{target} stdlib 22 + %{dep:../worker-lib/x_ocaml_lib.cma})))
+2 -1
worker/eval.ml
··· 67 67 List.rev out 68 68 in 69 69 let respond ~(at_loc : Location.t) = 70 - let loc = at_loc.loc_end.pos_cnum - line_number in 70 + let loc = at_loc.loc_end.pos_cnum in 71 71 let out = get_out () in 72 72 output ~loc out 73 73 in ··· 89 89 | Ptop_dir { pdir_loc = loc; _ } -> loc 90 90 | _ -> assert false 91 91 in 92 + X_ocaml_lib.id := (id, at_loc.loc_end.pos_cnum); 92 93 try 93 94 Location.reset (); 94 95 let phrase = preprocess_phrase phrase in