diff --git a/a.out b/a.out index a434301..02fabc2 100755 Binary files a/a.out and b/a.out differ diff --git a/pretty_printing.cmi b/pretty_printing.cmi index fb0adfb..8363eb2 100644 Binary files a/pretty_printing.cmi and b/pretty_printing.cmi differ diff --git a/pretty_printing.cmo b/pretty_printing.cmo index 5c5e058..358514f 100644 Binary files a/pretty_printing.cmo and b/pretty_printing.cmo differ diff --git a/pretty_printing.ml b/pretty_printing.ml index 23bfcd3..b7d1450 100644 --- a/pretty_printing.ml +++ b/pretty_printing.ml @@ -130,7 +130,7 @@ let draw_line_bresenham mat cls origin x1 y1 x2 y2 cutoff = done;; let display mat cls = - let colors = [|"\027[40m"; "\027[41m"; "\027[42m"; "\027[43m"; "\027[44m"; "\027[45m"; "\027[46m"; "\027[47m"; "\027[100m"; "\027[101m"; "\027[102m"; "\027[103m"; "\027[104m"; "\027[105m"; "\027[106m"; "\027[107m"|] in + let colors = [|"\027[0m"; "\027[41m"; "\027[42m"; "\027[43m"; "\027[44m"; "\027[45m"; "\027[46m"; "\027[47m"; "\027[100m"; "\027[101m"; "\027[102m"; "\027[103m"; "\027[104m"; "\027[105m"; "\027[106m"; "\027[107m"|] in for i = 0 to (Array.length mat -1) do for j = 0 to (Array.length mat.(i) -1) do if cls.(i).(j) = 0 then @@ -223,18 +223,35 @@ let extremely_fancy_graph_printing g size wmult mode = (* show the image *) ignore (Sys.command "clear"); if mode = "SPECIFIC" then begin - Printf.printf "Enter the node you want to highlight (type -1 to show all; or -2 to exit)\n"; - ignore (Sys.command "clear"); - let nd = ref (-2) in - - nd := Scanf.bscanf Scanf.Scanning.stdin "%d\n" identity; + let halt = ref false in + while !halt = false do - if !nd >= 0 && !nd < Array.length g then - display_specific px cls (!nd+1) - else if !nd = -1 then - display px cls - else - () + Stdlib.print_endline "Enter the node you want to highlight (type -1 to show all; -2 to exit; -3 to stream all)"; + let nd = ref (-2) in + + nd := Scanf.bscanf Scanf.Scanning.stdin "%d\n" identity; + ignore (Sys.command "clear"); + + if !nd >= 0 && !nd < Array.length g then + display_specific px cls (!nd+1) + else if !nd = -1 then + display px cls + else if !nd = -2 then + halt := true + else if !nd = -3 then begin + for i = 0 to (Array.length g -1) do + ignore (Sys.command "clear"); + display_specific px cls (i+1); + Stdlib.print_endline "_"; + ignore (Sys.command "sleep 1"); + done; + display px cls; + Stdlib.print_endline "_"; + ignore (Sys.command "sleep 1"); + end + else + () + done end else display px cls ;; @@ -244,6 +261,6 @@ let gr = [|[|3; 5; 7|]; [|0|]; [|1; 7; 8|]; [|2; 6|]; [|0; 1; 3|]; [|6; 7|]; [|0 (*print_mat gr ;;*) -extremely_fancy_graph_printing gr 44 4 "EVERYTHING" ; +extremely_fancy_graph_printing gr 44 4 "SPECIFIC" ; (* ocamlfind ocamlc -linkpkg -package unix pretty_printing.ml *) \ No newline at end of file