home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / szadb21b / source / src / help.c < prev    next >
C/C++ Source or Header  |  1991-07-09  |  3KB  |  125 lines

  1. /* Copyright (c) 1990 by Sozobon, Limited.  Authors: Johann Ruegg, Don Dugger
  2.  *
  3.  * Permission is granted to anyone to use this software for any purpose
  4.  * on any computer system, and to redistribute it freely, with the
  5.  * following restrictions:
  6.  * 1) No charge may be made other than reasonable charges for reproduction.
  7.  * 2) Modified versions must be clearly marked as such.
  8.  * 3) The authors are not responsible for any harmful consequences
  9.  *    of using this software, even if they result from defects in it.
  10.  *
  11.  *    help.c
  12.  */
  13. /*
  14.  *  Modifications:
  15.  *    - this file compiled conditionally only if HELP defined
  16.  *    - tie up a number of lines displayed to a window size
  17.  *    - all 'display help' functions consolidated in this file.
  18.  *    - function help does not save an image of a current line
  19.  *      but it contents and a positioning information
  20.  *    Michal Jaegermann, July 1991
  21.  */
  22. char     *svline;        /* define always, since start.s refers to it */
  23. #ifdef HELP
  24.  
  25. #include <setjmp.h>
  26. #include "adb.h"
  27.  
  28. #define IN_HELP
  29. #define H_WIDTH 40        /* witdh of a help line */
  30. #include "lang.h"
  31.  
  32. extern char    *linbuf;
  33. extern int      l_restart, w_restart;
  34.  
  35. char          **helplist[] = {
  36.                   help4,
  37.                   help3,
  38.                   help2,
  39.                   help1,
  40.                   0
  41. };
  42.  
  43. extern struct window w;
  44.  
  45. extern char *screen;
  46. extern w_curc(), w_putc(), lcopy();
  47. extern unsigned long   wcurl_max;
  48.  
  49.  
  50. void
  51. help ()
  52. {
  53.     char         ***p;
  54.     char          **q;
  55.     register char *cp;
  56.     int        svcol, width = w.cols;
  57.     int         svlr, svwr;
  58.     int             i;
  59.  
  60.     w_curs (0);                /* cursor off */
  61.     svcol = w.curc;            /* cursor was here */
  62.     svlr = l_restart;            /* keep backspacing info */
  63.     svwr = w_restart;
  64.     w.curc = width - H_WIDTH;        /* last H_WIDTH columns used by help */
  65.     bcopy (linbuf, svline, width);    /* keep the current line */
  66.     width -= 1;
  67.     svline[width] = '\0';
  68.  
  69.     for (p = helplist; *p;) {        /* show help screens */
  70.     q = *p++;
  71.     helpscr (q, *p != 0);
  72.     if (*p) {
  73.         i = gemdos (7) & 0xff;
  74.         if (i == 'q' || i == 'Q')
  75.         break;
  76.     }
  77.     }
  78.  
  79.     w.curl = wcurl_max;            /* go to the last line */
  80.     
  81.     w.curc = 0;
  82.     cp = svline;
  83.     while (*cp)                /* restore saved lined at the bottom */
  84.     w_put (*cp++);
  85.     bcopy(svline, linbuf, width);
  86.     l_restart = svlr;            /* restore backspacing info */
  87.     w_restart = svwr;
  88.     w.curc = svcol;            /* and our line position */
  89.     w_curs (1);                /* cursor on */
  90. }
  91.  
  92. helpscr (p, more)
  93.     char          **p;
  94. {
  95.     int             nlines = 0;
  96.  
  97.     for (nlines = 0; nlines < w.lines - 1; nlines++) {
  98.     if (*p)
  99.         helpline (*p++, nlines, H_WIDTH);
  100.     else
  101.         helpline ("", nlines, H_WIDTH);
  102.     }
  103. /*    helpline(more ? "   q - quit  <space> - more" : "", nlines, 39); */
  104.     helpline (more ? M1 : "", nlines, H_WIDTH - 1);
  105. }
  106.  
  107. #define W_HLINE(line) \
  108.     (w.curl=(unsigned long)(line) * w.lsz, w.curc=w.cols - H_WIDTH)
  109.  
  110. #define W_HCHR(c)     w_put((c))
  111.  
  112. helpline (p, line, n)
  113.     char           *p;
  114. {
  115.     int             i;
  116.  
  117.     W_HLINE (line);
  118.     for (i = 0; i < n; i++)
  119.     if (*p)
  120.         W_HCHR (*p++);
  121.     else
  122.         W_HCHR (' ');
  123. }
  124. #endif
  125.