/* shchars.c */ /* compile me: cc -o shchars -lcurses shchars.c */ #include #include #include #include #include static unsigned char stoplist [256]; static void ruler (void); #define Valid(p) ((p)!=NULL && (p)!=(char *)-1 && *(p)) static void ParseArgs (int *pargc, char ***pargv); typedef struct SeqT { const char *name; const char *seq; const char *defval; } SeqT; static SeqT Seq[]= { {"enacs", NULL, "\x1b(B\x1b)0"}, /* G0 := default charset G1 := char-graph charset */ {"smacs", NULL, "\x0e"}, /* SO (Shift Out) i.e. use G1 */ {"rmacs", NULL, "\x0f"}, /* SI (Shift In) i.e. use G0 */ {"acsc", NULL, "``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"} }; static int NSeq= (int)((sizeof Seq)/(sizeof Seq[0])); #define enacs Seq[0].seq #define smacs Seq[1].seq #define rmacs Seq[2].seq #define acsc Seq[3].seq int main (int argc, char **argv) { const char *term; int err, rc, i, j, c, len; ParseArgs (&argc, &argv); term= getenv ("TERM"); if (Valid (term)) { fprintf (stderr, "TERM=%s\n", term); } else { fprintf (stderr, "TERM variable not set, exiting\n"); return 4; } rc= setupterm ((char *)term, 1, &err); if (rc!=OK) { fprintf (stderr, "setupterm(\"%s\") failed err=%d, using defaults\n", term, err); for (i=0; i