=== modified file 'ppio.ml' --- ppio.ml 2019-04-13 01:27:26 +0000 +++ ppio.ml 2019-04-12 23:54:31 +0000 @@ -56,36 +56,6 @@ Out_channel.flush stderr; ;; -type display_mode = NoFormat | Normal | Escaped;; -type pretty_state = {to_print: Buffer.t; mutable dm: display_mode};; - -let pp_writer hideendl endl colors = - let s = {to_print = Buffer.create 80; dm = NoFormat} in - let write_out () = - if Buffer.length s.to_print > 0 then ( - Buffer.add_string s.to_print "\x1b[0m"; - Out_channel.output_buffer stderr s.to_print; - Out_channel.flush stderr; - Buffer.clear s.to_print; - s.dm <- NoFormat; - ) - and add_char c = - if c >= ' ' && c <= '~' then ( - Buffer.add_string s.to_print "\x1b["; - Buffer.add_string s.to_print colors.normal; - Buffer.add_char s.to_print 'm'; - Buffer.add_char s.to_print c; - ) else ( - bprintf s.to_print "\x1b[%sm\\x%02x" colors.escaped (Char.to_int c); - ) - in - fun (len:int) (buffer:Bytes.t) -> ( - for n = 0 to len - 1 do - add_char (Bytes.get buffer n); - done; - write_out ()) -;; - (* Copy data from the reader to the writer, using the provided buffer as scratch space *) let rec copy_blocks bufsize buffer r w cb () = @@ -137,13 +107,9 @@ Lwt_unix.set_blocking ~set_flags:true fd1 false; Unix.close stdin_r; Unix.close stdout_w; - let i_cb, o_cb = match color with - | None -> (cb_null, cb_null) - | Some cs -> ((pp_writer hideendl endl cs.i), (pp_writer hideendl endl cs.o)) - in Lwt_main.run (Lwt.join [ - copy_cb fd0 stdin_w i_cb; - copy_cb stdout_r fd1 o_cb; + copy_cb fd0 stdin_w cb_null; + copy_cb stdout_r fd1 cb_null; ]); let _, status = Subprocess.waitpid [] pid in exit (Subprocess.wait_estatus status);