2 ** Copyright (C) 1991, 1997 Free Software Foundation, Inc.
4 ** This file is part of TACK.
6 ** TACK is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2, or (at your option)
11 ** TACK is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
16 ** You should have received a copy of the GNU General Public License
17 ** along with TACK; see the file COPYING. If not, write to
18 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 ** Boston, MA 02111-1307, USA.
24 MODULE_ID("$Id: charset.c,v 1.2 1999/05/09 18:30:49 tom Exp $")
27 Menu definitions for alternate character set and SGR tests.
30 static void charset_bel(struct test_list *t, int *state, int *ch);
31 static void charset_flash(struct test_list *t, int *state, int *ch);
32 static void charset_civis(struct test_list *t, int *state, int *ch);
33 static void charset_cvvis(struct test_list *t, int *state, int *ch);
34 static void charset_cnorm(struct test_list *t, int *state, int *ch);
35 static void charset_hs(struct test_list *t, int *state, int *ch);
36 static void charset_status(struct test_list *t, int *state, int *ch);
37 static void charset_dsl(struct test_list *t, int *state, int *ch);
38 static void charset_enacs(struct test_list *t, int *state, int *ch);
39 static void charset_smacs(struct test_list *t, int *state, int *ch);
40 static void charset_attributes(struct test_list *t, int *state, int *ch);
41 static void charset_sgr(struct test_list *t, int *state, int *ch);
43 const struct test_list acs_test_list[] = {
44 {0, 0, 0, 0, "e) edit terminfo", 0, &edit_menu},
45 {MENU_NEXT, 3, "bel", 0, 0, charset_bel, 0},
46 {MENU_NEXT, 3, "flash", 0, 0, charset_flash, 0},
47 {MENU_NEXT, 3, "civis", 0, 0, charset_civis, 0},
48 {MENU_NEXT, 3, "cvvis", 0, 0, charset_cvvis, 0},
49 {MENU_NEXT, 3, "cnorm", 0, 0, charset_cnorm, 0},
50 {MENU_NEXT, 3, "hs", 0, 0, charset_hs, 0},
51 {MENU_NEXT, 3, "tsl) (fsl) (wsl", "hs", 0, charset_status, 0},
52 {MENU_NEXT, 3, "dsl", "hs", 0, charset_dsl, 0},
53 {MENU_NEXT, 0, "acsc) (enacs) (smacs) (rmacs", 0, 0, charset_enacs, 0},
54 {MENU_NEXT, 0, "smacs) (rmacs", 0, 0, charset_smacs, 0},
55 {MENU_NEXT, 11, 0, 0, 0, charset_attributes, 0},
56 {MENU_NEXT, 11, "sgr) (sgr0", "ma", 0, charset_sgr, 0},
57 {MENU_LAST, 0, 0, 0, 0, 0, 0}
60 const struct mode_list alt_modes[] = {
61 {"normal", "(sgr0)", "(sgr0)", 1},
62 {"standout", "(smso)", "(rmso)", 2},
63 {"underline", "(smul)", "(rmul)", 4},
64 {"reverse", "(rev)", "(sgr0)", 8},
65 {"blink", "(blink)", "(sgr0)", 16},
66 {"dim", "(dim)", "(sgr0)", 32},
67 {"bold", "(bold)", "(sgr0)", 64},
68 {"invis", "(invis)", "(sgr0)", 128},
69 {"protect", "(prot)", "(sgr0)", 256},
70 {"altcharset", "(smacs)", "(rmacs)", 512}
73 /* On many terminals the underline attribute is the last scan line.
74 This is OK unless the following line is reverse video.
75 Then the underline attribute does not show up. The following map
76 will reorder the display so that the underline attribute will
78 const int mode_map[10] = {0, 1, 3, 4, 5, 6, 7, 8, 9, 2};
80 struct graphics_pair {
85 static struct graphics_pair glyph[] = {
86 {'+', "arrow pointing right"},
87 {',', "arrow pointing left"},
88 {'.', "arrow pointing down"},
89 {'0', "solid square block"},
90 {'i', "lantern symbol"},
91 {'-', "arrow pointing up"},
93 {'a', "checker board (stipple)"},
94 {'f', "degree symbol"},
96 {'h', "board of squares"},
97 {'j', "lower right corner"},
98 {'k', "upper right corner"},
99 {'l', "upper left corner"},
100 {'m', "lower left corner"},
102 {'o', "scan line 1"},
103 {'p', "scan line 3"},
104 {'q', "horizontal line"},
105 {'r', "scan line 7"},
106 {'s', "scan line 9"},
107 {'t', "left tee (|-)"},
108 {'u', "right tee (-|)"},
109 {'v', "bottom tee(_|_)"},
110 {'w', "top tee (T)"},
111 {'x', "vertical line"},
113 {'z', "greater/equal"},
116 {'}', "UK pound sign"},
122 ** charset_hs(test_list, status, ch)
124 ** (hs) test Has status line
132 if (has_status_line != 1) {
133 ptext("(hs) Has-status line is not defined. ");
134 generic_done_message(t, state, ch);
139 ** charset_status(test_list, status, ch)
141 ** (tsl) (fsl) (wsl) test Status line
151 static char m[] = "*** status line *** 123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.";
153 if (has_status_line != 1) {
157 max = width_status_line == -1 ? columns : width_status_line;
158 sprintf(temp, "Terminal has status line of %d characters", max);
161 put_str("This line s");
162 s = tparm(to_status_line, 0);
164 for (i = 0; i < max; i++)
166 tc_putp(from_status_line);
167 putln("hould not be broken.");
168 ptextln("If the previous line is not a complete sentence then (tsl) to-status-line, (fsl) from-status-line, or (wsl) width-of-status-line is incorrect." );
169 generic_done_message(t, state, ch);
173 ** charset_dsl(test_list, status, ch)
175 ** (dsl) test Disable status line
183 if (has_status_line != 1) {
186 if (dis_status_line) {
187 ptextln("Disable status line (dsl)");
188 tc_putp(dis_status_line);
189 ptext("If you can still see the status line then (dsl) disable-status-line has failed. ");
191 ptext("(dsl) Disable-status-line is not defined. ");
193 generic_done_message(t, state, ch);
199 { /* put a blank if this is not a magic cookie
201 if (magic_cookie_glitch < 1)
208 { /* send the attribute string (with or without
210 tc_putp(tparm(s)); /* allow % execution */
216 { /* set the attribute from the bits in a */
219 if (magic_cookie_glitch > 0) {
220 char_count += magic_cookie_glitch;
222 if (a == 0 && exit_attribute_mode) {
223 put_mode(exit_attribute_mode);
226 for (i = 0; i < 31; i++) {
229 tc_putp(tparm(set_attributes, b[1], b[2], b[3], b[4], b[5],
230 b[6], b[7], b[8], b[9]));
234 ** charset_sgr(test_list, status, ch)
236 ** (sgr) test Set Graphics Rendition
246 if (!set_attributes) {
247 ptext("(sgr) Set-graphics-rendition is not defined. ");
248 generic_done_message(t, state, ch);
251 if (!exit_attribute_mode) {
252 ptextln("(sgr0) Set-graphics-rendition-zero is not defined.");
253 /* go ahead and test anyway */
255 ptext("Test video attributes (sgr)");
257 for (i = 0; i < (int) (sizeof(alt_modes) / sizeof(struct mode_list));
260 sprintf(temp, "%d %-20s", i, alt_modes[i].name);
262 set_attr(alt_modes[i].number);
263 sprintf(temp, "%s", alt_modes[i].name);
268 putln("\n\nDouble mode test");
269 for (i = 0; i <= 9; i++) {
270 sprintf(temp, " %2d ", mode_map[i]);
273 for (i = 0; i <= 9; i++) {
275 sprintf(temp, "%d", mode_map[i]);
277 for (j = 0; j <= 9; j++) {
279 set_attr((1 << mode_map[i]) | (1 << mode_map[j]));
288 if (max_attributes >= 0) {
289 sprintf(temp, "(ma) Maximum attributes %d ", max_attributes);
292 generic_done_message(t, state, ch);
296 ** test_one_attr(mode-number, begin-string, end-string)
298 ** Display one attribute line.
308 sprintf(temp, "%-10s %s ", alt_modes[n].name, alt_modes[n].begin_mode);
310 for (; char_count < 19;) {
315 put_mode(begin_mode);
316 put_str(alt_modes[n].name);
317 for (i = strlen(alt_modes[n].name); i < 13; i++) {
322 sprintf(temp, ". %s", alt_modes[n].end_mode);
325 strcpy(temp, ". (sgr)");
329 for (i = 0; i < magic_cookie_glitch; i++)
331 put_str("*** missing ***");
332 for (i = 0; i < magic_cookie_glitch; i++)
339 ** charset_attributes(test_list, status, ch)
349 putln("Test video attributes");
350 test_one_attr(1, enter_standout_mode, exit_standout_mode);
351 test_one_attr(2, enter_underline_mode, exit_underline_mode);
352 test_one_attr(9, enter_alt_charset_mode, exit_alt_charset_mode);
353 if (!exit_attribute_mode && !set_attributes) {
354 ptextln("(sgr0) exit attribute mode is not defined.");
355 generic_done_message(t, state, ch);
358 test_one_attr(3, enter_reverse_mode, exit_attribute_mode);
359 test_one_attr(4, enter_blink_mode, exit_attribute_mode);
360 test_one_attr(5, enter_dim_mode, exit_attribute_mode);
361 test_one_attr(6, enter_bold_mode, exit_attribute_mode);
362 test_one_attr(7, enter_secure_mode, exit_attribute_mode);
363 test_one_attr(8, enter_protected_mode, exit_attribute_mode);
364 generic_done_message(t, state, ch);
370 ** charset_smacs(test_list, status, ch)
372 ** display all posible acs characters
383 if (enter_alt_charset_mode) {
385 ptextln("The following characters are available. (smacs) (rmacs)");
386 for (i = ' '; i <= '`'; i += 32) {
388 put_mode(exit_alt_charset_mode);
389 for (c = 0; c < 32; c++) {
393 put_mode(enter_alt_charset_mode);
394 for (c = 0; c < 32; c++) {
397 put_mode(exit_alt_charset_mode);
400 put_mode(exit_alt_charset_mode);
402 generic_done_message(t, state, ch);
410 { /* alternate character set */
412 char valid_glyph[GLYPHS];
413 char acs_table[GLYPHS];
414 static unsigned char vt100[] = "`afgjklmnopqrstuvwxyz{|}~";
417 for (i = 0; i < GLYPHS; i++) {
418 valid_glyph[i] = FALSE;
422 sprintf(temp, "Alternate character set map: %s",
425 for (i = 0; acs_chars[i]; i += 2) {
426 if (acs_chars[i + 1] == 0) {
430 if (glyph[j].c == (unsigned char) acs_chars[i]) {
431 acs_table[glyph[j].c] = acs_chars[i + 1];
432 valid_glyph[glyph[j].c] = TRUE;
435 if (glyph[j].name[0] == '\0') {
436 if (isgraph(acs_chars[i])) {
440 sprintf(temp, " 0x%02x",
441 (acs_chars[i] & 0xff));
443 strcpy(&temp[5], " *** has no mapping ***");
450 ptextln("acs_chars not defined (acsc)");
451 /* enable the VT-100 graphics characters (default) */
452 for (i = 0; vt100[i]; i++) {
453 valid_glyph[vt100[i]] = TRUE;
459 _nc_init_acs(); /* puts 'ena_acs' and incidentally links acs_map[] */
460 for (i = 0; glyph[i].name[0]; i++) {
461 if (valid_glyph[glyph[i].c]) {
462 put_mode(enter_alt_charset_mode);
463 put_this(acs_table[glyph[i].c]);
465 put_mode(exit_alt_charset_mode);
466 if (magic_cookie_glitch >= 1) {
467 sprintf(temp, " %-30.30s", glyph[i].name);
469 if (char_count + 33 >= columns)
472 sprintf(temp, " %-24.24s", glyph[i].name);
474 if (char_count + 26 >= columns)
477 if (line_count >= lines) {
483 if (char_count > 1) {
488 put_mode(enter_alt_charset_mode);
489 put_this(ACS_ULCORNER);
491 put_this(ACS_URCORNER);
492 put_this(ACS_ULCORNER);
494 put_this(ACS_URCORNER);
496 put_mode(exit_alt_charset_mode);
498 put_mode(enter_alt_charset_mode);
503 if (magic_cookie_glitch >= 1)
506 put_mode(exit_alt_charset_mode);
508 put_mode(enter_alt_charset_mode);
512 put_mode(exit_alt_charset_mode);
513 put_str(" Here are 2 boxes");
515 put_mode(enter_alt_charset_mode);
516 put_this(ACS_LLCORNER);
518 put_this(ACS_LRCORNER);
519 put_this(ACS_LLCORNER);
521 put_this(ACS_LRCORNER);
523 put_mode(exit_alt_charset_mode);
529 ** charset_bel(test_list, status, ch)
540 ptextln("Testing bell (bel)");
542 ptext("If you did not hear the Bell then (bel) has failed. ");
544 ptext("(bel) Bell is not defined. ");
546 generic_done_message(t, state, ch);
550 ** charset_flash(test_list, status, ch)
552 ** (flash) test Visual bell
561 ptextln("Testing visual bell (flash)");
562 tc_putp(flash_screen);
563 ptext("If you did not see the screen flash then (flash) has failed. ");
565 ptext("(flash) Flash is not defined. ");
567 generic_done_message(t, state, ch);
571 ** charset_civis(test_list, status, ch)
573 ** (civis) test Cursor invisible
582 if (cursor_invisible) {
583 ptext("(civis) Turn off the cursor. ");
584 tc_putp(cursor_invisible);
585 ptext("If you can still see the cursor then (civis) has failed. ");
587 ptext("(civis) Cursor-invisible is not defined. ");
589 generic_done_message(t, state, ch);
590 tc_putp(cursor_normal);
595 ** charset_cvvis(test_list, status, ch)
597 ** (cvvis) test Cursor very visible
606 if (cursor_visible) {
607 ptext("(cvvis) Make cursor very visible. ");
608 tc_putp(cursor_visible);
609 ptext("If the cursor is not very visible then (cvvis) has failed. ");
611 ptext("(cvvis) Cursor-very-visible is not defined. ");
613 generic_done_message(t, state, ch);
614 tc_putp(cursor_normal);
619 ** charset_cnorm(test_list, status, ch)
621 ** (cnorm) test Cursor normal
630 ptext("(cnorm) Normal cursor. ");
631 tc_putp(cursor_normal);
632 ptext("If the cursor is not normal then (cnorm) has failed. ");
634 ptext("(cnorm) Cursor-normal is not defined. ");
636 generic_done_message(t, state, ch);
640 ** charset_enacs(test_list, status, ch)
642 ** test Alternate character set mode and alternate characters
643 ** (acsc) (enacs) (smacs) (rmacs)
653 if (enter_alt_charset_mode || acs_chars) {
658 for terminals that use separate fonts for
659 attributes (such as X windows) the line
660 drawing characters must be checked for
663 if (c >= '0' && c <= '9') {
664 test_acs(alt_modes[c - '0'].number);
671 ptextln("[r] to repeat, [012345789] to test with attributes on, [?] for a list of attributes, anything else to go to next test. ");
672 generic_done_message(t, state, ch);
676 for (i = 0; i <= 9; i++) {
677 sprintf(temp, " %d %s %s", i, alt_modes[i].begin_mode,
682 if (*ch >= '0' && *ch <= '9') {
690 ptext("(smacs) Enter-alt-char-set-mode and (acsc) Alternate-char-set are not defined. ");
691 generic_done_message(t, state, ch);
696 ** charset_can_test()
698 ** Initialize the can_test data base
701 charset_can_test(void)
705 for (i = 0; i < 9; i++) {
706 can_test(alt_modes[i].begin_mode, FLAG_CAN_TEST);
707 can_test(alt_modes[i].end_mode, FLAG_CAN_TEST);