Skip to content

Commit

Permalink
Strip Lwt_io from SvgPainter
Browse files Browse the repository at this point in the history
Now, Lwt is only used in the small apps using the lib.
  • Loading branch information
jnavila committed Nov 3, 2017
1 parent 809a996 commit 2e6c1eb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/plotgitsch.ml
Expand Up @@ -97,7 +97,7 @@ let process_file initctx svg_name content =
initctx >>= fun init ->
content >|= Str.split (Str.regexp "\n") >>= fun lines ->
Lwt_stream.fold parse_line (Lwt_stream.of_list lines) init >>= fun endcontext ->
Lwt_io.with_file ~mode:Lwt_io.Output svg_name (fun o -> SvgPainter.write o (output_context endcontext))
Lwt_io.with_file ~mode:Lwt_io.Output svg_name (fun o -> Lwt_io.write o (SvgPainter.write @@ output_context endcontext))

let rev_parse r =
let open Lwt_process in
Expand Down
2 changes: 1 addition & 1 deletion src/plotkicadsch.ml
Expand Up @@ -9,7 +9,7 @@ let process_file init sch =
fun o -> Lwt_io.open_file ~mode:Lwt_io.Input sch >>=
fun i -> Lwt_stream.fold parse_line (Lwt_io.read_lines i) init >>=
fun endcontext -> let canvas:SvgPainter.t = (output_context endcontext) in
SvgPainter.write o canvas >>=
Lwt_io.write o (SvgPainter.write canvas) >>=
fun _ -> Lwt_io.close i >>=
fun _ -> Lwt_io.close o

Expand Down
7 changes: 2 additions & 5 deletions src/svgPainter.ml
Expand Up @@ -76,11 +76,8 @@ let get_context () = {d=(0,0) ; c=[]}

let set_canevas_size x y ctxt = {ctxt with d = (x,y)}

let write oc {d= (x,y); c} =
let write {d= (x,y); c} =
let fx = float x in
let fy = float y in
let svg_doc = svg ~a:[a_width (fx *. 0.00254, Some `Cm); a_height (fy *. 0.00254, Some `Cm); a_viewBox (0.,0., float x, float y); a_font_family "Noto Sans"] c in
let s = Format.asprintf "%a" (Tyxml.Svg.pp ()) svg_doc in
(* let fmt = Format.formatter_of_out_channel oc in
Tyxml.Svg.pp () fmt svg_doc *)
Lwt_io.write oc s
Format.asprintf "%a" (Tyxml.Svg.pp ()) svg_doc

0 comments on commit 2e6c1eb

Please sign in to comment.