home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1151 < prev    next >
Internet Message Format  |  1990-12-28  |  40KB

  1. From: pjc@pcbox.UUCP (Paul J. Condie)
  2. Newsgroups: alt.sources
  3. Subject: menu(1)  part 9 of 11
  4. Message-ID: <431@pcbox.UUCP>
  5. Date: 6 Apr 90 17:56:28 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 9 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file utilities.d/libgeti.d/ShowChar.c continued
  12. #
  13. CurArch=9
  14. if test ! -r s2_seq_.tmp
  15. then echo "Please unpack part 1 first!"
  16.      exit 1; fi
  17. ( read Scheck
  18.   if test "$Scheck" != $CurArch
  19.   then echo "Please unpack part $Scheck next!"
  20.        exit 1;
  21.   else exit 0; fi
  22. ) < s2_seq_.tmp || exit 1
  23. echo "x - Continuing file utilities.d/libgeti.d/ShowChar.c"
  24. sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/ShowChar.c
  25. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  26. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  27. X                "Only alpha/numberic characters allowed.") ;
  28. X            wattrOff (stdscr);
  29. X                 wmove(win, rowStart, col) ;
  30. X                 BELL;
  31. X              }
  32. X              break ;
  33. X
  34. X          case UPPER:
  35. X              if (isalpha(*ch)) 
  36. X        {
  37. X            if (insertmode)
  38. X            {
  39. X                junk = doinsert (win, row, col, colStart, 
  40. X                        colEnd, charKeyed, fldMask,
  41. X                        fldCharType, fldType, rowStart,
  42. X                        fldAttrib, fldRange, fldLength,
  43. X                        fldErrRow, origAttr);
  44. X                if (junk != 0)
  45. X                    break;
  46. X            }
  47. X
  48. X                 *ch = toupper(*ch);
  49. X                 wattrset(win, fldAttrib) ;
  50. X                 waddch(win, *ch) ;
  51. X                 wattrset(win, 0) ;
  52. X                 *(charKeyed + col - colStart) = 'Y' ;
  53. X              } 
  54. X        else 
  55. X        {
  56. X            CLEARROW (fldErrRow);
  57. X            wattrOn (stdscr, A_REVERSE|A_BOLD);
  58. X                 mvwaddstr(stdscr,
  59. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  60. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  61. X                "Only alpha characters allowed.") ;
  62. X            wattrOff (stdscr);
  63. X                 wmove(win, rowStart, col) ;
  64. X                 BELL;
  65. X              }
  66. X              break;
  67. X
  68. X          case NUMERIC:
  69. X              if (isdigit(*ch)  ||
  70. X                 ((fldType == FLOAT ||
  71. X                   fldType == DOUBLE ||
  72. X                   fldType == MONEY) && *ch == '.') ) 
  73. X        {
  74. X            if (insertmode)
  75. X            {
  76. X                junk = doinsert (win, row, col, colStart, 
  77. X                        colEnd, charKeyed, fldMask,
  78. X                        fldCharType, fldType, rowStart,
  79. X                        fldAttrib, fldRange, fldLength,
  80. X                        fldErrRow, origAttr);
  81. X                if (junk != 0)
  82. X                    break;
  83. X            }
  84. X
  85. X                 wattrset(win, fldAttrib) ;
  86. X                 waddch(win, *ch) ;
  87. X                 wattrset(win, 0) ;
  88. X                 *(charKeyed + col - colStart) = 'Y' ;
  89. X                 if (fldType == FLOAT || fldType == DOUBLE ||
  90. X                         fldType == MONEY) 
  91. X            {
  92. X                        int   firstCol ;
  93. X
  94. X                        firstCol = colStart ;
  95. X                        while (*(charKeyed + firstCol - colStart) == 'M')
  96. X                               firstCol++;
  97. X                        if (col == firstCol) 
  98. X                {
  99. X                               cmdstr[0] = *ch ;
  100. X                               cmdstr[1] = '\0' ;
  101. X                               while (++col < colEnd)
  102. X                                  *(charKeyed + col - colStart) = 'N' ;
  103. X                               ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, fldCharType,
  104. X                                    fldType, cmdstr, colEnd, charKeyed, 0, origAttr) ;
  105. X                                   wattrOn(win, fldAttrib) ;
  106. X                               mvwaddstr(win, rowStart, colStart + 1, "   ") ;
  107. X                               wattrOff(win) ;
  108. X                               wmove(win, rowStart, colStart + 1) ;
  109. X                        }
  110. X                 }
  111. X
  112. X            } 
  113. X        else 
  114. X        {
  115. X            CLEARROW (fldErrRow);
  116. X            wattrOn (stdscr, A_REVERSE|A_BOLD);
  117. X                 mvwaddstr(stdscr,
  118. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  119. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  120. X                    "Only numbers allowed.") ;
  121. X            wattrOff (stdscr);
  122. X                 wmove(win, rowStart, col) ;
  123. X                 BELL;
  124. X              }
  125. X              break ;
  126. X
  127. X          default:
  128. X              BELL;
  129. X              break ;
  130. X
  131. X       } /* end switch */
  132. X
  133. X       getyx(win, row, col) ;
  134. X       if (col == colEnd && keyStream == TRUE)
  135. X    {
  136. X        *ch = KEY_RETURN;
  137. X              return(FALSE) ;
  138. X    }
  139. X       else 
  140. X              if (col != colEnd && fldMask != NULL) 
  141. X              {
  142. X             /* skip cursor over format characters in the mask */
  143. X                 while (col != colEnd && 
  144. X                   *(charKeyed+col-colStart) == 'M')
  145. X                        col++;
  146. X                 wmove(win, rowStart, col) ;
  147. X                 return(TRUE) ;
  148. X              }
  149. X
  150. X       return (TRUE);
  151. X}
  152. SHAR_EOF
  153. echo "File utilities.d/libgeti.d/ShowChar.c is complete"
  154. chmod 0444 utilities.d/libgeti.d/ShowChar.c || echo "restore of utilities.d/libgeti.d/ShowChar.c fails"
  155. echo "x - extracting utilities.d/libgeti.d/ShowHelp.c (Text)"
  156. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowHelp.c &&
  157. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  158. X
  159. X#include     <curses.h>
  160. X#include    <ctype.h>
  161. X#include    "keys.h"
  162. X#include    "GetInput.h"
  163. X
  164. X
  165. X#ifndef    KEY_BEG
  166. X#define    KEY_BEG        0542
  167. X#endif
  168. X#ifndef    KEY_END
  169. X#define    KEY_END        0550
  170. X#endif
  171. X#ifndef    KEY_HELP
  172. X#define    KEY_HELP    0553
  173. X#endif
  174. X#ifndef    KEY_CANCEL
  175. X#define    KEY_CANCEL    0543
  176. X#endif
  177. X
  178. X#ifndef BELL
  179. X#define BELL    printf ("%c", 7);
  180. X#endif
  181. X#define    NEXTPAGE    1
  182. X#define    PREVPAGE    2
  183. X#define    SCROLLDOWN    3
  184. X#define    SCROLLUP    4
  185. X#define    FIRSTPAGE    5
  186. X#define    LASTPAGE    6
  187. X
  188. X#define    SCROLLRATE    (wrows/2)            /* # lines to scroll */
  189. X#define    MAXTOC        24                /* max TOC entries */
  190. X#define    TOCTAG        "TABLE_OF_CONTENTS"        /* helptag for TOC */
  191. X
  192. X#define    SKIPJUNK(s)     /* \
  193. X            **  This macro skips over spaces, tabs, etc. \
  194. X            **  ARGS:  char  *s \
  195. X            */ \
  196. X            for (;*s != '\0' && (isspace(*s)); s++) \
  197. X                ;
  198. X
  199. Xstruct TableOfContents
  200. X{
  201. X    char    helpfile[16];
  202. X    char    helptag[30];
  203. X    char    text[100];
  204. X};
  205. X
  206. X
  207. XShowHelp (HelpFile, Tag, fldErrRow)
  208. X    char    HelpFile[];
  209. X    char    Tag[];
  210. X    int    fldErrRow;
  211. X{
  212. X    WINDOW    *helpWin;
  213. X       FILE    *fopen(), *fp;
  214. X    char    *fgets();
  215. X    char    *getenv();
  216. X    long    ftell();
  217. X    char    line[100];
  218. X    char    *sptr;
  219. X    int    row;
  220. X    int    col;
  221. X    int    wrows;
  222. X    int    wcols;
  223. X    char    helpfile[80];
  224. X    int    longline; /*0*/
  225. X    int    ch;
  226. X    char    title[100];
  227. X    int    scrollflag;
  228. X    int    linecount;
  229. X    long    lineoffset[200];        /* start of line in file */
  230. X    static int    helpHelp = FALSE;
  231. X    struct TableOfContents    TOC[MAXTOC];
  232. X    int    rc;
  233. X    int    TOCflag = FALSE;
  234. X    char    fileName[100];
  235. X    char    tag[80];
  236. X
  237. X
  238. X    strcpy (fileName, HelpFile);
  239. X    strcpy (tag, Tag);
  240. Xrestart:
  241. X    strcat (tag, "\n");
  242. X    linecount = 0;
  243. X    /* do we have a help tag ? */
  244. X    if (strcmp (tag, "") == 0)
  245. X    {
  246. X               BELL;
  247. X        CLEARROW (fldErrRow);
  248. X        wattrOn (stdscr, A_REVERSE|A_BOLD);
  249. X               mvwaddstr(stdscr,
  250. X            ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  251. X            ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  252. X                "No help available.");
  253. X        wattrOff (stdscr);
  254. X        return (1);
  255. X    }
  256. X
  257. X    /*
  258. X    **  open help file
  259. X    */
  260. X       if ((fp = fopen (fileName, "r")) == NULL)
  261. X       {
  262. X        if (getenv("HELPDIR") != (char *)NULL)
  263. X                  sprintf (helpfile, "%s/%s", getenv ("HELPDIR"), 
  264. X                 fileName);
  265. X              fp = fopen (helpfile, "r");
  266. X              if (fp == NULL) 
  267. X              {
  268. X                 BELL;
  269. X            CLEARROW (fldErrRow);
  270. X            wattrOn (stdscr, A_REVERSE|A_BOLD);
  271. X                       mvwaddstr(stdscr,
  272. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  273. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  274. X                "No help available.");
  275. X            wattrOff (stdscr);
  276. X                 return(1) ;
  277. X              }
  278. X       }
  279. X
  280. X    if (!TOCflag) 
  281. X        TOCflag = loadTOC (fp, TOC) == 0 ? TRUE : FALSE;
  282. X
  283. X    /*
  284. X    **  Locate starting tag.
  285. X    */
  286. X    while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
  287. X        if (strncmp (line, tag, strlen(tag)) == 0)
  288. X            break;
  289. X
  290. X    if (sptr == (char *)NULL)
  291. X    {
  292. X        /* Did not find starting tag */
  293. X              BELL;
  294. X        CLEARROW (fldErrRow);
  295. X        wattrOn (stdscr, A_REVERSE|A_BOLD);
  296. X                   mvwaddstr(stdscr,
  297. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  298. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  299. X            "No help available.");
  300. X        wattrOff (stdscr);
  301. X              fclose(fp) ;
  302. X              return(1) ;
  303. X    }
  304. X
  305. X    /*
  306. X    **    Found starting tag.
  307. X    **    determine how big of a window to make by searching for 
  308. X    **      ending tag
  309. X    **    check for a .TITLE line
  310. X    */
  311. X    lineoffset[linecount+1] = ftell (fp);
  312. X    fscanf (fp, "%s", title);
  313. X    if (strcmp (title, ".TITLE") == 0)
  314. X    {
  315. X        fseek (fp, 1, 1);            /* skip 1 byte */
  316. X        sptr = fgets (title, sizeof(title)-1, fp);
  317. X        title[strlen(title)-1] = '\0';        /* junk \n */
  318. X        lineoffset[linecount+1] = ftell (fp);     /* reset beg of help */
  319. X    }
  320. X    else
  321. X        strcpy (title, "");
  322. X    longline = strlen(title)+2;
  323. X
  324. X    fseek (fp, lineoffset[1], 0);        /* back to row 1 */
  325. X    while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
  326. X    {
  327. X        /* check for ending tag */
  328. X        if (strncmp (line, tag, strlen(tag)) == 0)
  329. X            break;
  330. X        
  331. X        /* calculate longest line */
  332. X        if (strlen(line) > longline)
  333. X            longline = strlen(line);
  334. X        linecount++;
  335. X        lineoffset[linecount+1] = ftell (fp);
  336. X    }
  337. X
  338. X    wrows = (linecount+2 < (LINES-2)) ? linecount+2 : (LINES-2);
  339. X    wcols = (longline+1 < COLS) ? longline+1 : COLS;    /* 1 for \n */
  340. X    /* center window on the screen */
  341. X       helpWin = newwin(wrows, wcols, LINES/2-wrows/2,COLS/2-wcols/2) ;
  342. X    keypad (helpWin, TRUE);
  343. X    scrollflag = (linecount+2 <= LINES) ? FALSE : TRUE;
  344. X    drawbox (helpWin, 1,1, wrows,wcols, 2,2, scrollflag,
  345. X            (helpHelp == FALSE ? TRUE : FALSE));
  346. X    if (strcmp (title, "") != 0)
  347. X    {
  348. X        wattrset (helpWin, A_STANDOUT);
  349. X        mvwprintw (helpWin, 0,2, "%s", title);
  350. X        wattrset (helpWin, A_NORMAL);
  351. X    }
  352. X
  353. X    row = 1;
  354. X    fseek (fp, lineoffset[row], 0);        /* back to row 1 */
  355. X    ch = KEY_BEG;
  356. X    do
  357. X    {
  358. X        switch (ch)
  359. X        {
  360. X           case KEY_TOC:
  361. X            if (!TOCflag)
  362. X                break;
  363. X            rc = showTOC (TOC);
  364. X            if (rc > 0)
  365. X            {
  366. X                fclose (fp);
  367. X                delwin (helpWin);
  368. X                strcpy (fileName,TOC[rc-1].helpfile);
  369. X                strcpy (tag,TOC[rc-1].helptag);
  370. X                goto restart;
  371. X            }
  372. X            touchwin (helpWin);
  373. X            break;
  374. X           case KEY_BEG:
  375. X            showpage (FIRSTPAGE,fp, wrows-2, wcols-2, helpWin,
  376. X                linecount, lineoffset);
  377. X            break;
  378. X           case KEY_DOWN:
  379. X            showpage (SCROLLDOWN,fp,wrows-2, wcols-2, helpWin,
  380. X                linecount, lineoffset);
  381. X            break;
  382. X           case KEY_UP:
  383. X            showpage (SCROLLUP, fp, wrows-2, wcols-2, helpWin,
  384. X                linecount, lineoffset);
  385. X            break;
  386. X           case KEY_END:
  387. X            showpage (LASTPAGE, fp, wrows-2, wcols-2, helpWin,
  388. X                linecount, lineoffset);
  389. X            break;
  390. X           case KEY_HELP:
  391. X            if (!helpHelp)
  392. X            {
  393. X                helpHelp = TRUE;
  394. X                ShowHelp (fileName, "help", fldErrRow);
  395. X                helpHelp = FALSE;
  396. X            }
  397. X            touchwin (helpWin);
  398. X            break;
  399. X        } /* end switch */
  400. X        wattrset (helpWin, A_STANDOUT);
  401. X        if (ftell(fp) != lineoffset[linecount+1])
  402. X        {
  403. X            /* we are not at end of file yet */
  404. X            mvwprintw (helpWin, wrows-1, 2, "--More--(%d%c)",
  405. X                    (int)((double)((double)(ftell(fp)-lineoffset[1]) / 
  406. X                    (lineoffset[linecount+1]-lineoffset[1])) * 100), 
  407. X               '%');
  408. X        }
  409. X        else
  410. X        {
  411. X            if (linecount+2 >= LINES)
  412. X                mvwprintw (helpWin, wrows-1, 2, 
  413. X                        "--End--       ");
  414. X            else
  415. X                mvwprintw (helpWin, wrows-1, 2, 
  416. X                        "              ");
  417. X        }
  418. X
  419. X        wattrset (helpWin, A_NORMAL);
  420. X        wmove (helpWin, wrows-2,wcols-2);
  421. X        wrefresh (helpWin);
  422. X        ch = wgetch (helpWin);
  423. X
  424. X        if (ch == KeyBeg || ch == KEY_BEG)
  425. X            ch = KEY_BEG;
  426. X        else if (ch == KeyDown || ch == KEY_DOWN)
  427. X            ch = KEY_DOWN;
  428. X        else if (ch == KeyUp || ch == KEY_UP)
  429. X            ch = KEY_UP;
  430. X        else if (ch == KeyCancel || ch == KEY_CANCEL)
  431. X            ch = KEY_CANCEL;
  432. X        else if (ch == KeyEnd || ch == KEY_END)
  433. X            ch = KEY_END;
  434. X        else if (ch == KeyHelp || ch == KEY_HELP)
  435. X            ch = KEY_HELP;
  436. X        else if (ch == KeyTOC || ch == KEY_TOC)
  437. X            ch = KEY_TOC;
  438. X        else
  439. X        {
  440. X            if (ftell(fp) != lineoffset[linecount+1])
  441. X                ch = KEY_DOWN;
  442. X            else
  443. X                ch = KEY_CANCEL;
  444. X        }
  445. X    } while (ch != KEY_CANCEL);
  446. X
  447. X       fclose(fp) ;
  448. X    delwin (helpWin);
  449. X    touchwin (stdscr);
  450. X    wnoutrefresh (stdscr);
  451. X       return(0) ;
  452. X}
  453. X
  454. X/*
  455. X**  RETURNS:
  456. X**        0    more info
  457. X**        -1    end of file or tag
  458. X*/
  459. Xshowpage (action, fp, wrows, wcols, helpWin, linecount, lineoffset)
  460. X    int    action;
  461. X    FILE    *fp;
  462. X    int    wrows;
  463. X    int    wcols;
  464. X    WINDOW    *helpWin;
  465. X    int    linecount;
  466. X    long    lineoffset[];        /* start of line in file */
  467. X{
  468. X    char        line[100];
  469. X    static int    here;                /* line top of screen */
  470. X    int        rowcount;
  471. X    int        i,j;
  472. X
  473. X
  474. X    switch (action)
  475. X    {
  476. X       case FIRSTPAGE:
  477. X        here = 1;
  478. X        break;
  479. X
  480. X       case LASTPAGE:
  481. X        if (here == linecount - wrows + 1) return (-1);
  482. X        here = linecount - wrows + 1;
  483. X        break;
  484. X
  485. X       case SCROLLDOWN:
  486. X        if (here + wrows > linecount)
  487. X            return(-1);                /* at EOF */
  488. X        if (here + wrows + SCROLLRATE <= linecount+1)
  489. X            here += SCROLLRATE;
  490. X        else
  491. X            here = linecount - wrows + 1;
  492. X        break;
  493. X
  494. X       case SCROLLUP:
  495. X        if (here == 1)
  496. X            return (-1);                /* at BOF */
  497. X        if (here - SCROLLRATE >= 1)
  498. X            here -= SCROLLRATE;
  499. X        else
  500. X            here = 1;
  501. X        break;
  502. X
  503. X       case NEXTPAGE:
  504. X        break;
  505. X
  506. X       case PREVPAGE:
  507. X        break;
  508. X    }
  509. X
  510. X    /* clear screen */
  511. X    for (i=1; i<=wrows; i++)
  512. X        for (j=1; j<=wcols; j++)
  513. X            mvwprintw (helpWin, i,j, " ");
  514. X    fseek (fp, lineoffset[here], 0);        /* first of screen */
  515. X    for (rowcount=1; rowcount<=wrows && rowcount<=linecount; rowcount++)
  516. X    {
  517. X        fgets (line, sizeof(line)-1, fp);
  518. X        line[strlen(line)-1] = '\0';        /* junk \n */
  519. X        showline (helpWin, rowcount, 1, line);
  520. X    }
  521. X    return (0);
  522. X}
  523. X
  524. X
  525. X
  526. X/*  FUNCTION:    displaytext()
  527. X**        Displays a string to the screen with atributes.
  528. X**  ARGS:    row    screen row
  529. X**        col    screen col
  530. X**        s    the string
  531. X**  RETURNS:    none
  532. X*/
  533. X#ifndef SYSV
  534. X#define    SYSV    1
  535. X#endif
  536. Xshowline (helpWin, row, col, s)
  537. X    WINDOW    *helpWin;
  538. X    int    row, col;
  539. X    char    s[];
  540. X{
  541. X    int    i;
  542. X
  543. X       wmove (helpWin, row, col);
  544. X
  545. X    /*
  546. X    **    Now display looking for terminal attributes.
  547. X    */
  548. X          for (i = 0; s[i] != '\0'; i++)
  549. X          {
  550. X             if (s[i] == '\\')
  551. X         {
  552. X#ifdef BSD
  553. X                /* Berkeley curses only supports standout */
  554. X                if (s[i+1] != 'N') s[i+1] = 'S';
  555. X#endif
  556. X                    switch (s[++i])
  557. X                    {
  558. X                      case 'S':
  559. X#ifdef BSD
  560. X                standout ();
  561. X#else
  562. X                   wattrset (helpWin, A_STANDOUT);
  563. X#endif
  564. X                break;
  565. X                      case 'B':
  566. X#ifdef SYSV
  567. X                wattrset (helpWin, A_BOLD);
  568. X#endif
  569. X                break;
  570. X                      case 'U':
  571. X#ifdef SYSV
  572. X                wattrset (helpWin, A_UNDERLINE);
  573. X#endif
  574. X                break;
  575. X                      case 'D':
  576. X#ifdef SYSV
  577. X                wattrset (helpWin, A_DIM);
  578. X#endif
  579. X                break;
  580. X                      case 'R':
  581. X#ifdef SYSV
  582. X                wattrset (helpWin, A_REVERSE);
  583. X#endif
  584. X                break;
  585. X                      case 'L':
  586. X#ifdef SYSV
  587. X                wattrset (helpWin, A_BLINK);
  588. X#endif
  589. X                break;
  590. X                      case 'N': 
  591. X#ifdef BSD
  592. X                standend ();
  593. X#else
  594. X                wattrset (helpWin, A_NORMAL);
  595. X#endif
  596. X                break;
  597. X            }
  598. X        }
  599. X             else
  600. X                    waddch (helpWin, s[i]);
  601. X    }
  602. X}
  603. X
  604. X
  605. X
  606. XloadTOC (fp, TOC)
  607. X    FILE            *fp;
  608. X    struct TableOfContents    TOC[];
  609. X{
  610. X    char    line[100];
  611. X    char    *sptr;
  612. X    int    count = 0;
  613. X
  614. X
  615. X    strcpy (TOC[0].text, "");
  616. X    /*
  617. X    **  Locate TABLE_OF_CONTENT tag.
  618. X    */
  619. X    while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
  620. X        if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
  621. X            break;
  622. X
  623. X    if (sptr == (char *)NULL) 
  624. X    {
  625. X        rewind (fp);
  626. X        return (-1);                /* no TOC */
  627. X    }
  628. X
  629. X    while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
  630. X    {
  631. X        /* check for ending tag */
  632. X        if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
  633. X            break;
  634. X        
  635. X           sscanf (sptr, "%s", TOC[count].helpfile);
  636. X        sptr += strlen(TOC[count].helpfile);
  637. X        SKIPJUNK(sptr);
  638. X           sscanf (sptr, "%s", TOC[count].helptag);
  639. X        sptr += strlen(TOC[count].helptag);
  640. X        SKIPJUNK(sptr);
  641. X        strcpy (TOC[count].text, sptr);
  642. X        TOC[count].text[strlen(TOC[count].text)-1] = '\0'; /* junk \n */
  643. X        count++;
  644. X    }
  645. X    strcpy (TOC[count].text, "");
  646. X    rewind (fp);
  647. X    return (0);
  648. X}
  649. X
  650. X
  651. X
  652. XshowTOC (TOC)
  653. X    struct TableOfContents    TOC[];
  654. X{
  655. X    int    count;
  656. X    int    length = 0;
  657. X    char    menu[MAXTOC+2][80];        /* popmenu items */
  658. X    int    menuid = 99;
  659. X    int    rc;
  660. X
  661. X
  662. X    for (count = 0; strcmp (TOC[count].text, "") != 0; count++)
  663. X    {
  664. X        strcpy (menu[count], TOC[count].text);
  665. X        if (strlen(menu[count]) > length)
  666. X            length = strlen(menu[count]);
  667. X    }
  668. X    strcpy (menu[count], "");
  669. X
  670. X    /* center on screen */
  671. X    popmenu (-2, menuid, (LINES/2)-(count/2)-3, (COLS/2)-(length/2)-2, 
  672. X            "Help - Table Of Contents", "", count, sizeof(menu[0]), 
  673. X            menu);
  674. X    rc = popmenu (menuid);
  675. X    return (rc);
  676. X}
  677. X/* Paul J. Condie  12/88 */
  678. SHAR_EOF
  679. chmod 0644 utilities.d/libgeti.d/ShowHelp.c || echo "restore of utilities.d/libgeti.d/ShowHelp.c fails"
  680. echo "x - extracting utilities.d/libgeti.d/ShowSet.c (Text)"
  681. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowSet.c &&
  682. Xstatic char Sccsid[] = "@(#)ShowSet.c    1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
  683. X#include    <curses.h>
  684. X#include    "GetInput.h"
  685. X
  686. XShowSet(win, rowStart, colStart, fldAttrib, fldRange, fldLength, pNum, colEnd, charKeyed, origAttr)
  687. X    WINDOW        *win ;        /* Window                    */
  688. X    int        rowStart ;
  689. X    int        colStart ;
  690. X    int        fldAttrib ;    /* Curses attribute            */
  691. X    char        *fldRange ;    /* enumeration list for SET         */
  692. X    unsigned    fldLength ;    /* Maximum length of output         */
  693. X    int        *pNum ;        /* enum to display */
  694. X    int        colEnd ;
  695. X    char        *charKeyed ;    /* characters keyed */
  696. X    int        origAttr[] ;    /* original attributes for field */
  697. X{
  698. X    char    *fldWrk ;
  699. X    int    count ;
  700. X    int    col ;
  701. X
  702. X    wmove (win, rowStart, colStart) ;
  703. X
  704. X    fldWrk = fldRange ;
  705. X
  706. X    count = 0 ;
  707. X
  708. X    while (*fldWrk != '\0') {
  709. X
  710. X        if (count == *pNum)
  711. X            break ;
  712. X
  713. X        while (*fldWrk != ','  &&  *fldWrk != '\0')
  714. X            fldWrk++ ;
  715. X
  716. X        if (*fldWrk == '\0') {
  717. X            fldWrk = fldRange ;
  718. X            *pNum = 0 ;
  719. X            break ;
  720. X        }
  721. X
  722. X        while (*fldWrk == ','  ||  *fldWrk == ' ')
  723. X            fldWrk++ ;
  724. X
  725. X        count++ ;
  726. X    }
  727. X
  728. X    if(fldAttrib != -1)
  729. X        wattrset (win, fldAttrib) ;
  730. X
  731. X    col = colStart ;
  732. X    while (*fldWrk != ','  &&  *fldWrk != '\0') {
  733. X        if(fldAttrib == -1)
  734. X            wattrset(win, origAttr[col++ - colStart]) ;
  735. X        waddch (win, *fldWrk++) ;
  736. X        *charKeyed++ = 'Y' ;
  737. X        fldLength-- ;
  738. X    }
  739. X
  740. X    if(fldAttrib != -1)
  741. X        wattrset (win, 0) ;
  742. X
  743. X    while (fldLength--) {
  744. X        *charKeyed++ = 'N' ;
  745. X        if(fldAttrib == -1)
  746. X            wattrset(win, origAttr[col++ - colStart]) ;
  747. X        waddch (win, ' ') ;
  748. X    }
  749. X
  750. X    wmove (win, rowStart, colStart) ;
  751. X    wattrset(win, 0) ;
  752. X
  753. X    return(0) ;
  754. X
  755. X}
  756. X
  757. X
  758. SHAR_EOF
  759. chmod 0444 utilities.d/libgeti.d/ShowSet.c || echo "restore of utilities.d/libgeti.d/ShowSet.c fails"
  760. echo "x - extracting utilities.d/libgeti.d/_Main.c (Text)"
  761. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/_Main.c &&
  762. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  763. X
  764. X#include     <curses.h>
  765. X#include     "GetInput.h"
  766. X#include     "keys.h"
  767. X
  768. X
  769. Xmain (argc, argv)
  770. X
  771. X    int   argc;
  772. X    char  *argv[];
  773. X{
  774. X   int       intV ;
  775. X   long      longV ;
  776. X   double       doubleV ;
  777. X   int       retCode ;
  778. X   char      cmdstr[128] ;
  779. X   union FldUnion Fld ;
  780. X
  781. X
  782. X   Initialize() ;
  783. X
  784. X   cmdstr[0]='\0';
  785. X   strcpy (cmdstr, "hi");
  786. X   Fld.strVal = cmdstr;
  787. X   retCode = GetInput (stdscr, 1, 1, &Fld, A_REVERSE, NOMASK, NORANGE,
  788. X       5, 0, ALPHANUM, RTADJ_BFILL, CHAR, NOAUTO, NOMUST, 20, 22,
  789. X       "Prompt", "GetInput.hlp", "GETINPUT");
  790. X
  791. X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
  792. X   refresh ();
  793. X
  794. X   /* Double */
  795. X   doubleV = 123.45 ;
  796. X   Fld.doubleVal = &doubleV ;
  797. X   retCode = GetInput (stdscr, 18, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 
  798. X    10, 0, NUMERIC, RTADJ_ZFILL, DOUBLE, NOAUTO,
  799. X        NOMUST, 20, 21, "Double: ") ;
  800. X   mvprintw (18, 40, "return code = :%d: value = :%f:", retCode, doubleV);
  801. X   refresh ();
  802. X
  803. X   /*
  804. X   cmdstr[0]='\0';
  805. X   Fld.strVal = cmdstr;
  806. X   retCode = GetInput (stdscr, 1, 1, &Fld, A_PROTECT, NOMASK, NORANGE,
  807. X       5, 2, ALPHANUM, NOFILL, CHAR, NOAUTO, MUSTENTER, 2010, 22,
  808. X       "Prompt                   %", "junk.hlp", "GETINPUT");
  809. X
  810. X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
  811. X   refresh ();
  812. X
  813. X
  814. X   strcpy(cmdstr, "AA") ;
  815. X   Fld.strVal = cmdstr ;
  816. X   retCode = GetInput (stdscr, 2, 1, &Fld, A_STANDOUT, 
  817. X    "[VV][VV][  ][  ][  ][  ][  ][  ]", NORANGE, 16, 2, UPPER_AN, NOFILL, 
  818. X    CHAR, NOAUTO, MUSTENTER, 23, 22, "Character field:", "testfile", 
  819. X    "FIELD 1") ;
  820. X
  821. X   mvprintw (2, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
  822. X   refresh ();
  823. X   */
  824. X
  825. X
  826. X/*
  827. X   cmdstr[0] = '\0' ;
  828. X   Fld.strVal = cmdstr ;
  829. X   retCode = GetInput (stdscr, 3, 1, &Fld, A_REVERSE, "HH:MM:SS:TT", NULL, 6, 6, 
  830. X    TIME, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, 
  831. X    "Time Field HH:MM:SS:TT: ", "testfile", "FIELD 2") ;
  832. X
  833. X   mvprintw (3, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
  834. X   refresh ();
  835. X*/
  836. X
  837. X
  838. X/* DATE */
  839. X/*
  840. X   cmdstr[0] = '\0' ;
  841. X   Fld.strVal = cmdstr ;
  842. X   retCode = GetInput (stdscr, 4, 0, &Fld, A_BOLD, "MM/DD/YY", NULL, 6, 6, DATE,
  843. X    NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Date Field MM/DD/YY: ", 
  844. X    "testfile", "FIELD 2") ;
  845. X
  846. X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
  847. X   refresh ();
  848. X*/
  849. X
  850. X/* ZIP */
  851. X/*
  852. X   cmdstr[0] = '\0' ;
  853. X   Fld.strVal = cmdstr ;
  854. X   retCode = GetInput (stdscr, 9, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 9, 0, 
  855. X    ZIP, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Zip Field XXXXX-XXXX",
  856. X    NOHELP, NOTAG) ;
  857. X
  858. X   mvprintw (9, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
  859. X   refresh ();
  860. X*/
  861. X
  862. X/*
  863. X   flash () ;
  864. X   cmdstr[0] = '\0' ;
  865. X   Fld.strVal = cmdstr ;
  866. X   retCode = GetInput (stdscr, 8, 0, &Fld, A_REVERSE, "(999) 999-9999", NULL, 10, 5, NUMERIC, RTADJ_ZFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Phone Number:", NULL, NULL) ;
  867. X
  868. X   flash () ;
  869. X   strcpy(cmdstr, "ABC") ;
  870. X   Fld.strVal = cmdstr ;
  871. X   retCode = GetInput (stdscr, 10, 0, &Fld, A_REVERSE, NULL, NULL, 9, 0, UPPER_AN, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Job Number:", NULL, NULL) ;
  872. X   mvprintw(12, 0, "strlen %d", strlen(cmdstr) ) ;
  873. X   refresh() ;
  874. X*/
  875. X
  876. X
  877. X/*
  878. X   strcpy(cmdstr, ";lkj") ;
  879. X   Fld.strVal = cmdstr ;
  880. X   retCode = GetInput (stdscr, 12, 0, &Fld, A_REVERSE, NOMASK, 
  881. X        ", INTeger, CHARacter, HEXdecimal, DATE", 12, 0, SET, NOFILL, 
  882. X        CHAR, NOAUTO, NOMUST, 20, 21, "enumeration field: ", 
  883. X        NOMSG, NOTAG) ;
  884. X   mvprintw (12, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
  885. X   refresh () ;
  886. X*/
  887. X
  888. X/*
  889. X   flash () ;
  890. X   intV = 200 ;
  891. X   Fld.intVal = &intV ;
  892. X   retCode = GetInput (stdscr, 13, 0, &Fld, A_REVERSE, NOMASK, "100, 200, 300", 
  893. X        12, 0, SET, NOFILL, INT, NOAUTO, MUSTENTER, 23, 22, 
  894. X        "enumeration field - int: ", NULL, NULL) ;
  895. X   mvprintw (13, 20, "return code = :%d: value = :%d:", retCode, intV);
  896. X   refresh () ;
  897. X
  898. X   flash () ;
  899. X   cmdstr[0] = '\0' ;
  900. X   Fld.strVal = cmdstr ;
  901. X   retCode = GetInput (stdscr, 14, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 2, 2, STATE, NOFILL, CHAR, AUTONEXT, MUSTENTER, 20, 21, "State Field: ", NULL, NULL) ;
  902. X   refresh () ;
  903. X
  904. X   flash () ;
  905. X   cmdstr[0] = '\0' ;
  906. X   Fld.strVal = cmdstr ;
  907. X   retCode = GetInput (stdscr, 16, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 6, 6, UPPER_AN, NOFILL, CHAR, NOAUTO, NOMUST,
  908. X        20, 21, "Six char field") ;
  909. X
  910. X   refresh () ;
  911. X
  912. X   */
  913. X
  914. X   refresh () ;
  915. X   sleep (4) ;
  916. X   Windup () ;
  917. X   exit (0) ;
  918. X}
  919. X
  920. X
  921. XInitialize ()
  922. X{
  923. X   initscr() ;
  924. X   cbreak() ;
  925. X   noecho() ;
  926. X   nonl() ;
  927. X   keypad(stdscr, TRUE) ;
  928. X   InitGetI() ;
  929. X   return(0) ;
  930. X}
  931. X
  932. X
  933. XWindup()
  934. X{
  935. X    /*
  936. X    **
  937. X    **    Take care of curses.
  938. X    **
  939. X    */
  940. X    endwin() ;
  941. X
  942. X    return(0) ;
  943. X}
  944. X
  945. X
  946. SHAR_EOF
  947. chmod 0644 utilities.d/libgeti.d/_Main.c || echo "restore of utilities.d/libgeti.d/_Main.c fails"
  948. echo "x - extracting utilities.d/libgeti.d/checkmask.c (Text)"
  949. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/checkmask.c &&
  950. X#ifndef LINT
  951. Xstatic char Sccsid[] = "@(#)checkmask.c    1.1   DeltaDate 11/21/88   ExtrDate 1/22/90";
  952. X#endif
  953. X
  954. X#include     <curses.h>
  955. X#include     <ctype.h>
  956. X#include     "GetInput.h"
  957. X
  958. Xcheckmask (col, colStart, fldMask, fldCharType, fldType, ch)
  959. X
  960. X    int    col ;
  961. X    int   colStart ;
  962. X    char  *fldMask ;      /* mask for character string      */
  963. X    char  fldCharType ;      /* type of character           */
  964. X    char  fldType ;       /* type of field         */
  965. X    int   ch ;             /* contains character keyed or being
  966. X                              moved */
  967. X{
  968. X       char  charType ;
  969. X       char  cmdstr[16] ;
  970. X
  971. X
  972. X
  973. X       if (fldCharType == STATE  || fldMask == NULL)
  974. X              charType = fldCharType ;
  975. X       else 
  976. X              if (fldCharType == DATE  ||  fldCharType == TIME)
  977. X                 charType = NUMERIC ;
  978. X              else
  979. X                 charType = *(fldMask + col - colStart) ;
  980. X
  981. X       switch (charType) 
  982. X       {
  983. X          case HEX:
  984. X              break ;
  985. X
  986. X          case ALPHA:
  987. X              if (isalpha(ch)) 
  988. X            return (ch);
  989. X        else 
  990. X            return (-1);
  991. X              break ;
  992. X
  993. X          case ALPHANUM:
  994. X          case UPPER_AN:
  995. X          case STATE:
  996. X              if (isprint(ch)) 
  997. X              {
  998. X                 if (charType == UPPER_AN  ||  charType == STATE)
  999. X                        ch = toupper(ch);
  1000. X            return (ch);
  1001. X              } 
  1002. X              else 
  1003. X            return (-1);
  1004. X              break ;
  1005. X
  1006. X          case UPPER:
  1007. X              if (isalpha(ch)) 
  1008. X        {
  1009. X                 ch = toupper(ch);
  1010. X            return (ch);
  1011. X              }
  1012. X        else
  1013. X            return (-1);
  1014. X              break ;
  1015. X
  1016. X          case NUMERIC:
  1017. X              if (isdigit(ch)  ||
  1018. X                 ( (fldType == FLOAT ||
  1019. X                    fldType == DOUBLE ||
  1020. X                    fldType == MONEY) && ch == '.') ) 
  1021. X        {
  1022. X            return (ch);
  1023. X              } 
  1024. X        else 
  1025. X            return (-1);
  1026. X              break ;
  1027. X
  1028. X          default:
  1029. X        return (-1);
  1030. X       } /* end switch */
  1031. X    return (-1);
  1032. X}
  1033. X/* Paul J. Condie  11/88 */
  1034. SHAR_EOF
  1035. chmod 0444 utilities.d/libgeti.d/checkmask.c || echo "restore of utilities.d/libgeti.d/checkmask.c fails"
  1036. echo "x - extracting utilities.d/libgeti.d/doinsert.c (Text)"
  1037. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/doinsert.c &&
  1038. X#ifndef LINT
  1039. Xstatic char Sccsid[] = "@(#)doinsert.c    1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
  1040. X#endif
  1041. X
  1042. X/*
  1043. X**  doinsert()
  1044. X**    Shifts characters to the right of cursor location over one and
  1045. X**    places a space where the new character will go.
  1046. X**  RETURNS:
  1047. X**        -1    field is full
  1048. X**        -2    didn't pass mask edits
  1049. X*/
  1050. X
  1051. X#include    <curses.h>
  1052. X#include    "GetInput.h"
  1053. X
  1054. X
  1055. Xdoinsert (win, row, col, colStart, colEnd, charKeyed, fldMask, fldCharType,
  1056. X    fldType, rowStart, fldAttrib, fldRange, fldLength, fldErrRow, origAttr)
  1057. X    WINDOW    *win;
  1058. X    int    row;
  1059. X    int    col;
  1060. X    int    colStart;
  1061. X    int    colEnd;
  1062. X    char    *charKeyed;
  1063. X    char    *fldMask;
  1064. X    char    fldCharType;
  1065. X    char    fldType;
  1066. X    int    rowStart;
  1067. X    int    fldAttrib;
  1068. X    char    *fldRange;
  1069. X    int    fldLength;
  1070. X    int    fldErrRow;
  1071. X    int    origAttr[];
  1072. X{
  1073. X    int    colSave;
  1074. X    char    fldStr[100];
  1075. X    char    *fldWrk;
  1076. X    int    junk;
  1077. X
  1078. X
  1079. X    colSave = col;        /* cursor location */
  1080. X
  1081. X    /* if we're sitting at end of field then no need to insert */
  1082. X    if (*(charKeyed+col-colStart) == 'N')
  1083. X        return (0);
  1084. X
  1085. X    /* do we have room to shift right on position ? */
  1086. X    col = colEnd;
  1087. X    while (col >= colStart)
  1088. X    {
  1089. X        if (*(charKeyed+col-colStart) == 'N')
  1090. X            break;                /* looks like we do */
  1091. X        if (*(charKeyed+col-colStart) == 'Y')
  1092. X        {
  1093. X            BELL;
  1094. X            return (-1);            /* no room */
  1095. X        }
  1096. X        col--;
  1097. X    }
  1098. X    if (col < colStart)
  1099. X    {
  1100. X        BELL;
  1101. X        return (-1);                /* all 'M' characters */
  1102. X    }
  1103. X
  1104. X    /* get field content & insert a space */
  1105. X    col = colStart;
  1106. X    fldWrk = fldStr;
  1107. X    while (col < colEnd)
  1108. X    {
  1109. X        if (col == colSave)
  1110. X            *fldWrk++ = ' ';    /* insert space */
  1111. X               if (*(charKeyed+col-colStart) == 'Y')
  1112. X                   *fldWrk++ = mvwinch(win, row, col) & A_CHARTEXT ;
  1113. X           col++;
  1114. X    }
  1115. X    *fldWrk = '\0';
  1116. X
  1117. X    /* validate new field against the mask */
  1118. X    if (fldMask != NOMASK)
  1119. X    {
  1120. X        junk = 0;
  1121. X        /* fldWrk - fldWrk, col - charKeyed */
  1122. X        for (fldWrk = fldStr, col = colStart; 
  1123. X             col < colEnd && *fldWrk != '\0'; col++)
  1124. X        {
  1125. X            /* only check shifted chars */
  1126. X            if (col <= colSave  || *(charKeyed+col-colStart) == 'M')
  1127. X            {
  1128. X                if (*(charKeyed+col-colStart) == 'Y')
  1129. X                    fldWrk++;
  1130. X                continue;
  1131. X            }
  1132. X
  1133. X                   junk = checkmask (col, colStart, fldMask, fldCharType,
  1134. X                       fldType, *fldWrk);
  1135. X
  1136. X            if (junk == -1)
  1137. X                break;
  1138. X            *fldWrk++ = junk;
  1139. X            junk = 0;
  1140. X        } /* end for */
  1141. X        if (junk == -1)
  1142. X        {
  1143. X            CLEARROW (fldErrRow);
  1144. X            wattrOn (stdscr, A_REVERSE|A_BOLD);
  1145. X                   mvwaddstr(stdscr,
  1146. X        ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
  1147. X        ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
  1148. X                    "Unable to insert character due to edits.");
  1149. X            wattrOff (stdscr);
  1150. X            BELL;
  1151. X            col = colSave;
  1152. X            wmove (win, rowStart, colSave);
  1153. X            return (-2);
  1154. X        }
  1155. X    }
  1156. X
  1157. X    /* set last N in charKeyd to Y */
  1158. X    col = colEnd;
  1159. X    while (col >= colStart)
  1160. X    {
  1161. X        if (*(charKeyed+col-colStart) == 'N')
  1162. X            junk = col;
  1163. X        if (*(charKeyed+col-colStart) == 'Y')
  1164. X        {
  1165. X            *(charKeyed+junk-colStart) = 'Y';
  1166. X            break;
  1167. X        }
  1168. X        col--;
  1169. X    }
  1170. X
  1171. X
  1172. X           ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, 
  1173. X            fldLength, fldCharType, fldType,
  1174. X            fldStr, colEnd, charKeyed, 0, origAttr);
  1175. X
  1176. X    col = colSave;
  1177. X    wmove (win, rowStart, colSave);
  1178. X    return (0);
  1179. X}
  1180. X/* Paul J. Condie  11/88 */
  1181. SHAR_EOF
  1182. chmod 0444 utilities.d/libgeti.d/doinsert.c || echo "restore of utilities.d/libgeti.d/doinsert.c fails"
  1183. echo "x - extracting utilities.d/libgeti.d/drawbox.c (Text)"
  1184. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/drawbox.c &&
  1185. X#ifndef LINT
  1186. Xstatic char Sccsid[] = "@(#)drawbox.c    1.2   DeltaDate 2/1/90   ExtrDate 2/1/90";
  1187. X#endif
  1188. X
  1189. X#include    <curses.h>
  1190. X#include    <term.h>
  1191. X#include    <ctype.h>
  1192. X
  1193. X#define    DumbLine    1    /* A_NORMAL */
  1194. X#define    StandoutLine    2    /* A_STANDOUT */
  1195. X#define    SingleLine    3    /* A_ALTCHARSET */
  1196. X#define    MosaicLine    4    /* A_ALTCHARSET */
  1197. X#define    DiamondLine    5    /* A_ALTCHARSET */
  1198. X#define    DotLine        6    /* A_ALTCHARSET */
  1199. X#define    PlusLine    7    /* A_ALTCHARSET */
  1200. X
  1201. X#define    CANDRAWGRAPHICS    (enter_alt_charset_mode != NULL  && \
  1202. X             strcmp(enter_alt_charset_mode, "") != 0)
  1203. X
  1204. Xextern    int    KeyHelp;
  1205. X
  1206. X
  1207. Xvoid drawbox (win, frow, fcol, trow, tcol, trythis, trythat, vscroll, help)
  1208. X    WINDOW    *win;
  1209. X    int    frow;            /* from row base 1 */
  1210. X    int    fcol;
  1211. X    int    trow;
  1212. X    int    tcol;
  1213. X    int    trythis;
  1214. X    int    trythat;
  1215. X    int    vscroll;
  1216. X    int    help;
  1217. X{
  1218. X    int    row;
  1219. X    int    col;
  1220. X    int    vchar;
  1221. X    int    hchar;
  1222. X    int    tlchar;                /* top left corner */
  1223. X    int    trchar;                /* top right corner */
  1224. X    int    brchar;                /* bottom right corner */
  1225. X    int    blchar;                /* bottom left corner */
  1226. X    int    attribute;
  1227. X    int    boxtype;
  1228. X
  1229. X
  1230. X
  1231. X    boxtype = trythis;
  1232. X    attribute = (boxtype == DumbLine || boxtype == StandoutLine) ? A_NORMAL : A_ALTCHARSET;
  1233. X    if (attribute == A_ALTCHARSET)
  1234. X        /* can this terminal do graphics ? */
  1235. X        boxtype = CANDRAWGRAPHICS ? trythis : trythat;
  1236. X
  1237. X    switch (boxtype)
  1238. X    {
  1239. X       case DumbLine:
  1240. X        /* draw a dumb line */
  1241. X        vchar = '|';
  1242. X        hchar = '-';
  1243. X        tlchar = '+';
  1244. X        trchar = '+';
  1245. X        brchar = '+';
  1246. X        blchar = '+';
  1247. X        break;
  1248. X
  1249. X       case StandoutLine:
  1250. X        /* draw a standout line */
  1251. X        attribute = A_STANDOUT;
  1252. X        vchar = ' ';
  1253. X        hchar = ' ';
  1254. X        tlchar = ' ';
  1255. X        trchar = ' ';
  1256. X        brchar = ' ';
  1257. X        blchar = ' ';
  1258. X        break;
  1259. X
  1260. X       case SingleLine:
  1261. X        /* attempt to draw a graphic single line */
  1262. X        vchar = 'x';
  1263. X        hchar = 'q';
  1264. X        tlchar = 'l';
  1265. X        trchar = 'k';
  1266. X        brchar = 'j';
  1267. X        blchar = 'm';
  1268. X        break;
  1269. X
  1270. X       case MosaicLine:
  1271. X        vchar = 'a';
  1272. X        hchar = 'a';
  1273. X        tlchar = 'a';
  1274. X        trchar = 'a';
  1275. X        brchar = 'a';
  1276. X        blchar = 'a';
  1277. X        break;
  1278. X
  1279. X       case DiamondLine:
  1280. X        vchar = '`';
  1281. X        hchar = '`';
  1282. X        tlchar = '`';
  1283. X        trchar = '`';
  1284. X        brchar = '`';
  1285. X        blchar = '`';
  1286. X        break;
  1287. X
  1288. X       case DotLine:
  1289. X        vchar = '~';
  1290. X        hchar = '~';
  1291. X        tlchar = '~';
  1292. X        trchar = '~';
  1293. X        brchar = '~';
  1294. X        blchar = '~';
  1295. X        break;
  1296. X
  1297. X       case PlusLine:
  1298. X        vchar = 'n';
  1299. X        hchar = 'n';
  1300. X        tlchar = 'n';
  1301. X        trchar = 'n';
  1302. X        brchar = 'n';
  1303. X        blchar = 'n';
  1304. X        break;
  1305. X
  1306. X       default:
  1307. X        return;
  1308. X    }
  1309. X
  1310. X#ifdef BSD
  1311. X    standout ();
  1312. X#else
  1313. X       wattrset (win, attribute);
  1314. X#endif
  1315. X       for (row = frow-1; row <= trow-1; row++)
  1316. X       {
  1317. X              if (row == frow-1  ||  row == trow-1)
  1318. X                 for (col = fcol-1; col <= tcol-1; col++)
  1319. X                        mvwaddch (win, row, col, hchar);
  1320. X              else
  1321. X              {
  1322. X                 mvwaddch (win, row, fcol-1, vchar);
  1323. X                 mvwaddch (win, row, tcol-1, vchar);
  1324. X              }
  1325. X       }
  1326. X    /* draw the corners */
  1327. X    mvwaddch (win, frow-1,fcol-1, tlchar);    /* top left */
  1328. X    mvwaddch (win, frow-1,tcol-1, trchar);    /* top right */
  1329. X    mvwaddch (win, trow-1,fcol-1, blchar);    /* bottom left */
  1330. X    mvwaddch (win, trow-1,tcol-1, brchar);    /* bottom right */
  1331. X
  1332. X    /* draw vertical scroll bars */
  1333. X    if (vscroll)
  1334. X    {
  1335. X        wattrset (win, A_REVERSE|A_BOLD);
  1336. X        mvwaddch (win, trow-7,tcol-1, '^');
  1337. X        mvwaddch (win, trow-6,tcol-1, 'v');
  1338. X    }
  1339. X    if (help)
  1340. X    {
  1341. X        wattrset (win, A_STANDOUT);
  1342. X        if (isprint(KeyHelp))
  1343. X            mvwprintw (win, trow-1,tcol-6, "Help %c", KeyHelp);
  1344. X        else
  1345. X            mvwprintw (win, trow-1,tcol-7, "Help %c", KeyHelp);
  1346. X    }
  1347. X
  1348. X#ifdef BSD
  1349. X       standend ();
  1350. X#else
  1351. X       wattrset (win, A_NORMAL);
  1352. X#endif
  1353. X}
  1354. X/* Paul J. Condie  10/88 */
  1355. SHAR_EOF
  1356. chmod 0444 utilities.d/libgeti.d/drawbox.c || echo "restore of utilities.d/libgeti.d/drawbox.c fails"
  1357. echo "x - extracting utilities.d/libgeti.d/popmenu.c (Text)"
  1358. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.c &&
  1359. X#ifndef LINT
  1360. Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
  1361. X#endif
  1362. X
  1363. X#include    <curses.h>
  1364. X#include    <term.h>
  1365. X#include    <varargs.h>
  1366. X
  1367. X#define    MAXMENUS    10
  1368. X#define    MAXITEMS    100
  1369. X#define    NEWMENU        0
  1370. X#define    DIMWINDOW    -1
  1371. X#define    CREATEMENU    -2    /* only if it does not exist */
  1372. X#define WRAPAROUND    TRUE
  1373. X#define    DumbLine    1    /* A_NORMAL */
  1374. X#define    StandoutLine    2    /* A_STANDOUT */
  1375. X#define    SingleLine    3    /* A_ALTCHARSET */
  1376. X
  1377. X#ifndef    KEY_RETURN
  1378. X#   define KEY_RETURN    '\r'
  1379. X#endif
  1380. X#ifndef KEY_HELP
  1381. X#   define KEY_HELP    0553
  1382. X#endif
  1383. X#ifndef KEY_CANCEL
  1384. X#   define KEY_CANCEL    0543
  1385. X#endif
  1386. X#ifndef KEY_DOWN
  1387. X#   define KEY_DOWN    0402
  1388. X#endif
  1389. X#ifndef KEY_UP
  1390. X#   define KEY_UP    0403
  1391. X#endif
  1392. X#ifndef KEY_REFRESH
  1393. X#   define KEY_REFRESH    565
  1394. X#endif
  1395. X
  1396. Xextern    int    KeyDown;
  1397. Xextern    int    KeyUp;
  1398. Xextern    int    KeyHelp;
  1399. Xextern    int    KeyCancel;
  1400. Xextern    int    KeyRedraw;
  1401. Xextern    int    KeyReturn;
  1402. X
  1403. Xtypedef struct    _menu
  1404. X{
  1405. X    int    MenuId;            /* numerical menu identifier */
  1406. X    int    row;
  1407. X    int    col;
  1408. X    char    *title ;        /* menu title */
  1409. X    char    *helpfile;        /* helpfile */
  1410. X    int    winSize ;        /* pop up window length */
  1411. X    WINDOW    *win;
  1412. X    int    NumItems;        /* number of items in menu */
  1413. X    int    width;            /* largest item */
  1414. X    char    *items[MAXITEMS+1];
  1415. X    int    ActiveItem;        /* last item selected */
  1416. X} MENU;
  1417. X
  1418. X
  1419. Xstatic MENU    *THEmenu[MAXMENUS+1];
  1420. X
  1421. X
  1422. X/*VARARGS*/
  1423. Xpopmenu (va_alist)
  1424. X
  1425. X    va_dcl
  1426. X{
  1427. X    va_list        ap;
  1428. X    int        action;
  1429. X    int        MenuId;
  1430. X    static int    midx = -1;        /* defined menus */
  1431. X    char        *ws;            /* base address of table */
  1432. X    char        **wws;            /* base address of table */
  1433. X    int        wssize;            /* size of one element */
  1434. X                        /*  or 0 if **wws is used */
  1435. X    register int    i, j;
  1436. X    int    rc;                /* return code */
  1437. X    int    idx;                /* tmp menu index */
  1438. X    int    NewMenu;            /* New Menu Flag */
  1439. X    static int    _runMenu();
  1440. X
  1441. X
  1442. X    va_start (ap);
  1443. X    action = va_arg (ap, int);
  1444. X
  1445. X    switch (action)
  1446. X    {
  1447. X       /*
  1448. X       **    Initialize a new popup menu
  1449. X       */
  1450. X       case NEWMENU:
  1451. X       case CREATEMENU:
  1452. X        MenuId = va_arg (ap, int);
  1453. X
  1454. X        /* do we already have this MenuId */
  1455. X        NewMenu = TRUE;
  1456. X        for (i = 0; i <= midx; i++)
  1457. X            if (THEmenu[i]->MenuId == MenuId)
  1458. X            {
  1459. X                /* Menu already exists */
  1460. X                NewMenu = FALSE;
  1461. X                if (action == CREATEMENU)
  1462. X                    break;    /* don't re-create it */
  1463. X
  1464. X                /* junk old menu */
  1465. X                delwin (THEmenu[i]->win);
  1466. X                free (THEmenu[i]);
  1467. X                idx = i;
  1468. X                break;
  1469. X            }
  1470. X        if (NewMenu == FALSE  && action == CREATEMENU)
  1471. X        {
  1472. X            va_end (ap);
  1473. X            break;
  1474. X        }
  1475. X        if (NewMenu == TRUE)
  1476. X            idx = ++midx;
  1477. X
  1478. X
  1479. X        /* build the new menu */
  1480. X        THEmenu[idx] = (MENU *)malloc (sizeof(MENU));
  1481. X        THEmenu[idx]->MenuId = MenuId;
  1482. X        THEmenu[idx]->row = va_arg (ap, int);    /* upper left corner */
  1483. X        THEmenu[idx]->col = va_arg (ap, int);
  1484. X        THEmenu[idx]->title = va_arg (ap, char *);
  1485. X        THEmenu[idx]->helpfile = va_arg (ap, char *);
  1486. X        if (THEmenu[idx]->helpfile != (char *)NULL  &&
  1487. X            strcmp (THEmenu[idx]->helpfile, "") == 0)
  1488. X            THEmenu[idx]->helpfile = (char *)NULL;
  1489. X        THEmenu[idx]->winSize = va_arg (ap, int);
  1490. X        THEmenu[idx]->NumItems = -1;
  1491. X        THEmenu[idx]->width = strlen (THEmenu[idx]->title);
  1492. X        wssize = va_arg (ap, int);    /* size of one element */
  1493. X        /* for char array, ws is used, otherwise, wws is used for
  1494. X        ** char *array.
  1495. X        */
  1496. X        if ( wssize > 0 )
  1497. X        {
  1498. X            ws = va_arg (ap, char *);    /* base address of table */
  1499. X            while (*ws != NULL)
  1500. X            {
  1501. X                THEmenu[idx]->NumItems++;
  1502. X                THEmenu[idx]->items[THEmenu[idx]->NumItems] = ws ;
  1503. X                if (strlen(ws) > THEmenu[idx]->width)
  1504. X                    THEmenu[idx]->width = strlen(ws);
  1505. X                ws += wssize ;
  1506. X            }
  1507. X        }
  1508. X        else        /* this is basically dup code as above */
  1509. X        {
  1510. X            wws = va_arg (ap, char **);  /* base address of table */
  1511. X            while (*wws != NULL)
  1512. X            {
  1513. X                THEmenu[idx]->NumItems++;
  1514. X                THEmenu[idx]->items[THEmenu[idx]->NumItems] = *wws ;
  1515. X                if (strlen(*wws) > THEmenu[idx]->width)
  1516. X                    THEmenu[idx]->width = strlen(*wws);
  1517. X                wws++ ;
  1518. X            }
  1519. X        }
  1520. X        /*
  1521. X         * adjust length of popmenu
  1522. X         */
  1523. X        if (THEmenu[idx]->winSize <= 0)        /* default length */
  1524. X            THEmenu[idx]->winSize = 6;
  1525. X        /* not enough items? */
  1526. X        if (THEmenu[idx]->winSize > THEmenu[idx]->NumItems+1 ) 
  1527. X            THEmenu[idx]->winSize = THEmenu[idx]->NumItems + 1 ;
  1528. X        /* roll off bottom of screen? */
  1529. X        if ( THEmenu[idx]->winSize > LINES-THEmenu[idx]->row-2 ) 
  1530. X            THEmenu[idx]->winSize = LINES - THEmenu[idx]->row - 2 ;
  1531. X
  1532. X        /*
  1533. X         * adjust the starting col of popmenu if the menu
  1534. X         * will roll off the right edge of screen
  1535. X         *      NOTE: col is 0 offset while width is not
  1536. X         */
  1537. X        if ( THEmenu[idx]->col > COLS-THEmenu[idx]->width-4 )
  1538. X            THEmenu[idx]->col = COLS - THEmenu[idx]->width - 4 ;
  1539. X
  1540. X        va_end (ap);
  1541. X        THEmenu[idx]->ActiveItem = 1;
  1542. X
  1543. X        THEmenu[idx]->win = newwin (THEmenu[idx]->winSize+2, 
  1544. X                THEmenu[idx]->width+4,
  1545. X                    THEmenu[idx]->row, THEmenu[idx]->col);
  1546. X
  1547. X        keypad (THEmenu[idx]->win, TRUE);
  1548. X        rc = 0;            /* 0 return code */
  1549. X        break;
  1550. X
  1551. X       case DIMWINDOW:
  1552. X        MenuId = va_arg (ap, int);
  1553. X        va_end (ap);
  1554. X
  1555. X        for (i = 0; i <= midx; i++)
  1556. X            if (THEmenu[i]->MenuId == MenuId)
  1557. X            {
  1558. X                drawbox( THEmenu[i]->win, 1, 1,
  1559. X                     THEmenu[i]->winSize+2,
  1560. X                     THEmenu[i]->width+4,
  1561. X                    SingleLine, DumbLine,
  1562. X                    (THEmenu[i]->winSize >= 4  &&
  1563. X                        THEmenu[i]->NumItems+1 >
  1564. X                        THEmenu[i]->winSize),
  1565. X                    (THEmenu[i]->helpfile !=
  1566. X                        (char *)NULL) ) ;
  1567. X                mvwprintw (THEmenu[i]->win, 0, 
  1568. X                    ((THEmenu[i]->width+4-
  1569. X                        strlen(THEmenu[i]->title))/2),
  1570. X                        "%s", THEmenu[i]->title);
  1571. X                wrefresh (THEmenu[i]->win);
  1572. X                break;
  1573. X            }
  1574. X        break;
  1575. X
  1576. X       default:
  1577. X        /*
  1578. X        **  Lets try to run a menu
  1579. X        */
  1580. X        va_end (ap);
  1581. X        MenuId = action;
  1582. X
  1583. X        /* Find the menu. */
  1584. X        for (i = 0; i <= midx; i++)
  1585. X            if (MenuId == THEmenu[i]->MenuId)
  1586. X                break;
  1587. X        if (i > midx)   return (-1);        /* invalid MenuId */
  1588. X        rc = _runMenu (THEmenu[i]);
  1589. X        break;
  1590. X    } /* end switch (action) */
  1591. X    return (rc);
  1592. X}
  1593. X
  1594. X
  1595. X
  1596. X_runMenu (menu)
  1597. X
  1598. X    MENU    *menu;
  1599. X{
  1600. X    register int    ch;
  1601. X    register int    fptr;            /* field pointer */
  1602. X    register int    i;
  1603. X    register int    top;
  1604. X    register int    inc;
  1605. X
  1606. X    putp ( cursor_invisible ) ;
  1607. X    inc = (int)( menu->winSize / 2 ) ;    /* window increment */
  1608. X    fptr = menu->ActiveItem;        /* set current item */
  1609. X    top = fptr - menu->winSize + 1 ;    /* set top item of window */
  1610. X    if ( top < 1 ) top = 1 ;        /* out of bound? */
  1611. X
  1612. X    /*
  1613. X    **    Display the menu.
  1614. X    */
  1615. X    for (i=0; i < menu->winSize && top+i-1 < menu->NumItems+1; i++)
  1616. X        mvwprintw (menu->win, i+1, 2, "%s", menu->items[top+i-1]);
  1617. X    drawbox( menu->win, 1, 1, menu->winSize+2, menu->width+4,
  1618. X            StandoutLine, StandoutLine,
  1619. X            (menu->winSize >= 4  &&
  1620. X                menu->NumItems+1 > menu->winSize),
  1621. X            (menu->helpfile != (char *)NULL) ) ;
  1622. X
  1623. X    /* display title */
  1624. X    wattrset (menu->win, A_STANDOUT);
  1625. X    mvwprintw (menu->win, 0, ((menu->width+4)/2)-(strlen(menu->title)/2), 
  1626. X        "%s", menu->title);
  1627. X    wattrset (menu->win, A_NORMAL);
  1628. X
  1629. X    while (1)
  1630. X    {
  1631. X        wattrset (menu->win, A_REVERSE);
  1632. X        mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
  1633. X        wattrset (menu->win, A_NORMAL);
  1634. X        wmove( menu->win, menu->winSize+1, menu->width+3 ) ;
  1635. X        touchwin (menu->win);
  1636. X        wrefresh (menu->win);
  1637. X
  1638. X        ch = wgetch (menu->win);
  1639. X        mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
  1640. X
  1641. X        if (ch == KeyReturn)       ch = KEY_RETURN;
  1642. X        if (ch == KeyDown)       ch = KEY_DOWN;
  1643. X        if (ch == KeyUp)       ch = KEY_UP;
  1644. X        if (ch == KeyHelp)       ch = KEY_HELP;
  1645. X        if (ch == KeyCancel)    ch = KEY_CANCEL;
  1646. X        if (ch == KeyRedraw)    ch = KEY_REFRESH;
  1647. X
  1648. X        if ( ch >= 'a' && ch <= 'z' )
  1649. X            ch = toupper( ch ) ;    /* deals in upper case only */
  1650. SHAR_EOF
  1651. echo "End of part 9"
  1652. echo "File utilities.d/libgeti.d/popmenu.c is continued in part 10"
  1653. echo "10" > s2_seq_.tmp
  1654. exit 0
  1655.