1 /* termcap - print termcap settings Author: Terrence Holm */
7 #define TC_BUFFER 1024 /* Size of termcap(3) buffer */
9 /****************************************************************/
11 /* termcap [ type ] */
13 /* Prints out all of the termcap capabilities as described */
14 /* in termcap(4). If "type" is not supplied then $TERM is */
17 /****************************************************************/
19 int main(int argc
, char **argv
);
20 void Print(char *comment
, char *name
);
21 void Error(char *message
, char *arg
);
29 char buffer
[ TC_BUFFER
];
32 /* Check for an argument */
35 Error( "Usage: %s [ type ]\n", argv
[0] );
40 term
= getenv( "TERM" );
43 Error( "termcap: $TERM is not defined\n", "" );
46 /* Read in the termcap entry */
48 if ( tgetent( buffer
, term
) != 1 )
49 Error( "termcap: No termcap entry for %s\n", term
);
52 /* Print out the entry's contents */
54 printf( "TERM = %s\n\n", term
);
56 if ( tgetflag( "am" ) == 1 )
57 printf( "End of line wraps to next line (am)\n" );
59 if ( tgetflag( "bs" ) == 1 )
60 printf( "Ctrl/H performs a backspace (bs)\n" );
62 printf( "Number of columns (co) = %d\n", tgetnum( "co" ) );
63 printf( "Number of lines (li) = %d\n", tgetnum( "li" ) );
65 Print( "Clear to end of line", "ce" );
66 Print( "Clear to end of screen", "cd" );
67 Print( "Clear the whole screen", "cl" );
69 Print( "Start \"stand out\" mode", "so" );
70 Print( "End \"stand out\" mode", "se" );
71 Print( "Start underscore mode", "us" );
72 Print( "End underscore mode", "ue" );
73 Print( "Start blinking mode", "mb" );
74 Print( "Start bold mode", "md" );
75 Print( "Start reverse mode", "mr" );
76 Print( "Return to normal mode", "me" );
78 Print( "Scroll backwards", "sr" );
79 Print( "Cursor motion", "cm" );
81 Print( "Up one line", "up" );
82 Print( "Down one line", "do" );
83 Print( "Left one space", "le" );
84 Print( "Right one space", "nd" );
85 Print( "Move to top left corner", "ho" );
87 Print( "Generated by \"UP\"", "ku" );
88 Print( "Generated by \"DOWN\"", "kd" );
89 Print( "Generated by \"LEFT\"", "kl" );
90 Print( "Generated by \"RIGHT\"", "kr" );
91 Print( "Generated by \"HOME\"", "kh" );
92 Print( "Generated by \"END\"", "@7" );
93 Print( "Generated by \"PGUP\"", "kP" );
94 Print( "Generated by \"PGDN\"", "kN" );
95 Print( "Generated by \"F1\" ", "k1" );
96 Print( "Generated by numeric \"+\"", "%5" );
97 Print( "Generated by numeric \"-\"", "%8" );
98 Print( "Generated by numeric \"5\"", "K2" );
108 /****************************************************************/
110 /* Print( comment, name ) */
112 /* If a termcap entry exists for "name", then */
113 /* print out "comment" and the entry. Control */
114 /* characters are printed as ^x. */
116 /****************************************************************/
119 void Print( comment
, name
)
127 if ( tgetstr( name
, &p
) == NULL
)
130 printf( "%-32s (%s) = ", comment
, name
);
132 for ( p
= entry
; *p
!= '\0'; ++p
)
134 printf( "^%c", *p
+ '@' );
135 else if ( *p
== '\177' )
148 /****************************************************************/
150 /* Error( message, arg ) */
152 /* Printf the "message" and abort. */
154 /****************************************************************/
157 void Error( message
, arg
)
162 fprintf( stderr
, message
, arg
);