home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume25 / ted / part05 / charset.c next >
Encoding:
C/C++ Source or Header  |  1991-11-06  |  23.8 KB  |  788 lines

  1. /*
  2. ** This software is Copyright (c) 1991 by Daniel Weaver.
  3. **
  4. ** Permission is hereby granted to copy, distribute or otherwise
  5. ** use any part of this package as long as you do not try to make
  6. ** money from it or pretend that you wrote it.  This copyright
  7. ** notice must be maintained in any copy made.
  8. **
  9. ** Use of this software constitutes acceptance for use in an AS IS
  10. ** condition. There are NO warranties with regard to this software.
  11. ** In no event shall the author be liable for any damages whatsoever
  12. ** arising out of or in connection with the use or performance of this
  13. ** software.  Any use of this software is at the user's own risk.
  14. **
  15. **  If you make modifications to this software that you feel
  16. **  increases it usefulness for the rest of the community, please
  17. **  email the changes, enhancements, bug fixes as well as any and
  18. **  all ideas to me. This software is going to be maintained and
  19. **  enhanced as deemed necessary by the community.
  20. */
  21. /* test alternate character sets and graphics modes */
  22.  
  23. #include "curses.h"
  24. #include "ted.h"
  25.  
  26. struct mode_list alt_modes[] = {
  27.    "normal",    "(sgr0)",    "(sgr0)",    1,
  28.    "standout",    "(smso)",    "(rmso)",    2,
  29.    "underline",    "(smul)",    "(rmul)",    4,
  30.    "reverse",    "(rev)",    "(sgr0)",    8,
  31.    "blink",    "(blink)",    "(sgr0)",    16,
  32.    "dim",    "(dim)",    "(sgr0)",    32,
  33.    "bold",    "(bold)",    "(sgr0)",    64,
  34.    "invis",    "(invis)",    "(sgr0)",    128,
  35.    "protect",    "(prot)",    "(sgr0)",    256,
  36.    "altcharset", "(smacs)",    "(rmacs)",    512};
  37.  
  38. /* On many terminals the underline attribute is the last scan line.
  39.    This is OK unless the following line is reverse video.
  40.    Then the underline attribute does not show up.  The following map
  41.    will reorder the display so that the underline attribute will
  42.    show up. */
  43. int mode_map[10] = {0, 1, 3, 4, 5, 6, 7, 8, 9, 2};
  44.  
  45. struct graphics_pair {
  46.    char c;
  47.    char *name;
  48. };
  49.  
  50. struct graphics_pair glyph[] = {
  51.     '+', "arrow pointing right",
  52.     ',', "arrow pointing left",
  53.     '.', "arrow pointing down",
  54.     '0', "solid square block",
  55.     'I', "lantern symbol",
  56.     '_', "arrow pointing up",
  57.     '`', "diamond",
  58.     'a', "checker board (stipple)",
  59.     'f', "degree symbol",
  60.     'g', "plus/minus",
  61.     'h', "board of squares",
  62.     'j', "lower right corner",
  63.     'k', "upper right corner",
  64.     'l', "upper left corner",
  65.     'm', "lower left corner",
  66.     'n', "plus",
  67.     'o', "scan line 1",
  68.     'p', "scan line 3",
  69.     'q', "horizontal line",
  70.     'r', "scan line 7",
  71.     's', "scan line 9",
  72.     't', "left tee (|-)",
  73.     'u', "right tee (-|)",
  74.     'v', "bottom tee(_|_)",
  75.     'w', "top tee (T)",
  76.     'x', "vertical line",
  77.     'y', "less/equal",
  78.     'z', "greater/equal",
  79.     '{', "Pi",
  80.     '|', "not equal",
  81.     '}', "UK pound sign",
  82.     '~', "bullet",
  83.     '\0', "\0"};
  84.  
  85. #ifdef TESTCAP
  86.  
  87. static char tc_buffer[4096];  /* buffer to hold new termcap strings */
  88. static char *tcb = tc_buffer;  /* pointer into termcap string buffer */
  89. extern char tgetflag();
  90. extern int tgetnum();
  91. extern CHARSTAR tgetstr();
  92.  
  93. /* In this scheme, characters in the alternate character sets have
  94.    seperate termcap entries */
  95. struct cap_graphics {
  96.    char *single_cap;  /* termcap entry name for single lines */
  97.    char *double_cap;  /* termcap entry name for double lines */
  98.    char *name;  /* expanded text name */
  99. };
  100.  
  101. static char *cap_single[256];
  102. static char *cap_double[256];
  103. static char *dual_caps[5][5][5];
  104. static char cap_cookies[5];
  105.  
  106. struct cap_mode_list {
  107.    char *name;
  108.    char *begin_mode, *end_mode;
  109.    char *cookie_count;
  110.    int attr;
  111. };
  112.  
  113. #ifdef TC
  114. struct cap_graphics tcg[] = {
  115.    "gv", "GV", "vertical line",
  116.    "gh", "GH", "horizontal line",
  117.    "g1", "G1", "top right corner",
  118.    "g4", "G4", "bottom right corner",
  119.    "g2", "G2", "top left corner",
  120.    "g3", "G3", "bottom left corner",
  121.    "gd", "GD", "down-tick character (T)",
  122.    "gl", "GL", "left-tick character (-|)",
  123.    "gr", "GR", "right-tick character (|-)",
  124.    "gc", "GC", "middle intersection",
  125.    "gu", "GU", "up-tick character (_|_)",
  126.    0, 0, 0};
  127.  
  128. struct cap_mode_list cap_alt_modes[] = {
  129.    "inverse",    "so", "se", "sg", 1,
  130.    "underline",    "us", "ue", "ug", 2,
  131.    "blink",    "bo", "be", "bb", 3,
  132.    "dim",    "it", "ie", "ig", 4,
  133.    "graphics",    "GS", "GE", "GG", 5,
  134.    0,        "a3", "A3", 0,    0x24,
  135.    0,        "a8", "A8", 0,    0x23,
  136.    0,        "b0", "B0", 0,    0x25,
  137.    0,        "a7", "A7", 0,    0x41,
  138.    0,        "a6", "A6", 0,    0x21,
  139.    0,        "b3", "B3", 0,    0x321,
  140.    0,        "b4", "B4", 0,    0x51,
  141.    0,        "b5", "B5", 0,    0x251,
  142.    0,        "b2", "B2", 0,    0x31,
  143.    0, 0, 0, 0, 0 };
  144.  
  145. #else
  146. #ifdef XENIX
  147. struct cap_graphics tcg[] = {
  148.    "gv", "GV", "vertical line",
  149.    "gh", "GH", "horizontal line",
  150.    "g1", "G1", "top right corner",
  151.    "g4", "G4", "bottom right corner",
  152.    "g2", "G2", "top left corner",
  153.    "g3", "G3", "bottom left corner",
  154.    "gd", "GD", "down-tick character (T)",
  155.    "gl", "GL", "left-tick character (-|)",
  156.    "gr", "GR", "right-tick character (|-)",
  157.    "gc", "GC", "middle intersection",
  158.    "gu", "GU", "up-tick character (_|_)",
  159. #ifdef WHO_KNOWS
  160.    "f1", "F1", "S/D top right corner",
  161.    "f4", "F4", "S/D bottom right corner",
  162.    "f2", "F2", "S/D top left corner",
  163.    "f3", "F3", "S/D bottom left corner",
  164.    "fd", "FD", "S/D down-tick character (T)",
  165.    "fl", "FL", "S/D left-tick character (-|)",
  166.    "fr", "FR", "S/D right-tick character (|-)",
  167.    "fc", "FC", "S/D middle intersection",
  168.    "fu", "FU", "S/D up-tick character (_|_)",
  169. #endif
  170.    0, 0, 0};
  171.  
  172. struct cap_mode_list cap_alt_modes[] = {
  173.    "inverse",    "so", "se", "sg", 1,
  174.    "underline",    "us", "ue", "ug", 2,
  175.    "blink",    "bo", "be", "bb", 3,
  176.    "dim",    "it", "ie", "ig", 4,
  177.    "graphics",    "GS", "GE", "GG", 5,
  178.    0,        "a3", "A3", 0,    0x24,
  179.    0,        "a8", "A8", 0,    0x23,
  180.    0,        "b0", "B0", 0,    0x25,
  181.    0,        "a7", "A7", 0,    0x41,
  182.    0,        "a6", "A6", 0,    0x21,
  183.    0,        "b3", "B3", 0,    0x321,
  184.    0,        "b4", "B4", 0,    0x51,
  185.    0,        "b5", "B5", 0,    0x251,
  186.    0,        "b2", "B2", 0,    0x31,
  187.    0, 0, 0, 0, 0 };
  188.  
  189. #else
  190. #ifdef MV
  191. struct cap_graphics tcg[] = {
  192.    "GV", "GGV", "vertical line",
  193.    "GH", "GGH", "horizontal line",
  194.    "G1", "GG1", "top right corner",
  195.    "G4", "GG4", "bottom right corner",
  196.    "G2", "GG2", "top left corner",
  197.    "G3", "GG3", "bottom left corner",
  198.    "GD", "GGD", "Down-tick character (T)",
  199.    "GL", "GGL", "Left-tick character (-|)",
  200.    "GR", "GGR", "Right-tick character (|-)",
  201.    "GC", "GGC", "middle intersection",
  202.    "GU", "GGU", "Up-tick character (_|_)",
  203.    0, 0, 0};
  204.  
  205. struct cap_mode_list cap_alt_modes[] = {
  206.    "standout",    "so", "se", "sg", 1,
  207.    "underline",    "us", "ue", "ug", 2,
  208.    "graphics",    "GS", "GE", "GG", 3,
  209.    "blink",    "mb", "me",    0, 4,
  210.    "dim",    "mh", "me",    0, 5,
  211.    "bold",    "md", "me",    0, 6,
  212.    "overstrike","mo", "me",    0, 7,
  213.    0, 0, 0, 0, 0 };
  214. #endif
  215. #endif
  216. #endif
  217. #endif
  218.  
  219. test_status()
  220.    {
  221.       int i, max;
  222.       char *s;
  223.       static char m[] = "*** status line *** 123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.";
  224.  
  225.       can_test("(hs)(wsl)(tsl)(fsl)(dsl)");
  226.       if (stop_testing) return;
  227.  
  228.       if (has_status_line != 1)
  229.          {
  230.             ptextln("Terminal has no status line (hs)");
  231.             return;
  232.          }
  233.  
  234.       max = width_status_line == -1 ? columns : width_status_line;
  235.       sprintf(temp, "Terminal has status line of %d characters", max);
  236.       ptextln(temp);
  237.       put_str("This line s");
  238.       s = tparm(to_status_line, 0);
  239.       putp(s);
  240.          for (i = 0; i < max; i++) putchp(m[i]);
  241.       putp(from_status_line);
  242.       putln("hould not be broken");
  243.       (void) wait_here();
  244.       if (dis_status_line)
  245.          {
  246.             ptextln("Disable status line (dsl)");
  247.             putp(dis_status_line);
  248.          }
  249.       else ptextln("Terminal can not disable status line (dsl)");
  250.    }
  251.  
  252.  
  253. eat_cookie()
  254.    {  /* put a blank if this is not a magic cookie terminal */
  255.       if (magic_cookie_glitch < 1) putchp(' ');
  256.    }
  257.  
  258.  
  259. put_mode(s)
  260. char *s;
  261.    {  /* send the attribute string (with or without % execution) */
  262. #ifdef SVR3_2
  263.       putp(tparm(s)); /* allow % execution */
  264. #else
  265.       putp(s);    /* ignore % */
  266. #endif
  267.    }
  268.  
  269.  
  270. void
  271. set_attr(a)
  272. int a;
  273.    {  /* set the attribute from the bits in a */
  274.       int i, b[32];
  275.  
  276.       if (magic_cookie_glitch > 0) char_count += magic_cookie_glitch;
  277.       if (a == 0 && exit_attribute_mode)
  278.          {
  279.             put_mode(exit_attribute_mode);
  280.             return;
  281.          }
  282.          for (i = 0; i < 31; i++) b[i] = (a >> i) & 1;
  283.       putp(tparm(set_attributes, b[1], b[2], b[3], b[4], b[5],
  284.          b[6], b[7], b[8], b[9]));
  285.    }
  286.  
  287.  
  288. static void
  289. test_sgr()
  290.    {
  291.       int i, j;
  292.  
  293.       maybe_wait(12);
  294.       if (!exit_attribute_mode)
  295.          ptextln("Terminal has no (sgr0) entry");
  296.       ptext("Test video attributes (sgr)");
  297.  
  298.          for (i = 0; i < (sizeof(alt_modes) / sizeof(struct mode_list));
  299.             i++) {
  300.             put_crlf();
  301.             sprintf(temp, "%d %-20s", i, alt_modes[i].name);
  302.             put_str(temp);
  303.             set_attr(alt_modes[i].number);
  304.             sprintf(temp, "%s", alt_modes[i].name);
  305.             put_str(temp);
  306.             set_attr(0);
  307.          }
  308.       maybe_wait(14);
  309.       putln("Double mode test");
  310.          for (i = 0; i <= 9; i++) {
  311.             sprintf(temp, " %2d ", mode_map[i]);
  312.             put_str(temp);
  313.          }
  314.          for (i = 0; i <= 9; i++) {
  315.             put_crlf();
  316.             sprintf(temp, "%d", mode_map[i]);  put_str(temp);
  317.                for (j = 0; j <= 9;  j++) {
  318.                   eat_cookie();
  319.                   set_attr((1 << mode_map[i]) | (1 << mode_map[j]));
  320.                   put_str("Aa");
  321.                   set_attr(0);
  322.                   if (j < 9) eat_cookie();
  323.                }
  324.          }
  325.       put_crlf();
  326. #ifdef SVR3_2
  327.       if (max_attributes >= 0)
  328.          {
  329.             sprintf(temp, "(ma) Maximum attributes %d", max_attributes);
  330.             put_crlf();
  331.             ptextln(temp);
  332.          }
  333. #endif
  334.    }
  335.  
  336.  
  337. #if defined(TC) || defined(XENIX) || defined(MV)
  338. static void
  339. test_attr_mode()
  340.    {  /* test TC sytle attributes */
  341.       int i, j, v, cookies;
  342.       char *cap_start, *cap_end;
  343.       char *test_string =    "123ABCXYZabcxyz";
  344.       char *missing_string =    "*** missing ***";
  345.  
  346.       if (stop_testing)
  347.          {
  348.                for (i = 0; cap_alt_modes[i].begin_mode; i++) {
  349.                   cap_test(cap_alt_modes[i].begin_mode);
  350.                   cap_test(cap_alt_modes[i].end_mode);
  351.                   cap_test(cap_alt_modes[i].cookie_count);
  352.                }
  353.             return;
  354.          }
  355.       maybe_wait(18);
  356.          for (i = j = 0; cap_alt_modes[i].begin_mode; i++) {
  357.             if (cap_start = tgetstr(cap_alt_modes[i].begin_mode, &tcb))
  358.                if (!cap_start[0]) cap_start = NULL;
  359.             if (cap_end = tgetstr(cap_alt_modes[i].end_mode, &tcb))
  360.                if (!cap_end[0]) cap_end = NULL;
  361.             cookies = tgetnum(cap_alt_modes[i].cookie_count, &tcb);
  362.             if (cap_start || cap_alt_modes[i].name)
  363.                {
  364.                   if (cookies < 0) cookies = 0;
  365.                   if (cap_alt_modes[i].name)
  366.                      {
  367.                         if (j < cookies) j = cookies;
  368.                      }
  369.                   else cookies = j;
  370.                   putchp(LEFT_BRACE);
  371.                   put_str(cap_alt_modes[i].begin_mode);
  372.                   putchp(RIGHT_BRACE);  putchp(' ');
  373.                   if (cookies < 1) putchp(' ');
  374.                   if (cap_start)
  375.                      {
  376.                         putp(cap_start);
  377.                         put_str(test_string);
  378.                         putp(cap_end);
  379.                      }
  380.                   else put_str(missing_string);
  381.                   if (cookies < 1) putchp(' ');
  382.                   putchp(' ');  putchp(LEFT_BRACE);
  383.                   put_str(cap_alt_modes[i].end_mode);
  384.                   putchp(RIGHT_BRACE);
  385.                   if (cap_alt_modes[i].cookie_count)
  386.                      {
  387.                         putchp(' ');  putchp(LEFT_BRACE);
  388.                         put_str(cap_alt_modes[i].cookie_count);
  389.                         putchp(RIGHT_BRACE);
  390.                         sprintf(temp, " %d", cookies);
  391.                         put_str(temp);
  392.                      }
  393.                      for (v = cap_alt_modes[i].attr; v; v >>= 4) {
  394.                         putchp(' ');
  395.                         put_str(cap_alt_modes[(v & 15) - 1].name);
  396.                      }
  397.                   put_crlf();
  398.                }
  399.          }
  400.    }
  401. #else
  402.  
  403.  
  404. static void
  405. test_one_attr(n, begin_mode, end_mode)
  406. int n;
  407. char *begin_mode, *end_mode;
  408.    {   /* test attributes without (sgr) */
  409.       int i;
  410.  
  411.       sprintf(temp, "%-10s %s ", alt_modes[n].name,
  412.          alt_modes[n].begin_mode);
  413.       ptext(temp);
  414.          for ( ; char_count < 19; ) putchp(' ');
  415.       if (begin_mode)
  416.          {
  417.             putchp('.');
  418.             put_mode(begin_mode);
  419.             put_str(alt_modes[n].name);
  420.                for (i = strlen(alt_modes[n].name); i < 13; i++)
  421.                   putchp(' ');
  422.             if (end_mode)
  423.                {
  424.                   put_mode(end_mode);
  425.                   sprintf(temp, ". %s", alt_modes[n].end_mode);
  426.                }
  427.             else
  428.                {
  429.                   set_attr(0);
  430.                   strcpy(temp, ". (sgr)");
  431.                }
  432.             ptextln(temp);
  433.          }
  434.       else
  435.          {
  436.                for (i = 0; i < magic_cookie_glitch; i++)
  437.                   putchp('*');
  438.             put_str("*** missing ***");
  439.                for (i = 0; i < magic_cookie_glitch; i++)
  440.                   putchp('*');
  441.             put_crlf();
  442.          }
  443.    }
  444.  
  445.  
  446. static void
  447. test_attr_mode()
  448.    {
  449.       if (stop_testing)
  450.          {
  451.             int i;
  452.  
  453.                for (i = 0; i < 9; i++) {
  454.                   can_test(alt_modes[i].begin_mode);
  455.                   can_test(alt_modes[i].end_mode);
  456.                }
  457.             can_test("sgr");
  458.             return;
  459.          }
  460.       maybe_wait(11);
  461.       putln("Test video attributes");
  462.       test_one_attr(1, enter_standout_mode, exit_standout_mode);
  463.       test_one_attr(2, enter_underline_mode, exit_underline_mode);
  464.       test_one_attr(9, enter_alt_charset_mode, exit_alt_charset_mode);
  465.       if (!exit_attribute_mode && !set_attributes)
  466.          {
  467.             ptextln("(sgr0) exit attribute mode is not defined.");
  468.             return;
  469.          }
  470.       test_one_attr(3, enter_reverse_mode, exit_attribute_mode);
  471.       test_one_attr(4, enter_blink_mode, exit_attribute_mode);
  472.       test_one_attr(5, enter_dim_mode, exit_attribute_mode);
  473.       test_one_attr(6, enter_bold_mode, exit_attribute_mode);
  474.       test_one_attr(7, enter_secure_mode, exit_attribute_mode);
  475.       test_one_attr(8, enter_protected_mode, exit_attribute_mode);
  476.    }
  477. #endif
  478.  
  479. #if defined(SVR3) || defined(TC) || defined(XENIX) || defined(MV)
  480. #define GLYPHS 256
  481. #undef acs_map
  482.  
  483. static void
  484. dump_acs()
  485.    {  /* display all posible acs characters */
  486.       int i, c;
  487.  
  488.       put_clear();
  489.       ptextln("The following characters are available. (smacs) (rmacs)");
  490.          for (i = ' '; i <= '`'; i += 32) {
  491.             put_crlf();
  492.             put_mode(exit_alt_charset_mode);
  493.                for (c = 0; c < 32; c++) {
  494.                   putchp(c + i);
  495.                }
  496.             put_crlf();
  497.             put_mode(enter_alt_charset_mode);
  498.                for (c = 0; c < 32; c++) {
  499.                   putchp(c + i);
  500.                }
  501.             put_mode(exit_alt_charset_mode);
  502.             put_crlf();
  503.          }
  504.       put_mode(exit_alt_charset_mode);
  505.       (void) wait_here();
  506.    }
  507.  
  508.  
  509. static int
  510. test_acs()
  511.    {  /* alternate character set */
  512.       int i, j;
  513.       char valid_glyph[GLYPHS];
  514.       char acs_map[GLYPHS];
  515.       static char vt100[] = "`afgjklmnopqrstuvwxyz{|}~";
  516.  
  517. #ifdef SVR3
  518.       if (stop_testing)
  519.          {
  520.             can_test("(acsc)(enacs)(smacs)(rmacs)");
  521.             return 0;
  522.          }
  523.       line_count = 0;
  524.          for (i = 0; i < GLYPHS; i++) {
  525.             valid_glyph[i] = FALSE;
  526.             acs_map[i] = i;
  527.          }
  528.       if (acs_chars)
  529.          {
  530.             sprintf(temp, "Alternate character set map: %s",
  531.                expand(acs_chars));
  532.             putln(temp);
  533.                for (i = 0; acs_chars[i]; i += 2) {
  534.                   if (acs_chars[i + 1] == 0) break;
  535.                      for (j = 0; ; j++) {
  536.                         if (glyph[j].c == acs_chars[i])
  537.                            {
  538.                               acs_map[glyph[j].c] = acs_chars[i + 1];
  539.                               valid_glyph[glyph[j].c] = TRUE;
  540.                               break;
  541.                            }
  542.                         if (glyph[j].name[0] == '\0')
  543.                            {
  544.                               sprintf(temp, " %c %s", acs_chars[i],
  545.                               "*** has no mapping ***");
  546.                               putln(temp);
  547.                               break;
  548.                            }
  549.                      }
  550.                }
  551.          }
  552.       else
  553.          {
  554.             ptextln("acs_chars not defined (acsc)");
  555.             /* enable the VT-100 graphics characters (default) */
  556.                for (i = 0; vt100[i]; i++) {
  557.                      valid_glyph[vt100[i]] = TRUE;
  558.                }
  559.          }
  560.       if (ena_acs) putp(ena_acs);
  561.          for (i = 0; glyph[i].name[0]; i++) {
  562.             if (valid_glyph[glyph[i].c])
  563.                {
  564.                   put_mode(enter_alt_charset_mode);
  565.                   put_this(acs_map[glyph[i].c]);  char_count++;
  566.                   put_mode(exit_alt_charset_mode);
  567.                   sprintf(temp, " %-30.30s", glyph[i].name);
  568.                   put_str(temp);
  569.                   if (char_count + 33 >= columns) put_crlf();
  570.                   if (line_count >= lines)
  571.                      {
  572.                         (void) wait_here();
  573.                         put_clear();
  574.                      }
  575.                }
  576.          }
  577.       if (char_count > 1) put_crlf();
  578. #ifdef ACS_ULCORNER
  579.       maybe_wait(5);
  580.       putln("Here are 2 boxes");
  581.       put_mode(enter_alt_charset_mode);
  582.       put_this(ACS_ULCORNER);  put_this(ACS_TTEE);
  583.       put_this(ACS_URCORNER);  put_this(ACS_ULCORNER);
  584.       put_this(ACS_HLINE); put_this(ACS_URCORNER);
  585.       char_count += 6;
  586.       if (move_standout_mode) put_crlf();
  587.       else
  588.          {
  589.             put_mode(exit_alt_charset_mode);
  590.             put_crlf();
  591.             put_mode(enter_alt_charset_mode);
  592.          }
  593.       put_this(ACS_LTEE);  put_this(ACS_PLUS);  put_this(ACS_RTEE);
  594.       put_this(ACS_VLINE);
  595.       if (magic_cookie_glitch >= 1) put_this(' ');
  596.       else
  597.          {
  598.             put_mode(exit_alt_charset_mode);
  599.             put_this(' ');
  600.             put_mode(enter_alt_charset_mode);
  601.          }
  602.       put_this(ACS_VLINE);
  603.       char_count += 6;
  604.       if (move_standout_mode) put_crlf();
  605.       else
  606.          {
  607.             put_mode(exit_alt_charset_mode);
  608.             put_crlf();
  609.             put_mode(enter_alt_charset_mode);
  610.          }
  611.       put_this(ACS_LLCORNER);  put_this(ACS_BTEE);
  612.       put_this(ACS_LRCORNER);  put_this(ACS_LLCORNER);
  613.       put_this(ACS_HLINE); put_this(ACS_LRCORNER);
  614.       char_count += 6;
  615.       put_mode(exit_alt_charset_mode);
  616.       put_crlf();
  617. #endif
  618. #else /* TESTCAP */
  619.       if (stop_testing)
  620.          {
  621.                for (i = 0; tcg[i].single_cap; i++) {
  622.                   cap_test(tcg[i].single_cap);
  623.                   cap_test(tcg[i].double_cap);
  624.                }
  625.             can_test("(smacs)(rmacs)");
  626.             return 0;
  627.          }
  628.       /* display graphics characters for termcap style graphics */
  629.       putln("single   double");
  630.          for (i = 0; tcg[i].single_cap; i++) {
  631.             cap_single[i] = tgetstr(tcg[i].single_cap, &tcb);
  632.             cap_double[i] = tgetstr(tcg[i].double_cap, &tcb);
  633.             putchp(LEFT_BRACE);
  634.             put_str(tcg[i].single_cap);
  635.             putchp(RIGHT_BRACE);  putchp(' ');
  636.             if (cap_single[i] && cap_single[i][0])
  637.                {
  638.                   putchp(' ');
  639.                   put_mode(enter_alt_charset_mode);
  640.                   put_str(cap_single[i]);
  641.                   put_mode(exit_alt_charset_mode);
  642.                   putchp(' ');
  643.                }
  644.             else put_str("***");
  645.             putchp(' ');  putchp(LEFT_BRACE);
  646.             put_str(tcg[i].double_cap);
  647.             putchp(RIGHT_BRACE);  putchp(' ');
  648.             if (cap_double[i] && cap_double[i][0])
  649.                {
  650.                   putchp(' ');
  651.                   put_mode(enter_alt_charset_mode);
  652.                   put_str(cap_double[i]);
  653.                   put_mode(exit_alt_charset_mode);
  654.                   putchp(' ');
  655.                }
  656.             else put_str("***");
  657.             putchp(' ');
  658.             putln(tcg[i].name);
  659.          }
  660. #endif
  661.       return wait_here();
  662.    }
  663. #endif
  664.  
  665.  
  666. void
  667. test_charset()
  668.    {  /* test begins here */
  669.       int ch;
  670.  
  671.       if (run_test(bell, "Terminal has no bell (bel)", FALSE))
  672.          do {
  673.             new_test(2);
  674.             sprintf(temp, "Testing bell (bel), %s", expand(bell));
  675.             ptextln(temp);
  676.             putp(bell);
  677.          } while (repeat_test(FALSE));
  678.  
  679.       if (run_test(flash_screen,
  680.          "Terminal has no flash screen (flash)", FALSE))
  681.          do {
  682.             new_test(2);
  683.             ptextln("Testing visual bell (flash)");
  684.             putp(flash_screen);
  685.          } while (repeat_test(FALSE));
  686.  
  687. #ifdef TC
  688.       new_test(6);
  689.       if (run_test(cursor_invisible,
  690.          "Terminal has no cursor off (civis)", FALSE))
  691.          do {
  692.             ptext("(civis) Turn off the cursor.");
  693.             putp(cursor_invisible);
  694.          } while (repeat_test(FALSE));
  695.  
  696.       can_test(":CO");
  697.       sprintf(temp, "Terminal has no cursor on %cCO%c",
  698.          LEFT_BRACE, RIGHT_BRACE);
  699.       if (run_test(cursor_on, temp, FALSE))
  700.          do {
  701.             putchp(LEFT_BRACE);
  702.             put_str("CO");
  703.             putchp(RIGHT_BRACE);
  704.             put_str(" Turn on the cursor.");
  705.             putp(cursor_on);
  706.          } while (repeat_test(FALSE));
  707.  
  708.       if (run_test(cursor_visible,
  709.          "Terminal has no cursor_visible (cvvis)", FALSE))
  710.          do {
  711.             ptext("(cvvis) Make cursor very visible.");
  712.             putp(cursor_visible);
  713.          } while (repeat_test(FALSE));
  714. #else
  715.       new_test(6);
  716.       can_test("(civis)(cvvis)");
  717.  
  718.       if (cursor_normal && run_test(cursor_invisible,
  719.          "Terminal has no cursor off (civis)", FALSE))
  720.          do {
  721.             ptext("(civis) Turn off the cursor.");
  722.             putp(cursor_invisible);
  723.          } while (repeat_test(FALSE));
  724.  
  725.       if (cursor_normal && run_test(cursor_visible,
  726.          "Terminal has no cursor_visible (cvvis)", FALSE))
  727.          do {
  728.             ptext("(cvvis) Make cursor very visible.");
  729.             putp(cursor_visible);
  730.          } while (repeat_test(FALSE));
  731. #endif
  732.       if (run_test(cursor_normal,
  733.          "Terminal has no cursor_normal (cnorm)", FALSE))
  734.          do {
  735.             ptext("(cnorm) Normal cursor.");
  736.             putp(cursor_normal);
  737.          } while (repeat_test(FALSE));
  738.  
  739.          do {
  740.             test_status();
  741.          } while (repeat_test(FALSE));
  742.  
  743. #if defined(SVR3) || defined(TC) || defined(XENIX) || defined(MV)
  744.       if (stop_testing) (void) test_acs();
  745.       else
  746. #endif
  747. #if defined(SVR3)
  748.       if (enter_alt_charset_mode || acs_chars)
  749. #endif
  750. #if defined(SVR3) || defined(TC) || defined(XENIX) || defined(MV)
  751.          {
  752.             putln("Display graphics symbols");
  753.             (void) wait_here();
  754.             put_clear();
  755.             ch = 0;
  756.                do {
  757.                   /* for terminals that use seperate fonts for
  758.                      attributes (such as X windows) the line drawing
  759.                      characters must be checked for each font.  */
  760.                   if (ch >= '0' & ch <= '8')
  761.                      {
  762.                         set_attr(alt_modes[ch - '0'].number);
  763.                         ch = test_acs();
  764.                         set_attr(0);
  765.                      }
  766.                   else ch = test_acs();
  767.                } while (ch == 'r' || ch == 'R' || (ch >= '0' && ch <= '9'));
  768.             if (enter_alt_charset_mode) dump_acs();
  769.             put_clear();
  770.          }
  771. #if defined(SVR3)
  772.       else ptextln("Terminal has no alternate character set (smacs)");
  773. #endif
  774. #endif
  775.  
  776.          do {
  777.             test_attr_mode();
  778.          } while (repeat_test(FALSE));
  779.  
  780. #ifndef TESTCAP
  781.       if (run_test(set_attributes,
  782.          "Terminal has no set attribute command (sgr)", TRUE))
  783.          do {
  784.             test_sgr();
  785.          } while (repeat_test(FALSE));
  786. #endif
  787.    }
  788.