1: #include "hd.h"
   2: #include <sgtty.h>
   3: 
   4: /* This module controls tty options.
   5: 
   6:    Tty states are treated as a stack.  Use tty_push and tty_pop.
   7: 
   8:    Push COOKEDMODE and RAWMODE onto the stack.  RAWMODE is now actually
   9:    CBREAK mode.
  10: */
  11: 
  12: struct sgttyb newstty, oldstty;     /* sgtty structures */
  13: int ttysp;              /* Sp for tty stack */
  14: extern short ospeed;            /* Speed for Joy's routines */
  15: 
  16: #define TTYLIM  16
  17: char tty_stack [TTYLIM];        /* The tty stack */
  18: 
  19: /* Initialize tty structures */
  20: 
  21: tty_init () {
  22: 
  23:     gtty (infile, &oldstty); gtty (infile, &newstty);
  24:     oldstty.sg_flags &= ~(CBREAK | RAW);
  25:     newstty.sg_flags |= CBREAK;
  26:     ospeed = oldstty.sg_ospeed;
  27: 
  28:     ttysp = 0;  tty_set (COOKEDMODE);
  29: }
  30: 
  31: /* Push a new tty mode.  Use RAWMODE and COOKEDMODE as parameters. */
  32: 
  33: tty_push (pmode) int pmode; {
  34:     ttysp++;
  35:     if (ttysp >= TTYLIM) {
  36:         putmsg ("Tty stack overflow\n");
  37:         leave ();
  38:     }
  39:     tty_set (pmode);
  40: }
  41: 
  42: tty_pop () {
  43:     ttysp--;
  44:     if (ttysp < 0) {
  45:         putmsg ("Tty stack underflow\n");
  46:         leave ();
  47:     }
  48:     tty_set (tty_stack [ttysp]);
  49: }
  50: 
  51: /* Tty_set sets the tty mode indicated by its parameter.  Stty is only
  52:    executed if a change will result.
  53: */
  54: 
  55: tty_set (pmode) int pmode; {
  56: 
  57:     static int curmode = -1;    /* Current tty mode */
  58: 
  59:     tty_stack [ttysp] = pmode;
  60:     if (pmode == curmode) return;
  61:     curmode = pmode;
  62:     if (pmode == RAWMODE) tty_raw ();
  63:     else tty_cooked ();
  64: }
  65: 
  66: tty_raw () { stty (infile, &newstty); }
  67: 
  68: tty_cooked () { stty (infile, &oldstty); }

Defined functions

tty_cooked defined in line 68; used 2 times
tty_init defined in line 21; used 1 times
tty_raw defined in line 66; used 1 times
  • in line 62
tty_set defined in line 55; used 3 times

Defined variables

newstty defined in line 12; used 3 times
oldstty defined in line 12; used 4 times
tty_stack defined in line 17; used 2 times
ttysp defined in line 13; used 7 times

Defined macros

TTYLIM defined in line 16; used 2 times
Last modified: 1980-08-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 994
Valid CSS Valid XHTML 1.0 Strict