home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume4 / snapshot / wy50.c < prev   
Encoding:
C/C++ Source or Header  |  1989-02-03  |  1.2 KB  |  63 lines

  1. /*
  2.  * wy50.c
  3.  */
  4.  
  5. #include <stdio.h>
  6.  
  7. /* Define as 1 to restore original cursor position at end. */
  8. #define RESTORE_POS 0
  9.  
  10. /* Row and column to return to when finished. */
  11. static int saver,
  12.         savec;
  13.  
  14. /*
  15.  * Save the initial cursor position.
  16.  */
  17. wy50_savepos()
  18. {
  19. #if RESTORE_POS
  20.     /* Transmit "send the cursor address" code. */
  21.     printf("\033?");
  22.     if (fflush(stdout) == EOF) {
  23.     fprintf(stderr, "Transmission error\n");
  24.     (void) cleanup();
  25.     return -1;
  26.     }
  27.     saver = getchar();
  28.     savec = getchar();
  29.     /* Discard CR. */
  30.     (void) getchar();
  31. #else
  32.     /* Place cursor on bottom line (row) for neatness. */
  33.     saver = 24 + 31;
  34.     savec = 1 + 31;
  35. #endif
  36. }
  37.  
  38. /*
  39.  * Restore the initial cursor position.
  40.  */
  41. wy50_restorepos()
  42. {
  43.     printf("\033=%c%c", saver, savec);
  44. }
  45.  
  46. /*
  47.  * Tell the terminal to transmit a line.
  48.  */
  49. wy50_transline(line)
  50.     int     line;
  51. {
  52.     /* Locate cursor at end of next line (row n, column 80). */
  53.     printf("\033=%c%c", line + 31, 80 + 31);
  54.     /*
  55.      * Send "transmit line" code.  This will send the whole line, padding to
  56.      * 80 columns with spaces.  Due to graphics and special mode codes, which
  57.      * will be sent as well, it could end up being well over 80 characters
  58.      * long. 
  59.      */
  60.     printf("\033");
  61.     printf("6");
  62. }
  63.