|
|
1.1 root 1: /*
2: * Copyright (c) 1980 The Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: char copyright[] =
20: "@(#) Copyright (c) 1980 The Regents of the University of California.\n\
21: All rights reserved.\n";
22: #endif /* not lint */
23:
24: #ifndef lint
25: static char sccsid[] = "@(#)tc3.c 5.3 (Berkeley) 2/28/89";
26: #endif /* not lint */
27:
28: /*
29: * tc3 [term]
30: * Dummy program to test out termlib. Input two numbers (row and col)
31: * and it prints out the tgoto string generated.
32: */
33: #include <stdio.h>
34: char buf[1024];
35: char *getenv(), *tgetstr();
36: char *rdchar();
37: char *tgoto();
38: char *CM;
39: char cmbuff[30];
40: char *x;
41: char *UP;
42: char *tgout;
43:
44: main(argc, argv) char **argv; {
45: char *p;
46: int rc;
47: int row, col;
48:
49: if (argc < 2)
50: p = getenv("TERM");
51: else
52: p = argv[1];
53: rc = tgetent(buf,p);
54: x = cmbuff;
55: UP = tgetstr("up", &x);
56: printf("UP = %x = ", UP); pr(UP); printf("\n");
57: if (UP && *UP==0)
58: UP = 0;
59: CM = tgetstr("cm", &x);
60: printf("CM = "); pr(CM); printf("\n");
61: for (;;) {
62: if (scanf("%d %d", &row, &col) < 2)
63: exit(0);
64: tgout = tgoto(CM, col, row);
65: pr(tgout);
66: printf("\n");
67: }
68: }
69:
70: pr(p)
71: register char *p;
72: {
73: for (; *p; p++)
74: printf("%s", rdchar(*p));
75: }
76:
77: /*
78: * rdchar() returns a readable representation of an ASCII character
79: * using ^ for control, ' for meta.
80: */
81: #include <ctype.h>
82: char *rdchar(c)
83: char c;
84: {
85: static char ret[4];
86: register char *p = ret;
87:
88: if ((c&0377) > 0177)
89: *p++ = '\'';
90: c &= 0177;
91: if (!isprint(c))
92: *p++ = '^';
93: *p++ = (isprint(c) ? c : c^0100);
94: *p = 0;
95: return (ret);
96: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.