1: #
   2: #include "hd.h"
   3: /*  Display and cursor control routines */
   4: 
   5: #define BELL    07
   6: 
   7: int putch ();
   8: extern char *CM, *CL, *UP, *tgoto ();       /* Joy's cursor stuff */
   9: 
  10: /*  Position cursor at the given (x, y) location.  Origin is
  11:     lower left hand side.  */
  12: 
  13: atxy (x, y)  int x, y;  {
  14: 
  15: tputs (tgoto (CM, x, 23 - y), 0, putch);
  16: 
  17: }
  18: 
  19: /*  This subroutine takes one parameter.
  20:     Position cursor at line ab from top at character cd.
  21:     At (101) positions cursor at top left;
  22:     At (2480) positions cursor at lower right.  */
  23: 
  24: at (abcd)  int abcd;  {
  25: 
  26:     int ab, cd;
  27:     ab = abcd / 100;  cd = abcd - (ab * 100);
  28:     atxy (cd - 1, 24 - ab);
  29: }
  30: 
  31: erase () {
  32:     tputs (CL, 0, putch);
  33:     putch (CR);
  34: }
  35: 
  36: /* erase chars on current line */
  37: clearline () {
  38: bufout ();
  39: printf ("%c%80s%s", CR, "", UP);
  40: unbufout ();
  41: }
  42: 
  43: /* Position cursor at specified file */
  44: atfile (file, col) int file, col; {
  45: 
  46: atxy (col, 21 - file);
  47: }
  48: 
  49: /* buffering subroutines */
  50: 
  51: char outbuf [BUFSIZ];       /* the buffer */
  52: int bcount = 0;         /* can buffer only once */
  53:                 /* additional attempts ignored */
  54: 
  55: bufout () {
  56: 
  57: if (bcount++ == 0) setbuf (stdout, outbuf);
  58: }
  59: 
  60: unbufout () {
  61: 
  62: fflush (stdout);
  63: if (--bcount == 0) setbuf (stdout, CNULL);
  64: }
  65: 
  66: /* Clear message lines (23-24) for a pcount line message */
  67: /* Lastcount keeps track of the lines with characters on them */
  68: /* Dispdir calls with parameter -1 to reset lastcount */
  69: 
  70: clearmsg (pcount) int pcount; {
  71: 
  72: static int lastcount;
  73: 
  74: at (2301);
  75: if (pcount == -1) lastcount = 0;
  76: else {
  77:     if (lastcount == 0);
  78:     else if (lastcount == 1) {
  79:         clearline ();
  80:     } else {
  81:         bufout ();
  82:         printf ("%159s", "");  unbufout ();
  83:     }
  84:     lastcount = pcount;
  85: }
  86: at (2301);
  87: }
  88: 
  89: /* Putmsg counts the number of lines in its parameter,
  90:    calls clearmsg with that count, and then displays the message.  */
  91: 
  92: putmsg (msg) char * msg; {
  93: 
  94:     extern char * index ();
  95: 
  96:     clearmsg (index (msg, LF) == NULL ? 1 : 2);
  97:     printf ("   %s", msg);
  98: }
  99: 
 100: /* Beep bell on terminal */
 101: beep () {
 102:     putch (BELL);
 103: }
 104: 
 105: /* Print error message about a file */
 106: myperror (parm) char * parm; {
 107: 
 108:     extern int errno, sys_nerr;
 109:     extern char *sys_errlist[];
 110:     register char *c;
 111: 
 112:     c = "Unknown error";
 113:     if(errno < sys_nerr)
 114:         c = sys_errlist[errno];
 115:     clearmsg (1);
 116:     printf ("  %s: %s", parm, c);
 117: }

Defined functions

atfile defined in line 44; used 5 times
atxy defined in line 13; used 2 times
beep defined in line 101; used 2 times
clearline defined in line 37; used 2 times

Defined variables

bcount defined in line 52; used 2 times
outbuf defined in line 51; used 1 times
  • in line 57

Defined macros

BELL defined in line 5; used 1 times
Last modified: 1980-08-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 889
Valid CSS Valid XHTML 1.0 Strict