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