1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/* termcap - print termcap settings Author: Terrence Holm */
#include <stdlib.h>
#include <termcap.h>
#include <stdio.h>
#define TC_BUFFER 1024 /* Size of termcap(3) buffer */
/****************************************************************/
/* */
/* termcap [ type ] */
/* */
/* Prints out all of the termcap capabilities as described */
/* in termcap(4). If "type" is not supplied then $TERM is */
/* used. */
/* */
/****************************************************************/
int main(int argc, char **argv);
void Print(char *comment, char *name);
void Error(char *message, char *arg);
int main(argc, argv)
int argc;
char *argv[];
{
char *term;
char buffer[ TC_BUFFER ];
/* Check for an argument */
if ( argc > 2 )
Error( "Usage: %s [ type ]\n", argv[0] );
if ( argc == 2 )
term = argv[1];
else
term = getenv( "TERM" );
if ( term == NULL )
Error( "termcap: $TERM is not defined\n", "" );
/* Read in the termcap entry */
if ( tgetent( buffer, term ) != 1 )
Error( "termcap: No termcap entry for %s\n", term );
/* Print out the entry's contents */
printf( "TERM = %s\n\n", term );
if ( tgetflag( "am" ) == 1 )
printf( "End of line wraps to next line (am)\n" );
if ( tgetflag( "bs" ) == 1 )
printf( "Ctrl/H performs a backspace (bs)\n" );
printf( "Number of columns (co) = %d\n", tgetnum( "co" ) );
printf( "Number of lines (li) = %d\n", tgetnum( "li" ) );
Print( "Clear to end of line", "ce" );
Print( "Clear to end of screen", "cd" );
Print( "Clear the whole screen", "cl" );
Print( "Start \"stand out\" mode", "so" );
Print( "End \"stand out\" mode", "se" );
Print( "Start underscore mode", "us" );
Print( "End underscore mode", "ue" );
Print( "Start blinking mode", "mb" );
Print( "Start bold mode", "md" );
Print( "Start reverse mode", "mr" );
Print( "Return to normal mode", "me" );
Print( "Scroll backwards", "sr" );
Print( "Cursor motion", "cm" );
Print( "Up one line", "up" );
Print( "Down one line", "do" );
Print( "Left one space", "le" );
Print( "Right one space", "nd" );
Print( "Move to top left corner", "ho" );
Print( "Generated by \"UP\"", "ku" );
Print( "Generated by \"DOWN\"", "kd" );
Print( "Generated by \"LEFT\"", "kl" );
Print( "Generated by \"RIGHT\"", "kr" );
Print( "Generated by \"HOME\"", "kh" );
Print( "Generated by \"END\"", "@7" );
Print( "Generated by \"PGUP\"", "kP" );
Print( "Generated by \"PGDN\"", "kN" );
Print( "Generated by \"F1\" ", "k1" );
Print( "Generated by numeric \"+\"", "%5" );
Print( "Generated by numeric \"-\"", "%8" );
Print( "Generated by numeric \"5\"", "K2" );
return( 0 );
}
/****************************************************************/
/* */
/* Print( comment, name ) */
/* */
/* If a termcap entry exists for "name", then */
/* print out "comment" and the entry. Control */
/* characters are printed as ^x. */
/* */
/****************************************************************/
void Print( comment, name )
char *comment;
char *name;
{
char entry[ 50 ];
char *p = entry;
if ( tgetstr( name, &p ) == NULL )
return;
printf( "%-32s (%s) = ", comment, name );
for ( p = entry; *p != '\0'; ++p )
if ( *p < ' ' )
printf( "^%c", *p + '@' );
else if ( *p == '\177' )
printf( "^?" );
else
putchar( *p );
putchar( '\n' );
}
/****************************************************************/
/* */
/* Error( message, arg ) */
/* */
/* Printf the "message" and abort. */
/* */
/****************************************************************/
void Error( message, arg )
char *message;
char *arg;
{
fprintf( stderr, message, arg );
exit( 1 );
}
|