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., 51 Franklin Street, Fifth Floor,
19 ** Boston, MA 02110-1301, USA
24 MODULE_ID("$Id: crum.c,v 1.5 2006/11/26 00:15:02 tom Exp $")
27 * Test cursor movement.
30 static void crum_clear(struct test_list *t, int *state, int *ch);
31 static void crum_home(struct test_list *t, int *state, int *ch);
32 static void crum_ll(struct test_list *t, int *state, int *ch);
33 static void crum_move(struct test_list *t, int *state, int *ch);
34 static void crum_os(struct test_list *t, int *state, int *ch);
36 static char crum_text[5][80];
38 struct test_list crum_test_list[] = {
39 {0, 0, 0, 0, "e) edit terminfo", 0, &edit_menu},
40 {MENU_NEXT, 0, "clear", 0, 0, crum_clear, 0},
41 {MENU_NEXT, 0, "home", 0, 0, crum_home, 0},
42 {MENU_NEXT, 0, "ll", 0, 0, crum_ll, 0},
43 {MENU_NEXT, 0, crum_text[0], "home cuu1", 0, crum_move, 0},
44 {MENU_NEXT + 1, 0, crum_text[1], "cub1 cud1 cuf1 cuu1", 0, crum_move, 0},
45 {MENU_NEXT + 2, 0, crum_text[2], "cub cud cuf cuu", 0, crum_move, 0},
46 {MENU_NEXT + 3, 0, crum_text[3], "vpa hpa", 0, crum_move, 0},
47 {MENU_NEXT + 4, 0, crum_text[4], "cup", 0, crum_move, 0},
48 {MENU_NEXT, 0, "cup", "os", 0, crum_os, 0},
49 {MENU_LAST, 0, 0, 0, 0, 0, 0}
53 ** move_to(from-row, from-column, to-row, to-column, selection)
55 ** move the cursor from (rf, cf) to (rt, ct) using sel
67 if (sel & 16) { /* use (cup) */
68 s = TPARM_2(cursor_address, rt, ct);
69 tputs(s, lines, tc_putch);
72 if (sel & 8) { /* use (hpa) (vpa) */
74 s = TPARM_1(column_address, ct);
75 tputs(s, 1, tc_putch);
79 s = TPARM_1(row_address, rt);
80 tputs(s, 1, tc_putch);
84 if (sel & 4) { /* parameterized relative cursor movement */
85 if (parm_right_cursor)
87 s = TPARM_1(parm_right_cursor, ct - cf);
88 tputs(s, ct - cf, tc_putch);
93 s = TPARM_1(parm_left_cursor, cf - ct);
94 tputs(s, cf - ct, tc_putch);
99 s = TPARM_1(parm_down_cursor, rt - rf);
100 tputs(s, rt - rf, tc_putch);
105 s = TPARM_1(parm_up_cursor, rf - rt);
106 tputs(s, rf - rt, tc_putch);
113 tc_putp(cursor_left);
117 do vertical motion next. Just in case cursor_down has a
118 side effect of changing the column. This could happen if
119 the tty handler translates NL to CRNL.
123 tc_putp(cursor_down);
133 tc_putp(cursor_right);
139 if (can_go_home) { /* a bit drastic but ... */
143 } else if (cursor_up) {
150 if (ct == 0 && rt > rf) {
155 if (ct == 0 && cf != 0) {
169 tc_putp(cursor_right);
173 /* go ahead and trash my display */
182 ** display_it(selection, text)
184 ** print the display using sel
196 ptextln(" The top line should be alternating <'s and >'s");
197 ptextln(" The left side should be alternating A's and V's");
203 move_to(done_line = line_count, 0, 0, 2, sel);
204 for (i = 4; i < columns - 2; i += 2) {
206 move_to(0, i - 1, 0, i, sel);
210 move_to(0, i + 1, 0, i - 1, sel);
211 for (; i > 2; i -= 2) {
213 move_to(0, i, 0, i - 3, sel);
218 move_to(0, 2, 0, 0, sel);
219 for (i = 2; i < lines - 1; i += 2) {
221 move_to(i - 2, 1, i, 0, sel);
225 move_to(i, 1, i + 1, 0, sel);
226 for (; i > 0; i -= 2) {
228 move_to(i + 1, 1, i - 1, 0, sel);
231 move_to(i + 1, 1, 0, 0, sel); /* go home first */
232 move_to(0, 0, done_line + 1, 3, sel);
238 ** crum_clear(test_list, status, ch)
240 ** (clear) test Clear screen
251 for (i = lines; i > 1; i--) {
255 ptextln("This line should start in the home position.");
256 ptext("The rest of the screen should be clear. ");
258 ptextln("(clear) Clear screen is not defined. ");
260 generic_done_message(t, state, ch);
264 ** crum_home(test_list, status, ch)
266 ** (home) test Home cursor
276 put_newlines(lines / 2);
279 ptext("The bottom line should have text.");
281 put_newlines(lines - 1);
282 ptext("This line is on the bottom.");
284 ptextln("This line starts in the home position.");
287 ptextln("(home) Home cursor is not defined. ");
289 generic_done_message(t, state, ch);
293 ** crum_ll(test_list, status, ch)
295 ** (ll) test Last line
304 (ll) may be simulated with (cup). Don't complain if (cup) is present.
308 put_str("This line could be anywhere.");
309 tc_putp(cursor_to_ll);
310 ptext("This line should be on the bottom");
314 if (cursor_address) {
317 ptextln("(ll) Move to last line is not defined. ");
319 generic_done_message(t, state, ch);
323 ** crum_move(test_list, status, ch)
325 ** (*) test all cursor move commands
336 switch (n = (t->flags & 15)) {
338 sprintf(buf, " (cr) (nel) (cub1)%s",
339 cursor_home ? " (home)" : (cursor_up ? " (cuu1)" : ""));
342 sprintf(buf, "%s%s%s%s", cursor_left ? " (cub1)" : "",
343 cursor_down ? " (cud1)" : "", cursor_right ? " (cuf1)" : "",
344 cursor_up ? " (cuu1)" : "");
345 if (buf[0] == '\0') {
346 ptext(" (cub1) (cud1) (cuf1) (cuu1) not defined.");
350 sprintf(buf, "%s%s%s%s", parm_left_cursor ? " (cub)" : "",
351 parm_down_cursor ? " (cud)" : "",
352 parm_right_cursor ? " (cuf)" : "",
353 parm_up_cursor ? " (cuu)" : "");
354 if (buf[0] == '\0') {
355 ptext(" (cub) (cud) (cuf) (cuu) not defined.");
359 sprintf(buf, "%s%s", row_address ? " (vpa)" : "",
360 column_address ? " (hpa)" : "");
361 if (buf[0] == '\0') {
362 ptext(" (vpa) (hpa) not defined.");
366 if (!cursor_address) {
367 ptext(" (cup) not defined. ");
368 generic_done_message(t, state, ch);
371 strcpy(buf, " (cup)");
374 if (buf[0] == '\0') {
377 can_test(buf, FLAG_TESTED);
378 strcpy(crum_text[n], &buf[2]);
379 crum_text[n][strlen(buf) - 3] = '\0';
381 display_it(1 << n, buf);
390 ** crum_os(test_list, status, ch)
392 ** (cup) test Cursor position on overstrike terminals
402 if (cursor_address && over_strike) {
404 for (i = 0; i < columns - 2; i++) {
407 for (i = 1; i < lines - 2; i++) {
411 for (i = 0; i < columns - 2; i++) {
412 tputs(TPARM_2(cursor_address, 0, i), lines, tc_putch);
415 for (i = 0; i < lines - 2; i++) {
416 tputs(TPARM_2(cursor_address, i, 0), lines, tc_putch);
422 ptext(" All the characters should look the same. ");
423 generic_done_message(t, state, ch);