home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume17 / mgr / part35 < prev    next >
Encoding:
Internet Message Format  |  1989-01-19  |  51.9 KB

  1. Subject:  v17i036:  MGR, Bellcore window manager, Part35/61
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: Stephen A. Uhler <sau@bellcore.com>
  6. Posting-number: Volume 17, Issue 36
  7. Archive-name: mgr/part35
  8.  
  9.  
  10.  
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 35 (of 61)."
  19. # Contents:  demo/misc/hpmgr.c font-16/Uoldeng22x30r lib/term.c
  20. #   src/get_menus.c
  21. # Wrapped by rsalz@papaya.bbn.com on Thu Nov 17 21:05:43 1988
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'demo/misc/hpmgr.c' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'demo/misc/hpmgr.c'\"
  25. else
  26. echo shar: Extracting \"'demo/misc/hpmgr.c'\" \(12178 characters\)
  27. sed "s/^X//" >'demo/misc/hpmgr.c' <<'END_OF_FILE'
  28. X/*                        Copyright (c) 1987 Bellcore
  29. X *                            All Rights Reserved
  30. X *       Permission is granted to copy or use this program, EXCEPT that it
  31. X *       may not be sold for profit, the copyright notice must be reproduced
  32. X *       on copies, and credit should be given to Bellcore where it is due.
  33. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  34. X */
  35. X/*
  36. X**    hp2621 terminal emulator
  37. X*/
  38. X#ifndef lint
  39. Xstatic char rcsid[] = "$Header: hpmgr.c,v 4.2 88/06/22 14:37:42 bianchi Exp $";
  40. X#endif
  41. X
  42. X#include "term.h"
  43. X#include <ctype.h>
  44. X
  45. X#define MAX_ROW        24
  46. X#define MAX_COL        80
  47. X
  48. X#define C_X    (MAX_COL*f_w)        /* width of the screen */
  49. X#define C_Y    (MAX_ROW*f_h)        /* height of the screen */
  50. X/*
  51. XFILE *outfile;
  52. X*/
  53. X
  54. Xextern int more_out;
  55. Xstatic char *m_fields[16];
  56. X
  57. Xint cur_x = 0;        /* cursor location */
  58. Xint cur_y = 0;
  59. X
  60. Xextern char *shiftline();
  61. Xextern char *del_line();
  62. Xint banner_space;
  63. Xint x,y,w,h,f_w,f_h;
  64. X
  65. Xint in_mode = 0;    /* insert mode flag */
  66. X
  67. X#define    min(a,b)    ((a)<(b)?(a):(b))
  68. X#define    max(a,b)    ((a)>(b)?(a):(b))
  69. X
  70. Xint margin;
  71. X
  72. Xmain(argc,argv)
  73. Xint argc;
  74. Xchar **argv;
  75. X{
  76. X    extern int verboseflag;
  77. X    int dummy;
  78. X
  79. X    ckmgrterm( *argv );
  80. X
  81. X    if (argc > 1 && !(strcmp(argv[1],"-v")))
  82. X    {
  83. X        verboseflag = 1;
  84. X    }
  85. X
  86. X/*
  87. X    if ((outfile = fopen("hpmgr.out","w+")) == NULL)
  88. X    {
  89. X        printf("can't create logfile\n");
  90. X        exit(1);
  91. X    }
  92. X*/
  93. X
  94. X    m_termin = stdin;
  95. X    m_termout = stdout;
  96. X
  97. X    m_push(P_MENU|P_POSITION|P_EVENT|P_FLAGS);
  98. X    m_setmode(M_ABS);
  99. X    get_size(&x,&y,&w,&h);
  100. X    get_font(&f_w,&f_h);
  101. X    get_margin(&margin);
  102. X
  103. X    banner_space = f_h+2;
  104. X
  105. X    m_setmode(M_BACKGROUND);
  106. X
  107. X    if ((w != C_X ) || ((C_Y + banner_space )!= h))
  108. X    {
  109. X        m_shapewindow(x,y,C_X+(2*margin),
  110. X                  C_Y + banner_space + (2*margin));
  111. X    }
  112. X
  113. X    get_size(&x,&y,&w,&h);
  114. X    m_clear();
  115. X
  116. X    /* print the banner line */
  117. X    m_printstr("                   HP2621 EMULATOR");
  118. X    m_flush();
  119. X    m_func(B_INVERT);
  120. X    m_bitwrite(0,0,w,banner_space-1);
  121. X    m_flush();
  122. X    m_func(B_OR);
  123. X
  124. X    m_textregion(0,banner_space,C_X,C_Y);
  125. X    m_clear();
  126. X    m_flush();
  127. X
  128. X    do_env("TERM=","h2");
  129. X    do_env("TERMCAP=","");
  130. X    getpty((char**)0);
  131. X    printf("\n\rPANIC -- getpty failed!! something is wrong!!\n\r");
  132. X}
  133. X
  134. X
  135. X
  136. Xint
  137. Xget_margin(x)
  138. Xint *x;
  139. X
  140. X   { 
  141. X   register int count;
  142. X
  143. X   if ((count = get_info(G_SYSTEM,m_fields)) >= 4) {
  144. X      *x = atoi(m_fields[3]); 
  145. X      return(1);
  146. X      }
  147. X   else 
  148. X    return(-count);
  149. X   }
  150. X
  151. Xinmassage(ptr,cnt)
  152. Xchar *ptr; int cnt;
  153. X{
  154. X    return(cnt);
  155. X}
  156. X
  157. Xoutmassage(ptr,cnt)
  158. Xchar *ptr; int cnt;
  159. X{
  160. X    char *start = ptr;
  161. X    char *to, *sptr, *shiftptr;
  162. X    int newcnt = 0;
  163. X    char newbuf[1024];
  164. X    char smallb[1024];
  165. X    static char holdb[1024];
  166. X    
  167. X    static int gotesc = 0;
  168. X    static int gotamp = 0;
  169. X    static int gota = 0;
  170. X    static int gotc = 0;
  171. X    static int goty = 0;
  172. X    static int gotr = 0;
  173. X    static int gotd = 0;
  174. X    static int gotj = 0;
  175. X
  176. X    static int xval = 0;
  177. X    static int yval = 0;
  178. X
  179. X/*
  180. Xfprintf(outfile,"outmassage --  more = %d  cnt = %d\n",more_out,cnt);
  181. Xfflush(outfile);
  182. X*/
  183. X    /*
  184. X    **    check to see if we have more data on hold
  185. X    */
  186. X    if (cnt == -2)
  187. X    {
  188. X        if (more_out)
  189. X        {
  190. X            to = ptr;
  191. X            mystrncpy(&to,holdb,more_out);
  192. X            cnt = more_out;
  193. X            more_out = 0;
  194. X        }
  195. X        else
  196. X        {
  197. X            printf("panic -- outmassage got cnt = %d and more_out = %d\n",
  198. X                            cnt,more_out);
  199. X            exit(1);
  200. X        }
  201. X    }
  202. X    else
  203. X    {
  204. X        if (cnt <= 0)
  205. X            return(cnt);
  206. X    }
  207. X
  208. X    for(to = newbuf;(cnt > 0) && (newcnt < (1024-100));ptr++,cnt--)
  209. X    {
  210. X
  211. X        *ptr &= 0177;
  212. X/*
  213. Xfputc(*ptr,outfile);
  214. X*/
  215. X
  216. X        if (gotesc)
  217. X        {
  218. X            switch (*ptr)
  219. X            {
  220. X                case '\000':
  221. X                    goto out;
  222. X                case ESC :
  223. X                    gotamp = gota = gotc = gotj = gotd  =
  224. X                        goty = gotr = 0;
  225. X                    goto out;
  226. X                case '&' :
  227. X                    gotamp = 1;
  228. X                    goto out;
  229. X                case 'a' :
  230. X                    gota = 1;
  231. X                    goto out;
  232. X                case 'y' :
  233. X                    goty = 1;
  234. X                    goto out;
  235. X                case 'r' :
  236. X                    gotr = 1;
  237. X                    goto out;
  238. X                case 'c' :
  239. X                    gotc = 1;
  240. X                    goto out;
  241. X
  242. X                case 'd' :
  243. X                    gotd = 1;
  244. X                    goto out;
  245. X                case '1' :
  246. X                case '2' :
  247. X                case '3' :
  248. X                    /*
  249. X                    **    skip tabs for now
  250. X                    */
  251. X                    if (!gotamp)
  252. X                    {
  253. X                        gotesc = 0;
  254. X                        goto out;
  255. X                    }
  256. X                case '0' :
  257. X                case '4' :
  258. X                case '5' :
  259. X                case '6' :
  260. X                case '7' :
  261. X                case '8' :
  262. X                case '9' :
  263. X                    if (gotc || goty || gotr)
  264. X                    {
  265. X                        yval *=10;
  266. X                        yval += (*ptr) - '0';
  267. X                    }
  268. X                    else
  269. X                    {
  270. X                        xval *=10;
  271. X                        xval += (*ptr) - '0';
  272. X                    }
  273. X                    goto out;
  274. X                case 'j' :
  275. X                    gotj = 1;
  276. X                    goto out;
  277. X                /*
  278. X                **    begin standout mode
  279. X                */
  280. X                case 'D' :
  281. X                    if (gotamp && gotd)
  282. X                    {
  283. X                        *to++ = ESC;
  284. X                        *to++ = 'i';
  285. X                        newcnt += 2;
  286. X                    }
  287. X                    gotesc = gotamp = gotj = gotd = 0;
  288. X                    goto out;
  289. X                /*
  290. X                **    skip keyboard mode for now
  291. X                **    but  handle end of standout mode
  292. X                */
  293. X                case '@' :
  294. X                    if (gotamp && gotd)
  295. X                    {
  296. X                        *to++ = ESC;
  297. X                        *to++ = 'n';
  298. X                        newcnt += 2;
  299. X                    }
  300. X                    gotesc = gotamp = gotj = gotd = 0;
  301. X                    goto out;
  302. X                case 'B' :
  303. X                    if (gotamp)
  304. X                    {
  305. X                        gotesc = gotamp = gotj = 0;
  306. X                        goto out;
  307. X                    }
  308. X                    goto parsepanic;
  309. X                
  310. X                /*
  311. X                **    clear screen
  312. X                */
  313. X                case 'J' :
  314. X                    *to++ = ESC;
  315. X                    *to++ = 'C';
  316. X                    newcnt += 2;
  317. X                    gotesc = 0;
  318. X                    goto out;
  319. X
  320. X                /*
  321. X                **    home cursor
  322. X                */
  323. X                case 'H' :
  324. X                    sprintf(smallb,"%c%d,%dM",ESC,0,0);    
  325. X                    mystrncpy(&to,smallb,strlen(smallb));
  326. X                    newcnt += strlen(smallb);
  327. X                    cur_x = cur_y = gotesc = 0;
  328. X                    goto out;
  329. X
  330. X                /*
  331. X                **    clear to eol
  332. X                */
  333. X                case 'K' :
  334. X                    *to++ = ESC;
  335. X                    *to++ = 'c';
  336. X                    newcnt += 2;
  337. X                    gotesc =0;
  338. X                    goto out;
  339. X                
  340. X                /*
  341. X                **    delete line
  342. X                */
  343. X                case 'M' :
  344. X                    *to++ = ESC;
  345. X                    *to++ = 'd';
  346. X                    newcnt += 2;
  347. X                    gotesc = 0;
  348. X                    goto out;
  349. X                    
  350. X                /*
  351. X                **    end insert mode 
  352. X                */
  353. X                case 'R' :
  354. X                    if (gota && gotamp)
  355. X                    {
  356. X                        goto vertaddr;
  357. X                    }
  358. X                    in_mode = 0;
  359. X                    gotesc = 0;
  360. X                    goto out;
  361. X                /*
  362. X                **    start insert mode 
  363. X                */
  364. X                case 'Q' :
  365. X                    in_mode = 1;
  366. X                    gotesc = 0;
  367. X                    goto out;
  368. X
  369. X                /*
  370. X                **    open line 
  371. X                */
  372. X                case 'L' :
  373. X                    *to++ = ESC;
  374. X                    *to++ = 'a';
  375. X                    newcnt += 2;
  376. X                    gotesc=0;
  377. X                    goto out;
  378. X                    
  379. X                /*
  380. X                **    up line 
  381. X                */
  382. X                case 'A' :
  383. X                    *to++ = ESC;
  384. X                    *to++ = 'u';
  385. X                    newcnt += 2;
  386. X                    gotesc=0;
  387. X                    goup();
  388. X                    goto out;
  389. X                    
  390. X                case 'i' :
  391. X                    cur_x -= (cur_x%8?cur_x%8:8);
  392. X                    sprintf(smallb,"%c%d,%dM", ESC,cur_x,cur_y);    
  393. X                    mystrncpy(&to,smallb,strlen(smallb));
  394. X                    newcnt += strlen(smallb);
  395. X                    gotesc = 0;
  396. X                    goto out;
  397. X
  398. X                /*
  399. X                **    delete char
  400. X                */
  401. X                case 'P' :
  402. X                    shiftptr = del_line();
  403. X                    mystrncpy(&to,shiftptr,strlen(shiftptr));
  404. X                    newcnt += strlen(shiftptr);
  405. X                    gotesc=0;
  406. X                    goto out;
  407. X                    
  408. X                /*
  409. X                **    non destructive space
  410. X                **    and horizontal motion
  411. X                */
  412. X                case 'C' :
  413. X                    if (gotamp)
  414. X                    {
  415. X                        if (gota)
  416. X                        {
  417. X                            if(gotr||goty)
  418. X                            {
  419. X                                goto fulladdr;
  420. X                            }
  421. X                            sprintf(smallb,
  422. X                                "%c%d,%dM",ESC,xval,cur_y);    
  423. X                            mystrncpy(&to,smallb,strlen(smallb));
  424. X                            newcnt += strlen(smallb);
  425. X                            cur_x = xval;
  426. X                            gotesc = gotamp = gota =
  427. X                                gotc = xval = yval = 0;
  428. X                        }
  429. X                        else
  430. X                        {
  431. X                            goto parsepanic;
  432. X                        }
  433. X                    }
  434. X                    else
  435. X                    {
  436. X                        *to++ = ESC;
  437. X                        *to++ = 'r';
  438. X                        newcnt += 2;
  439. X                        gotesc=0;
  440. X                        goright();
  441. X                    }
  442. X                    goto out;
  443. X                    
  444. X
  445. X                case 'Y' :
  446. X            vertaddr:
  447. X                    if (gotamp && gota)
  448. X                    {
  449. X            fulladdr:
  450. X                        if (goty || gotr)
  451. X                        {
  452. X                            int tmp;
  453. X                            tmp = xval;
  454. X                            xval = yval;
  455. X                            yval = tmp;
  456. X                        }
  457. X                        if (gotc || goty || gotr)
  458. X                        {
  459. X                            /*
  460. X                            **    2-D cursor motion
  461. X                            */
  462. X/*
  463. Xfprintf(outfile,"xval = %d, yval = %d",xval,yval);
  464. Xfflush(outfile);
  465. X*/
  466. X                            if (yval > MAX_ROW-1)
  467. X                            {
  468. X                                fprintf(stderr,
  469. X                                "PANIC -- got address > 23 = %d", yval);
  470. X                                sleep(10);
  471. X                            }
  472. X                            sprintf(smallb,"%c%d,%dM",
  473. X                                ESC,xval,yval);    
  474. X                            mystrncpy(&to,smallb,strlen(smallb));
  475. X                            newcnt += strlen(smallb);
  476. X                            cur_x = xval;
  477. X                            cur_y = yval;
  478. X                            gotesc = gotamp = gota = gotc =
  479. X                                xval = yval = goty = gotr = 0;
  480. X                        }
  481. X                        else
  482. X                        {
  483. X                            /*
  484. X                            **    vertical motion
  485. X                            */
  486. X                            if (xval > MAX_ROW-1)
  487. X                            {
  488. X                                fprintf(stderr,
  489. X                                "PANIC -- got address > 23 = %d", xval);
  490. X                                sleep(10);
  491. X                            }
  492. X                            sprintf(smallb,
  493. X                                "%c%d,%dM",ESC,cur_x,xval);    
  494. X                            mystrncpy(&to,smallb,strlen(smallb));
  495. X                            newcnt += strlen(smallb);
  496. X                            cur_y = xval;
  497. X                            gotesc = gotamp = gota =
  498. X                                gotr = goty = gotc = xval = yval = 0;
  499. X                        }
  500. X                        goto out;
  501. X                    }
  502. X                    else
  503. X                    {
  504. X                        goto parsepanic;
  505. X                    }
  506. X                default : 
  507. X          parsepanic:;
  508. X/*
  509. X                    fprintf(outfile,"|BAD ESCAPE CODE esc = %d gotamp = %d gota = %d gotc = %d gotj = %d goty = %d gotr = %d code = %o|\n",
  510. X                    gotesc,gotamp,gota,gotc,
  511. X                        gotj,goty,gotr,*ptr);
  512. X*/
  513. X                    printf("|BAD ESCAPE CODE esc = %d gotamp = %d gota = %d gotc = %d gotj = %d goty = %d gotr = %d code = %o|\n",
  514. X                    gotesc,gotamp,gota,gotc,
  515. X                        gotj,goty,gotr,*ptr);
  516. X                    sleep(10);
  517. X                    gotesc = gotamp = gota = gotc = xval = yval = 0;
  518. X                    goto out;
  519. X            }
  520. X        }
  521. X
  522. X        switch (*ptr)
  523. X        {
  524. X            case '\000' :
  525. X                break;
  526. X            case ESC:
  527. X                gotamp = gota = gotc = gotj =
  528. X                    goty = gotr = xval = yval = 0;
  529. X                gotesc = 1;
  530. X                break;
  531. X            case '\010' :
  532. X                goleft();
  533. X                goto dochar;
  534. X            case '\012' :
  535. X                godown();
  536. X                goto dochar;
  537. X            case '\015' :
  538. X                cur_x = 0;
  539. X                goto dochar;
  540. X            case '\011' :
  541. X                cur_x += (8 - (cur_x%8));
  542. X                goto dochar;
  543. X            default:
  544. X                if (in_mode && isprint(*ptr))
  545. X                {
  546. X                    shiftptr = shiftline();
  547. X                    mystrncpy(&to,shiftptr,strlen(shiftptr));
  548. X                    newcnt += strlen(shiftptr);
  549. X                }
  550. X                goright();
  551. X        dochar :
  552. X                *to++ = *ptr;
  553. X                newcnt++;
  554. X                break;
  555. X        }
  556. X    out:;
  557. X    }
  558. X
  559. X    /*
  560. X    **    make sure we didn't over run the end of the buffer
  561. X    */
  562. X    if ((newcnt < 0) || (newcnt >= 1024))
  563. X    {
  564. X        printf("panic: newcnt = %d, out of range\n",newcnt);
  565. X    }
  566. X    /*
  567. X    **    did we run out of buffer space before finishing the input?
  568. X    */
  569. X    if (cnt)
  570. X    {
  571. X        to = holdb;
  572. X        mystrncpy(&to,ptr,cnt);
  573. X        more_out = cnt;
  574. X    }
  575. X    strncpy(start,newbuf,newcnt);
  576. X/*
  577. X    fprintf(outfile,"newcnt = %d\n",newcnt);
  578. X    if ((newcnt > 0) && (newcnt < 1024))
  579. X        fwrite(start,sizeof(char),newcnt,outfile);
  580. X*/
  581. X    return(newcnt);
  582. X}
  583. X
  584. Xgoright()
  585. X{
  586. X    if (cur_x == (MAX_COL-1))
  587. X    {
  588. X        cur_x = 0;
  589. X        godown();
  590. X    }
  591. X    else
  592. X    {
  593. X        cur_x++;
  594. X    }
  595. X}
  596. X
  597. Xgoleft()
  598. X{
  599. X    cur_x = max(0,cur_x - 1);
  600. X}
  601. X
  602. Xgoup()
  603. X{
  604. X    cur_y = max(0,cur_y - 1);
  605. X}
  606. X
  607. Xgodown()
  608. X{
  609. X    cur_y = min(MAX_ROW - 1, cur_y + 1);
  610. X}
  611. X
  612. Xchar *
  613. Xshiftline()
  614. X{
  615. X    static char shiftbuf[1024];
  616. X    static char buf2[1024];
  617. X
  618. X/*
  619. Xfprintf(outfile,"cur_x = %d cur_y = %d\n\n",cur_x, cur_y);
  620. Xfflush(outfile);
  621. X*/
  622. X
  623. X    /*    m_func     */
  624. X    sprintf(shiftbuf,"%c%d%c",ESC,B_COPY,E_BITBLT);
  625. X
  626. X    /*    m_bitcopy */
  627. X    sprintf(buf2,"%c%d,%d,%d,%d,%d,%d%c",
  628. X          ESC,
  629. X          (cur_x+1)*f_w,            /* dest  x */
  630. X          banner_space + (cur_y*f_h),        /* dest  y */
  631. X          f_w*((MAX_COL-1)-cur_x),        /* width  */
  632. X          f_h,                    /* height */
  633. X          cur_x*f_w,                /* src  x */
  634. X          banner_space + (cur_y*f_h),        /* src  y */
  635. X          E_BITBLT);
  636. X    strcat(shiftbuf,buf2);
  637. X
  638. X    /*    m_func        */
  639. X    sprintf(buf2,"%c%d%c",ESC,B_CLEAR,E_BITBLT);
  640. X    strcat(shiftbuf,buf2);
  641. X
  642. X/*
  643. X    sprintf(buf2,"%c%d,%d,%d,%d%c",
  644. X          ESC,
  645. X          cur_x*f_w,             x
  646. X          banner_space + (cur_y*f_h),     y 
  647. X          f_w,                width 
  648. X          f_h,                height
  649. X          E_BITBLT);
  650. X    strcat(shiftbuf,buf2);
  651. X
  652. X*/
  653. X    /*    m_func        */
  654. X    sprintf(buf2,"%c%d%c",ESC,B_OR,E_BITBLT);
  655. X    strcat(shiftbuf,buf2);
  656. X    return(shiftbuf);
  657. X}
  658. X
  659. Xchar *
  660. Xdel_line()
  661. X{
  662. X    static char shiftbuf[1024];
  663. X    static char buf2[1024];
  664. X    /*    m_func     */
  665. X    sprintf(shiftbuf,"%c%d%c",ESC,B_COPY,E_BITBLT);
  666. X
  667. X    /*    m_bitcopy */
  668. X    sprintf(buf2,"%c%d,%d,%d,%d,%d,%d%c",
  669. X          ESC,
  670. X          cur_x*f_w,                /* dest x */
  671. X          banner_space + (cur_y*f_h),        /* dest y */
  672. X          f_w*((MAX_COL-1)-cur_x),        /* width  */
  673. X          f_h,                    /* height */
  674. X          (cur_x+1)*f_w,            /* src  x */
  675. X          banner_space + (cur_y*f_h),        /* src  y */
  676. X          E_BITBLT);
  677. X    strcat(shiftbuf,buf2);
  678. X
  679. X    /*    m_func        */
  680. X    sprintf(buf2,"%c%d%c",ESC,B_CLEAR,E_BITBLT);
  681. X    strcat(shiftbuf,buf2);
  682. X
  683. X    sprintf(buf2,"%c%d,%d,%d,%d%c",
  684. X          ESC,
  685. X          C_X-f_w,            /*  x */
  686. X          banner_space + (cur_y*f_h),    /*  y */
  687. X          f_w,                /* width  */
  688. X          f_h,                /* height */
  689. X          E_BITBLT);
  690. X    strcat(shiftbuf,buf2);
  691. X
  692. X    /*    m_func        */
  693. X    sprintf(buf2,"%c%d%c",ESC,B_OR,E_BITBLT);
  694. X    strcat(shiftbuf,buf2);
  695. X    return(shiftbuf);
  696. X}
  697. X
  698. Xmystrncpy(to,from,cnt)
  699. Xchar **to, *from; int cnt;
  700. X{
  701. X    while(cnt > 0)
  702. X    {
  703. X        **to = *from;
  704. X        (*to)++;    /* increment the pointer,NOT the pointer to the pointer */
  705. X        from++;
  706. X        cnt--;
  707. X    }
  708. X}
  709. Xcleanup()
  710. X{
  711. X    m_pop();
  712. X    m_textreset();
  713. X    m_clear();
  714. X    exit(0);
  715. X}
  716. END_OF_FILE
  717. # end of 'demo/misc/hpmgr.c'
  718. fi
  719. if test -f 'font-16/Uoldeng22x30r' -a "${1}" != "-c" ; then 
  720.   echo shar: Will not clobber existing file \"'font-16/Uoldeng22x30r'\"
  721. else
  722. echo shar: Extracting \"'font-16/Uoldeng22x30r'\" \(12277 characters\)
  723. sed "s/^X//" >'font-16/Uoldeng22x30r' <<'END_OF_FILE'
  724. Xbegin 644 oldeng22x30r.fnt
  725. XM%A8>"%L@                          @                         
  726. XM                                                            
  727. XM          /0 XP,  1 G_P XSQ!QB( !$ XW@!D  #C, XW@#C>  !$@> 1
  728. XM "& /(P  A@#R.  _  ?@0#$8 (C  P&# 8"(.(P!                   
  729. XM   @      $              #      "          "   (            
  730. XM                                                            
  731. XM         !P                                                 
  732. XM                                              ?X!_@^ (O __X!
  733. XM_G_#_'X B\!_OR"R  '^8!_OP'^_( #ET_ _ ./ ?KZ #CP'JW !_P __P'E
  734. XM] <OH!Y??@\#X?)Z!P 0                  !       ,      (      
  735. XM /@     4          4   0                                    
  736. XM                                             #X             
  737. XM                                      "                     
  738. XM                      _L!_#. 1_ __\!_/_#^/X!'\!_9\&Y  '\X!_1
  739. XMY']GP -VY_!_ \7@_L< /%X/[#@"!XA__P!V. ^QP =GQQ.'P_*\!__P    
  740. XM              "@      <      $       SP     <          <  !P
  741. XM                            "       @  "                    
  742. XM                     !X                                #  #(
  743. XM  !@  &   .  /^  (( ! P  P  #                             @\
  744. XM!&,. R> 90>!&0.",9P#)X!&X8 [  $8X!&@^$;A@ 9\Y#B>!WCPCX< =X\(
  745. XM^#@$ _!'_@!T. /AP ?'1P.'@G,< __@                  #P      < 
  746. XM     &      !QP     <          <  !P                        
  747. XM    $      !   $                                          H 
  748. XM                               'T 'P  #Z  /H  .  /^  ?X #_@ 
  749. XM!]  'T                            !< #8.!F( #0. !@  "X@&80 !
  750. XMX0 =   "X !@< 'A !ITX#@(#.AP#H< SH< Z#@$ . $" !T. .AP ='1P'(
  751. XM '(< /_                   #X      <      /      !P      <   
  752. XM       <  !P                            <      #   ,        
  753. XM                                  0                         
  754. XM      ![X +@  ]\ #WP  <  ?\ !_P '_@ >^ ![X                  
  755. XM          =. ,X.#.( '0. &@  ,X@,X@ &X  =   ,X &@( ;A #ITX#P(
  756. XM#.@X#H< SH. Z#@& $ (B !T. .AP ='1P'( '(<  "                 
  757. XM  !P      <      '@     !P      <          <  !P            
  758. XM                <      &   8                                
  759. XM          @                               !PX #@  X< #AP  < 
  760. XM 0  !W@  _  <. !PX                            ^. <X.#.( '0. 
  761. XM.@  <X@,Y  .X  =   <X .@  [A #ITX#P('.@X#H<!SH. Z#@/P  9B !T
  762. XM. .AP ='1P#P '(<  "                    @      <      #P     
  763. XM!P      <   0  !   <  !P                            <      &
  764. XM   8                                                        
  765. XM                  !PX #@  X< #AP  8  0  !P   "  <. !PX      
  766. XM                      ^' <Z,&.( '8> .@  <X@8Z  .Z( =   <X .A
  767. XMP [A #ITX"X(&.@<#H<!CH' Z#@;^#@SB !T. .AP ='1P#P '(<  $     
  768. XM                      <      !X     !P      <   X  #@  <  !P
  769. XM                            <      .   X                    
  770. XM                                                      !PX #@
  771. XM  X< #AP  X  0  !P   "  <. !PX "   (                      "'
  772. XM \Z8&.( /7N >G  \_@8\  >Z\ ]   \X >FX![A 'OWX&X(..@<'O\#CH'!
  773. XMZ' 9_]PSB #W^ >_P ='1P/^ //\  (                           < 
  774. XM      \     !P      <   0  !   <  !P                        
  775. XM    <      .   X                                            
  776. XM                              !PX #@  P< #!P  T  0  !P   $  
  777. XM<. !PX '   <                      $'!\[L..( ?0. ^OH!\_@X_@ ^
  778. XM[<!]  !\X ^XX#[A /OWX.<(..@</H<#CH'#Z< </\ACB 'T. ^AP ]_?P/^
  779. XM ?(<  0                           <       >@    !^      <   
  780. XM       <  !P                            ?@     .   X        
  781. XM                                                            
  782. XM      !PX #@   <  !P !L  XX !P   (  <. !PX /@  ^            
  783. XM          '_A\^...( ?0. ^_P!\_@XZ8 ^^<!]  !\X ^@<#[A /OWX.?X
  784. XM.._\/H<#CO_#[^ /!^!CB 'T. ^AP!]'1P/^ ?(< '\                 
  785. XM      $P  =@  &   O  !@ !^   ,  <P  R  #(  <0 !P  """ ((  " 
  786. XM !$   @  R0  80 ?@  @@ '"  <(( X2 #+( /@@                   
  787. XM                                          !PX #@   \  #@ !< 
  788. XM _] !P@  (  ?^ !QX '   <                      /_A\Z...( ?7N 
  789. XM^@@!\_@XZ, ^Z<!]  !\X ^@<#[A /OWX/^(..@</H<#CH'#_. 'Y/#CB 'W
  790. XM^ ^_P!]'1P!X ?(< '\                       /]  ?Z  /P ''  'P 
  791. XM!\   R0 =Z !\  'P  =X !P  '//@<^  /  #^  #P !_P !_@ ?  !QP '
  792. XMO0 >\]!\^ 'WP ?_                                            
  793. XM                  !PX #@  #\  '  "<  Y^ !WT  8  /\ "^X "   (
  794. XM                      /_P<Z...( '8> .@@ <X@X[\ .[\ =   <X .@
  795. XM8 [A #ITX".(..@<#O\#CH' ^. #_##CB !T. .AP!]_?P"< '(< '\     
  796. XM                  &^  =\ !_P ''  \P !P  '#P >< "X  #@  >< !P
  797. XM  /WW _< !SH 'G0 <Z "[P '?  <  !SX #S@ //.!/\ +C@ G^        
  798. XM                                            ^         !PX #@
  799. XM  '\  #H $<  @> !XX  P  ?^  0X                            (!
  800. XMP<[^..( '0. .@@ <X@XZ. .Z< =   <X .AP [A #ITX"'(.._\#H<#CO_ 
  801. XMZ'  _[#CB !T. .AP ='1P"< '/\ "                        ".  <<
  802. XM !Y@ ''  <X !P  '#@ <<  X  #@  <, !P  ''' << !QP #C@ <<  Y@ 
  803. XM'&  <  !QP #C@ ... .8 #C@  ,                                
  804. XM                   !\         !PX #@  ,   !P /_@  . !PX  P  
  805. XM<.   X                            0!P<Z...( '0. .@@ <X@XZ. .
  806. XM[\ =   <X .GP [A #ITX"'(&.@8#H<!CH& Z'  '_#CB !T. .AP ='1P$.
  807. XM '(< "                        #.  << !P  ''  << !P  '#@ <<  
  808. XMX  #@  <8 !P  ''' << !QP #C@ <<  X  '$  <  !QP #C@ ... '  #C
  809. XM@  P                                                   #X   
  810. XM      !PX #@  (   !P  <   . !PX !P  <.   X                  
  811. XM          0 X8[^',) '0. .@@ <X@8S\ .Z< =   <X .XX [! #ITX"#H
  812. XM',@8#H<!S(& Z'  $_!S"0!T. .AP ='1P$. '(< $                  
  813. XM      &N  << !P  ''  <8 !P  '#@ <<  X  #@  =X !P  ''' << !QP
  814. XM #C@ <<  X  '^  <  !QP #C@ ... '  #C@ !                     
  815. XM                                          !PX #@  0   !P  < 
  816. XM  . !PX !@  <.   X                            @ X1R.'() &0. 
  817. XM,@@ 8X@<B, ,R< =   8X ,@X R! #ITX"#H# @P#H< P(, Z#@ $;!R"0!T
  818. XM. .AP ='1P(' '(< (                        ..  << !P  ''  =@ 
  819. XM!P  '#@ <<  X  #@  >X !P  ''' << !QP #C@ <<  X  !_@ <  !QP #
  820. XMC@ ... #@ #C@ /P                                            
  821. XM    (      "      !PX #@  0   !P  <   . !PX #@  <.   X "   (
  822. XM                     !P0<#".#P+ %P. /P@ 8X@,"8 .B8 9  !PX /A
  823. XM< _! #ITX'!X# @P#H< P(, \#@ (3 \"P!\. .AP ?'1P<' '(< 0      
  824. XM                  ..  << !P  ''  >  !P  '#@ <<  X  #@  <X !P
  825. XM  ''' << !QP #C@ <<  X   C@ <  !QP #C@ ... #@ #C@ $         
  826. XM                                        <      '      !PX #@
  827. XM  3X  ]P  <  /N !PX #P  <.  >X '   <                     '\@
  828. XM</R.#0^ '\. ?^B!^X@,"X ?C8#1  'XX ?R<!_Y(/)TX;QX!PC@/H< <(X!
  829. XM_+@'_" T/@!_. .!P ?G1Q_+D'(< ?@$                      ..  <<
  830. XM !P  ''  <  !P  '#@ <<  X  #@  <= !P  ''' << !QP #C@ <<  X  
  831. XM!C@ <  !QP #C@ ... YP #C@ $                                 
  832. XM                ^      /@     !]X #H  G] !_P  =  ?^ !]X #V  
  833. XM?>  _X /@  ^                     /_ <?^.!_\ /_> __\#_X@'#P _
  834. XM^0'Q  /\P _\.C__P?)TXO\X \O ?N\ /;P#_QT/_\ ?_ #_^@/_P _W_S_S
  835. XMH'(< __X                      '?  N< "X@ +G  ?$ "Y  'S@ ^<  
  836. XMX  #@  N> "Z  /OG@^> "YP 'S@ N<  Y  #[@ N@ !SX #C@ ...!_R #C
  837. XM@ /\@                                               >      '
  838. XM      "^  'P  _^ #_   ^  _X "^  !X  O@ !_@ '   >            
  839. XM         >. ,\?P _X >/P!X/X'GP@#C !Y\0/^  >>@!XX/'@_@_RX=\<X
  840. XM .\ ?O  #G 'CAX9_X /^ 'CW '@ !Y[P'CAP(_X!__P                
  841. XM      #F  '@  ?  !X  /X  >  /_@ <8  <  !P  '<  <  ''' <<  > 
  842. XM /\  '\ !>  '^  '  #]P %\  7]P#^\ #_@ ?_                    
  843. XM                            *      "       ,  !@  X$ ""   , 
  844. XM P0  ,   @  #  !!  "   *                     P$ %@'  /( P#@#
  845. XM !P,!@@ \ # 8@(\  P' # 0&, ' C@0+@(8 #P 3L   ^ ,! PPGP #R , 
  846. XMB !  # 1 ,! @8'P# ?@                      !$  "   ,   @  #@ 
  847. XM (   S0 (0  (   P  "(  (  """ ((  (  +P  "<  ,   8  "   P@  
  848. XMP  #C ",8 !@   ^                                            
  849. XM    $                                                      $
  850. XM                     P  !@    ( P  #   ,  @   #  @(   P  #  
  851. XM ,   @  #@      #H   " ,   @@   " ,      #   ,   8          
  852. XM                                         !P  0      X       
  853. XM             #@   <                           "             
  854. XM                                        (                   
  855. XM                                   (                     @  
  856. XM!     ( @  "   (  @   "  0&   @  "   (   @  #       #H   " (
  857. XM   A    " (      "   (   8                                  
  858. XM                 !P  (      X                    #@   <     
  859. XM                      "'                                    
  860. XM                                                            
  861. XM                                 @  !     ( @  "   (  @   " 
  862. XM 8!@  @  "   (   0  "       #H   # (   1    " (      "   (  
  863. XM 8'P                                                  P  ,  
  864. XM    8                    #@   <                           "/
  865. XM@                                                           
  866. XM                                                            
  867. XM         @  !     ( @  "   (  @   "  <    @  "   (   0  "   
  868. XM    #H   #"(   .    " (      "   (   /_X                    
  869. XM                            & P  .      8                   
  870. XM #@   <                           #_@                       
  871. XM                                                            
  872. XM                                             @  !     ( @  "
  873. XM " (  @   "  <    @  "   ( ( ,  "       #H   #B(        " ( 
  874. XM     "   (   /_\                                            
  875. XM    -A@  .     'P                    #@   >                 
  876. XM          #X@                                               
  877. XM                                                            
  878. XM                     0   @    8 0  ! , $ !@   !  \    0  !  
  879. XM $ P #@ !       #@   !\$        & $      !   $   'X$        
  880. XM                                        +7   >     /@       
  881. XM             #    <                           !P@           
  882. XM                                                            
  883. XM                                                         ,  
  884. XM 9    X ,   PP # #@    P X    ,   P  ##      P      #0    \#
  885. XM        . #       P  #     $                                
  886. XM                 N   <     /                     "    8     
  887. XM                        @                                   
  888. XM                                                            
  889. XM                                 #   &    0 #   /   P!     ,
  890. XM P    #   ,   \      ,      "     8 P       $  P      ,   P 
  891. XM                                                     8   8  
  892. XM   )                     $    0                            #
  893. XM         P@(    X     @ (        @   (    __@               
  894. XM                                          & P   X       8   
  895. XM                     #@   !P                                
  896. XM#_@                                                         
  897. XM                                                            
  898. XM                                (   !      @ (   " "  @ "   
  899. XM  "  <     (   "    @ @ #   "         Z    #B @         "  @
  900. XM       "    @   #__                                         
  901. XM                 V&   #@      ?                         .   
  902. XM '@                                /B                       
  903. XM                                                            
  904. XM                                                            
  905. XM       0   "     &  0   $ P !  8     $ #P     0   $   ! ,  #
  906. XM@  $        #@    'P!          8 !        $   !    'X$      
  907. XM                                                   "UP   >  
  908. XM    #X                         P    <                       
  909. XM          <(                                                
  910. XM                                                            
  911. XM                                          P   &0    X  P   ,
  912. XM,  # #@     , .      P   ,   ##       ,        -     / #    
  913. XM     #@ #        ,   #      0                               
  914. XM                           N   !P      /                    
  915. XM     "    !@                                  @             
  916. XM                                                            
  917. XM                                                            
  918. XM                 P   &    !   P   /   # $      , P      P   
  919. XM,   #P       ,        @     8 #         $  #        ,   #   
  920. XM                                                            
  921. XM !@   &       D                         0    $              
  922. X5                    ,       
  923. Xend
  924. END_OF_FILE
  925. # end of 'font-16/Uoldeng22x30r'
  926. fi
  927. if test -f 'lib/term.c' -a "${1}" != "-c" ; then 
  928.   echo shar: Will not clobber existing file \"'lib/term.c'\"
  929. else
  930. echo shar: Extracting \"'lib/term.c'\" \(12324 characters\)
  931. sed "s/^X//" >'lib/term.c' <<'END_OF_FILE'
  932. X/*                        Copyright (c) 1987 Bellcore
  933. X *                            All Rights Reserved
  934. X *       Permission is granted to copy or use this program, EXCEPT that it
  935. X *       may not be sold for profit, the copyright notice must be reproduced
  936. X *       on copies, and credit should be given to Bellcore where it is due.
  937. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  938. X */
  939. X/*    $Header: term.c,v 4.3 88/07/01 09:33:49 bianchi Exp $
  940. X    $Source: /tmp/mgrsrc/lib/RCS/term.c,v $
  941. X*/
  942. Xstatic char    RCSid_[] = "$Source: /tmp/mgrsrc/lib/RCS/term.c,v $$Revision: 4.3 $";
  943. X
  944. X/* routines for writing to mgr terminal emulator */
  945. X
  946. X#include "term.h"
  947. X#include "restart.h"
  948. X
  949. XFILE    *m_termout;
  950. XFILE    *m_termin;
  951. Xint    m_flags;
  952. Xint    m_envcount = 0;
  953. Xint    m_saveenvcount = 0;
  954. Xchar    m_escchar = ESC;
  955. Xchar    m_menuchar = M_DELIM;
  956. X
  957. Xjmp_buf _env;
  958. X
  959. Xstruct sgttyb    sgtty__save[TTYMAX];
  960. Xint        sgtty_cnt = 0;
  961. Xchar        m_linebuf[MAXLINE];
  962. Xstatic char    *m_fields[16];
  963. X
  964. X/******************************************************************************
  965. X *
  966. X *    setup
  967. X */
  968. X
  969. Xint
  970. Xm_setup(flags)
  971. Xint flags;
  972. X   {
  973. X   m_flags = flags;
  974. X
  975. X   if (!(m_flags&M_DEBUG)) {
  976. X      m_termout = fopen(M_DEVICEOUT,"w");
  977. X      m_termin = fopen(M_DEVICEIN,"r");
  978. X      }
  979. X
  980. X   if (m_termin == NULL || m_termout == NULL) 
  981. X      m_flags |= M_DEBUG;
  982. X
  983. X   if (m_flags&M_DEBUG) {
  984. X      m_termin = stdin;
  985. X      m_termout = stdout;
  986. X      }
  987. X   return(m_flags);
  988. X   }
  989. X
  990. X/******************************************************************************
  991. X *
  992. X *    get generic window parameters
  993. X */
  994. X
  995. Xint
  996. Xget_info(type,list)
  997. Xint type;
  998. Xchar **list;
  999. X   { 
  1000. X   if (type > G_MAX )
  1001. X      return(-1);
  1002. X   switch( type ) {
  1003. X   case G_ALL:
  1004. X   case G_ALLMINE:
  1005. X    return(-1);
  1006. X   }
  1007. X   _m_ttyset();
  1008. X   m_getinfo(type);
  1009. X   m_gets(m_linebuf);
  1010. X   _m_ttyreset();
  1011. X   return  parse(m_linebuf,list); 
  1012. X   }
  1013. X
  1014. X/******************************************************************************
  1015. X *
  1016. X *    read window parameters off of standard input
  1017. X */
  1018. X
  1019. Xint
  1020. Xget_windata(windatap)
  1021. Xstruct window_data *windatap;
  1022. X   { 
  1023. X   if( parse(m_gets(m_linebuf),m_fields) < 8 )
  1024. X    return 0;
  1025. X   windatap->x = atoi(m_fields[0]);
  1026. X   windatap->y = atoi(m_fields[1]);
  1027. X   windatap->w = atoi(m_fields[2]);
  1028. X   windatap->h = atoi(m_fields[3]);
  1029. X   strcpy(windatap->tty,m_fields[4]);
  1030. X   windatap->num = atoi(m_fields[5]);
  1031. X   windatap->status = *m_fields[6];
  1032. X   windatap->setid = atoi(m_fields[7]);
  1033. X   return 1;
  1034. X}
  1035. X
  1036. X/******************************************************************************
  1037. X *
  1038. X *    Get window parameters, one window at a time.
  1039. X *    Returns 1 if window_data structure has been filled, 0 otherwise.
  1040. X *    It is important to call get_eachwin() in a tight loop that doesn't
  1041. X *    ever exit, so that all the data is picked up.
  1042. X */
  1043. X
  1044. Xint
  1045. Xget_eachwin( windatap )
  1046. Xstruct window_data *windatap;
  1047. X   { 
  1048. X   static int i = 0;
  1049. X
  1050. X   if( !i ) {
  1051. X      _m_ttyset();
  1052. X      m_getinfo(G_ALL);
  1053. X   }
  1054. X   i = get_windata( windatap );
  1055. X   if( !i )
  1056. X      _m_ttyreset();
  1057. X   return(i);
  1058. X   }
  1059. X
  1060. X
  1061. X/******************************************************************************
  1062. X *
  1063. X *    Get window parameters for the current window set, one window at a time.
  1064. X *    Returns 1 if window_data structure has been filled, 0 otherwise.
  1065. X *    It is important to call get_eachcleintwin() in a tight loop that
  1066. X *    doesn' tever exit, so that all the data is picked up.
  1067. X */
  1068. X
  1069. Xint
  1070. Xget_eachclientwin( windatap )
  1071. Xstruct window_data *windatap;
  1072. X   { 
  1073. X   static int i = 0;
  1074. X
  1075. X   if( !i ) {
  1076. X      _m_ttyset();
  1077. X      m_getinfo(G_ALLMINE);
  1078. X   }
  1079. X   i = get_windata( windatap );
  1080. X   if( !i )
  1081. X      _m_ttyreset();
  1082. X   return(i);
  1083. X   }
  1084. X
  1085. X/******************************************************************************
  1086. X *
  1087. X *    Get all window parameters.
  1088. X *    NOTE CAREFULLY: The array of window_data structures pointed to by
  1089. X *    list must be more than the total number of windows on the screen;
  1090. X *    not a robust technique.
  1091. X *    get_eachwin() is recommended above this.
  1092. X */
  1093. X
  1094. Xint
  1095. Xget_all(list)
  1096. Xstruct window_data *list;
  1097. X   { 
  1098. X   register int i;
  1099. X
  1100. X   for(i=0;  get_eachwin( list );  i++ )
  1101. X      list++;
  1102. X   return(i);
  1103. X   }
  1104. X
  1105. X/******************************************************************************
  1106. X *
  1107. X *    Get window parameters for client windows.
  1108. X *    NOTE CAREFULLY: The array of window_data structures pointed to by
  1109. X *    list must be more than the total number of windows on the screen;
  1110. X *    not a robust technique.
  1111. X *    get_eachclientwin() is recommended above this.
  1112. X */
  1113. X
  1114. Xint
  1115. Xget_client(list)
  1116. Xstruct window_data *list;
  1117. X   { 
  1118. X   register int i;
  1119. X
  1120. X   _m_ttyset();
  1121. X   m_getinfo(G_ALLMINE);
  1122. X   for(i=0;  get_windata( list );  i++ )
  1123. X      list++;
  1124. X   _m_ttyreset();
  1125. X   return(i);
  1126. X   }
  1127. X
  1128. X/******************************************************************************
  1129. X *
  1130. X *    get the window size
  1131. X */
  1132. X
  1133. Xint
  1134. Xget_size(x,y,wide,high)
  1135. Xint *x, *y, *wide, *high;
  1136. X
  1137. X   { 
  1138. X   register int count;
  1139. X
  1140. X   if ((count = get_info(G_COORDS,m_fields)) >= 4) {
  1141. X      if (x)
  1142. X         *x = atoi(m_fields[0]); 
  1143. X      if (y)
  1144. X         *y = atoi(m_fields[1]); 
  1145. X      if (wide)
  1146. X         *wide = atoi(m_fields[2]); 
  1147. X      if (high)
  1148. X         *high = atoi(m_fields[3]); 
  1149. X      return(count);
  1150. X      }
  1151. X   else return(-count);
  1152. X   }
  1153. X
  1154. X/******************************************************************************
  1155. X *
  1156. X *    get the mouse coords
  1157. X */
  1158. X
  1159. Xint
  1160. Xget_mouse(x,y)
  1161. Xint *x, *y;
  1162. X
  1163. X   { 
  1164. X   register int count;
  1165. X
  1166. X   if ((count = get_info(G_MOUSE2,m_fields)) >= 3) {
  1167. X      if (x)
  1168. X         *x = atoi(m_fields[0]); 
  1169. X      if (y)
  1170. X         *y = atoi(m_fields[1]); 
  1171. X      return(atoi(m_fields[2]));
  1172. X      }
  1173. X   else return(-count);
  1174. X   }
  1175. X
  1176. X/******************************************************************************
  1177. X *
  1178. X *    get system parameters
  1179. X */
  1180. X
  1181. Xint
  1182. Xget_param(host,xmax,ymax,border)
  1183. Xchar *host;
  1184. Xint *xmax, *ymax, *border;
  1185. X
  1186. X   { 
  1187. X   register int count;
  1188. X
  1189. X   if ((count = get_info(G_SYSTEM,m_fields)) >= 4) {
  1190. X      if (host)
  1191. X         strcpy(host,m_fields[0]);
  1192. X      if (xmax)
  1193. X         *xmax = atoi(m_fields[1]); 
  1194. X      if (ymax)
  1195. X         *ymax = atoi(m_fields[2]); 
  1196. X      if (border)
  1197. X         *border = atoi(m_fields[3]); 
  1198. X      return(count);
  1199. X      }
  1200. X   else return(-count);
  1201. X   }
  1202. X
  1203. X/******************************************************************************
  1204. X *
  1205. X *    get the cursor position
  1206. X */
  1207. X
  1208. Xint
  1209. Xget_cursor(x,y)
  1210. Xint *x, *y;
  1211. X
  1212. X   { 
  1213. X   register int count;
  1214. X
  1215. X   if ((count = get_info(G_CURSOR,m_fields)) > 2) {
  1216. X      if (x)
  1217. X         *x = atoi(m_fields[0]); 
  1218. X      if (y)
  1219. X         *y = atoi(m_fields[1]); 
  1220. X      return(2);
  1221. X      }
  1222. X   else return(-count);
  1223. X   }
  1224. X
  1225. X/******************************************************************************
  1226. X *
  1227. X *    get the window size - rows and columns
  1228. X */
  1229. X
  1230. Xint
  1231. Xget_colrow(cols,rows)
  1232. Xint *cols, *rows;
  1233. X
  1234. X   { 
  1235. X   register int count;
  1236. X
  1237. X   if ((count = get_info(G_WINSIZE,m_fields)) == 2) {
  1238. X      if (cols)
  1239. X         *cols = atoi(m_fields[0]); 
  1240. X      if (rows)
  1241. X         *rows = atoi(m_fields[1]); 
  1242. X      return(2);
  1243. X      }
  1244. X   else return(-count);
  1245. X   }
  1246. X
  1247. X/******************************************************************************
  1248. X *
  1249. X *    get the termcap entry
  1250. X */
  1251. X
  1252. Xchar *
  1253. Xget_termcap()
  1254. X   { 
  1255. X   _m_ttyset();
  1256. X   m_getinfo(G_TERMCAP);
  1257. X   m_gets(m_linebuf);
  1258. X   _m_ttyreset();
  1259. X   return(m_linebuf);
  1260. X   }
  1261. X
  1262. X/******************************************************************************
  1263. X *
  1264. X *    get the font size
  1265. X */
  1266. X
  1267. Xint
  1268. Xget_font(wide,high)
  1269. Xint  *wide, *high;
  1270. X
  1271. X   { 
  1272. X   register int count, result;
  1273. X
  1274. X   if ((count = get_info(G_FONT,m_fields)) >= 3) {
  1275. X      if (wide)
  1276. X         *wide = atoi(m_fields[0]); 
  1277. X      if (high)
  1278. X         *high = atoi(m_fields[1]); 
  1279. X      result = atoi(m_fields[2]); 
  1280. X      return(result);
  1281. X      }
  1282. X   else return(-count);
  1283. X   }
  1284. X
  1285. X/******************************************************************************
  1286. X *
  1287. X *    make a new window
  1288. X */
  1289. X
  1290. Xint
  1291. Xm_makewindow(x,y,wide,high)
  1292. Xint  x,y,wide,high;
  1293. X   { 
  1294. X   register int count, result;
  1295. X   _m_ttyset();
  1296. X   m_newwin(x,y,wide,high);
  1297. X   m_gets(m_linebuf);
  1298. X   _m_ttyreset();
  1299. X   return(atoi(m_linebuf));
  1300. X   }
  1301. X
  1302. X/******************************************************************************
  1303. X *
  1304. X *    see if window is active
  1305. X */
  1306. X
  1307. Xint
  1308. Xis_active()
  1309. X   { 
  1310. X   *m_linebuf = '\0';
  1311. X   get_info(G_STATUS,m_fields);
  1312. X   return(*m_linebuf == 'a');
  1313. X   }
  1314. X
  1315. X/******************************************************************************
  1316. X *
  1317. X *    return last line read
  1318. X */
  1319. X
  1320. Xchar *
  1321. Xm_lastline()
  1322. X   {
  1323. X   return(m_linebuf);
  1324. X   }   
  1325. X
  1326. X/******************************************************************************
  1327. X *
  1328. X *    down load a menu
  1329. X */
  1330. X
  1331. Xmenu_load(n,count,text)
  1332. Xint n;                /* menu number */
  1333. Xint count;            /* number of menu items */
  1334. Xstruct menu_entry *text;    /* menu choices */
  1335. X   {
  1336. X   register int i, len;
  1337. X
  1338. X   if (text == (struct menu_entry *) 0)
  1339. X      return (-1);
  1340. X
  1341. X   /* calculate string lengths */
  1342. X
  1343. X   len = 2 * count + 1;
  1344. X
  1345. X   for (i=0;i<count;i++)
  1346. X       len += strlen(text[i].value) + strlen(text[i].action);
  1347. X   
  1348. X   fprintf(m_termout,"%c%d,%d%c%c",m_escchar,n,len,E_MENU,m_menuchar);
  1349. X
  1350. X   for (i=0;i<count;i++)
  1351. X      fprintf(m_termout,"%s%c",text[i].value,m_menuchar);
  1352. X
  1353. X   for (i=0;i<count;i++)
  1354. X      fprintf(m_termout,"%s%c",text[i].action,m_menuchar);
  1355. X
  1356. X   m_flush();
  1357. X   }
  1358. X
  1359. X/******************************************************************************
  1360. X *
  1361. X *    download a bitmap 
  1362. X */
  1363. X
  1364. Xm_bitload(x,y,w,h,data)
  1365. Xint x,y;
  1366. Xint w,h;
  1367. Xregister char *data;
  1368. X   {
  1369. X   register int size = h * ((w+15)&~15)/8;        /* round to 16 bit boundary */
  1370. X   m_bitld(w,h,x,y,size);
  1371. X   while(size-- > 0)
  1372. X      fputc(*data++,m_termout);
  1373. X   m_flush();
  1374. X   }
  1375. X
  1376. X/******************************************************************************
  1377. X *
  1378. X *    Set and save the terminal mode  (if required);
  1379. X */
  1380. X
  1381. Xm_ttyset()
  1382. X   {
  1383. X    int code;
  1384. X   struct sgttyb buff;
  1385. X
  1386. X   code = gtty(fileno(m_termout),sgtty__save + sgtty_cnt);
  1387. X
  1388. X   if (sgtty__save[sgtty_cnt].sg_flags&(ECHO|RAW)) {
  1389. X      buff = sgtty__save[sgtty_cnt];
  1390. X      buff.sg_flags &= ~(ECHO|RAW);
  1391. X      m_flush();
  1392. X      stty(fileno(m_termout),&buff);
  1393. X      }
  1394. X
  1395. X   if (sgtty_cnt < TTYMAX)
  1396. X      sgtty_cnt++;
  1397. X
  1398. X    return(code);
  1399. X   }
  1400. X
  1401. X
  1402. X/******************************************************************************
  1403. X *
  1404. X *    Restore the terminal mode 
  1405. X */
  1406. X
  1407. Xm_ttyreset()
  1408. X   {
  1409. X   if (sgtty_cnt)
  1410. X      sgtty_cnt--;
  1411. X   else
  1412. X      return(1);
  1413. X
  1414. X   if (sgtty__save[sgtty_cnt].sg_flags&(ECHO|RAW)) {
  1415. X      m_flush();
  1416. X      return(stty(fileno(m_termout),sgtty__save + sgtty_cnt));
  1417. X      }
  1418. X   else
  1419. X      return(0);
  1420. X   }
  1421. X
  1422. X/******************************************************************************
  1423. X *
  1424. X *    change the terminal modes
  1425. X */
  1426. X
  1427. Xm_resetflags(flags)
  1428. X   {
  1429. X   struct sgttyb buff;
  1430. X      gtty(fileno(m_termin),&buff);
  1431. X      if (buff.sg_flags & flags) {
  1432. X         buff.sg_flags &= ~flags;
  1433. X     m_flush();
  1434. X         stty(fileno(m_termin),&buff);
  1435. X         }
  1436. X   }
  1437. X
  1438. Xm_setflags(flags)
  1439. X   {
  1440. X   struct sgttyb buff;
  1441. X      gtty(fileno(m_termin),&buff);
  1442. X      if (!( buff.sg_flags & flags)) {
  1443. X         buff.sg_flags |= flags;
  1444. X     m_flush();
  1445. X         stty(fileno(m_termin),&buff);
  1446. X         }
  1447. X   }
  1448. X
  1449. X/**
  1450. X    Given a bitmap id and an icon name,
  1451. X    have mgr load that icon into that bitmap, returning the icon width
  1452. X    and height via the given integer pointers.
  1453. X    Return a positive number if successful.
  1454. X    If the icon is not loaded, set the width and height values to 0 and
  1455. X    return 0.
  1456. X*/
  1457. Xint
  1458. Xm_bitfile( bitmapid, iconname, iconwidthp, iconheightp )
  1459. Xint    bitmapid;
  1460. Xchar    *iconname;
  1461. Xint    *iconwidthp,
  1462. X    *iconheightp;
  1463. X   {
  1464. X    *iconwidthp = *iconheightp = 0;
  1465. X    m_bitfromfile( bitmapid, iconname );
  1466. X    m_flush();
  1467. X    return( sscanf( m_get(), "%d %d", iconwidthp, iconheightp ) == 2 );
  1468. X   }
  1469. X
  1470. X/*****************************************************************************
  1471. X *    parse a line into fields
  1472. X */
  1473. X
  1474. X#ifndef iswhite
  1475. X#define iswhite(x)    ((x)==' ' || (x)=='\t')
  1476. X#endif
  1477. X
  1478. Xint
  1479. Xparse(line,fields)
  1480. Xregister char *line;
  1481. Xregister char **fields;
  1482. X   {
  1483. X   int inword = 0;
  1484. X   int count = 0;
  1485. X   char *start;
  1486. X   register char c;
  1487. X
  1488. X   for(start = line;(c = *line) && c != '\n';line++)
  1489. X      if (inword && iswhite(c)) {
  1490. X         inword = 0;
  1491. X         *line = '\0';
  1492. X         *fields++ = start;
  1493. X         count++;
  1494. X         }
  1495. X      else if (!inword && !iswhite(c)) {
  1496. X         start = line;
  1497. X         inword = 1;
  1498. X         }
  1499. X
  1500. X   if (inword) {
  1501. X      *fields++ = start;
  1502. X      count++;
  1503. X      if (c == '\n')
  1504. X         *line = '\0';
  1505. X      }
  1506. X   *fields = (char *) 0;
  1507. X   return(count);
  1508. X   }
  1509. X
  1510. X/******************************************
  1511. X *    stuff for restarting
  1512. X */
  1513. X
  1514. X_Catch()
  1515. X   {
  1516. X   ioctl(fileno(m_termin),TIOCFLUSH,0);
  1517. X   longjmp(_env,1);
  1518. X   }
  1519. X
  1520. X_Clean()
  1521. X   {
  1522. X   while(m_saveenvcount < m_envcount)
  1523. X      m_pop(0);
  1524. X   exit(1);
  1525. X   }
  1526. END_OF_FILE
  1527. # end of 'lib/term.c'
  1528. fi
  1529. if test -f 'src/get_menus.c' -a "${1}" != "-c" ; then 
  1530.   echo shar: Will not clobber existing file \"'src/get_menus.c'\"
  1531. else
  1532. echo shar: Extracting \"'src/get_menus.c'\" \(11895 characters\)
  1533. sed "s/^X//" >'src/get_menus.c' <<'END_OF_FILE'
  1534. X/*                        Copyright (c) 1987 Bellcore
  1535. X *                            All Rights Reserved
  1536. X *       Permission is granted to copy or use this program, EXCEPT that it
  1537. X *       may not be sold for profit, the copyright notice must be reproduced
  1538. X *       on copies, and credit should be given to Bellcore where it is due.
  1539. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1540. X */
  1541. X/*    $Header: get_menus.c,v 4.1 88/06/21 13:33:43 bianchi Exp $
  1542. X    $Source: /tmp/mgrsrc/src/RCS/get_menus.c,v $
  1543. X*/
  1544. Xstatic char    RCSid_[] = "$Source: /tmp/mgrsrc/src/RCS/get_menus.c,v $$Revision: 4.1 $";
  1545. X
  1546. X/******************************************************************************
  1547. X *
  1548. X *    low level popup menu management routines
  1549. X */
  1550. X
  1551. X#include <stdio.h>
  1552. X#include "bitmap.h"
  1553. X#include "menu.h"
  1554. X#include "font.h"
  1555. X
  1556. X#define MAX_LIST    100    /* max number of choices */
  1557. X#define BLIP        8    /* size of cursor blip */
  1558. X
  1559. X#define BETWEEN(a,x,b)    (x)<(a)?a:((x)>(b)?b:x)
  1560. X
  1561. X#define Pr_ropall(S,f)    bit_blit(S,0,0,BIT_WIDE(S),BIT_HIGH(S),f,NULL_DATA,0,0)
  1562. X
  1563. X#define BAR(s,z)    bit_blit(s, 0, (z+1)*state->bar_sizey, \
  1564. X                               state->bar_sizex, state->bar_sizey, \
  1565. X                               BIT_NOT(BIT_DST), NULL_DATA, 0, 0);
  1566. X
  1567. X#ifdef NOTRACK
  1568. X#define TRACKON(s,x,y)
  1569. X#define TRACKOFF(s,x,y)
  1570. X#else
  1571. X#define TRACKON(s,x,y) { \
  1572. X    bit_blit(&track,0,0,BLIP,BLIP, \
  1573. X    BIT_SRC,s,(x)-BLIP/2,(y)-BLIP/2); \
  1574. X    bit_blit(s,(x)-BLIP/2,(y)-BLIP/2,BLIP,BLIP, \
  1575. X    BIT_NOT(BIT_SRC) & BIT_DST,&mouse_bull,0,0); \
  1576. X    bit_blit(s,(x)-BLIP/2,(y)-BLIP/2,BLIP,BLIP, \
  1577. X    BIT_SRC | BIT_DST,&mouse_bull2,0,0); \
  1578. X    }
  1579. X#define TRACKOFF(s,x,y) \
  1580. X    bit_blit(s,(x)-BLIP/2,(y)-BLIP/2,BLIP,BLIP, \
  1581. X    BIT_SRC,&track,0,0)
  1582. X#endif
  1583. X
  1584. X#ifndef Min
  1585. X#define Min(x,y)        ((x)>(y)?(y):(x))
  1586. X#endif
  1587. X#ifndef Max
  1588. X#define Max(x,y)        ((x)>(y)?(x):(y))
  1589. X#endif
  1590. X#define LIMIT(x,max)        (x)>(max)?1:(-(x)>(max)?-1:0)
  1591. X#define Abs(x)            ((x)>0?(x):-(x))
  1592. X#define MENU            struct menu_state
  1593. X
  1594. X/*    The height of each selection area (i.e. word) in the pop-up menu.
  1595. X    The 2 extra pixels create a 1-pixel boarder above and below each word.
  1596. X*/
  1597. X#define HIGH        (font->head.high+2)
  1598. X
  1599. Xextern BITMAP mouse_bull, mouse_bull2;
  1600. Xstatic unsigned short save_bits[BLIP];
  1601. Xstatic bit_static(track,BLIP,BLIP,save_bits,DEPTH);
  1602. X
  1603. X/* allocate space for and initialize menu */
  1604. X
  1605. Xstruct menu_state *
  1606. Xmenu_define(font,list,values,max,fg,bg)
  1607. Xstruct font *font;        /* which font to use for menu */
  1608. Xchar *list[];            /* list of menu items */
  1609. Xchar *values[];            /* list of return values */
  1610. Xint max;            /* max number of menu items */
  1611. Xint fg,bg;        /* clt values for menu color */
  1612. X   {
  1613. X   register int i, incr, count;    /* counters */
  1614. X   int size_x=0, size_y=0;
  1615. X   struct menu_state *state;    /* menu state */
  1616. X   char *malloc(), *save_line();
  1617. X   BITMAP *menu,            /* menu image */
  1618. X     *box,            /* menu pix_rect */
  1619. X     *inside,        /* box - border */
  1620. X     *save;            /* part of screen covered by menu */
  1621. X   int box_x, box_y;        /* dimensions of menu box */
  1622. X
  1623. X   /* find size of box */
  1624. X
  1625. X   for(count=0;list[count]!=(char *) 0 && count<(max>0?max:MAX_LIST); count++) {
  1626. X      size_x = Max(size_x,strlen(list[count]));
  1627. X      }
  1628. X
  1629. X   /*    The 2 extra pixels are to allow a 1-pixel border to the left and right
  1630. X    of each word.
  1631. X   */
  1632. X   size_x = size_x * font->head.wide + 2;
  1633. X   size_y = count * HIGH;
  1634. X   box_x =size_x+2*MENU_BORDER;
  1635. X   box_y =size_y+2*MENU_BORDER;
  1636. X
  1637. X   /* build box */
  1638. X
  1639. X   menu = bit_alloc(box_x,box_y,NULL_DATA,DEPTH);
  1640. X   inside = bit_create(menu,MENU_BORDER,MENU_BORDER,size_x,size_y);
  1641. X
  1642. X   /* paint text into box */
  1643. X
  1644. X#ifdef COLOR
  1645. X   Pr_ropall(menu,BIT_SRC|GETCOLOR(fg));
  1646. X   Pr_ropall(inside,BIT_SRC|GETCOLOR(bg));
  1647. X#else
  1648. X   Pr_ropall(menu,BIT_SET);
  1649. X   Pr_ropall(inside,BIT_CLR);
  1650. X#endif
  1651. X   for(i=0,incr=HIGH-1;i<count;i++,incr+=HIGH) {
  1652. X#ifdef COLOR
  1653. X      /* do local color here */
  1654. X      put_str(inside,1,incr,font,
  1655. X              BIT_SRC^BIT_DST | GETCOLOR(bg)^GETCOLOR(fg),list[i]);
  1656. X#else
  1657. X      put_str(inside,1,incr,font,BIT_SRC,list[i]);
  1658. X#endif
  1659. X      }
  1660. X
  1661. X   /* save the menu state */
  1662. X
  1663. X   if ((state = (MENU *) malloc(sizeof(struct menu_state))) == (MENU *) 0) {
  1664. X      bit_destroy(inside);
  1665. X      bit_destroy(menu);
  1666. X      return(state);
  1667. X      }
  1668. X
  1669. X   /* get the values */
  1670. X
  1671. X   if (values != (char **) 0) {
  1672. X      state -> action = (struct menu_action *) 
  1673. X               malloc(count * sizeof(struct menu_action));
  1674. X      if (state->action) for(i=0;i<count;i++) {
  1675. X         state->action[i].value = save_line(values[i]);
  1676. X         state->action[i].next_menu = -1;
  1677. X         }
  1678. X      
  1679. X      }
  1680. X   else
  1681. X      state->action = (struct menu_action *) 0;
  1682. X
  1683. X   state -> menu = menu;
  1684. X   state -> bar_sizex = size_x;
  1685. X   state -> bar_sizey = HIGH;
  1686. X   state -> count = count;
  1687. X   state -> current = 0;
  1688. X   state -> next = -1;
  1689. X   state->flags = 0;
  1690. X   state -> screen = (BITMAP *) 0;
  1691. X   state -> save = (BITMAP *) 0;
  1692. X
  1693. X   bit_destroy(inside);
  1694. X   return(state);
  1695. X   }
  1696. X
  1697. X/* put the menu on the display */
  1698. X
  1699. Xstruct menu_state *
  1700. Xmenu_setup(state,screen,x,y,start)
  1701. Xstruct menu_state *state;    /* existing menu state */
  1702. XBITMAP *screen;            /* where to put the menu */
  1703. Xint x,y;            /* current offset of mouse on screen */
  1704. Xint start;            /* preselected item */
  1705. X   {
  1706. X   register int i, incr, count;    /* counters */
  1707. X   char *malloc();
  1708. X
  1709. X   /* position the box on the screen */
  1710. X
  1711. X   if (state->BIT_WIDE(menu)>BIT_WIDE(screen) ||
  1712. X       state->BIT_WIDE(menu)>BIT_WIDE(screen) ||
  1713. X       state->save)
  1714. X       return((MENU *) 0);
  1715. X
  1716. X   x = Min(x,BIT_WIDE(screen) - state->BIT_WIDE(menu));
  1717. X   y = Min(y,BIT_HIGH(screen) - 
  1718. X                 state->BIT_HIGH(menu) - state->bar_sizey);
  1719. X   y = Max(y,state->bar_sizey+BLIP);
  1720. X
  1721. X   state->save = bit_alloc(state->BIT_WIDE(menu),state->BIT_HIGH(menu),
  1722. X                  NULL_DATA,DEPTH);
  1723. X   bit_blit(state->save,0,0,state->BIT_WIDE(menu),
  1724. X          state->BIT_HIGH(menu),BIT_SRC,screen,x,y);
  1725. X
  1726. X   /* initialize the menu */
  1727. X
  1728. X   state -> screen = screen;
  1729. X   state -> current = start;
  1730. X   state -> menu_startx = x;
  1731. X   state -> menu_starty = y;
  1732. X   state -> x_pos = state-> bar_sizex/2;
  1733. X
  1734. X   bit_blit(screen,x,y,state->BIT_WIDE(menu),state->BIT_HIGH(menu),BIT_SRC,
  1735. X          state->menu,0,0);
  1736. X
  1737. X   if (start>=0 && start<state->count) {
  1738. X       BITMAP *inside = bit_create(screen,state->menu_startx+MENU_BORDER,
  1739. X                    state->menu_starty+MENU_BORDER,
  1740. X                    state->bar_sizex,state->bar_sizey*state->count);
  1741. X       BAR(inside,start-1);
  1742. X       bit_destroy(inside);
  1743. X       }
  1744. X   
  1745. X   return(state);
  1746. X   }
  1747. X
  1748. X
  1749. X/******************************************************************************
  1750. X
  1751. Xallow user to select an item 
  1752. X
  1753. X */
  1754. X
  1755. Xint menu_get(state,mouse,button,exit)
  1756. Xstruct menu_state *state;
  1757. Xint mouse;            /* fd to read mouse data from */
  1758. Xint button;            /* button termination condition (not yet)*/
  1759. Xint exit;            /* off-menu exit codes */
  1760. X   {
  1761. X   register BITMAP *inside;    /* the menu */
  1762. X   register int y_position;
  1763. X   register int x_position;
  1764. X   int push;
  1765. X   int x_mouse, y_mouse;    /* mouse delta's */
  1766. X   int done=0;
  1767. X   int inverse;            /* selected item */
  1768. X   int count;            /* number of items */
  1769. X   int old;
  1770. X
  1771. X   if (state == (MENU *) 0)
  1772. X       return(-1);
  1773. X
  1774. X   old = inverse = state -> current;
  1775. X   count = state -> count;
  1776. X   state->exit=0;
  1777. X
  1778. X   /* set up text region */
  1779. X
  1780. X   inside = bit_create(state->screen,state->menu_startx+MENU_BORDER,
  1781. X                    state->menu_starty+MENU_BORDER - state->bar_sizey,
  1782. X                    state->bar_sizex,state->bar_sizey*(count+2));
  1783. X
  1784. X   /* make sure we aren't already exited */
  1785. X
  1786. X   if (exit&EXIT_BOTTOM && inverse >= count) {
  1787. X      old = inverse = count-1;
  1788. X      BAR(inside,inverse);    /* on */
  1789. X      }
  1790. X
  1791. X   /* set initial blip position */
  1792. X
  1793. X   x_position = state->x_pos;
  1794. X   y_position = state->bar_sizey*(inverse+1) + state->bar_sizey/2;
  1795. X
  1796. X   /* track the mouse */
  1797. X
  1798. X   TRACKON(inside,x_position,y_position);        /* on */
  1799. X   do {
  1800. X      push = mouse_get(mouse,&x_mouse,&y_mouse);
  1801. X      TRACKOFF(inside,x_position,y_position);        /* off */
  1802. X      x_position += x_mouse;
  1803. X      y_position -= y_mouse;
  1804. X      y_position = BETWEEN(BLIP, y_position, (2+count)*state->bar_sizey-BLIP);
  1805. X
  1806. X      if (x_position <= 0 && (exit&EXIT_LEFT)) {
  1807. X         state->exit = EXIT_LEFT;
  1808. X         done++;
  1809. X         }
  1810. X      else if (x_position >= BIT_WIDE(inside) && (exit&EXIT_RIGHT)) {
  1811. X         state->exit = EXIT_RIGHT;
  1812. X         done++;
  1813. X         }
  1814. X
  1815. X      x_position = BETWEEN(BLIP/2, x_position, BIT_WIDE(inside) - BLIP/2);
  1816. X
  1817. X      TRACKON(inside,x_position,y_position);        /* on */
  1818. X
  1819. X      if (done)
  1820. X         break;
  1821. X
  1822. X      /* fix bar */
  1823. X
  1824. X      inverse = (2+count) * y_position / BIT_HIGH(inside) - 1;
  1825. X      if (inverse != old) {
  1826. X         TRACKOFF(inside,x_position,y_position);        /* off */
  1827. X         if (old >=0 && old < count)
  1828. X            BAR(inside,old);        /* off */
  1829. X         if (inverse >=0 && inverse < count)
  1830. X            BAR(inside,inverse);    /* on */
  1831. X         old = inverse;
  1832. X
  1833. X         if (inverse < 0 && exit&EXIT_TOP) {
  1834. X            state->exit = EXIT_TOP;
  1835. X            done++;
  1836. X            }
  1837. X         else if (inverse >= count && exit&EXIT_BOTTOM) {
  1838. X            state->exit = EXIT_BOTTOM;
  1839. X            done++;
  1840. X            }
  1841. X         TRACKON(inside,x_position,y_position);        /* on */
  1842. X         }
  1843. X      }
  1844. X      while (push != button && !done);
  1845. X   state->current = inverse;
  1846. X   state->x_pos = x_position;
  1847. X   TRACKOFF(inside,x_position,y_position);        /* off */
  1848. X   bit_destroy(inside);
  1849. X   return(0);
  1850. X   }
  1851. X
  1852. X/******************************************************************************
  1853. X
  1854. Xremove the menu drom the screen, restore previous screen contents
  1855. X
  1856. X */
  1857. X
  1858. Xstruct menu_state *
  1859. Xmenu_remove(state)
  1860. Xstruct menu_state *state;
  1861. X   {
  1862. X   if (state == (MENU *) 0) return(state);
  1863. X   if (state->save != (BITMAP *) 0) {
  1864. X      bit_blit(state->screen,state->menu_startx,state->menu_starty,
  1865. X         state->BIT_WIDE(save),state->BIT_HIGH(save),BIT_SRC,state->save,0,0);
  1866. X      bit_destroy(state->save);
  1867. X      state->save = (BITMAP *) 0;
  1868. X      }
  1869. X   return(state);
  1870. X   }
  1871. X
  1872. X/* free space associated with a menu */
  1873. X
  1874. Xint
  1875. Xmenu_destroy(state)
  1876. Xstruct menu_state *state;
  1877. X   {
  1878. X   register int i;
  1879. X
  1880. X   menu_remove(state);
  1881. X
  1882. X   if (state->menu != (BITMAP *)0)
  1883. X      bit_destroy(state->menu);
  1884. X
  1885. X   if (state->action != (struct menu_action *) 0) {
  1886. X      for(i=0;i<state->count;i++)
  1887. X         if (state->action[i].value)
  1888. X            free(state->action[i].value);
  1889. X      free(state->action);
  1890. X      }
  1891. X
  1892. X   free(state);
  1893. X   return(0);
  1894. X   }
  1895. X
  1896. X/* put a character string into a bitmap - only used for menus */
  1897. X
  1898. Xint
  1899. Xput_str(map,x,y,font,op,str)
  1900. XBITMAP *map;
  1901. Xregister int x;
  1902. Xint y;
  1903. Xstruct font *font;
  1904. Xint op;
  1905. Xregister char *str;
  1906. X   {
  1907. X   register char c;
  1908. X   register int wide = font->head.wide;
  1909. X   register int high = font->head.high;
  1910. X
  1911. X   while (c = *str++) {
  1912. X      bit_blit(map,x,y-high,wide,high,op,font->glyph[c],0,0);
  1913. X      x+=wide;
  1914. X      }
  1915. X   }
  1916. X
  1917. X/* copy a menu  - for environment stacks */
  1918. X
  1919. Xstruct menu_state *
  1920. Xmenu_copy(menu)
  1921. Xregister struct menu_state *menu;
  1922. X   {
  1923. X   register struct menu_state *tmp;
  1924. X   register int i;
  1925. X   char *alloc(), *malloc(), *save_line();
  1926. X
  1927. X   if (menu == (struct menu_state *) 0)
  1928. X      return(menu);
  1929. X
  1930. X   if ((tmp = (struct menu_state *) malloc(sizeof(struct menu_state))) 
  1931. X                                                   == (struct menu_state *) 0)
  1932. X      return((struct menu_state *) 0);
  1933. X
  1934. X   bcopy((char *) menu,(char *)tmp,sizeof(struct menu_state));
  1935. X
  1936. X   /* copy menu image */
  1937. X
  1938. X   if (menu->menu) {
  1939. X      tmp->menu = bit_alloc(BIT_WIDE(menu->menu),
  1940. X                            BIT_HIGH(menu->menu),NULL_DATA,DEPTH);
  1941. X      bit_blit(tmp->menu,0,0,BIT_WIDE(tmp->menu),BIT_HIGH(tmp->menu),
  1942. X                            BIT_SRC,menu->menu,0,0);
  1943. X      }
  1944. X
  1945. X   /* copy menu values */
  1946. X
  1947. X   if (menu->action != (struct menu_action *) 0) {
  1948. X      tmp->action = (struct menu_action *) 
  1949. X                    malloc(sizeof(struct menu_action)*menu->count);
  1950. X      if (tmp->action)
  1951. X         for(i=0;i<menu->count;i++) {
  1952. X            tmp->action[i].value = save_line(menu->action[i].value);
  1953. X            tmp->action[i].next_menu = menu->action[i].next_menu;
  1954. X            } 
  1955. X      }
  1956. X
  1957. X   return(tmp);
  1958. X   }
  1959. END_OF_FILE
  1960. # end of 'src/get_menus.c'
  1961. fi
  1962. echo shar: End of archive 35 \(of 61\).
  1963. cp /dev/null ark35isdone
  1964. MISSING=""
  1965. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  1966.     21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 \
  1967.     38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 \
  1968.     55 56 57 58 59 60 61 ; do
  1969.     if test ! -f ark${I}isdone ; then
  1970.     MISSING="${MISSING} ${I}"
  1971.     fi
  1972. done
  1973. if test "${MISSING}" = "" ; then
  1974.     echo You have unpacked all 61 archives.
  1975.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1976. else
  1977.     echo You still need to unpack the following archives:
  1978.     echo "        " ${MISSING}
  1979. fi
  1980. ##  End of shell archive.
  1981. exit 0
  1982.