1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055
|
/*
* $Id: x11.trm,v 1.106 2004/04/14 05:53:42 sfeam Exp $
*
*/
/* GNUPLOT - x11.trm */
/*[
* Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the complete modified source code. Modifications are to
* be distributed as patches to the released version. Permission to
* distribute binaries produced by compiling modified sources is granted,
* provided you
* 1. distribute the corresponding source modifications from the
* released version in the form of a patch file along with the binaries,
* 2. add special version identification to distinguish your version
* in addition to the base release version number,
* 3. provide your name and address as the primary contact for the
* support of your modified version, and
* 4. retain our contact information in regard to use of the base
* software.
* Permission to distribute the released version of the source code along
* with corresponding source modifications in the form of a patch file is
* granted with same provisions 2 through 4 for binary distributions.
*
* This software is provided "as is" without express or implied warranty
* to the extent permitted by applicable law.
]*/
/*
* x11.trm --- inboard terminal driver for X11
*/
/* Petr Mikulik and Johannes Zellner: added mouse support (October 1999)
* Implementation and functionality is based on pm.trm
*/
/* X11 support for Petr Mikulik's pm3d
* by Johannes Zellner <johannes@zellner.org>
* (November 1999 - January 2000)
*/
/* Dynamic font support, enhanced text mode support,
* additional feedback from outboard driver
* Ethan A Merritt <merritt@u.washington.edu>
* 2003
*/
#include "driver.h"
#ifdef TERM_REGISTER
register_term(x11)
#endif
#ifdef TERM_PROTO
int X11_args __PROTO((int argc, char *argv[]));
TERM_PUBLIC void X11_options __PROTO((void));
TERM_PUBLIC void X11_init __PROTO((void));
TERM_PUBLIC void X11_graphics __PROTO((void));
TERM_PUBLIC void X11_text __PROTO((void));
TERM_PUBLIC int X11_set_font __PROTO((const char * fontname));
TERM_PUBLIC void X11_reset __PROTO((void));
TERM_PUBLIC void X11_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void X11_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void X11_linewidth __PROTO((double lw));
TERM_PUBLIC void X11_pointsize __PROTO((double ps));
TERM_PUBLIC void X11_linetype __PROTO((int lt));
TERM_PUBLIC void X11_put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
TERM_PUBLIC int X11_text_angle __PROTO((int i));
TERM_PUBLIC int X11_justify_text __PROTO((enum JUSTIFY mode));
TERM_PUBLIC void X11_point __PROTO((unsigned int x, unsigned int y, int number));
TERM_PUBLIC void X11_fillbox __PROTO((int style, unsigned int x, unsigned y, unsigned int width, unsigned int height));
# ifdef USE_MOUSE
TERM_PUBLIC int X11_waitforinput __PROTO((void));
TERM_PUBLIC void X11_set_ruler __PROTO((int, int));
TERM_PUBLIC void X11_set_cursor __PROTO((int, int, int));
TERM_PUBLIC void X11_put_tmptext __PROTO((int, const char str[]));
TERM_PUBLIC void X11_set_clipboard __PROTO((const char[]));
TERM_PUBLIC void X11_update_opts __PROTO((void));
# endif
# ifdef PM3D
TERM_PUBLIC int X11_make_palette __PROTO((t_sm_palette *));
TERM_PUBLIC void X11_set_color __PROTO((double));
TERM_PUBLIC void X11_filled_polygon __PROTO((int, gpiPoint *));
/* these must match the definitions in gplt_x11.c */
# define X11_GR_MAKE_PALETTE 'p'
# define X11_GR_RELEASE_PALETTE 'e'
# define X11_GR_SET_COLOR 'c'
# define X11_GR_FILLED_POLYGON 'f'
# endif
/* To support "set term x11 enhanced" */
TERM_PUBLIC void ENHX11_put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
TERM_PUBLIC void ENHX11_OPEN __PROTO((char * fontname, double fontsize,
double base, TBOOLEAN widthflag, TBOOLEAN showflag,
int overprint));
TERM_PUBLIC void ENHX11_FLUSH __PROTO((void));
# define X11_XMAX 4096
# define X11_YMAX 4096
/* approximations for typical font/screen sizes */
# define X11_VCHAR (X11_YMAX/25)
# define X11_HCHAR (X11_XMAX/100)
# define X11_VTIC (X11_YMAX/100)
# define X11_HTIC (X11_XMAX/150)
#endif /* TERM_PROTO */
#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
#include <ctype.h>
#ifdef PM3D
# include "getcolor.h"
#endif
/* non-zero if '-display' found on command line */
static int X11_Display = 0;
static char X11_default_font[MAX_ID_LEN+1] = {'\0'};
static char X11_last_font_used[MAX_ID_LEN+1] = {'\01','\0'};
static char X11_next_font_used[MAX_ID_LEN+1] = {'\0'};
static enum JUSTIFY X11_last_justification = LEFT;
static void X11_atexit __PROTO((void));
static void X11_set_default_font __PROTO((void));
/* Merged the old char X11_opts[] and int X11_optarg[]
* into one array of structs.
* Loosely based on XrmOptionDescRec, the use of which
* would probably be overkill here. */
typedef enum { hasNoArg, hasArg } OptionArg;
static struct x11opt {
const char *option; /* Name of option */
OptionArg arg; /* Whether option has argument */
} X11_cmdopts[] = {
{ "-mono", hasNoArg}, { "-gray", hasNoArg}, { "-clear", hasNoArg},
{ "-tvtwm", hasNoArg}, { "-pointsize", hasArg},
{ "-iconic", hasNoArg}, { "-rv", hasNoArg},
{ "-reverse", hasNoArg}, { "+rv", hasNoArg},
{ "-synchronous", hasNoArg},
{ "-display", hasArg}, { "-geometry", hasArg}, { "-bg", hasArg},
{ "-background", hasArg}, { "-bd", hasArg},
{ "-bordercolor", hasArg}, { "-bw", hasArg},
{ "-borderwidth", hasArg}, { "-fg", hasArg},
{ "-foreground", hasArg}, { "-fn", hasArg}, { "-font", hasArg},
{ "-name", hasArg},
{ "-selectionTimeout", hasArg}, { "-title", hasArg},
{ "-xnllanguage", hasArg}, { "-xrm", hasArg},
{ "-raise", hasNoArg}, { "-noraise", hasNoArg},
{ "-persist", hasNoArg}
#ifdef USE_MOUSE
, { "-nofeedback", hasNoArg}
, { "-noevents", hasNoArg}
#endif
};
#define X11_nopts (sizeof(X11_cmdopts) / sizeof(X11_cmdopts[0]))
static FILE *X11_ipc = (FILE *) 0;
#ifdef PIPE_IPC
#define X11_ipc_back_fd ipc_back_fd
#endif
static char **xargv = (char **) NULL;
/* reserve a minimum 10 driver opts */
static char *optvec[2 * X11_nopts + 1 + 10];
/* gnuplot_x11 has extension .exe on OS/2 and Windows (and on RSX/VMS, but
these construct their own full path GNUPLOT_X11 in their build script).
*/
# if defined(OS2) || defined(_Windows)
# ifndef GNUPLOT_X11
static char X11_default_command[] = "gnuplot_x11.exe";
# else
static char X11_default_command[] = GNUPLOT_X11 ".exe";
# endif
# else /* thus !OS/2 && !Windows */
# ifndef GNUPLOT_X11
static char X11_default_command[] = "gnuplot_x11";
# else
static char X11_default_command[] = GNUPLOT_X11;
# endif
# endif /* OS/2 || Windows */
static char *X11_command = X11_default_command;
static char *X11_command_parsed = NULL;
static char *X11_full_command_path = NULL;
/* must match the definition in src/gplt_x11.c: */
static int persist = UNSET;
static int do_raise = UNSET;
#ifdef USE_MOUSE
/* Interlock to prevent the mouse channel from being coopted more than
* once per plot by the gnuplot_x11<->x11.trm font information query.
*/
static TBOOLEAN default_font_size_known = FALSE;
static TBOOLEAN X11_MOUSE_FEEDBACK = TRUE;
#endif
#ifdef PIPE_IPC
static TBOOLEAN IPC_LOCK = FALSE;
#endif
static int parse_driver __PROTO((const char *));
static int
parse_driver(const char *cmd)
{
int nr = 0;
char *ptr;
/* make a copy of cmd, as parsing will modify the string */
X11_command_parsed = gp_realloc(X11_command_parsed,
strlen(cmd) + 1, "x11->parse_driver");
strcpy(X11_command_parsed, X11_command);
ptr = X11_command_parsed;
while (*ptr != '\0' && nr < sizeof(optvec) / sizeof(char)) {
/* Strip whitespace. Use nulls, so that
* the previous argument is terminated
* automatically.
*/
while (isspace((unsigned char)*ptr))
*ptr++ = '\0';
if (!(*ptr)) /* don't count the terminating NULL */
break;
/* Save the argument. */
optvec[nr++] = ptr;
/* Skip over the argument. */
while ('\0' != *ptr && !isspace((unsigned char)*ptr)) {
ptr++;
}
}
/* HBB 20020214: new code to prepend the environment X11_DRIVER_DIR
* to the command name, if it doesn't contain any slashes yet */
if (!strchr(optvec[0],'/')) {
char *dir = getenv("GNUPLOT_DRIVER_DIR");
if (!dir)
dir = X11_DRIVER_DIR;
#ifndef OS2
if (dir[0] != '/' && dir[0] != '.')
int_error(NO_CARET, "Illegal X11 driver directory name!");
#endif
X11_full_command_path = gp_realloc(X11_full_command_path,
strlen(dir) + strlen(optvec[0]) + 2,
"x11 driver pathname");
/* optvec[0] = X11_full_command_path; */
if (*dir)
sprintf(X11_full_command_path, "%s/%s", dir, optvec[0]);
else
sprintf(X11_full_command_path, "%s", optvec[0]);
}
return nr;
}
/* X11_args - scan gnuplot command line for standard X Toolkit options
* called from plot.c so must not be TERM_PUBLIC (which may be static)
*/
int
X11_args(int argc, char *argv[])
{
int nx11 = 0, i, n;
xargv = (char **) gp_alloc(argc * sizeof(char *), "<xargv>");
if (!xargv) {
fputs("not enough memory to copy argv - quitting\n", stderr);
exit(EXIT_FAILURE);
}
/* We make a copy of the argument vector because
* argv is modified later. */
memcpy(xargv, argv, argc * sizeof(char *));
i = parse_driver(X11_command);
while (++argv, ++xargv, --argc > 0) {
for (n = 0; n < X11_nopts; n++) {
if (strcmp(*argv, X11_cmdopts[n].option) == 0) {
optvec[i++] = *xargv;
#ifdef USE_MOUSE
if (strcmp(*argv, "-nofeedback") == 0)
X11_MOUSE_FEEDBACK = FALSE;
#endif
if (strcmp(*argv, "-display") == 0)
X11_Display++;
if (X11_cmdopts[n].arg == hasArg) {
if (--argc <= 0)
return nx11;
optvec[i++] = *++xargv, ++argv;
nx11++;
}
if (i >= (sizeof(optvec) / sizeof(char))) {
fprintf(stderr, "warning: X11 options will be truncated\n");
return nx11; /* optvec is full */
}
nx11++;
break;
}
}
if (n == X11_nopts)
break;
}
return (nx11);
}
static unsigned int X11_plot_number;
enum X11_id {
X11_RESET,
X11_CLOSE,
X11_PERSIST,
X11_NOPERSIST,
X11_RAISE,
X11_NORAISE,
X11_FONT,
X11_TITLE,
X11_ENHANCED,
X11_OTHER
};
static struct gen_table X11_opts[] = {
{"res$et", X11_RESET},
{"cl$ose", X11_CLOSE},
{"per$sist", X11_PERSIST},
{"noper$sist", X11_NOPERSIST},
{"rai$se", X11_RAISE},
{"norai$se", X11_NORAISE},
{"font", X11_FONT},
{"fn$ame", X11_FONT},
{"ti$tle", X11_TITLE},
{"enh$anced", X11_ENHANCED},
{NULL, X11_OTHER}
};
TERM_PUBLIC void
X11_options()
{
#define NOT_PROCESS_IF_DUPLICATION 1
struct value a;
int c_title_token = 0;
int new_term_number = 0;
TBOOLEAN duplication = FALSE;
TBOOLEAN set_reset = FALSE, set_persist = FALSE, set_raise = FALSE, set_font = FALSE;
TBOOLEAN set_title = FALSE, set_number = FALSE, set_close = FALSE;
while (!END_OF_COMMAND) {
switch (lookup_table(&X11_opts[0], c_token)) {
case X11_RESET:
c_token++;
if (set_reset) duplication=TRUE;
set_reset = TRUE;
break;
case X11_CLOSE:
c_token++;
if (set_close) duplication=TRUE;
set_close = TRUE;
break;
case X11_PERSIST:
persist = yes;
c_token++;
if (set_persist) duplication=TRUE;
set_persist = TRUE;
break;
case X11_NOPERSIST:
persist = no;
c_token++;
if (set_persist) duplication=TRUE;
set_persist = TRUE;
break;
case X11_RAISE:
do_raise = yes;
c_token++;
if (set_raise) duplication=TRUE;
set_raise = TRUE;
break;
case X11_NORAISE:
do_raise = no;
c_token++;
if (set_raise) duplication=TRUE;
set_raise = TRUE;
break;
case X11_FONT:
c_token++;
if (END_OF_COMMAND)
int_error(c_token, "expecting font name");
if (isstring(c_token))
quote_str( X11_default_font, c_token, sizeof(X11_default_font) );
else
copy_str( X11_default_font, c_token, sizeof(X11_default_font) );
c_token++;
if (set_font) duplication=TRUE;
set_font = TRUE;
break;
case X11_TITLE:
c_token++;
if (END_OF_COMMAND)
int_error(c_token, "expecting title text");
c_title_token = c_token;
c_token++;
if (set_title) duplication=TRUE;
set_title = TRUE;
break;
case X11_ENHANCED:
term->put_text = ENHX11_put_text;
c_token++;
break;
case X11_OTHER:
default:
/* let gnuplot_x11 check range */
new_term_number = (int) real(const_express(&a));
if (set_number) duplication=TRUE;
set_number = TRUE;
break;
}
if (duplication) {
int_error(c_token-1, "duplicated or contradicting arguments in X11 term options");
}
}
X11_init();
if (set_reset)
X11_atexit(); /* tell gnuplot_x11 to shut down */
/* Leave the current window unchanged when closing an old window */
if (set_close) {
if (X11_ipc) {
fprintf(X11_ipc, (set_number ? "C%d\n" : "C\n"), new_term_number);
fflush(X11_ipc);
}
} else if (set_number) {
X11_plot_number = new_term_number;
if (X11_ipc) {
fprintf(X11_ipc, "N%d\n", X11_plot_number);
fflush(X11_ipc);
}
}
sprintf(term_options, "%d", X11_plot_number);
if (UNSET != do_raise) {
strcat(term_options, (yes == do_raise ? " raise" : " noraise"));
}
if (UNSET != persist) {
strcat(term_options, (yes == persist ? " persist" : " nopersist"));
}
if (term->put_text == ENHX11_put_text) {
strcat(term_options, " enhanced");
}
if (*X11_default_font) {
strcat(term_options, " font \"");
strcat(term_options, X11_default_font);
strcat(term_options, "\"");
}
if (set_title) {
char *title;
strncat(term_options, " title \"", MAX_LINE_LEN-strlen(term_options));
title = term_options + strlen(term_options);
if (isstring(c_title_token))
quote_str(term_options+strlen(term_options), c_title_token, MAX_LINE_LEN-strlen(term_options));
else
copy_str(term_options+strlen(term_options), c_title_token, MAX_LINE_LEN-strlen(term_options));
#define X11_COMMAND_BUFFER_LENGTH 1024
/* #include "gplt_x11.h" X11_COMMAND_BUFFER_LENGTH defined in here in future */
if (X11_ipc) {
/* Send up to maximum buffer length minus three characters of
* title string to account for required 'n', '\0', '\n'.
*/
int i;
fputc('n', X11_ipc);
for (i=0; i < X11_COMMAND_BUFFER_LENGTH-3 && title[i] != '\0'; i++)
fputc(title[i], X11_ipc);
fputc('\0', X11_ipc);
fputc('\n', X11_ipc);
fflush(X11_ipc);
}
strncat(term_options, "\"", MAX_LINE_LEN-strlen(term_options));
}
#ifdef USE_MOUSE
X11_update_opts();
#endif
}
#ifdef USE_MOUSE
TERM_PUBLIC void
X11_update_opts(void)
{
if (X11_ipc && (UNSET != do_raise || UNSET != persist)) {
fprintf(X11_ipc, "X %d %d\n", do_raise, persist);
fflush(X11_ipc);
}
}
#endif
/*-----------------------------------------------------------------------------
* Three different versions of the remainder of the X11 terminal driver
* are provided to support three different types of IPC with the
* gnuplot_x11 outboard terminal driver:
*
* DEFAULT_X11: popen() pipe for most un*x platforms
*
* CRIPPLED_SELECT : file IPC for un*x platforms with incomplete or faulty
* implementation of BSD select()
*
* VMS : mailbox/spawn IPC
*---------------------------------------------------------------------------*/
#define DEFAULT_X11
#if defined(VMS) || defined(CRIPPLED_SELECT)
# undef DEFAULT_X11
#endif
#if defined(VMS) && defined(CRIPPLED_SELECT)
Error.Incompatible options.
#endif
/* we do not want to have to duplicate all the code, so we
* do most of it with macros.
* PRINT0(format), PRINT1(format, p1), PRINT2(format, p1, p2) etc
* also FLUSH0(format), etc, which do an additional flush
*/
#ifdef DEFAULT_X11
/*-----------------------------------------------------------------------------
* DEFAULT_X11 popen() pipe IPC
*---------------------------------------------------------------------------*/
static void
X11_atexit()
{
if (X11_ipc) {
fputs("R\n", X11_ipc);
fclose(X11_ipc);
/* dont wait(), since they might be -persist */
X11_ipc = NULL;
#ifdef PIPE_IPC
close(ipc_back_fd);
ipc_back_fd = -1;
#endif
}
}
#ifdef USE_MOUSE
TERM_PUBLIC int
X11_waitforinput()
{
#ifdef PIPE_IPC
fd_set fds;
static struct gp_event_t ge;
static int l = 0;
int n;
int fd = fileno(stdin);
int repeat_count = 0;
AGAIN:
/* XXX: if the input device it not a tty (e.g. /dev/null)
* mouse events are not processed. This is necessary
* as on some systems /dev/null is not selectable.
* TODO: should we close the ipc_back_fd in this case ? */
if (ipc_back_fd >= 0)
do {
int ierr;
FD_ZERO(&fds);
FD_SET(fd, &fds);
FD_SET(ipc_back_fd, &fds);
ierr = select(ipc_back_fd + 1, SELECT_TYPE_ARG234 &fds, 0, 0, NULL);
if (ierr < 0 && errno == EINTR) {
FD_ZERO(&fds);
continue;
}
if (FD_ISSET(ipc_back_fd, &fds)) {
n = read(ipc_back_fd, (void *) (l + (char *) &ge), sizeof(ge) - l);
if (n == 0) {
close(ipc_back_fd);
ipc_back_fd = -1;
/* don't close X11_ipc, otherwise later writes
* to it will cause a segfault */
IPC_LOCK = FALSE;
break; /* outboard driver has stopped */
}
l += n;
if (l == sizeof(ge)) {
/* note: do_event() may not return (if an
* error occurs), so need to reset l first */
l = 0;
do_event(&ge);
if (ge.type == GE_fontprops) {
if (repeat_count > 0) {
FPRINTF((stderr,
"X11_waitforinput: caught GE_fontprops after %d tries\n",
repeat_count));
}
return(GE_fontprops);
}
}
}
} while (!FD_ISSET(fd, &fds));
/* If ipc_back_fd is not open, we will never see any mouse clicks! */
else if (paused_for_mouse) {
paused_for_mouse = FALSE;
int_error(NO_CARET,"Mousing not active");
}
/* IPC_LOCK indicates that we are specifically waiting for a reply on */
/* the mousing channel. If stdin unblocks first, defer reading it, */
/* wait a few microseconds, and try again. */
/* FIXME EAM - Give up after 1.0 second. This will drop input chars, */
/* but at least it won't hang forever if the X11 connection is bad. */
if (IPC_LOCK) {
#ifdef HAVE_USLEEP
usleep(10);
#endif
if (repeat_count++ < 100000)
goto AGAIN;
}
/* Same sort of thing if we are specifically waiting for mouse input. */
if (paused_for_mouse) {
#ifdef HAVE_USLEEP
usleep(10);
#endif
goto AGAIN;
}
#endif /* PIPE_IPC */
# if 0
/* HBB 20010620: switching back and forth between X11 and a non-GUI
* terminal, while stdin is redirected, causes gnuplot to terminate
* right after it re-enters the X11 terminal --- read() returns a '\0'
* character once, and then EOF. Switching to <stdio.h>'s getc() fixed
* that, for me. */
if (read(0, &c, 1) != 1)
return EOF;
else
return c;
# else
return getc(stdin);
# endif /* 0/1 */
}
#endif /* USE_MOUSE */
TERM_PUBLIC void
X11_init()
{
static int been_here = 0;
if (!X11_ipc) {
/* first time through or after a reset */
#if defined(OSK)
/* OS-9 popen() does not block on close for child to end, so
* we can safely use it here
*/
/* FIXME HBB 20020214: This doesn't understand X11_DRIVER_DIR
* or $GNUPLOT_DRIVER_DIR yet. This may break execution of
* freshly built gnuplot until 'make install' */
X11_ipc = popen(X11_command, "w");
#else
#if defined(OS2)
/* FIXME amai 20020219: nice try...
* But popen() does return a non-NULL handle to almost command,
* it's just a new session which will stop if the command does
* not exist... We should stat() for the argument?! */
/* X11_ipc = popen(X11_full_command_path, "w");
if (X11_ipc==NULL) */
{
X11_ipc = popen(X11_command, "w");
}
#else /* !(OSK || OS/2) */
int fdes[2];
# ifdef PIPE_IPC
int fdes_back[2];
#define X11_ALLOW_EVENTS (mouse_setting.on || isatty_state)
if (X11_ALLOW_EVENTS) {
if (pipe(fdes_back))
perror("pipe() failed:");
}
# endif /* PIPE_IPC */
if (pipe(fdes))
perror("pipe() failed:");
if (fork() == 0) {
/* child */
# ifdef PIPE_IPC
char noevents[] = "-noevents";
if (X11_ALLOW_EVENTS) {
dup2(fdes_back[1], 1); /* stdout to pipe */
close(fdes_back[0]);
} else {
char **ptr;
for (ptr = optvec; ptr && *ptr; ptr++)
; /* do nothing: skip over set arguments */
/* tell the driver not to supply any events by
* appending "-noevents" to the optvec list. */
*ptr = noevents;
*++ptr = (char *) 0; /* terminate */
}
# endif /* PIPE_IPC */
/* close the write side of the child's forward fd */
close(fdes[1]);
dup2(fdes[0], 0); /* stdin from pipe */
execvp(X11_full_command_path, optvec);
/* if we get here, something went wrong */
fprintf(stderr,"Expected X11 driver: %s\n",X11_full_command_path);
perror("Exec failed");
fprintf(stderr,"See 'help x11' for more details\n");
exit(EXIT_FAILURE);
}
/* parent */
# ifdef PIPE_IPC
/* X11_ipc_out = fdopen(fdes[0], "r"); */
if (ipc_back_fd > 0) {
fprintf(stderr, "(X11_init) warning: unclosed ipc_back_fd.\n");
fprintf(stderr, " this is probably a program error.\n");
close(ipc_back_fd);
}
if (X11_ALLOW_EVENTS) {
ipc_back_fd = fdes_back[0];
close(fdes_back[1]); /* the parent doesn't need this */
} else {
/* we do not open a bidirectional communication
* for non-tty's by default. If this is desired,
* the mouse must be turned on explicitely *before*
* starting the x11 driver.
* So: if we're here, we close the ipc-back-channel
* which will cause a SIGPIPE in the driver. This
* is *ugly* but it works. (joze) */
/* close(fdes_back[0]); */
/* mark ipc_back_fd as unusable */
ipc_back_fd = IPC_BACK_UNUSABLE;
}
# endif /* PIPE_IPC */
/* close the read side of the parent's forward fd */
close(fdes[0]);
X11_ipc = fdopen(fdes[1], "w");
#endif /* !OSK */
#endif /* !OS/2 */
}
if (!been_here) {
GP_ATEXIT(X11_atexit);
been_here++;
}
#ifdef USE_MOUSE
default_font_size_known = FALSE;
X11_update_opts();
#endif
}
TERM_PUBLIC void
X11_reset()
{
/* leave the pipe alone, until exit or set term x11 reset */
}
#define PRINT0(fmt) fprintf(X11_ipc, fmt)
#define PRINT1(fmt,p1) fprintf(X11_ipc, fmt,p1)
#define PRINT2(fmt,p1,p2) fprintf(X11_ipc, fmt,p1,p2)
#define PRINT3(fmt,p1,p2,p3) fprintf(X11_ipc, fmt,p1,p2,p3)
#define PRINT4(fmt,p1,p2,p3,p4) fprintf(X11_ipc, fmt,p1,p2,p3,p4)
#define PRINT5(fmt,p1,p2,p3,p4,p5) fprintf(X11_ipc, fmt,p1,p2,p3,p4,p5)
#define FFLUSH() fflush(X11_ipc)
#define BEFORE_GRAPHICS /* nowt */
#define AFTER_TEXT /* nowt */
#elif defined(CRIPPLED_SELECT)
/* PLEASE CAN SOMEONE CHECK THAT THIS STILL WORKS !!! */
/*-----------------------------------------------------------------------------
* CRIPPLED_SELECT file IPC
*---------------------------------------------------------------------------*/
static char X11_tmp[32], X11_tmp0[32], X11_shutdown[32];
static int X11_pid;
TERM_PUBLIC void
X11_init()
{
if (!(X11_pid = fork())) {
execvp(X11_full_command_path, optvec);
_exit(1);
}
sprintf(X11_tmp, "/tmp/Gnuplot_%d", X11_pid);
sprintf(X11_tmp0, "%s-", X11_tmp);
sprintf(X11_shutdown, "echo R >%s", X11_tmp);
}
TERM_PUBLIC void
X11_reset()
{
system(X11_shutdown);
}
#define BEFORE_GRAPHICS \
if (!(X11_ipc = fopen(X11_tmp0, "w"))) { \
perror(X11_tmp0); system(X11_shutdown); exit(1); \
}
#define AFTER_TEXT \
{ fclose(X11_ipc); rename(X11_tmp0, X11_tmp); }
#define PRINT0(fmt) fprintf(X11_ipc, fmt)
#define PRINT1(fmt,p1) fprintf(X11_ipc, fmt,p1)
#define PRINT2(fmt,p1,p2) fprintf(X11_ipc, fmt,p1,p2)
#define PRINT3(fmt,p1,p2,p3) fprintf(X11_ipc, fmt,p1,p2,p3)
#define PRINT4(fmt,p1,p2,p3,p4) fprintf(X11_ipc, fmt,p1,p2,p3,p4)
#define PRINT5(fmt,p1,p2,p3,p4,p5) fprintf(X11_ipc, fmt,p1,p2,p3,p4,p5)
#define FFLUSH() fflush(X11_ipc)
static void
X11_atexit()
{
/* WHAT SHOULD I DO ? */
}
#elif defined(VMS)
/*-----------------------------------------------------------------------------
* VMS mailbox/spawn IPC - Yehavi Bourvine - YEHAVI@VMS.HUJI.AC.IL
*---------------------------------------------------------------------------*/
#include <iodef.h>
#include <descrip.h>
#include <dvidef.h>
#ifdef __DECC
#include <lib$routines.h>
#include <starlet.h>
#endif
#ifdef __GNUC__
#include <errno.h>
#else
int vaxc$errno;
#endif
#define SS$_NORMAL 1 /* or include <ssdef.h> for all SS$_ def's */
#define MBXMXMSG 128 /* DEFMBXMXMSG is set by SYSGEN */
static short X11_channel;
struct iosb {
unsigned short stat;
unsigned short count;
unsigned long info;
};
TERM_PUBLIC void
X11_init()
{
struct iosb iosb;
static char devnam_string[64];
static $DESCRIPTOR(devnam, devnam_string);
struct {
short int buf_len;
short int item;
char *buf_addr;
unsigned short int *ret_len;
int end;
} item_list = {
devnam.dsc$w_length, DVI$_DEVNAM, devnam.dsc$a_pointer, &devnam.dsc$w_length, 0};
#define CMDLEN 1024
char cmdline[CMDLEN], *cmdp;
int optindex;
if (!X11_channel) {
int one = 1;
/* Create a descriptor for the command line that starts
GNUPLOT_X11. $DESCRIP doesn't work in this context... */
/* FIXME!
* This does not work anymore since X11 option passing has been
* changed to use execvp() in the DEFAULT_X11 case
*/
struct dsc$descriptor_s pgmdsc = { 0, DSC$K_DTYPE_T,
DSC$K_CLASS_S, 0
};
optindex = 0;
strcpy(cmdline, optvec[optindex]);
cmdp = cmdline + strlen(optvec[optindex]);
while (optvec[++optindex] != NULL) {
*cmdp++ = ' ';
*cmdp++ = '\"';
strcpy(cmdp, optvec[optindex]);
cmdp += strlen(optvec[optindex]);
*cmdp++ = '\"';
}
pgmdsc.dsc$w_length = cmdp - cmdline;
pgmdsc.dsc$a_pointer = cmdline;
/* Create a mailbox which will be used as a pipe for commands to the
* subprocess. What we'll write to it will be read by the subprocess
* as its STDIN. Use an unnamed mailbox and refer to it by its device
* number */
vaxc$errno = sys$crembx(0, &X11_channel, MBXMXMSG, MBXMXMSG, 0, 0, 0, 0);
if ((vaxc$errno & SS$_NORMAL) != SS$_NORMAL) {
printf("SYS$CreMbx failed with status=%d\r\n", vaxc$errno);
os_error(NO_CARET, "sys$crembx failed");
}
vaxc$errno = sys$getdviw(0, X11_channel, 0, &item_list, &iosb, 0, 0, 0);
if ((vaxc$errno & SS$_NORMAL) == SS$_NORMAL)
vaxc$errno = iosb.stat;
if ((vaxc$errno & SS$_NORMAL) != SS$_NORMAL) {
printf("SYS$Getdviw failed with status=%d\r\n", vaxc$errno);
sys$dassgn(X11_channel);
X11_channel = 0;
os_error(NO_CARET, "sys$getdviw failed");
}
/* Create a subprocess whose input is this mailbox. */
vaxc$errno = lib$spawn(&pgmdsc, &devnam, 0, &one, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if ((vaxc$errno & SS$_NORMAL) != SS$_NORMAL) {
printf("LIB$SPAWN failed with status=%d\r\n", vaxc$errno);
sys$dassgn(X11_channel);
X11_channel = 0;
os_error(NO_CARET, "lib$spawn failed");
}
}
{
static int been_here = 0;
if (!been_here) {
GP_ATEXIT(X11_atexit);
been_here = 1;
}
}
}
/* We use $QIO in order to avoid buffering problems, although it might
* work as well with simple Fprintf calls.
*/
#define GO(x) \
{ \
char buffer[512]; int status; struct iosb iosb;\
sprintf x; \
if (strlen(buffer) >= MBXMXMSG ) { \
printf("buffer contents (%d char) catenated to mailbox size (%d bytes)\n", \
strlen(buffer), MBXMXMSG); \
buffer[MBXMXMSG-1] = '\0';\
printf("%s\n", buffer); \
} \
status = sys$qiow(0, X11_channel, IO$_WRITEVBLK, &iosb, 0, 0, buffer, strlen(buffer), 0, 0, 0, 0); \
if ((status & SS$_NORMAL) == SS$_NORMAL) status = iosb.stat; \
if((status & SS$_NORMAL) != SS$_NORMAL) exit(status); \
}
#define PRINT0(fmt) GO( (buffer, fmt) )
#define PRINT1(fmt,p1) GO( (buffer, fmt,p1) )
#define PRINT2(fmt,p1,p2) GO( (buffer, fmt,p1,p2) )
#define PRINT3(fmt,p1,p2,p3) GO( (buffer, fmt,p1,p2,p3) )
#define PRINT4(fmt,p1,p2,p3,p4) GO( (buffer, fmt,p1,p2,p3,p4) )
#define PRINT5(fmt,p1,p2,p3,p4,p5) GO( (buffer, fmt,p1,p2,p3,p4,p5) )
#define FFLUSH() /* nowt */
#define BEFORE_GRAPHICS /* nowt */
#define AFTER_TEXT /* nowt */
static void
X11_atexit()
{
if (X11_channel) {
PRINT0("R\n");
sleep(2); /* Wait for subprocess to finish */
sys$dassgn(X11_channel);
X11_channel = 0;
}
}
TERM_PUBLIC void
X11_reset()
{
/* do nothing until exit */
}
#else /* !VMS */
You lose.
#endif /* !VMS */
/* common stuff, using macros defined above */
TERM_PUBLIC void
X11_graphics()
{
#ifdef USE_MOUSE
static unsigned long windowid = 0;
#endif
static enum set_encoding_id last_encoding = S_ENC_DEFAULT;
BEFORE_GRAPHICS; /* kludge for crippled select */
#ifndef USE_MOUSE
/* for VMS sake, keep as separate prints */
PRINT1("G%d\n", X11_plot_number);
#else
#ifdef PIPE_IPC
/* if we know the outboard driver has stopped, restart it */
if (ipc_back_fd == IPC_BACK_CLOSED) {
fclose(X11_ipc);
X11_ipc = NULL;
X11_init();
}
#endif
/* send also XID of gnuplot window (<space> then raises it up) */
if (!windowid) {
char *window_env = (char *) getenv("WINDOWID");
if (window_env)
sscanf(window_env, "%lu", &windowid);
}
#ifndef OS2
PRINT2("G%d %lu\n", X11_plot_number, windowid);
#else
PRINT3("G%d %lu %i\n", X11_plot_number, windowid, getpid());
#endif
#endif /* USE_MOUSE */
#ifdef ULTRIX_KLUDGE
fflush(X11_ipc);
#endif
if (encoding != last_encoding) {
PRINT1("QE%d\n",encoding);
last_encoding = encoding;
}
#if defined(USE_MOUSE) && defined(PIPE_IPC)
/* EAM June 2003 - Flush the set font command through the pipe */
/* to gnuplot_x11, then wait for it to return the resulting */
/* font size information (v_char and h_char). The feedback is */
/* caught by do_event() as an event of type GE_fontprops. */
if (ipc_back_fd >= 0 && X11_MOUSE_FEEDBACK) {
if (!default_font_size_known) {
IPC_LOCK = TRUE;
PRINT1("QG%s\n",X11_default_font);
FFLUSH();
X11_waitforinput();
default_font_size_known = TRUE;
IPC_LOCK = FALSE;
}
}
#endif
/* Force default font at start of plot */
X11_set_default_font();
X11_set_font("");
}
TERM_PUBLIC void
X11_text()
{
#ifdef USE_MOUSE
/* EAM July 2003: send over a snapshot of the final axis scaling
* so that subsequent mouse events can be transformed into plot
* coordinates even though the plot is no longer active.
*/
#ifdef PIPE_IPC
if (ipc_back_fd >= 0) {
#endif
/* Construct a mask showing which axes are active */
int axis_mask = 0;
int i;
for (i = FIRST_AXES; i < 2*SECOND_AXES; i++) {
if (axis_array[i].ticmode != NO_TICS)
axis_mask |= (1 << i);
}
PRINT2("S %2d %d\n", -1, axis_mask);
PRINT5("S %2d %14.3g %14d %14.3g %14.3g\n", FIRST_X_AXIS,
axis_array[FIRST_X_AXIS].min,
axis_array[FIRST_X_AXIS].term_lower,
axis_array[FIRST_X_AXIS].term_scale,
axis_array[FIRST_X_AXIS].log ? axis_array[FIRST_X_AXIS].log_base : 0);
PRINT5("S %2d %14.3g %14d %14.3g %14.3g\n", FIRST_Y_AXIS,
axis_array[FIRST_Y_AXIS].min,
axis_array[FIRST_Y_AXIS].term_lower,
axis_array[FIRST_Y_AXIS].term_scale,
axis_array[FIRST_Y_AXIS].log ? axis_array[FIRST_Y_AXIS].log_base : 0);
PRINT5("S %2d %14.3g %14d %14.3g %14.3g\n", SECOND_X_AXIS,
axis_array[SECOND_X_AXIS].min,
axis_array[SECOND_X_AXIS].term_lower,
axis_array[SECOND_X_AXIS].term_scale,
axis_array[SECOND_X_AXIS].log ? axis_array[SECOND_X_AXIS].log_base : 0);
PRINT5("S %2d %14.3g %14d %14.3g %14.3g\n", SECOND_Y_AXIS,
axis_array[SECOND_Y_AXIS].min,
axis_array[SECOND_Y_AXIS].term_lower,
axis_array[SECOND_Y_AXIS].term_scale,
axis_array[SECOND_Y_AXIS].log ? axis_array[SECOND_Y_AXIS].log_base : 0);
#ifdef PIPE_IPC
}
#endif
#endif
PRINT0("E\n");
FFLUSH();
#ifdef ULTRIX_KLUDGE
PRINT0("E\n");
FFLUSH();
#endif
AFTER_TEXT; /* kludge for crippled select */
}
TERM_PUBLIC void
X11_move(unsigned int x, unsigned int y)
{
PRINT2("M%04d%04d\n", x, y);
}
TERM_PUBLIC void
X11_vector(unsigned int x, unsigned int y)
{
PRINT2("V%04d%04d\n", x, y);
}
TERM_PUBLIC void
X11_pointsize(double ps)
{
PRINT2("P-2 %d %d\n", /* size of point symbols */
(int) (term->h_tic * ps * 0.5), (int) (term->v_tic * ps * 0.5));
}
TERM_PUBLIC void
X11_linewidth(double lw)
{
PRINT1("W%04d\n", (int) lw);
}
TERM_PUBLIC void
X11_linetype(int lt)
{
PRINT1("L%04d\n", lt);
}
TERM_PUBLIC void
X11_put_text(unsigned int x, unsigned int y, const char str[])
{
/* Only send the font change request to X11 if it really is a change */
if (strcmp(X11_last_font_used,X11_next_font_used)) {
strcpy(X11_last_font_used,X11_next_font_used);
PRINT1("QF%s\n", X11_next_font_used);
}
/* badly outrange labels can overflow into text field */
if (x < 10000 && y < 10000) {
PRINT3("T%04d%04d%s\n", x, y, str);
}
}
TERM_PUBLIC int
X11_text_angle(int ang)
{
PRINT1("A%d\n", ang);
return TRUE;
}
TERM_PUBLIC int
X11_justify_text(enum JUSTIFY mode)
{
PRINT1("J%04d\n", mode);
X11_last_justification = mode;
return (TRUE);
}
TERM_PUBLIC void
X11_point(unsigned int x, unsigned int y, int number)
{
PRINT3("P%d %d %d\n", number, x, y);
}
TERM_PUBLIC int
X11_set_font(const char *fontname)
{
/* PRINT1("QF%s\n", fontname?fontname:""); */
strncpy(X11_next_font_used,fontname?fontname:"",sizeof(X11_next_font_used)-1);
return( TRUE );
}
static void
X11_set_default_font()
{
PRINT1("QD%s\n",X11_default_font);
}
TERM_PUBLIC void
X11_fillbox(int style, unsigned int x, unsigned int y, unsigned int w, unsigned int h)
{
if (X11_ipc) {
PRINT5("F%04d%04u%04u%04u%04u\n", style, x, y, w, h);
}
}
#ifdef USE_MOUSE
TERM_PUBLIC void
X11_put_tmptext(int i, const char str[])
{
if (X11_ipc) {
PRINT2("t%04d%s\n", i, str);
FFLUSH();
}
}
TERM_PUBLIC void
X11_set_ruler(int x, int y)
{
if (X11_ipc) {
PRINT2("r%04d%04d\n", x < 9999 ? x : 9999, y < 9999 ? y : 9999);
FFLUSH();
}
}
TERM_PUBLIC void
X11_set_cursor(int c, int x, int y)
{
if (X11_ipc) {
PRINT3("u%04d%04d%04d\n", c, x, y);
FFLUSH();
}
}
TERM_PUBLIC void
X11_set_clipboard(const char s[])
{
if (X11_ipc) {
PRINT1("z%s\n", s);
FFLUSH();
}
}
#endif /* USE_MOUSE */
#ifdef PM3D
static void transmit_gradient( gradient_struct *gradient, int cnt )
{
int i = 0;
fprintf( X11_ipc, "%d", cnt );
for( i=0; i<cnt; i++ ) {
/* this %50 *must* match the corresponding %50 in gplt_x11.c */
if( i%50 == 0 ) {
fputs( "\n", X11_ipc );
fflush( X11_ipc );
}
fprintf( X11_ipc, "%s", gradient_entry_to_str( &(gradient[i]) ) );
}
fputs( "\n", X11_ipc );
}
TERM_PUBLIC int
X11_make_palette(t_sm_palette *palette)
{
if( !palette ) {
return 0;
}
if( !X11_ipc ) {
fprintf(stderr, "(X11_make_palette) 0 == X11_ipc\n");
return -1;
}
fprintf( X11_ipc, "%c %c %c %c %d\n",
X11_GR_MAKE_PALETTE, (char)(palette->colorMode),
(char)(palette->positive), (char)(palette->cmodel),
palette->use_maxcolors );
switch( palette->colorMode ) {
case SMPAL_COLOR_MODE_GRAY:
fprintf( X11_ipc,"%g\n", palette->gamma );
break;
case SMPAL_COLOR_MODE_RGB:
fprintf( X11_ipc, "%d %d %d\n", palette->formulaR,
palette->formulaG, palette->formulaB );
break;
case SMPAL_COLOR_MODE_GRADIENT:
transmit_gradient( palette->gradient, palette->gradient_num );
break;
case SMPAL_COLOR_MODE_FUNCTIONS: {
int cnt=0;
gradient_struct *gradient;
gradient = approximate_palette( palette, 500, 0.01, &cnt );
transmit_gradient( gradient, cnt );
break;
}
default:
fprintf( stderr, "%s:%d ooops: Unknown colorMode '%c'.\n",
__FILE__, __LINE__, (char)(palette->colorMode) );
}
fflush( X11_ipc );
return 0;
}
TERM_PUBLIC void
X11_set_color(double gray)
{
fputc(X11_GR_SET_COLOR, X11_ipc);
PRINT1("%f\n", gray);
FFLUSH();
return;
}
TERM_PUBLIC void
X11_filled_polygon(int points, gpiPoint *corners)
{
int i;
fputc(X11_GR_FILLED_POLYGON, X11_ipc);
/* FIXME HBB 20010919: this %04d format somewhat arbitrarily
* limits us to 10000 vertices in the polygon */
PRINT1("%04d", points);
for (i = 0; i < points; i++) {
PRINT2("%04d%04d", corners[i].x, corners[i].y);
/* HBB 20010919: fix for buffer overflow problem: start
* another line every 100 points, to avoid overflowing
* fixed-size buffer in gplt_x11. Number of points == -1
* signals continuation line */
if ((i % 100) == 99) {
PRINT1("xxxx\n%c-001", X11_GR_FILLED_POLYGON);
FFLUSH();
}
}
fputc('\n', X11_ipc);
FFLUSH();
return;
}
#endif /* PM3D */
/*
* Ethan A Merritt November 2003
* - Support for enhanced text mode
*
* PROBLEMS:
* - The default font must be scalable
* - Without more feedback from the outboard driver (gnuplot_x11) it is
* hard to set up proper text rotation. The current approximation is so-so.
* - Right- and Center- justified text is problematic for the same reason.
* - The default font size is not really known, and font scaling
* in general could be improved
*/
static TBOOLEAN ENHx11_opened_string;
static TBOOLEAN ENHx11_sizeonly = FALSE;
static TBOOLEAN ENHx11_show = TRUE;
static TBOOLEAN ENHx11_overprint = FALSE;
static TBOOLEAN ENHx11_widthflag = TRUE;
static double ENHx11_base;
static double ENHx11_fontsize;
static char *ENHx11_font;
TERM_PUBLIC void
ENHX11_OPEN(fontname, fontsize, base, widthflag, showflag, overprint)
char *fontname;
TBOOLEAN widthflag, showflag;
double fontsize, base;
int overprint;
{
/* If the overprint code requests a save or request, that's all we do */
if (overprint == 3) {
PRINT2("Tp%04d%04d\n", 0, 0);
return;
} else if (overprint == 4) {
PRINT2("Tr%04d%04d\n", 0, 0);
return;
}
if (!ENHx11_opened_string) {
ENHx11_opened_string = TRUE;
enhanced_cur_text = &enhanced_text[0];
ENHx11_font = fontname;
ENHx11_fontsize = fontsize;
ENHx11_base = base * 10; /* FIXME - should this be v_char? v_tic? */
ENHx11_show = showflag;
ENHx11_overprint = overprint;
ENHx11_widthflag = widthflag;
}
}
/*
* Write a string fragment and update current position.
* We leave the real work up to gnuplot_x11!
*/
TERM_PUBLIC void
ENHX11_FLUSH()
{
/* Send a command to print this string at current position */
if (ENHx11_opened_string) {
char tmpfont[128]; /* FIXME - there must be a better way! */
*enhanced_cur_text = '\0';
sprintf(tmpfont,"%s,%.1f", ENHx11_font, ENHx11_fontsize);
PRINT1("QF%s\n", tmpfont);
*X11_last_font_used = '\01';
if (!ENHx11_show || ENHx11_sizeonly)
PRINT3("Ts%04d%04d%s\n", 0, (int)ENHx11_base, enhanced_text);
else if (ENHx11_overprint == 1)
PRINT3("Tc%04d%04d%s\n", 0, (int)ENHx11_base, enhanced_text);
else if (!ENHx11_widthflag && !ENHx11_overprint)
PRINT3("To%04d%04d%s\n", 0, (int)ENHx11_base, enhanced_text);
else
PRINT3("Tu%04d%04d%s\n", 0, (int)ENHx11_base, enhanced_text);
ENHx11_opened_string = FALSE;
}
}
TERM_PUBLIC void
ENHX11_put_text(x, y, str)
unsigned int x, y;
const char *str;
{
char *original_string = (char *)str;
int pass = 1;
if (ignore_enhanced_text) {
X11_put_text(x,y,str);
return;
}
if (!strlen(str))
return;
/* if there are no magic characters, we should just be able
* punt the string to X11_put_text()
*/
if (!strpbrk(str, "{}^_@&~")) {
X11_put_text(x,y,str);
return;
}
/* set up the global variables needed by enhanced_recursion() */
enhanced_fontscale = 1.25;
ENHx11_opened_string = FALSE;
strncpy(enhanced_escape_format,"%c",sizeof(enhanced_escape_format));
/* Tell gnuplot_x11 to set the current position to (x,y) */
PRINT2("T%04d%04d\n", x, y);
/* Text justification requires two passes. During the first pass we */
/* don't draw anything, we just measure the space it will take. */
if (X11_last_justification != LEFT) {
PRINT1("J%04d\n", LEFT);
ENHx11_sizeonly = TRUE;
}
PASS2:
/* Make sure that we start out using the default font.
* FIXME: Really we should get feedback from gnuplot_x11 as to what
* the default font size is.
*/
ENHx11_font = "DEFAULT";
ENHx11_fontsize = 12; /* FIXME - are we going to need this? */
/* Set the recursion going. We say to keep going until a
* closing brace, but we don't really expect to find one.
* If the return value is not the nul-terminator of the
* string, that can only mean that we did find an unmatched
* closing brace in the string. We increment past it (else
* we get stuck in an infinite loop) and try again.
*/
while (*(str = enhanced_recursion((char *)str, TRUE,
ENHx11_font, ENHx11_fontsize,
0.0, TRUE, TRUE, 0))) {
(term->enhanced_flush)();
/* I think we can only get here if *str == '}' */
enh_err_check(str);
if (!*++str)
break; /* end of string */
/* else carry on and process the rest of the string */
}
/* Restore text justification flag after 2nd pass */
if (pass > 1) {
PRINT1("J%04d\n", X11_last_justification);
return;
}
/* In order to do text justification we need to do a second pass that */
/* uses information stored by gnuplot_x11 during the first pass. */
if (X11_last_justification != LEFT) {
ENHx11_sizeonly = FALSE;
if (X11_last_justification == RIGHT) {
PRINT2("Tj%04d%04d\n", x, y);
} else if (X11_last_justification == CENTRE) {
PRINT2("Tk%04d%04d\n", x, y);
}
str = original_string;
pass = 2;
goto PASS2;
}
}
#endif /* TERM_BODY */
#ifdef TERM_TABLE
TERM_TABLE_START(x11_driver)
"x11", "X11 Window System",
X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR,
X11_VTIC, X11_HTIC, X11_options, X11_init, X11_reset,
X11_text, null_scale, X11_graphics, X11_move, X11_vector,
X11_linetype, X11_put_text, X11_text_angle,
X11_justify_text, X11_point, do_arrow, X11_set_font,
X11_pointsize, TERM_CAN_MULTIPLOT|TERM_INIT_ON_REPLOT,
X11_text /* suspend can use same routine */ , 0 /* resume */ ,
X11_fillbox, X11_linewidth
#ifdef USE_MOUSE
, X11_waitforinput, X11_put_tmptext, X11_set_ruler, X11_set_cursor, X11_set_clipboard
#endif
#ifdef PM3D
, X11_make_palette, 0 /* X11_previous_palette */ ,
X11_set_color, X11_filled_polygon
#endif
, ENHX11_OPEN, ENHX11_FLUSH, do_enh_writec
TERM_TABLE_END(x11_driver)
#undef LAST_TERM
#define LAST_TERM x11_driver
TERM_TABLE_START(X11_driver)
"X11", "X11 Window System (identical to x11)",
X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR,
X11_VTIC, X11_HTIC, X11_options, X11_init, X11_reset,
X11_text, null_scale, X11_graphics, X11_move, X11_vector,
X11_linetype, X11_put_text, X11_text_angle,
X11_justify_text, X11_point, do_arrow, X11_set_font,
X11_pointsize, TERM_CAN_MULTIPLOT,
X11_text /* suspend can use same routine */ , 0 /* resume */ ,
X11_fillbox, X11_linewidth
#ifdef USE_MOUSE
, X11_waitforinput, X11_put_tmptext, X11_set_ruler, X11_set_cursor, X11_set_clipboard
#endif
#ifdef PM3D
, X11_make_palette, 0 /* X11_previous_palette */ ,
X11_set_color, X11_filled_polygon
#endif
, ENHX11_OPEN, ENHX11_FLUSH, do_enh_writec
TERM_TABLE_END(X11_driver)
#undef LAST_TERM
#define LAST_TERM x11_driver
#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */
#ifdef TERM_HELP
START_HELP(x11)
"1 x11",
"?commands set terminal x11",
"?set terminal x11",
"?set term x11",
"?terminal x11",
"?term x11",
"?x11",
"?X11",
" `gnuplot` provides the `x11` terminal type for use with X servers. This",
" terminal type is set automatically at startup if the `DISPLAY` environment",
" variable is set, if the `TERM` environment variable is set to `xterm`, or",
" if the `-display` command line option is used.",
"",
" Syntax:",
" set terminal x11 [reset] <n> [[no]enhanced] [font <fontspec>]",
" [title \"<string>\"] [[no]persist] [[no]raise] [close]",
"",
" Multiple plot windows are supported: `set terminal x11 <n>` directs the",
" output to plot window number n. If n>0, the terminal number will be",
" appended to the window title (unless a title has been supplied manually)",
" and the icon will be labeled `gplt <n>`. The active window may be",
" distinguished by a change in cursor (from default to crosshair.)",
"",
" The x11 terminal support enhanced text mode (see `enhanced`), subject",
" to the available fonts. In order for font size commands embedded in text",
" to have any effect, the default x11 font must be scalable. Thus the first",
" example below will work as expected, but the second will not.",
"",
" set term x11 enhanced font \"arial,15\" ",
" set title '{\\=20 Big} Medium {\\=5 Small}' ",
"",
" set term x11 enhanced font \"terminal-14\" ",
" set title '{\\=20 Big} Medium {\\=5 Small}' ",
"",
" Plot windows remain open even when the `gnuplot` driver is changed to a",
" different device. A plot window can be closed by pressing the letter q",
" while that window has input focus, or by choosing `close` from a window",
" manager menu. All plot windows can be closed by specifying `reset`, which",
" actually terminates the subprocess which maintains the windows (unless",
" `-persist` was specified). The `close` command can be used to close",
" individual plot windows by number. However, after a `reset`, those plot",
" windows left due to persist cannot be closed with the command `close`.",
" A `close` without a number closes the current active plot window.",
"",
" The gnuplot outboard driver, gnuplot_x11, is searched in a default place",
" chosen when the program is compiled. You can override that by defining",
" the environment variable GNUPLOT_DRIVER_DIR to point to a different",
" location.",
"",
" Plot windows will automatically be closed at the end of the session",
" unless the `-persist` option was given.",
"",
" The options `persist` and `raise` are unset by default, which means that",
" the defaults (persist == no and raise == yes) or the command line options",
" -persist / -raise or the Xresources are taken. If [no]persist or",
" [no]raise are specified, they will override command line options and",
" Xresources. Setting one of these options takes place immediately, so",
" the behaviour of an already running driver can be modified.",
"",
" The option `title \"<title name>\"` will supply the title name of the window",
" for the current plot window or plot window <n> if a number is given.",
" Where (or if) this title is shown depends on your X window manager.",
"",
" The size or aspect ratio of a plot may be changed by resizing the `gnuplot`",
" window.",
"",
" Linewidths and pointsizes may be changed from within `gnuplot` with",
" `set linestyle`.",
"",
" For terminal type `x11`, `gnuplot` accepts (when initialized) the standard",
" X Toolkit options and resources such as geometry, font, and name from the",
" command line arguments or a configuration file. See the X(1) man page",
" (or its equivalent) for a description of such options.",
"",
" A number of other `gnuplot` options are available for the `x11` terminal.",
" These may be specified either as command-line options when `gnuplot` is",
" invoked or as resources in the configuration file \".Xdefaults\". They are",
" set upon initialization and cannot be altered during a `gnuplot` session.",
" (except `persist` and `raise`)",
"2 x11_fonts",
"?commands set terminal x11 x11_fonts",
"?set terminal x11 x11_fonts",
"?set term x11 x11_fonts",
"?x11 x11_fonts",
"?x11_fonts",
" Upon initial startup, the default font is taken from the X11 resources",
" as set in the system or user .Xdefaults file or on the command line.",
"",
" Example:",
" gnuplot*font: lucidasans-bold-12",
" A new default font may be specified to the x11 driver from inside",
" gnuplot using",
" `set term x11 font \"<fontspec>\"`",
" The driver first queries the X-server for a font of the exact name given,",
" for example `set term x11 font \"lucidasans-10\"`. If this query fails, then",
" it tries to interpret <fontspec> as \"<font>,<size>,<slant>,<weight>\" ",
" and to construct a full X11 font name of the form",
" -*-<font>-<weight>-<s>-*-*-<size>-*-*-*-*-*-<encoding>",
"",
" <font> is the base name of the font (e.g. Times or Symbol)",
" <size> is the point size (defaults to 12 if not specified)",
" <s> is `i` if <slant>==\"italic\" `o` if <slant>==\"oblique\" `r` otherwise",
" <weight> is `medium` or `bold` if explicitly requested, otherwise `*`",
" <encoding> is set based on the current character set (see help for `set encoding`).",
" So `set term x11 font \"arial,15,italic\"` will be translated to",
" -*-arial-*-i-*-*-15-*-*-*-*-*-iso8859-1 (assuming default encoding).",
" The <size>, <slant>, and <weight> specifications are all optional.",
" If you do not specify <slant> or <weight> then you will get whatever font ",
" variant the font server offers first.",
" The driver also recognizes some common PostScript font names and",
" replaces them with possible X11 or TrueType equivalents.",
" This same sequence is used to process font requests from `set label`.",
"2 command-line_options",
"?commands set terminal x11 command-line-options",
"?set terminal x11 command-line-options",
"?set term x11 command-line-options",
"?x11 command-line-options",
"?command-line-options",
" In addition to the X Toolkit options, the following options may be specified",
" on the command line when starting `gnuplot` or as resources in your",
" \".Xdefaults\" file (note that `raise` and `persist` can be overridden",
" later by `set term x11 [no]raise [no]persist)`:",
"@start table - first is interactive cleartext form",
" `-mono` forces monochrome rendering on color displays.",
" `-gray` requests grayscale rendering on grayscale or color displays.",
" (Grayscale displays receive monochrome rendering by default.)",
" `-clear` requests that the window be cleared momentarily before a",
" new plot is displayed.",
" `-tvtwm` requests that geometry specifications for position of the",
" window be made relative to the currently displayed portion",
" of the virtual root.",
" `-raise` raises plot window after each plot",
" `-noraise` does not raise plot window after each plot",
#ifdef USE_MOUSE
" `-noevents` does not process mouse and key events",
#endif
" `-persist` plot windows survive after main gnuplot program exits",
"#\\begin{tabular}{|cl|} \\hline",
"#`-mono` & forces monochrome rendering on color displays.\\\\",
"#`-gray` & requests grayscale rendering on grayscale or color displays.\\\\",
"# & (Grayscale displays receive monochrome rendering by default.) \\\\",
"#`-clear` & requests that the window be cleared momentarily before a\\\\",
"# & new plot is displayed. \\\\",
"#`-tvtwm` & requests that geometry specifications for position of the\\\\",
"# & window be made relative to the currently displayed portion\\\\",
"# & of the virtual root. \\\\",
"#`-raise` & raises plot window after each plot. \\\\",
"#`-noraise` & does not raise plot window after each plot. \\\\",
#ifdef USE_MOUSE
"#`-noevents` & does not process mouse and key events. \\\\",
#endif
"#`-persist` & plot windows survive after main gnuplot program exits. \\\\",
"%c l .",
"%`-mono`@forces monochrome rendering on color displays.",
"%`-gray`@requests grayscale rendering on grayscale or color displays.",
"% @(Grayscale displays receive monochrome rendering by default.)",
"%`-clear`@requests that the window be cleared momentarily before a",
"% @new plot is displayed.",
"%`-tvtwm`@requests that geometry specifications for position of the",
"% @window be made relative to the currently displayed portion",
"% @of the virtual root.",
"%`-raise`@raises plot window after each plot",
"%`-noraise`@does not raise plot window after each plot",
#ifdef USE_MOUSE
"%`-novevents`@does not process mouse and key events",
#endif
"%`-persist`@plot windows survive after main gnuplot program exits",
"@end table",
" The options are shown above in their command-line syntax. When entered as",
" resources in \".Xdefaults\", they require a different syntax.",
"",
" Example:",
" gnuplot*gray: on",
"",
" `gnuplot` also provides a command line option (`-pointsize <v>`) and a",
" resource, `gnuplot*pointsize: <v>`, to control the size of points plotted",
" with the `points` plotting style. The value `v` is a real number (greater",
" than 0 and less than or equal to ten) used as a scaling factor for point",
" sizes. For example, `-pointsize 2` uses points twice the default size, and",
" `-pointsize 0.5` uses points half the normal size.",
"",
" The `-noevents` switch disables all mouse and key event processing (except",
" for `q` and `<space>` for closing the window). This is useful for programs",
" which use the x11 driver independent of the gnuplot main program.",
"2 monochrome_options",
"?commands set terminal x11 monochrome_options",
"?set terminal x11 monochrome_options",
"?set term x11 monochrome_options",
"?x11 monochrome_options",
"?monochrome_options",
" For monochrome displays, `gnuplot` does not honor foreground or background",
" colors. The default is black-on-white. `-rv` or `gnuplot*reverseVideo: on`",
" requests white-on-black.",
"",
"2 color_resources",
"?commands set terminal x11 color_resources",
"?set terminal x11 color_resources",
"?set term x11 color_resources",
"?x11 color_resources",
"?color_resources",
" For color displays, `gnuplot` honors the following resources (shown here",
" with their default values) or the greyscale resources. The values may be",
" color names as listed in the X11 rgb.txt file on your system, hexadecimal",
" RGB color specifications (see X11 documentation), or a color name followed",
" by a comma and an `intensity` value from 0 to 1. For example, `blue, 0.5`",
" means a half intensity blue.",
"@start table - first is interactive cleartext form",
" gnuplot*background: white",
" gnuplot*textColor: black",
" gnuplot*borderColor: black",
" gnuplot*axisColor: black",
" gnuplot*line1Color: red",
" gnuplot*line2Color: green",
" gnuplot*line3Color: blue",
" gnuplot*line4Color: magenta",
" gnuplot*line5Color: cyan",
" gnuplot*line6Color: sienna",
" gnuplot*line7Color: orange",
" gnuplot*line8Color: coral",
"#\\begin{tabular}{|cl|} \\hline",
"#&gnuplot*background: white\\\\",
"#&gnuplot*textColor: black\\\\",
"#&gnuplot*borderColor: black\\\\",
"#&gnuplot*axisColor: black\\\\",
"#&gnuplot*line1Color: red\\\\",
"#&gnuplot*line2Color: green\\\\",
"#&gnuplot*line3Color: blue\\\\",
"#&gnuplot*line4Color: magenta\\\\",
"#&gnuplot*line5Color: cyan\\\\",
"#&gnuplot*line6Color: sienna\\\\",
"#&gnuplot*line7Color: orange\\\\",
"#&gnuplot*line8Color: coral\\\\",
"%c l .",
"%@gnuplot*background: white",
"%@gnuplot*textColor: black",
"%@gnuplot*borderColor: black",
"%@gnuplot*axisColor: black",
"%@gnuplot*line1Color: red",
"%@gnuplot*line2Color: green",
"%@gnuplot*line3Color: blue",
"%@gnuplot*line4Color: magenta",
"%@gnuplot*line5Color: cyan",
"%@gnuplot*line6Color: sienna",
"%@gnuplot*line7Color: orange",
"%@gnuplot*line8Color: coral",
"@end table",
"",
" The command-line syntax for these is simple only for background,",
" which maps directly to the usual X11 toolkit option \"-bg\". All",
" others can only be set on the command line by use of the generic",
" \"-xrm\" resource override option",
"",
" Examples:",
"",
" gnuplot -background coral",
" to change the background color.",
"",
" gnuplot -xrm 'gnuplot*line1Color:blue'",
" to override the first linetype color.",
"",
"2 grayscale_resources",
"?commands set terminal x11 grayscale_resources",
"?set terminal x11 grayscale_resources",
"?set term x11 grayscale_resources",
"?x11 grayscale_resources",
"?grayscale_resources",
" When `-gray` is selected, `gnuplot` honors the following resources for",
" grayscale or color displays (shown here with their default values). Note",
" that the default background is black.",
"@start table - first is interactive cleartext form",
" gnuplot*background: black",
" gnuplot*textGray: white",
" gnuplot*borderGray: gray50",
" gnuplot*axisGray: gray50",
" gnuplot*line1Gray: gray100",
" gnuplot*line2Gray: gray60",
" gnuplot*line3Gray: gray80",
" gnuplot*line4Gray: gray40",
" gnuplot*line5Gray: gray90",
" gnuplot*line6Gray: gray50",
" gnuplot*line7Gray: gray70",
" gnuplot*line8Gray: gray30",
"#\\begin{tabular}{|cl|} \\hline",
"#&gnuplot*background: black\\\\",
"#&gnuplot*textGray: white\\\\",
"#&gnuplot*borderGray: gray50\\\\",
"#&gnuplot*axisGray: gray50\\\\",
"#&gnuplot*line1Gray: gray100\\\\",
"#&gnuplot*line2Gray: gray60\\\\",
"#&gnuplot*line3Gray: gray80\\\\",
"#&gnuplot*line4Gray: gray40\\\\",
"#&gnuplot*line5Gray: gray90\\\\",
"#&gnuplot*line6Gray: gray50\\\\",
"#&gnuplot*line7Gray: gray70\\\\",
"#&gnuplot*line8Gray: gray30\\\\",
"%c l .",
"%@gnuplot*background: black",
"%@gnuplot*textGray: white",
"%@gnuplot*borderGray: gray50",
"%@gnuplot*axisGray: gray50",
"%@gnuplot*line1Gray: gray100",
"%@gnuplot*line2Gray: gray60",
"%@gnuplot*line3Gray: gray80",
"%@gnuplot*line4Gray: gray40",
"%@gnuplot*line5Gray: gray90",
"%@gnuplot*line6Gray: gray50",
"%@gnuplot*line7Gray: gray70",
"%@gnuplot*line8Gray: gray30",
"@end table",
"",
"2 line_resources",
"?commands set terminal x11 line_resources",
"?set terminal x11 line_resources",
"?set term x11 line_resources",
"?x11 line_resources",
"?line_resources",
" `gnuplot` honors the following resources for setting the width (in pixels) of",
" plot lines (shown here with their default values.) 0 or 1 means a minimal",
" width line of 1 pixel width. A value of 2 or 3 may improve the appearance of",
" some plots.",
"@start table - first is interactive cleartext form",
" gnuplot*borderWidth: 2",
" gnuplot*axisWidth: 0",
" gnuplot*line1Width: 0",
" gnuplot*line2Width: 0",
" gnuplot*line3Width: 0",
" gnuplot*line4Width: 0",
" gnuplot*line5Width: 0",
" gnuplot*line6Width: 0",
" gnuplot*line7Width: 0",
" gnuplot*line8Width: 0",
"#\\begin{tabular}{|cl|} \\hline",
"#&gnuplot*borderWidth: 2\\\\",
"#&gnuplot*axisWidth: 0\\\\",
"#&gnuplot*line1Width: 0\\\\",
"#&gnuplot*line2Width: 0\\\\",
"#&gnuplot*line3Width: 0\\\\",
"#&gnuplot*line4Width: 0\\\\",
"#&gnuplot*line5Width: 0\\\\",
"#&gnuplot*line6Width: 0\\\\",
"#&gnuplot*line7Width: 0\\\\",
"#&gnuplot*line8Width: 0\\\\",
"%c l .",
"%@gnuplot*borderWidth: 2",
"%@gnuplot*axisWidth: 0",
"%@gnuplot*line1Width: 0",
"%@gnuplot*line2Width: 0",
"%@gnuplot*line3Width: 0",
"%@gnuplot*line4Width: 0",
"%@gnuplot*line5Width: 0",
"%@gnuplot*line6Width: 0",
"%@gnuplot*line7Width: 0",
"%@gnuplot*line8Width: 0",
"@end table",
"",
" `gnuplot` honors the following resources for setting the dash style used for",
" plotting lines. 0 means a solid line. A two-digit number `jk` (`j` and `k`",
" are >= 1 and <= 9) means a dashed line with a repeated pattern of `j` pixels",
" on followed by `k` pixels off. For example, '16' is a \"dotted\" line with one",
" pixel on followed by six pixels off. More elaborate on/off patterns can be",
" specified with a four-digit value. For example, '4441' is four on, four off,",
" four on, one off. The default values shown below are for monochrome displays",
" or monochrome rendering on color or grayscale displays. For color displays,",
" the default for each is 0 (solid line) except for `axisDashes` which defaults",
" to a '16' dotted line.",
"@start table - first is interactive cleartext form",
" gnuplot*borderDashes: 0",
" gnuplot*axisDashes: 16",
" gnuplot*line1Dashes: 0",
" gnuplot*line2Dashes: 42",
" gnuplot*line3Dashes: 13",
" gnuplot*line4Dashes: 44",
" gnuplot*line5Dashes: 15",
" gnuplot*line6Dashes: 4441",
" gnuplot*line7Dashes: 42",
" gnuplot*line8Dashes: 13",
"#\\begin{tabular}{|cl|} \\hline",
"#&gnuplot*borderDashes: 0\\\\",
"#&gnuplot*axisDashes: 16\\\\",
"#&gnuplot*line1Dashes: 0\\\\",
"#&gnuplot*line2Dashes: 42\\\\",
"#&gnuplot*line3Dashes: 13\\\\",
"#&gnuplot*line4Dashes: 44\\\\",
"#&gnuplot*line5Dashes: 15\\\\",
"#&gnuplot*line6Dashes: 4441\\\\",
"#&gnuplot*line7Dashes: 42\\\\",
"#&gnuplot*line8Dashes: 13\\\\",
"%c l .",
"%@gnuplot*borderDashes: 0",
"%@gnuplot*axisDashes: 16",
"%@gnuplot*line1Dashes: 0",
"%@gnuplot*line2Dashes: 42",
"%@gnuplot*line3Dashes: 13",
"%@gnuplot*line4Dashes: 44",
"%@gnuplot*line5Dashes: 15",
"%@gnuplot*line6Dashes: 4441",
"%@gnuplot*line7Dashes: 42",
"%@gnuplot*line8Dashes: 13",
"@end table"
#ifdef PM3D
, "",
"2 x11 pm3d_resources",
"?commands set terminal x11 pm3d_resources",
"?set terminal x11 pm3d_resources",
"?set term x11 pm3d_resources",
"?x11 pm3d_resources",
"?pm3d_resources",
"?x11 pm3d",
" Choosing the appropriate visual class and number of colors is a crucial",
" point in X11 applications and a bit awkward, since X11 supports six visual",
" types in different depths.",
"",
" By default `gnuplot` uses the default visual of the screen. The number of",
" colors which can be allocated depends on the visual class chosen. On a",
" visual class with a depth > 12bit, gnuplot starts with a maximal number",
" of 0x200 colors. On a visual class with a depth > 8bit (but <= 12 bit)",
" the maximal number of colors is 0x100, on <= 8bit displays the maximum",
" number of colors is 240 (16 are left for line colors).",
"",
" Gnuplot first starts to allocate the maximal number of colors as stated",
" above. If this fails, the number of colors is reduced by the factor 2",
" until gnuplot gets all colors which are requested. If dividing `maxcolors`",
" by 2 repeatedly results in a number which is smaller than `mincolors`",
" `gnuplot` tries to install a private colormap. In this case the window",
" manager is responsible for swapping colormaps when the pointer is moved",
" in and out the x11 driver's window.",
"",
" The default for `mincolors` is maxcolors / (num_colormaps > 1 ? 2 : 8),",
" where num_colormaps is the number of colormaps which are currently used",
" by gnuplot (usually 1, if only one x11 window is open).",
"",
" Some systems support multiple (different) visual classes together on one",
" screen. On these systems it might be necessary to force gnuplot to use a",
" specific visual class, e.g. the default visual might be 8bit PseudoColor",
" but the screen would also support 24bit TrueColor which would be the",
" preferred choice.",
"",
" The information about an Xserver's capabilities can be obtained with the",
" program `xdpyinfo`. For the visual names below you can choose one of",
" StaticGray, GrayScale, StaticColor, PseudoColor, TrueColor, DirectColor.",
" If an Xserver supports a requested visual type at different depths,",
" `gnuplot` chooses the visual class with the highest depth (deepest).",
" If the requested visual class matches the default visual and multiple",
" classes of this type are supported, the default visual is preferred.",
"",
" Example: on an 8bit PseudoColor visual you can force a private color map",
" by specifying `gnuplot*maxcolors: 240` and `gnuplot*mincolors: 240`.",
"",
"@start table - first is interactive cleartext form",
" gnuplot*maxcolors: <integer number>",
" gnuplot*mincolors: <integer number>",
" gnuplot*visual: <visual name>",
"#\\begin{tabular}{|cl|} \\hline",
"#&gnuplot*maxcolors: <integer number>\\\\",
"#&gnuplot*mincolors: <integer number>\\\\",
"#&gnuplot*visual: <visual name>\\\\",
"%c l .",
"%@gnuplot*maxcolors: <integer number>",
"%@gnuplot*mincolors: <integer number>",
"%@gnuplot*visual: <visual name>",
"@end table"
#endif /* PM3D */
END_HELP(x11)
#endif /* TERM_HELP */
|