122071Sdist /* 236499Sbostic * Copyright (c) 1980 The Regents of the University of California. 336499Sbostic * All rights reserved. 436499Sbostic * 536499Sbostic * Redistribution and use in source and binary forms are permitted 636499Sbostic * provided that the above copyright notice and this paragraph are 736499Sbostic * duplicated in all such forms and that any documentation, 836499Sbostic * advertising materials, and other materials related to such 936499Sbostic * distribution and use acknowledge that the software was developed 1036499Sbostic * by the University of California, Berkeley. The name of the 1136499Sbostic * University may not be used to endorse or promote products derived 1236499Sbostic * from this software without specific prior written permission. 1336499Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1436499Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1536499Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1622071Sdist */ 1722071Sdist 1813299Ssam #ifndef lint 1936499Sbostic char copyright[] = 2036499Sbostic "@(#) Copyright (c) 1980 The Regents of the University of California.\n\ 2136499Sbostic All rights reserved.\n"; 2236499Sbostic #endif /* not lint */ 2313299Ssam 2436499Sbostic #ifndef lint 25*36934Sjak static char sccsid[] = "@(#)tc3.c 5.3 (Berkeley) 02/28/89"; 2636499Sbostic #endif /* not lint */ 2736499Sbostic 2813299Ssam /* 2913299Ssam * tc3 [term] 30*36934Sjak * Dummy program to test out termlib. Input two numbers (row and col) 31*36934Sjak * and it prints out the tgoto string generated. 3213299Ssam */ 3313299Ssam #include <stdio.h> 3413299Ssam char buf[1024]; 3513299Ssam char *getenv(), *tgetstr(); 3613299Ssam char *rdchar(); 3713299Ssam char *tgoto(); 3813299Ssam char *CM; 3913299Ssam char cmbuff[30]; 4013299Ssam char *x; 4113299Ssam char *UP; 4213299Ssam char *tgout; 4313299Ssam 4413299Ssam main(argc, argv) char **argv; { 4513299Ssam char *p; 4613299Ssam int rc; 4713299Ssam int row, col; 4813299Ssam 4913299Ssam if (argc < 2) 5013299Ssam p = getenv("TERM"); 5113299Ssam else 5213299Ssam p = argv[1]; 5313299Ssam rc = tgetent(buf,p); 5413299Ssam x = cmbuff; 5513299Ssam UP = tgetstr("up", &x); 5613299Ssam printf("UP = %x = ", UP); pr(UP); printf("\n"); 5713299Ssam if (UP && *UP==0) 5813299Ssam UP = 0; 5913299Ssam CM = tgetstr("cm", &x); 6013299Ssam printf("CM = "); pr(CM); printf("\n"); 6113299Ssam for (;;) { 6213299Ssam if (scanf("%d %d", &row, &col) < 2) 6313299Ssam exit(0); 64*36934Sjak tgout = tgoto(CM, col, row); 6513299Ssam pr(tgout); 6613299Ssam printf("\n"); 6713299Ssam } 6813299Ssam } 6913299Ssam 7013299Ssam pr(p) 7113299Ssam register char *p; 7213299Ssam { 7313299Ssam for (; *p; p++) 7413299Ssam printf("%s", rdchar(*p)); 7513299Ssam } 7613299Ssam 7713299Ssam /* 78*36934Sjak * rdchar() returns a readable representation of an ASCII character 79*36934Sjak * using ^ for control, ' for meta. 8013299Ssam */ 8113299Ssam #include <ctype.h> 8213299Ssam char *rdchar(c) 8313299Ssam char c; 8413299Ssam { 8513299Ssam static char ret[4]; 86*36934Sjak register char *p = ret; 8713299Ssam 88*36934Sjak if ((c&0377) > 0177) 89*36934Sjak *p++ = '\''; 9013299Ssam c &= 0177; 91*36934Sjak if (!isprint(c)) 92*36934Sjak *p++ = '^'; 93*36934Sjak *p++ = (isprint(c) ? c : c^0100); 94*36934Sjak *p = 0; 95*36934Sjak return (ret); 9613299Ssam } 97