1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
   2: static char rcsid[] = "$Header: help.c,v 2.6 85/08/22 16:03:38 timo Exp $";
   3: 
   4: /*
   5:  * B editor -- Print help blurb.
   6:  */
   7: 
   8: #include "feat.h"
   9: 
  10: #ifdef HELPFUL
  11: 
  12: #include "unix.h"
  13: 
  14: #ifdef IBMPC
  15: #define getchar() getch()
  16: #endif IBMPC
  17: 
  18: #ifdef SIGNAL
  19: #include <signal.h>
  20: #endif SIGNAL
  21: 
  22: #ifdef SGTTY_H
  23: #include <sgtty.h>
  24: #endif SGTTY_H
  25: 
  26: #include "b.h"
  27: 
  28: string unixerror();
  29: 
  30: #ifndef HELPBLURB
  31: #define HELPBLURB "/usr/new/lib/B/Bed_help"
  32: #endif
  33: 
  34: #define SOBIT 0200
  35: 
  36: extern int winheight;
  37: extern int llength;
  38: extern int winstart;
  39: 
  40: 
  41: /*
  42:  * Interrupt catcher while printing message.
  43:  */
  44: 
  45: Hidden int intr;
  46: 
  47: #ifdef SIGNAL
  48: Hidden Procedure
  49: stop()
  50: {
  51:     intr = Yes;
  52:     signal(SIGINT, stop);
  53: }
  54: #endif SIGNAL
  55: 
  56: 
  57: /*
  58:  * Print help blurb.
  59:  * This is done through the standard screen interface.
  60:  * An interrupt during the printing only stops the printing.
  61:  * The user must type [return] to continue.
  62:  */
  63: 
  64: Visible bool
  65: help()
  66: {
  67:     FILE *fp;
  68:     string helpblurb;
  69:     char buffer[81];
  70:     int len = sizeof buffer;
  71:     string cp;
  72: #ifdef SIGNAL
  73:     int (*prevsig)();
  74: #endif SIGNAL
  75: #ifdef SGTTY_H
  76:     struct sgttyb tty;
  77: #endif SGTTY_H
  78:     int c;
  79: 
  80:     helpblurb = getenv("BED_HELP");
  81:     if (!helpblurb || !helpblurb[0])
  82:         helpblurb = HELPBLURB;
  83:     fp = fopen(helpblurb, "r");
  84:     if (!fp) {
  85:         error("Sorry, I can't help [%s]", unixerror(helpblurb));
  86:         return No;
  87:     }
  88: #ifdef SIGNAL
  89:     intr = No;
  90:     prevsig = signal(SIGINT, stop);
  91: #endif SIGNAL
  92:     if (llength < (sizeof buffer)-1)
  93:         len = llength+1;
  94:     while (!intr && fgets(buffer, len, fp)) {
  95:         cp = index(buffer, '\n');
  96:         if (cp)
  97:             *cp = '\0';
  98:         trmputdata(winheight, winheight, 0, buffer);
  99:         trmscrollup(0, winheight, 1);
 100:         trmsync(winheight, 0);
 101:     }
 102:     fclose(fp);
 103: #ifdef SIGNAL
 104:     signal(SIGINT, prevsig);
 105:     if (intr)
 106:         trmundefined();
 107:         /* UNIX discards output when interrupted */
 108:         /* so output position is uncertain */
 109: #endif SIGNAL
 110:     trmputdata(winheight, winheight, 0, "");
 111:     strcpy(buffer, "Press [return] to continue");
 112:     for (cp = buffer; *cp; )
 113:         *cp++ |= SOBIT;
 114:     trmputdata(winheight, winheight, 0, buffer);
 115:     trmsync(winheight, cp - buffer);
 116:     c = getchar();
 117:     while (c != '\n' && c != '\r' && c != EOF) {
 118:         trmbell();
 119:         c = getchar();
 120:     }
 121:     trmputdata(winheight, winheight, 0, "");
 122:     winstart = winheight;
 123:     return Yes;
 124: }
 125: #endif HELPFUL

Defined functions

help defined in line 64; used 2 times
stop defined in line 48; used 2 times

Defined variables

intr defined in line 45; used 4 times
rcsid defined in line 2; never used

Defined macros

HELPBLURB defined in line 31; used 2 times
SOBIT defined in line 34; used 1 times
getchar defined in line 15; used 2 times
Last modified: 1985-08-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2483
Valid CSS Valid XHTML 1.0 Strict