home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 13ansi / ansi_cpr.c next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  824 b   |  41 lines

  1. /*
  2.  *    ansi_cpr -- report where the cursor is located
  3.  *    The position information is placed in the keyboard buffer
  4.  *    in the form ESC[rr;ccR where ESC is the value of the
  5.  *    ESCAPE character (\033) and r and c represent
  6.  *    decimal values of row and column data.
  7.  */
  8.  
  9. #include <local\ansi.h>
  10.  
  11. void
  12. ansi_cpr(row, col)
  13. int    *row,
  14.     *col;
  15. {
  16.     int i;
  17.  
  18.     /* request a cursor position report */
  19.     ANSI_DSR;
  20.  
  21.     /* toss the ESC and '[' */
  22.     (void) getkey();
  23.     (void) getkey();
  24.  
  25.     /* read the row number */
  26.     *row = 10 * (getkey() - '0');
  27.     *row = *row + getkey() - '0';
  28.     
  29.     /* toss the ';' separator */
  30.     (void) getkey();
  31.     
  32.     /* read the column number */
  33.     *col = 10 * (getkey() - '0');
  34.     *col = *col + getkey() - '0';
  35.  
  36.     /* toss the trailing ('R') and return */
  37.     (void) getkey();
  38.     (void) getkey();
  39.     return;
  40. }
  41.