How do you ask a terminal what it is?

Jim Walker jwwalker at opusc.csd.scarolina.edu
Sun Jan 20 15:24:02 AEST 1991


I'm a UNIX novice, though not a programming novice, and I'm
trying to figure out how a program can determine whether a DEC
terminal is capable of ReGIS graphics.  I don't know of any way
to do that with standard Unix functions like stty.  So I tried to
write a program that would ask the terminal what it is.  It
almost works.  Here's what I tried:

  #include "stdio.h"
  
    main ()
  {
    int c;
  
    fputs("\033[c", stdout);
    c = getchar();
    while ((c != EOF) && (c != 'c'))
      {
        if (c != '\033')
          putchar(c);
        printf( " = %d, ", c );
        c = getchar();
      }
    putchar('\n');
    fflush(stdout);
  }

What happens is that the terminal echos the response, something
like ^[[?1;2c, and the cursor just sits there at the end of the
line.  If I then hit Return, the program proceeds and produces
the expected output.  Any expanations or alternatives?
-- 
  -- Jim Walker 76367.2271 at compuserve.com



More information about the Comp.unix.programmer mailing list