comparison scripts/plot/private/__gnuplot_has_terminal__.m @ 10967:2470b1bf191a

__gnuplot_has_terminal__.m: New function.
author Ben Abbott <bpabbott@mac.com>
date Mon, 13 Sep 2010 20:56:01 -0400
parents
children c9b0a75b02e8
comparison
equal deleted inserted replaced
10966:07b4cd795742 10967:2470b1bf191a
1 ## Copyright (C) 2010 Ben Abbott
2 ##
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
7 ##
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU General Public License
14 ## along with Octave; see the file COPYING. If not, see
15 ## <http://www.gnu.org/licenses/>.
16
17 ## -*- texinfo -*-
18 ## @deftypefn {Function File} {@var{has_terminal} =} __gnuplot_has_terminal__ (@var{terminal})
19 ## Undocumented internal function.
20 ## @end deftypefn
21
22 ## Author: Ben Abbott <bpabbott@mac.com>
23 ## Created: 2010-09-13
24
25 function gnuplot_supports_term = __gnuplot_has_terminal__ (term, plot_stream)
26 term = deblank (term);
27 n = find (term == " ", 1);
28 if (! isempty (n))
29 term = term(1:n-1);
30 endif
31 if (__gnuplot_has_feature__ ("variable_GPVAL_TERMINALS"))
32 if (nargin < 2)
33 plot_stream = __gnuplot_open_stream__ (2);
34 endif
35 available_terminals = __gnuplot_get_var__ (plot_stream, "GPVAL_TERMINALS");
36 available_terminals = regexp (available_terminals, "\\b\\w+\\b", "match");
37 if (nargin < 2 && ! isempty (plot_stream))
38 pclose (plot_stream(1));
39 if (numel (plot_stream) > 1)
40 pclose (plot_stream(2));
41 endif
42 if (numel (plot_stream) > 2)
43 waitpid (plot_stream(3));
44 endif
45 endif
46 else
47 ## Gnuplot 4.0 terminals. No new terminals were added until 4.4 which
48 ## allows the list of terminals to be obtained from GPVAL_TERMINALS.
49 available_terminals = {"aifm", "aqua", "canvas", "cgm", "corel", ...
50 "dumb", "dxf", "eepic", "emf", "epslatex", ...
51 "epson_180dpi", "fig", "gif", "gnugraph", ...
52 "gpic", "hp2623A", "hp2648", "hp500c", ...
53 "hpgl", "hpljii", "hppj", "imagen", "jpeg", ...
54 "latex", "mf", "mif", "mp", "pbm", "pdf", ...
55 "pm", "png", "postscript", "pslatex", ...
56 "pstex", "pstricks", "qms", "regis", "rgip", ...
57 "svg", "texdraw", "tgif", "tkcanvas", ...
58 "tpic", "windows", "x11", "xlib", "xterm"};
59 endif
60 gnuplot_supports_term = any (strcmpi (available_terminals, term));
61 endfunction
62