# HG changeset patch # User Ben Abbott # Date 1259046128 -3600 # Node ID a14e1561350950029a878dfb567852eab89bf6d6 # Parent 52d8ad5d28d6925ee65331f03344928d89ccbb23 gnuplot_drawnow.m: Support gnuplot's dumb terminal. diff -r 52d8ad5d28d6 -r a14e15613509 scripts/ChangeLog --- a/scripts/ChangeLog Tue Nov 24 08:02:00 2009 +0100 +++ b/scripts/ChangeLog Tue Nov 24 08:02:08 2009 +0100 @@ -1,3 +1,7 @@ +2009-11-08 Petr Mikulik + + * plot/gnuplot_drawnow.m: Support gnuplot's dumb terminal. + 2009-11-02 Stefan Hepp * plot/gnuplot_drawnow.m (gnuplot_default_term): Don't set term to diff -r 52d8ad5d28d6 -r a14e15613509 scripts/plot/gnuplot_drawnow.m --- a/scripts/plot/gnuplot_drawnow.m Tue Nov 24 08:02:00 2009 +0100 +++ b/scripts/plot/gnuplot_drawnow.m Tue Nov 24 08:02:08 2009 +0100 @@ -87,9 +87,29 @@ else new_stream = false; endif - enhanced = gnuplot_set_term (plot_stream (1), new_stream, h); + term = gnuplot_default_term (); + if (strcmp (term, "dumb")) + ## popen2 eats stdout of gnuplot, use temporary file instead + dumb_tmp_file = tmpnam (); + enhanced = gnuplot_set_term (plot_stream (1), new_stream, h, ... + term, dumb_tmp_file); + else + enhanced = gnuplot_set_term (plot_stream (1), new_stream, h, term); + end __go_draw_figure__ (h, plot_stream (1), enhanced, mono, 0); fflush (plot_stream (1)); + if (strcmp (term, "dumb")) + fid = -1; + while (fid < 0) + pause (0.1); + fid = fopen (dumb_tmp_file, 'r'); + endwhile + ## reprint the plot on screen + [a, count] = fscanf (fid, '%c', Inf); + puts (a); + fclose (fid); + unlink (dumb_tmp_file); + endif else print_usage (); endif @@ -143,8 +163,8 @@ if (! isempty (h) && isfigure (h)) - ## Generate gnuoplot title string for backend plot windows. - if (output_to_screen (term)) + ## Generate gnuplot title string for backend plot windows. + if (output_to_screen (term) && ~strcmp (term, "dumb")) fig.numbertitle = get (h, "numbertitle"); fig.name = get (h, "name"); if (strcmpi (get (h, "numbertitle"), "on")) @@ -239,6 +259,15 @@ elseif (strncmpi (term, "aqua", 3)) ## Aqua has size, but the format is different. size_str = sprintf ("size %d %d", gnuplot_size); + elseif (strncmpi (term, "dumb", 3)) + new_stream = 1; + if (~isempty (getenv ("COLUMNS")) && ~isempty (getenv ("LINES"))) + ## Let dumb use full text screen size. + size_str = ["size ", getenv("COLUMNS"), " ", getenv("LINES")]; + else + ## Use the gnuplot default. + size_str = ""; + end elseif (strncmpi (term, "fig", 3)) ## Fig also has size, but the format is different. size_str = sprintf ("size %.15g %.15g", gnuplot_size); @@ -290,7 +319,7 @@ ## flickering window (x11, windows, & wxt) when the mouse and ## multiplot are set in gnuplot. fputs (plot_stream, "unset multiplot;\n"); - flickering_terms = {"x11", "windows", "wxt"}; + flickering_terms = {"x11", "windows", "wxt", "dumb"}; if (! any (strcmp (term, flickering_terms)) || numel (findall (h, "type", "axes")) > 1 || numel (findall (h, "type", "image")) > 0) @@ -315,7 +344,6 @@ ## figure title, enhanced mode, or position. endif - endfunction function term = gnuplot_default_term () @@ -329,7 +357,7 @@ elseif (! isempty (getenv ("DISPLAY"))) term = "x11"; else - term = "unknown"; + term = "dumb"; endif endif endfunction @@ -363,7 +391,7 @@ endfunction function ret = output_to_screen (term) - ret = any (strcmpi ({"aqua", "wxt", "x11", "windows", "pm"}, term)); + ret = any (strcmpi ({"aqua", "dumb", "wxt", "x11", "windows", "pm"}, term)); endfunction function ret = term_units_are_pixels (term)