1*47926Sbostic /*- 2*47926Sbostic * Copyright (c) 1983 The Regents of the University of California. 336499Sbostic * All rights reserved. 436499Sbostic * 5*47926Sbostic * %sccs.include.redist.c% 622071Sdist */ 722071Sdist 813299Ssam #ifndef lint 936499Sbostic char copyright[] = 10*47926Sbostic "@(#) Copyright (c) 1983 The Regents of the University of California.\n\ 1136499Sbostic All rights reserved.\n"; 1236499Sbostic #endif /* not lint */ 1313299Ssam 1436499Sbostic #ifndef lint 15*47926Sbostic static char sccsid[] = "@(#)tc3.c 5.4 (Berkeley) 04/12/91"; 1636499Sbostic #endif /* not lint */ 1736499Sbostic 1813299Ssam /* 1913299Ssam * tc3 [term] 2036934Sjak * Dummy program to test out termlib. Input two numbers (row and col) 2136934Sjak * and it prints out the tgoto string generated. 2213299Ssam */ 2313299Ssam #include <stdio.h> 2413299Ssam char buf[1024]; 2513299Ssam char *getenv(), *tgetstr(); 2613299Ssam char *rdchar(); 2713299Ssam char *tgoto(); 2813299Ssam char *CM; 2913299Ssam char cmbuff[30]; 3013299Ssam char *x; 3113299Ssam char *UP; 3213299Ssam char *tgout; 3313299Ssam 3413299Ssam main(argc, argv) char **argv; { 3513299Ssam char *p; 3613299Ssam int rc; 3713299Ssam int row, col; 3813299Ssam 3913299Ssam if (argc < 2) 4013299Ssam p = getenv("TERM"); 4113299Ssam else 4213299Ssam p = argv[1]; 4313299Ssam rc = tgetent(buf,p); 4413299Ssam x = cmbuff; 4513299Ssam UP = tgetstr("up", &x); 4613299Ssam printf("UP = %x = ", UP); pr(UP); printf("\n"); 4713299Ssam if (UP && *UP==0) 4813299Ssam UP = 0; 4913299Ssam CM = tgetstr("cm", &x); 5013299Ssam printf("CM = "); pr(CM); printf("\n"); 5113299Ssam for (;;) { 5213299Ssam if (scanf("%d %d", &row, &col) < 2) 5313299Ssam exit(0); 5436934Sjak tgout = tgoto(CM, col, row); 5513299Ssam pr(tgout); 5613299Ssam printf("\n"); 5713299Ssam } 5813299Ssam } 5913299Ssam 6013299Ssam pr(p) 6113299Ssam register char *p; 6213299Ssam { 6313299Ssam for (; *p; p++) 6413299Ssam printf("%s", rdchar(*p)); 6513299Ssam } 6613299Ssam 6713299Ssam /* 6836934Sjak * rdchar() returns a readable representation of an ASCII character 6936934Sjak * using ^ for control, ' for meta. 7013299Ssam */ 7113299Ssam #include <ctype.h> 7213299Ssam char *rdchar(c) 7313299Ssam char c; 7413299Ssam { 7513299Ssam static char ret[4]; 7636934Sjak register char *p = ret; 7713299Ssam 7836934Sjak if ((c&0377) > 0177) 7936934Sjak *p++ = '\''; 8013299Ssam c &= 0177; 8136934Sjak if (!isprint(c)) 8236934Sjak *p++ = '^'; 8336934Sjak *p++ = (isprint(c) ? c : c^0100); 8436934Sjak *p = 0; 8536934Sjak return (ret); 8613299Ssam } 87