home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / mg2a_dos.sha / ttyio.c < prev    next >
C/C++ Source or Header  |  1989-03-17  |  2KB  |  110 lines

  1. /*
  2.  * Name:    Mg 2b
  3.  *        MSDOS terminal I/O (TurboC 1.5)
  4.  *
  5.  * The functions in this file
  6.  * negotiate with the operating system for
  7.  * keyboard characters, and write characters to
  8.  * the display
  9.  *
  10.  * This version goes along with tty/ibmbios/tty.c.
  11.  * Terminal size is determined there, rather than here.
  12.  */
  13. #include    "def.h"
  14.  
  15. #include    <stdio.h>
  16. #include    <fcntl.h>
  17. #include    <signal.h>
  18.  
  19. static int ttyactivep = FALSE;        /* terminal in editor mode?    */
  20.  
  21. int    nrow;                /* Terminal size, rows.        */
  22. int    ncol;                /* Terminal size, columns.    */
  23.  
  24. /*
  25.  * This function gets called once, to set up
  26.  * the terminal channel.  This is essentially a no-op
  27.  * on msdos, since I/O will all be done via bios calls.
  28.  */
  29. ttopen()
  30. {
  31.     if (ttyactivep)
  32.         return;
  33.  
  34.     signal(SIGINT, SIG_IGN);
  35.  
  36.     nrow = 25;            /* initial guess */
  37.     ncol = 80;
  38.  
  39.     ttyactivep = TRUE;
  40. }
  41.  
  42. /*
  43.  * This function gets called just
  44.  * before we go back home to the shell. Another
  45.  * MSDOS no_op.
  46.  */
  47. ttclose()
  48. {
  49.     if(!ttyactivep)
  50.         return;
  51.     ttyactivep = FALSE;
  52. }
  53.  
  54. /********************************************************************/
  55. /* ttputc, ttgetc & typeahead have been deleted from this file, and */
  56. /* moved into the tty specific code.  There is no operating-system  */
  57. /* generic way to do these                                          */
  58. /********************************************************************/
  59.  
  60. /*
  61.  * Flush output.  This function is a no-op
  62.  */
  63. ttflush()
  64. {
  65. }
  66.  
  67. /*
  68.  * panic:  print error and die, leaving core file.
  69.  */
  70. panic(s)
  71. char *s;
  72. {
  73.     fprintf(stderr, "%s\r\n", s);
  74. #ifdef SYSCLEANUP
  75.     SYSCLEANUP;
  76. #endif
  77.     exit(1);
  78. }
  79.  
  80.  
  81. /*
  82. ** This should check the size of the window, and reset if needed.
  83. */
  84.  
  85. setttysize()
  86. {
  87.     nrow = 25;
  88.     ncol = 80;
  89. }
  90.  
  91.  
  92. void interrupt donothing()
  93.     {
  94.     return;    /* continue program */
  95.     }
  96.  
  97. /* Turbo C does not have a "signal" function. */
  98. /* since all I need to use it for is to ignore ^C, this substitute works ok */
  99. signal(sig, action)
  100. int sig;
  101. int (*action)();
  102.     {
  103.     if (sig != SIGINT || action != SIG_IGN)
  104.     {
  105.     printf("Runtime error in signal: only SIGINT, SIG_IGN supported!\n");
  106.     exit(1);
  107.     }
  108.     setvect(0x23, donothing);
  109.     }
  110.