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