2 ** Copyright (C) 1991, 1997-2000 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.8 2001/06/18 18:44:26 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 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 #ifdef max_attributes
289 if (max_attributes >= 0) {
290 sprintf(temp, "(ma) Maximum attributes %d ", max_attributes);
294 generic_done_message(t, state, ch);
298 ** test_one_attr(mode-number, begin-string, end-string)
300 ** Display one attribute line.
310 sprintf(temp, "%-10s %s ", alt_modes[n].name, alt_modes[n].begin_mode);
312 for (; char_count < 19;) {
317 put_mode(begin_mode);
318 put_str(alt_modes[n].name);
319 for (i = strlen(alt_modes[n].name); i < 13; i++) {
324 sprintf(temp, ". %s", alt_modes[n].end_mode);
327 strcpy(temp, ". (sgr)");
331 for (i = 0; i < magic_cookie_glitch; i++)
333 put_str("*** missing ***");
334 for (i = 0; i < magic_cookie_glitch; i++)
341 ** charset_attributes(test_list, status, ch)
351 putln("Test video attributes");
352 test_one_attr(1, enter_standout_mode, exit_standout_mode);
353 test_one_attr(2, enter_underline_mode, exit_underline_mode);
354 test_one_attr(9, enter_alt_charset_mode, exit_alt_charset_mode);
355 if (!exit_attribute_mode && !set_attributes) {
356 ptextln("(sgr0) exit attribute mode is not defined.");
357 generic_done_message(t, state, ch);
360 test_one_attr(3, enter_reverse_mode, exit_attribute_mode);
361 test_one_attr(4, enter_blink_mode, exit_attribute_mode);
362 test_one_attr(5, enter_dim_mode, exit_attribute_mode);
363 test_one_attr(6, enter_bold_mode, exit_attribute_mode);
364 test_one_attr(7, enter_secure_mode, exit_attribute_mode);
365 test_one_attr(8, enter_protected_mode, exit_attribute_mode);
366 generic_done_message(t, state, ch);
372 ** charset_smacs(test_list, status, ch)
374 ** display all possible acs characters
385 if (enter_alt_charset_mode) {
387 ptextln("The following characters are available. (smacs) (rmacs)");
388 for (i = ' '; i <= '`'; i += 32) {
390 put_mode(exit_alt_charset_mode);
391 for (c = 0; c < 32; c++) {
395 put_mode(enter_alt_charset_mode);
396 for (c = 0; c < 32; c++) {
399 put_mode(exit_alt_charset_mode);
402 put_mode(exit_alt_charset_mode);
404 generic_done_message(t, state, ch);
412 { /* alternate character set */
414 char valid_glyph[GLYPHS];
415 char acs_table[GLYPHS];
416 static unsigned char vt100[] = "`afgjklmnopqrstuvwxyz{|}~";
419 for (i = 0; i < GLYPHS; i++) {
420 valid_glyph[i] = FALSE;
424 sprintf(temp, "Alternate character set map: %s",
427 for (i = 0; acs_chars[i]; i += 2) {
428 if (acs_chars[i + 1] == 0) {
432 if (glyph[j].c == (unsigned char) acs_chars[i]) {
433 acs_table[glyph[j].c] = acs_chars[i + 1];
434 valid_glyph[glyph[j].c] = TRUE;
437 if (glyph[j].name[0] == '\0') {
438 if (isgraph(UChar(acs_chars[i]))) {
442 sprintf(temp, " 0x%02x",
443 UChar(acs_chars[i]));
445 strcpy(&temp[5], " *** has no mapping ***");
452 ptextln("acs_chars not defined (acsc)");
453 /* enable the VT-100 graphics characters (default) */
454 for (i = 0; vt100[i]; i++) {
455 valid_glyph[vt100[i]] = TRUE;
461 _nc_init_acs(); /* puts 'ena_acs' and incidentally links acs_map[] */
462 for (i = 0; glyph[i].name[0]; i++) {
463 if (valid_glyph[glyph[i].c]) {
464 put_mode(enter_alt_charset_mode);
465 put_this(acs_table[glyph[i].c]);
467 put_mode(exit_alt_charset_mode);
468 if (magic_cookie_glitch >= 1) {
469 sprintf(temp, " %-30.30s", glyph[i].name);
471 if (char_count + 33 >= columns)
474 sprintf(temp, " %-24.24s", glyph[i].name);
476 if (char_count + 26 >= columns)
479 if (line_count >= lines) {
485 if (char_count > 1) {
490 put_mode(enter_alt_charset_mode);
491 put_this(ACS_ULCORNER);
493 put_this(ACS_URCORNER);
494 put_this(ACS_ULCORNER);
496 put_this(ACS_URCORNER);
498 put_mode(exit_alt_charset_mode);
500 put_mode(enter_alt_charset_mode);
505 if (magic_cookie_glitch >= 1)
508 put_mode(exit_alt_charset_mode);
510 put_mode(enter_alt_charset_mode);
514 put_mode(exit_alt_charset_mode);
515 put_str(" Here are 2 boxes");
517 put_mode(enter_alt_charset_mode);
518 put_this(ACS_LLCORNER);
520 put_this(ACS_LRCORNER);
521 put_this(ACS_LLCORNER);
523 put_this(ACS_LRCORNER);
525 put_mode(exit_alt_charset_mode);
531 ** charset_bel(test_list, status, ch)
542 ptextln("Testing bell (bel)");
544 ptext("If you did not hear the Bell then (bel) has failed. ");
546 ptext("(bel) Bell is not defined. ");
548 generic_done_message(t, state, ch);
552 ** charset_flash(test_list, status, ch)
554 ** (flash) test Visual bell
563 ptextln("Testing visual bell (flash)");
564 tc_putp(flash_screen);
565 ptext("If you did not see the screen flash then (flash) has failed. ");
567 ptext("(flash) Flash is not defined. ");
569 generic_done_message(t, state, ch);
573 ** charset_civis(test_list, status, ch)
575 ** (civis) test Cursor invisible
584 if (cursor_invisible) {
585 ptext("(civis) Turn off the cursor. ");
586 tc_putp(cursor_invisible);
587 ptext("If you can still see the cursor then (civis) has failed. ");
589 ptext("(civis) Cursor-invisible is not defined. ");
591 generic_done_message(t, state, ch);
592 tc_putp(cursor_normal);
597 ** charset_cvvis(test_list, status, ch)
599 ** (cvvis) test Cursor very visible
608 if (cursor_visible) {
609 ptext("(cvvis) Make cursor very visible. ");
610 tc_putp(cursor_visible);
611 ptext("If the cursor is not very visible then (cvvis) has failed. ");
613 ptext("(cvvis) Cursor-very-visible is not defined. ");
615 generic_done_message(t, state, ch);
616 tc_putp(cursor_normal);
621 ** charset_cnorm(test_list, status, ch)
623 ** (cnorm) test Cursor normal
632 ptext("(cnorm) Normal cursor. ");
633 tc_putp(cursor_normal);
634 ptext("If the cursor is not normal then (cnorm) has failed. ");
636 ptext("(cnorm) Cursor-normal is not defined. ");
638 generic_done_message(t, state, ch);
642 ** charset_enacs(test_list, status, ch)
644 ** test Alternate character set mode and alternate characters
645 ** (acsc) (enacs) (smacs) (rmacs)
655 if (enter_alt_charset_mode || acs_chars) {
660 for terminals that use separate fonts for
661 attributes (such as X windows) the line
662 drawing characters must be checked for
665 if (c >= '0' && c <= '9') {
666 test_acs(alt_modes[c - '0'].number);
673 ptextln("[r] to repeat, [012345789] to test with attributes on, [?] for a list of attributes, anything else to go to next test. ");
674 generic_done_message(t, state, ch);
678 for (i = 0; i <= 9; i++) {
679 sprintf(temp, " %d %s %s", i, alt_modes[i].begin_mode,
684 if (*ch >= '0' && *ch <= '9') {
692 ptext("(smacs) Enter-alt-char-set-mode and (acsc) Alternate-char-set are not defined. ");
693 generic_done_message(t, state, ch);
698 ** charset_can_test()
700 ** Initialize the can_test data base
703 charset_can_test(void)
707 for (i = 0; i < 9; i++) {
708 can_test(alt_modes[i].begin_mode, FLAG_CAN_TEST);
709 can_test(alt_modes[i].end_mode, FLAG_CAN_TEST);