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

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