home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2974 < prev    next >
Internet Message Format  |  1991-03-04  |  56KB

  1. From: guido@cwi.nl (Guido van Rossum)
  2. Newsgroups: alt.sources
  3. Subject: STDWIN 0.9.5, Part 13/19
  4. Message-ID: <3077@charon.cwi.nl>
  5. Date: 4 Mar 91 11:58:15 GMT
  6.  
  7. Archive-name: stdwin/part13
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 13 (of 19)."
  16. # Contents:  Appls/bed/bed.c Appls/dpv/dpvcontrol.c
  17. #   Conf/proto.os.amoeba Ports/alfa/event.c Ports/alfa/syswin.c
  18. #   Ports/mac/macwin.h Ports/mac/stdwin.c Ports/x11/cursor.c
  19. #   Ports/x11/event.c
  20. # Wrapped by guido@voorn.cwi.nl on Mon Mar  4 12:37:30 1991
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. if test -f 'Appls/bed/bed.c' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'Appls/bed/bed.c'\"
  24. else
  25. echo shar: Extracting \"'Appls/bed/bed.c'\" \(5379 characters\)
  26. sed "s/^X//" >'Appls/bed/bed.c' <<'END_OF_FILE'
  27. X#include <stdio.h>
  28. X#include <ctype.h>
  29. X#include "bed.h"
  30. X#include "menu.h"
  31. X
  32. X#define MINSQRSIZE    5
  33. X#define MAXSQRSIZE    15
  34. X
  35. XMENU    *pfmenu ;
  36. XMENU    *pmmenu ;
  37. XMENU    *popmenu ;
  38. X
  39. Xint    sqrsize ;
  40. X
  41. Xint    map_width = DEF_COLS ;
  42. Xint    map_height = DEF_ROWS ;
  43. X
  44. Xchar    *raster = NULL ;
  45. Xint    raster_lenght ;
  46. Xint    stride ;
  47. X
  48. Xint    lastbyte ;
  49. Xchar    bits[] = { 0xFF, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F } ;
  50. X
  51. Xchar    *title = NULL ;
  52. Xchar    *fname = NULL ;
  53. X
  54. XWINDOW    *win ;
  55. X
  56. Xbool    changed = FALSE ;
  57. X
  58. Xbool    text_only = FALSE ;
  59. X
  60. Xextern bool    drawline ;
  61. X
  62. Xextern bool    drawcircle ;
  63. X
  64. Xextern bool    selrect ;
  65. Xextern int    sr_left ;
  66. Xextern int    sr_top ;
  67. Xextern int    sr_right ;
  68. Xextern int    sr_bottom ;
  69. X
  70. Xextern void    invertbit () ;
  71. X
  72. Xvoid
  73. Xdrawproc (win, left, top, right, bottom)
  74. X    WINDOW    *win ;
  75. X    int    left ;
  76. X    int    top ;
  77. X    int    right ;
  78. X    int    bottom ;
  79. X{
  80. X    int     row ;
  81. X    register int     col ;
  82. X    register int    l ;
  83. X    register int    r ;
  84. X    int    t ;
  85. X    int    b ;
  86. X    int    rend ;
  87. X    int fcol, fbyte, fbit, flr ;
  88. X
  89. X    if (left < 0) left = 0 ;
  90. X    if (right > map_width * sqrsize) right = map_width * sqrsize ;
  91. X    if (top < 0) top = 0 ;
  92. X    if (bottom > map_height * sqrsize ) bottom = map_height * sqrsize ;
  93. X
  94. X    rend = (right+sqrsize-1) / sqrsize ;
  95. X
  96. X    fcol = left / sqrsize ;
  97. X    flr =  fcol * sqrsize ;
  98. X    fbyte = fcol / 8 ;
  99. X    fbit = fcol % 8 ;
  100. X
  101. X    for (row = top / sqrsize, t = row * sqrsize, b = t + sqrsize ;
  102. X         t < bottom ;
  103. X         ++row, t += sqrsize, b = t + sqrsize) {
  104. X
  105. X        register char    *byte ;
  106. X        register int    pbit ;
  107. X
  108. X        col    = fcol ;
  109. X        l = r    = flr ;
  110. X        byte    = raster + (row * stride) + fbyte ;
  111. X        pbit    = fbit ;
  112. X
  113. X        while (col++ < rend) {
  114. X            if (*byte & (1 << pbit)) {
  115. X                r += sqrsize ;
  116. X            }
  117. X            else {
  118. X                if (l < r) {
  119. X                    wpaint(l, t, r, b);
  120. X                    l = r ;
  121. X                }
  122. X                l += sqrsize ;
  123. X                r = l ;
  124. X            }
  125. X
  126. X            if (++pbit >= 8) {
  127. X                pbit = 0 ;
  128. X                ++byte ;
  129. X            }
  130. X        }
  131. X
  132. X        if (l < r) wpaint (l, t, r, b) ;
  133. X    }
  134. X
  135. X    if (drawline) plotline (invertbit, TRUE) ;
  136. X    else if (drawcircle) plotline (invertbit, TRUE) ;
  137. X    else if (selrect)
  138. X        wxorrect (sr_left * sqrsize, sr_top * sqrsize,
  139. X            sr_right * sqrsize, sr_bottom * sqrsize) ;
  140. X}
  141. X
  142. Xvoid
  143. Xnewraster ()
  144. X{
  145. X    int    i ;
  146. X
  147. X    if (raster != NULL) {
  148. X        free (raster) ;
  149. X        raster = NULL ;
  150. X    }
  151. X
  152. X    lastbyte = map_width % 8 ;
  153. X    stride = (map_width + 7) / 8 ;
  154. X    raster_lenght = stride * map_height ;
  155. X
  156. X    raster = (char *) malloc (raster_lenght) ;
  157. X    if (raster == NULL) {
  158. X        wdone () ;
  159. X        fprintf (stderr, "cannot get enough memory\n") ;
  160. X        exit (1) ;
  161. X    }
  162. X
  163. X    for (i = 0 ; i < raster_lenght ; ++i)
  164. X        raster[i] = 0 ;
  165. X}
  166. X
  167. Xvoid
  168. Xsetsqrsize ()
  169. X{    
  170. X    if (wlineheight () == 1)
  171. X        text_only = sqrsize = 1 ;
  172. X    else {
  173. X        sqrsize = 1 ;
  174. X    /*    int    width ;
  175. X        int    height ;
  176. X        int    swidth ;
  177. X        int    sheight ;
  178. X
  179. X        wgetscrsize (&width, &height) ;
  180. X
  181. X        swidth = (2 * width) / (3 * map_width) ;
  182. X        sheight = (2 * height) / (3 * map_height) ;
  183. X        sqrsize = swidth < sheight ? swidth : sheight ;
  184. X        if (sqrsize < MINSQRSIZE)
  185. X            sqrsize = MINSQRSIZE ;
  186. X        else if (sqrsize > MAXSQRSIZE)
  187. X            sqrsize = MAXSQRSIZE ;
  188. X    */
  189. X    }
  190. X}
  191. X
  192. Xvoid
  193. Xsetup()
  194. X{
  195. X    int    i ;
  196. X
  197. X    setsqrsize () ;
  198. X
  199. X    wsetdefwinsize (map_width * sqrsize, map_height * sqrsize) ;
  200. X    
  201. X    win = wopen (title == NULL ? "Untitled" : title, drawproc) ;
  202. X    if (win == NULL) {
  203. X        wmessage ("Can't open window") ;
  204. X        return ;
  205. X    }
  206. X
  207. X    wsetdocsize (win, map_width * sqrsize, map_height * sqrsize) ;
  208. X    
  209. X    pfmenu = wmenucreate(FILE_MENU, "File"); 
  210. X    wmenuadditem (pfmenu, "Open", 'O') ;
  211. X    wmenuadditem (pfmenu, "New", 'N') ;
  212. X    wmenuadditem (pfmenu, "", -1) ;
  213. X    wmenuadditem (pfmenu, "Save", 'S') ;
  214. X    wmenuadditem (pfmenu, "Save As ...", -1) ;
  215. X    wmenuadditem (pfmenu, "", -1) ;
  216. X    wmenuadditem (pfmenu, "Quit", 'Q') ;
  217. X
  218. X    pmmenu = wmenucreate (MODE_MENU, "Mode") ;
  219. X    wmenuadditem (pmmenu, "Pencil", -1) ;
  220. X    wmenuadditem (pmmenu, "Line", -1) ;
  221. X    wmenuadditem (pmmenu, "Circle", -1) ;
  222. X    wmenuadditem (pmmenu, "Select", -1) ;
  223. X
  224. X    popmenu = wmenucreate(OP_MENU, "Operations") ;
  225. X    wmenuadditem (popmenu, "Clear bits", -1) ;
  226. X    wmenuadditem (popmenu, "Set bits", -1) ;
  227. X    wmenuadditem (popmenu, "Invert bits", -1) ;
  228. X    wmenuadditem (popmenu, "", -1) ;
  229. X    wmenuadditem (popmenu, "Transpose major", -1) ;
  230. X    wmenuadditem (popmenu, "Transpose minor", -1) ;
  231. X    wmenuadditem (popmenu, "Rotate left", -1) ;
  232. X    wmenuadditem (popmenu, "Rotate right", -1) ;
  233. X    wmenuadditem (popmenu, "Flip horizontal", -1) ;
  234. X    wmenuadditem (popmenu, "Flip vertical", -1) ;
  235. X    wmenuadditem (popmenu, "Zoom in", '+') ;
  236. X    wmenuadditem (popmenu, "Zoom out", '-') ;
  237. X
  238. X    wmenucheck (pmmenu, PENCIL_ITEM, TRUE) ;
  239. X
  240. X    for (i = TRANS_MAJ_ITEM ; i <= FLIP_VERT_ITEM ; i++)
  241. X        wmenuenable (popmenu, i, FALSE) ;
  242. X}
  243. X
  244. Xvoid
  245. Xmainloop ()
  246. X{
  247. X    for (;;) {
  248. X        EVENT    e ;
  249. X    
  250. X        wgetevent (&e) ;
  251. X        switch (e.type) {
  252. X        case WE_MOUSE_DOWN :
  253. X        case WE_MOUSE_MOVE :
  254. X        case WE_MOUSE_UP :
  255. X            do_mouse (&e) ;
  256. X            break;
  257. X        case WE_COMMAND :
  258. X            switch (e.u.command) {
  259. X            case WC_CLOSE :
  260. X                if (do_quit ())
  261. X                    return ;
  262. X                break ;
  263. X            case WC_CANCEL :
  264. X                return ;
  265. X            }
  266. X            break ;
  267. X        case WE_CLOSE :
  268. X            if (do_quit ())
  269. X                return ;
  270. X            break ;
  271. X        case WE_MENU :
  272. X            switch (e.u.m.id) {
  273. X            case FILE_MENU :
  274. X                if (do_file_menu (&e))
  275. X                    return ;
  276. X                break ;
  277. X            case MODE_MENU :
  278. X                do_mode_menu (&e) ;
  279. X                break ;
  280. X            case OP_MENU :
  281. X                do_op_menu (&e) ;
  282. X                break ;
  283. X            }
  284. X            break ;
  285. X        }
  286. X    }
  287. X}
  288. X
  289. Xmain (argc, argv)
  290. X    int    argc ;
  291. X    char    *argv[] ;
  292. X{
  293. X    extern char    *strip () ;
  294. X
  295. X    winitargs (&argc, &argv) ;
  296. X    
  297. X    if (argc > 1) {
  298. X        fname = strdup (argv[1]) ;
  299. X        title = strip (fname) ;
  300. X        if (!readbitmap ()) {
  301. X            free (fname) ;
  302. X            fname = title = NULL ;
  303. X            newraster () ;
  304. X        }
  305. X    }
  306. X    else
  307. X        newraster () ;
  308. X
  309. X    setup () ;
  310. X
  311. X    mainloop () ;
  312. X
  313. X    wdone () ;
  314. X
  315. X    exit (0) ;
  316. X}
  317. END_OF_FILE
  318. if test 5379 -ne `wc -c <'Appls/bed/bed.c'`; then
  319.     echo shar: \"'Appls/bed/bed.c'\" unpacked with wrong size!
  320. fi
  321. # end of 'Appls/bed/bed.c'
  322. fi
  323. if test -f 'Appls/dpv/dpvcontrol.c' -a "${1}" != "-c" ; then 
  324.   echo shar: Will not clobber existing file \"'Appls/dpv/dpvcontrol.c'\"
  325. else
  326. echo shar: Extracting \"'Appls/dpv/dpvcontrol.c'\" \(5402 characters\)
  327. sed "s/^X//" >'Appls/dpv/dpvcontrol.c' <<'END_OF_FILE'
  328. X/* dpv -- ditroff previewer.  User interface, controlling the rest. */
  329. X
  330. X#include "dpv.h"
  331. X#include "dpvmachine.h"
  332. X#include "dpvoutput.h"
  333. X
  334. X#ifdef unix
  335. X#define DO_PRINTMENU
  336. X#endif
  337. X
  338. Xchar *devname;
  339. X
  340. Xpreview(file, firstpage)
  341. X    char *file;
  342. X    int firstpage;
  343. X{
  344. X    initialize(file, firstpage);
  345. X    addmenus();
  346. X    eventloop(file);
  347. X    cleanup();
  348. X    wdone();
  349. X}
  350. X
  351. XMENU *mainmmenu;
  352. X
  353. X/* Menu IDs */
  354. X#define MAINMENU    1
  355. X#define PRINTMENU    2
  356. X
  357. X/* Control menu items */
  358. X#define FIRSTPAGE    0
  359. X#define PREVPAGE    1
  360. X#define NEXTPAGE    2
  361. X#define LASTPAGE    3
  362. X/* --- */
  363. X#define GOTOPAGE    5
  364. X/* --- */
  365. X#define QUIT        7
  366. X
  367. X#ifdef DO_PRINTMENU
  368. X
  369. XMENU *printmenu;
  370. X
  371. X#define MAXNPRINT 50    /* Max # items in print menu */
  372. X
  373. Xstruct _printitem {
  374. X    char *text;    /* Menu item text */
  375. X    char *device;    /* Required device, or NULL if N/A */
  376. X    char *command;    /* Shell command to execute */
  377. X} printitems[MAXNPRINT]= {
  378. X    /* XXX This is extremely site-dependent */
  379. X    {"Typeset on Harris",        "har",    "lpr -Phar -n %s"},
  380. X    {"Harris emulation on Agfa",    "har",    "toagfa %s"},
  381. X    {"Print on ${PRINTER-psc}",    "psc",    "lpr -P${PRINTER-psc} -n %s"},
  382. X    {"Print on Oce",        "psc",    "lpr -Poce -n %s"},
  383. X    {"Print on PostScript",        "psc",    "lpr -Ppsc -n %s"},
  384. X    {"Print on Agfa",        "psc",    "lpr -Pagfa -n %s"},
  385. X};
  386. X
  387. Xint nprint;
  388. X
  389. Xint
  390. Xcountprintmenu()
  391. X{
  392. X    while (nprint < MAXNPRINT && printitems[nprint].text != NULL)
  393. X        nprint++;
  394. X}
  395. X
  396. Xint
  397. Xaddprinter(name)
  398. X    char *name;
  399. X{
  400. X    char buf[100];
  401. X    countprintmenu();
  402. X    if (nprint >= MAXNPRINT) {
  403. X        error(WARNING, "too many printer definitions, rest igonred");
  404. X        return;
  405. X    }
  406. X    sprintf(buf, "Print on %s", name);
  407. X    printitems[nprint].text = strdup(buf);
  408. X    printitems[nprint].device = NULL; /* Unspecified */
  409. X    sprintf(buf, "lpr -P%s -n %%s", name);
  410. X    printitems[nprint].command = strdup(buf);
  411. X    nprint++;
  412. X}
  413. X
  414. X#endif
  415. X
  416. Xaddmenus()
  417. X{
  418. X    MENU *mp;
  419. X    int i;
  420. X    
  421. X    mainmmenu= mp= wmenucreate(MAINMENU, "Command");
  422. X    
  423. X    wmenuadditem(mp, "First page", 'F');
  424. X    wmenuadditem(mp, "Previous page", 'P');
  425. X    wmenuadditem(mp, "Next page", 'N');
  426. X    wmenuadditem(mp, "Last page", 'L');
  427. X    wmenuadditem(mp, "", -1);
  428. X    wmenuadditem(mp, "Go to page...", 'G');
  429. X    wmenuadditem(mp, "", -1);
  430. X    wmenuadditem(mp, "Quit", 'Q');
  431. X    
  432. X#ifdef DO_PRINTMENU
  433. X    countprintmenu();
  434. X    printmenu= mp= wmenucreate(PRINTMENU, "Print");
  435. X    for (i= 0; i < nprint; ++i) {
  436. X        wmenuadditem(mp, printitems[i].text, -1);
  437. X        if (!canprint(i))
  438. X            wmenuenable(mp, i, FALSE);
  439. X    }
  440. X#endif
  441. X}
  442. X
  443. Xeventloop(filename)
  444. X    char *filename;
  445. X{
  446. X    int num= -1;
  447. X    for (;;) {
  448. X        EVENT e;
  449. X        int lastnum= num;
  450. X        wgetevent(&e);
  451. X        num= -1;
  452. X        switch(e.type) {
  453. X        
  454. X        case WE_MENU:
  455. X            switch (e.u.m.id) {
  456. X            case MAINMENU:
  457. X                if (e.u.m.item == QUIT)
  458. X                    return;
  459. X                do_mainmenu(e.u.m.item);
  460. X                break;
  461. X            case PRINTMENU:
  462. X                do_printmenu(filename, e.u.m.item);
  463. X                break;
  464. X            }
  465. X            break;
  466. X        
  467. X        case WE_CHAR:
  468. X            /* The mnemonics used here may remind you of
  469. X               the main menu's shortcuts, the 'vi' editor,
  470. X               the 'more' pages, or the 'rn' news reader... */
  471. X            switch (e.u.character) {
  472. X            case 'q':
  473. X            case 'Q':
  474. X                return;
  475. X            case ' ':
  476. X            case '+':
  477. X            case 'n':
  478. X            case 'N':
  479. X                forwpage(lastnum);
  480. X                break;
  481. X            case '-':
  482. X                if (lastnum > 0)
  483. X                    backpage(lastnum);
  484. X                else
  485. X                    gotopage(prevpage);
  486. X                break;
  487. X            case 'b':
  488. X            case 'B':
  489. X            case 'p':
  490. X            case 'P':
  491. X                backpage(lastnum);
  492. X                break;
  493. X            case '^':
  494. X            case 'f':
  495. X            case 'F':
  496. X                gotopage(1);
  497. X                break;
  498. X            case '$':
  499. X                gotopage(32000);
  500. X                break;
  501. X            case 'g':
  502. X            case 'G':
  503. X            case 'l':
  504. X            case 'L':
  505. X                if (lastnum > 0)
  506. X                    gotopage(lastnum);
  507. X                else
  508. X                    gotopage(32000);
  509. X                break;
  510. X            case '.':
  511. X                if (lastnum > 0)
  512. X                    gotopage(lastnum);
  513. X                else
  514. X                    changeall(); /* Force a redraw */
  515. X                break;
  516. X            default:
  517. X                if (isdigit(e.u.character)) {
  518. X                    num= e.u.character - '0';
  519. X                    if (lastnum > 0)
  520. X                        num += 10*lastnum;
  521. X                }
  522. X                else {
  523. X                    wfleep();
  524. X                    lastnum= 0;
  525. X                }
  526. X            }
  527. X            break;
  528. X        
  529. X        case WE_CLOSE:
  530. X            return;
  531. X
  532. X        case WE_COMMAND:
  533. X            switch (e.u.command) {
  534. X            case WC_RETURN:
  535. X                if (lastnum > 0)
  536. X                    gotopage(lastnum);
  537. X                else
  538. X                    forwpage(1);
  539. X                break;
  540. X            case WC_DOWN:
  541. X                forwpage(lastnum);
  542. X                break;
  543. X            case WC_UP:
  544. X            case WC_BACKSPACE:
  545. X                backpage(lastnum);
  546. X                break;
  547. X            case WC_CLOSE:
  548. X            /*
  549. X            case WC_CANCEL:
  550. X            */
  551. X                return;
  552. X            default:
  553. X                wfleep();
  554. X            }
  555. X            break;
  556. X        
  557. X        }
  558. X    }
  559. X}
  560. X
  561. Xdo_mainmenu(item)
  562. X    int item;
  563. X{
  564. X    switch (item) {
  565. X    case FIRSTPAGE:
  566. X        gotopage(1);
  567. X        break;
  568. X    case PREVPAGE:
  569. X        backpage(1);
  570. X        break;
  571. X    case NEXTPAGE:
  572. X        forwpage(1);
  573. X        break;
  574. X    case LASTPAGE:
  575. X        gotopage(32000);
  576. X        break;
  577. X    case GOTOPAGE:
  578. X        {
  579. X            static char buf[10];
  580. X            int num;
  581. X            char extra;
  582. X            if (!waskstr("Go to page:", buf, sizeof buf)
  583. X                    || buf[0] == '\0')
  584. X                return;
  585. X            if (sscanf(buf, " %d %c", &num, &extra) != 1 ||
  586. X                num <= 0) {
  587. X                wmessage("Invalid page number");
  588. X                return;
  589. X            }
  590. X            gotopage(num);
  591. X        }
  592. X        break;
  593. X    }
  594. X}
  595. X
  596. Xdo_printmenu(filename, item)
  597. X    char *filename;
  598. X    int item;
  599. X{
  600. X#ifdef DO_PRINTMENU
  601. X    char buf[256];
  602. X    int sts;
  603. X    
  604. X    if (item < 0 || item >= nprint)
  605. X        return;
  606. X    
  607. X    if (!canprint(item)) {
  608. X        sprintf(buf, "Can't convert %s output to %s",
  609. X            devname == NULL ? "unspecified" : devname,
  610. X            printitems[item].device);
  611. X        wmessage(buf);
  612. X        return;
  613. X    }
  614. X    
  615. X    sprintf(buf, printitems[item].command, filename);
  616. X    sts= system(buf);
  617. X    if (sts != 0) {
  618. X        sprintf(buf, "Print command failed, exit status 0x%x", sts);
  619. X        wmessage(buf);
  620. X    }
  621. X#endif
  622. X}
  623. X
  624. X#ifdef DO_PRINTMENU
  625. Xstatic bool
  626. Xcanprint(item)
  627. X    int item;
  628. X{
  629. X    return printitems[item].device == NULL ||
  630. X        devname != NULL &&
  631. X            strcmp(printitems[item].device, devname) == 0;
  632. X}
  633. X#endif
  634. END_OF_FILE
  635. if test 5402 -ne `wc -c <'Appls/dpv/dpvcontrol.c'`; then
  636.     echo shar: \"'Appls/dpv/dpvcontrol.c'\" unpacked with wrong size!
  637. fi
  638. # end of 'Appls/dpv/dpvcontrol.c'
  639. fi
  640. if test -f 'Conf/proto.os.amoeba' -a "${1}" != "-c" ; then 
  641.   echo shar: Will not clobber existing file \"'Conf/proto.os.amoeba'\"
  642. else
  643. echo shar: Extracting \"'Conf/proto.os.amoeba'\" \(1230 characters\)
  644. sed "s/^X//" >'Conf/proto.os.amoeba' <<'END_OF_FILE'
  645. X
  646. X#
  647. X# Definitions for operating system Amoeba
  648. X#
  649. X
  650. X# Define the name of this O.S. here.
  651. X#
  652. XOS=        amoeba
  653. X
  654. X# Choose ONE of the following definitions of RANLIB.
  655. X# BSD-based systems will need ranlib to be called after a library is
  656. X# changed.
  657. X# SYSV-based systems don't have ranlib; the value 'true' makes Make happy.
  658. X#
  659. XRANLIB=        ranlib            # for BSD
  660. X#RANLIB=    true            # for SYSV
  661. X
  662. X# Define the name of the script used to update the dependencies in
  663. X# the Makefile.
  664. X# Choices are:
  665. X#    slowmkdep -- always works (as far as I know)
  666. X#    fastmkdep -- uses cc -M, which isn't always available
  667. X#    makedepend -- Todd Brunhoff's superfast tool (comes with X11)
  668. X#                  (This needs -Dunix because of configure.h)
  669. X# You may also place this definition in the proto.arch.* file if no
  670. X# method works for every architecture supported by this OS.
  671. X#
  672. X#MKDEP=        $(CONF)/slowmkdep
  673. X#MKDEP=        $(CONF)/fastmkdep
  674. X#MKDEP=        makedepend -Dunix
  675. X
  676. X# Define the system libraries to link with programs that use termcap and X11
  677. X# (In some cases these are architecture-dependent)
  678. X#
  679. X#LIBTERMCAP=    -ltermcap
  680. X#LIBX11=    -lX11
  681. X
  682. X# Other OS-specific choices (-I flags, -D flags, compiler options)
  683. X#
  684. XOSINCLS=    -I/usr/amoeba/src/h -I/usr/amoeba/src/h/posix
  685. XOSDEFS=        -DAMOEBA -DSYSV
  686. XOSOPTS=        
  687. END_OF_FILE
  688. if test 1230 -ne `wc -c <'Conf/proto.os.amoeba'`; then
  689.     echo shar: \"'Conf/proto.os.amoeba'\" unpacked with wrong size!
  690. fi
  691. # end of 'Conf/proto.os.amoeba'
  692. fi
  693. if test -f 'Ports/alfa/event.c' -a "${1}" != "-c" ; then 
  694.   echo shar: Will not clobber existing file \"'Ports/alfa/event.c'\"
  695. else
  696. echo shar: Extracting \"'Ports/alfa/event.c'\" \(6191 characters\)
  697. sed "s/^X//" >'Ports/alfa/event.c' <<'END_OF_FILE'
  698. X/* STDWIN -- EVENTS. */
  699. X
  700. X#include "alfa.h"
  701. X
  702. X/* There are three levels of event processing.
  703. X   The lowest ('raw') level only inputs single characters.
  704. X   The middle ('sys') level translates sequences of keys to menu shortcuts
  705. X   and 'commands'.
  706. X   The highest ('appl') level executes certain commands and can call the
  707. X   interactive menu selection code.  It also sets the window parameter.
  708. X   For each level there are variants to wait or poll.
  709. X   Additional routines to get from one level to another:
  710. X   wmapchar: inspect key map and possibly convert char event
  711. X   wsyscommand: execute/transform system menu
  712. X
  713. X/* Raw event -- read one character.  If blocking is FALSE,
  714. X   don't read if trmavail() returns -1, meaning it can't tell whether
  715. X   there is input or not.  In that case only synchronous input works. */
  716. X
  717. X
  718. Xstatic bool
  719. Xwrawevent(ep, blocking)
  720. X    EVENT *ep;
  721. X    bool blocking;
  722. X{
  723. X    if (!blocking && trmavail() <= 0)
  724. X        return FALSE;
  725. X    ep->u.character= trminput();
  726. X    if (ep->u.character < 0) {
  727. X        ep->type= WE_NULL;
  728. X        return FALSE;
  729. X    }
  730. X    else {
  731. X        ep->type= WE_CHAR;
  732. X        return TRUE;
  733. X    }
  734. X}
  735. X
  736. Xstatic void wmapchar(); /* Forward */
  737. X
  738. X/* System event -- read a character and translate using the key map. */
  739. X
  740. Xbool
  741. Xwsysevent(ep, blocking)
  742. X    EVENT *ep;
  743. X    bool blocking;
  744. X{
  745. X    struct keymap mapentry;
  746. X    
  747. X    if (!wrawevent(ep, blocking))
  748. X        return FALSE;
  749. X    /* Using a temporary to avoid a tahoe C compiler bug */
  750. X    mapentry= _wprimap[ep->u.character & 0xff];
  751. X    wmapchar(ep, mapentry);
  752. X    return ep->type != WE_NULL;
  753. X}
  754. X
  755. X/* Key map translation from raw event.
  756. X   This may read more characters if the start of a multi-key sequence is
  757. X   found. */
  758. X
  759. Xstatic void
  760. Xwmapchar(ep, mapentry)
  761. X    EVENT *ep;
  762. X    struct keymap mapentry;
  763. X{
  764. X    switch (mapentry.type) {
  765. X    
  766. X    case SHORTCUT:
  767. X        ep->type= WE_MENU;
  768. X        ep->u.m.id= mapentry.id;
  769. X        ep->u.m.item= mapentry.item;
  770. X        break;
  771. X    
  772. X    case SECONDARY:
  773. X        if (wrawevent(ep, TRUE)) {
  774. X            struct keymap *map;
  775. X            struct keymap *altmap= NULL;
  776. X            for (map= _wsecmap[mapentry.id];
  777. X                map->type != SENTINEL;
  778. X                ++map) {
  779. X                if (map->key == ep->u.character) {
  780. X                    wmapchar(ep, *map);
  781. X                    return;
  782. X                }
  783. X                else if (islower(ep->u.character) &&
  784. X                    map->key == toupper(ep->u.character))
  785. X                    altmap= map;
  786. X            }
  787. X            if (altmap != NULL) {
  788. X                wmapchar(ep, *altmap);
  789. X                return;
  790. X            }
  791. X        }
  792. X        trmbell();
  793. X        ep->type= WE_NULL;
  794. X        break;
  795. X    
  796. X    }
  797. X}
  798. X
  799. Xvoid
  800. Xwgoto(ep, type)
  801. X    EVENT *ep;
  802. X    int type;
  803. X{
  804. X    int h, v;
  805. X    
  806. X    trmsense(&v, &h);
  807. X    if (v >= 0) {
  808. X        WINDOW *win;
  809. X        for (win= &winlist[1]; win < &winlist[MAXWINDOWS]; ++win) {
  810. X            if (win->open && v >= win->top && v < win->bottom) {
  811. X                if (win == front) {
  812. X                    ep->type= type;
  813. X                    ep->u.where.h= h;
  814. X                    ep->u.where.v= v + win->offset;
  815. X                    ep->u.where.clicks= 1;
  816. X                    ep->u.where.button= 1;
  817. X                    ep->u.where.mask=
  818. X                        (type == WE_MOUSE_UP ? 0 : 1);
  819. X                    return;
  820. X                }
  821. X                wsetactive(win);
  822. X                break;
  823. X            }
  824. X        }
  825. X    }
  826. X    ep->type= WE_NULL;
  827. X}
  828. X
  829. Xvoid
  830. Xwmouseup(ep)
  831. X    EVENT *ep;
  832. X{
  833. X    int h, v;
  834. X    
  835. X    trmsense(&v, &h);
  836. X    if (v < 0)
  837. X        ep->type= WE_NULL;
  838. X    else {
  839. X        ep->type= WE_MOUSE_UP;
  840. X        ep->u.where.h= h;
  841. X        ep->u.where.v= v + front->offset;
  842. X        ep->u.where.clicks= 1;
  843. X        ep->u.where.button= 1;
  844. X        ep->u.where.mask= 0;
  845. X    }
  846. X}
  847. X
  848. Xstatic void wdoupdates(); /* Forward */
  849. X
  850. X/* Application event. */
  851. X
  852. Xstatic EVENT ebuf;
  853. X
  854. Xvoid
  855. Xwungetevent(ep)
  856. X    EVENT *ep;
  857. X{
  858. X    ebuf= *ep;
  859. X}
  860. X
  861. Xbool
  862. Xwpollevent(ep)
  863. X    EVENT *ep;
  864. X{
  865. X    return wevent(ep, FALSE);
  866. X}
  867. X
  868. Xvoid
  869. Xwgetevent(ep)
  870. X    EVENT *ep;
  871. X{
  872. X    (void) wevent(ep, TRUE);
  873. X}
  874. X
  875. Xstatic bool
  876. Xwevent(ep, blocking)
  877. X    EVENT *ep;
  878. X    bool blocking;
  879. X{
  880. X    static int lasttype= WE_NULL;
  881. X    
  882. X    if (ebuf.type != WE_NULL) {
  883. X        *ep= ebuf;
  884. X        ebuf.type= WE_NULL;
  885. X        return TRUE;
  886. X    }
  887. X    
  888. X    ep->type= WE_NULL;
  889. X    ep->window= NULL;
  890. X    if (lasttype == WE_MOUSE_DOWN)
  891. X        wmouseup(ep);
  892. X    while (ep->type == WE_NULL) {
  893. X        if (front != wasfront) {
  894. X            if (wasfront != NULL) {
  895. X                ep->type= WE_DEACTIVATE;
  896. X                ep->window= wasfront;
  897. X                wasfront= NULL;
  898. X            }
  899. X            else {
  900. X                menubarchanged();
  901. X                ep->type= WE_ACTIVATE;
  902. X                wasfront= front;
  903. X            }
  904. X        }
  905. X        else {
  906. X            if (trmavail() <= 0)
  907. X                wdoupdates(ep);
  908. X            if (ep->type == WE_NULL) {
  909. X                /* Remove this call if no select() exists */
  910. X                if (_w_checktimer(ep, blocking))
  911. X                    break;
  912. X                if (!wsysevent(ep, blocking)) {
  913. X                    ep->type= WE_NULL;
  914. X                    break;
  915. X                }
  916. X                if (ep->type == WE_MENU && ep->u.m.id == 0)
  917. X                    wsyscommand(ep);
  918. X            }
  919. X        }
  920. X    }
  921. X    if (ep->window == NULL && front != syswin)
  922. X        ep->window= front;
  923. X    lasttype= ep->type;
  924. X    return ep->type != WE_NULL;
  925. X}
  926. X
  927. Xvoid
  928. Xwsyscommand(ep)
  929. X    EVENT *ep;
  930. X{
  931. X    ep->type= WE_NULL;
  932. X    
  933. X    switch (ep->u.m.item) {
  934. X    
  935. X    default:
  936. X        if (ep->u.m.item <= LAST_CMD) {
  937. X            ep->type= WE_COMMAND;
  938. X            ep->u.command= ep->u.m.item - FIRST_CMD;
  939. X        }
  940. X        break;
  941. X    
  942. X    case NEXT_WIN:
  943. X        _wselnext();
  944. X        break;
  945. X    
  946. X    case PREV_WIN:
  947. X        _wselprev();
  948. X        break;
  949. X    
  950. X    case SUSPEND_PROC:
  951. X        _wsuspend();
  952. X        break;
  953. X    
  954. X    case REDRAW_SCREEN:
  955. X        _wredraw();
  956. X        break;
  957. X    
  958. X    case MOUSE_DOWN:
  959. X    case MOUSE_UP:
  960. X        wgoto(ep, ep->u.m.item - MOUSE_DOWN + WE_MOUSE_DOWN);
  961. X        break;
  962. X    
  963. X    case LITERAL_NEXT:
  964. X        _wlitnext(ep);
  965. X        break;
  966. X    
  967. X    case MENU_CALL:
  968. X        menuselect(ep);
  969. X        break;
  970. X    
  971. X    }
  972. X}
  973. X
  974. X/* Flush output and place cursor. */
  975. X
  976. Xvoid
  977. Xwflush()
  978. X{
  979. X    int y= front->curv - front->offset;
  980. X    int x= front->curh;
  981. X    
  982. X    if (front->curv < 0 || y < front->top || y >= front->bottom) {
  983. X        y= front->top;
  984. X        if (y > 0)
  985. X            --y;
  986. X        x= 0;
  987. X    }
  988. X    else if (x < 0)
  989. X        x= 0;
  990. X    else if (x >= columns)
  991. X        x= columns-1;
  992. X    trmsync(y, x);
  993. X}
  994. X
  995. X/* Process pending window updates.
  996. X   If a window has no draw procedure, a WE_DRAW event is generated instead. */
  997. X
  998. Xstatic void
  999. Xwdoupdates(ep)
  1000. X    EVENT *ep;
  1001. X{
  1002. X    WINDOW *win;
  1003. X    int left, top, right, bottom;
  1004. X    
  1005. X    for (win= winlist; win < &winlist[MAXWINDOWS]; ++win) {
  1006. X        if (win->open) {
  1007. X            if (win->top > 0 && !uptodate[win->top - 1])
  1008. X                wdrawtitle(win);
  1009. X            if (wgetchange(win, &left, &top, &right, &bottom)) {
  1010. X                if (win->drawproc == NULL) {
  1011. X                    ep->type= WE_DRAW;
  1012. X                    ep->window= win;
  1013. X                    ep->u.area.left= left;
  1014. X                    ep->u.area.top= top;
  1015. X                    ep->u.area.right= right;
  1016. X                    ep->u.area.bottom= bottom;
  1017. X                    return;
  1018. X                }
  1019. X                else {
  1020. X                    wbegindrawing(win);
  1021. X                    (*win->drawproc)(win,
  1022. X                        left, top, right, bottom);
  1023. X                    wenddrawing(win);
  1024. X                }
  1025. X            }
  1026. X            if(win->resized) {
  1027. X                win->resized = FALSE;
  1028. X                ep->type = WE_SIZE;
  1029. X                ep->window = win;
  1030. X                return;
  1031. X            }
  1032. X        }
  1033. X    }
  1034. X    wflush();
  1035. X}
  1036. X
  1037. Xvoid
  1038. X_wlitnext(ep)
  1039. X    EVENT *ep;
  1040. X{
  1041. X    (void) wrawevent(ep, TRUE);
  1042. X}
  1043. END_OF_FILE
  1044. if test 6191 -ne `wc -c <'Ports/alfa/event.c'`; then
  1045.     echo shar: \"'Ports/alfa/event.c'\" unpacked with wrong size!
  1046. fi
  1047. # end of 'Ports/alfa/event.c'
  1048. fi
  1049. if test -f 'Ports/alfa/syswin.c' -a "${1}" != "-c" ; then 
  1050.   echo shar: Will not clobber existing file \"'Ports/alfa/syswin.c'\"
  1051. else
  1052. echo shar: Extracting \"'Ports/alfa/syswin.c'\" \(6713 characters\)
  1053. sed "s/^X//" >'Ports/alfa/syswin.c' <<'END_OF_FILE'
  1054. X/* STDWIN -- SYSTEM WINDOW. */
  1055. X
  1056. X#include "alfa.h"
  1057. X
  1058. XWINDOW *syswin;        /* Window id 0, the system window */
  1059. X            /* Global because wgetevent needs to know about
  1060. X               it, so it can suppress events belonging to
  1061. X               this window. */
  1062. X
  1063. Xstatic void
  1064. Xhelpmessage()
  1065. X{
  1066. X    char buf[256];
  1067. X    char shortcut[256];
  1068. X    
  1069. X    getbindings(shortcut, 0, MENU_CALL);
  1070. X    sprintf(buf, "[Use  %s  to get a menu of commands]", shortcut);
  1071. X    wmessage(buf);
  1072. X}
  1073. X
  1074. Xvoid
  1075. Xinitsyswin()
  1076. X{
  1077. X    syswin= wopen("System", wsysdraw);
  1078. X    helpmessage();
  1079. X}
  1080. X
  1081. Xchar *sysmsg;        /* Message to be drawn at (0, 0) */
  1082. XTEXTEDIT *syste;    /* Textedit record to be drawn, too */
  1083. X
  1084. X#ifdef EM
  1085. Xstatic char **Butt=NULL;
  1086. X#endif
  1087. X
  1088. X/*ARGSUSED*/
  1089. Xvoid
  1090. Xwsysdraw(win, left, top, right, bottom)
  1091. X    WINDOW *win;
  1092. X    int left, top;
  1093. X    int right, bottom;
  1094. X{
  1095. X    if (sysmsg != NULL) {
  1096. X        (void) wdrawtext(0, 0, sysmsg, -1);
  1097. X        if (syste != NULL)
  1098. X            tedraw(syste);
  1099. X#ifdef EM 
  1100. X        if(Butt)
  1101. X            drawbuttons();    
  1102. X#endif
  1103. X    }
  1104. X    else
  1105. X        drawmenubar();
  1106. X}
  1107. X
  1108. Xvoid
  1109. Xmenubarchanged()
  1110. X{
  1111. X    uptodate[0]= FALSE;
  1112. X}
  1113. X
  1114. X/* Print a message in the system window.
  1115. X   If the message is non-null, the screen is updated immediately. */
  1116. X
  1117. Xvoid
  1118. Xwmessage(str)
  1119. X    char *str;
  1120. X{
  1121. X    if (sysmsg != NULL)
  1122. X        free(sysmsg);
  1123. X    sysmsg= strdup(str);
  1124. X    if (syste != NULL) {
  1125. X        tefree(syste);
  1126. X        syste= NULL;
  1127. X    }
  1128. X    wchange(syswin, 0, 0, 9999, 9999);
  1129. X    wnocaret(syswin);
  1130. X    if (str != NULL) {
  1131. X        wupdate(syswin);
  1132. X        wflush();
  1133. X    }
  1134. X}
  1135. X
  1136. X/* Ask for an input string. */
  1137. X
  1138. Xbool
  1139. Xwaskstr(prompt, buf, len)
  1140. X    char *prompt;
  1141. X    char *buf;
  1142. X    int len;
  1143. X{
  1144. X    WINDOW *savewin= front;
  1145. X    WINDOW *win= syswin;
  1146. X    bool ok= FALSE;
  1147. X    bool stop= FALSE;
  1148. X    int teleft;
  1149. X    
  1150. X    wsetactive(win);
  1151. X    wmessage((char *) NULL);
  1152. X    sysmsg= prompt;
  1153. X    teleft= wtextwidth(prompt, -1) + wtextwidth(" ", 1);
  1154. X    if (teleft > columns * 3/4)
  1155. X        teleft= columns * 3/4;
  1156. X    syste= tealloc(syswin, teleft, 0, columns-teleft);
  1157. X    tereplace(syste, buf);
  1158. X    tesetfocus(syste, 0, 9999);
  1159. X    do {
  1160. X        EVENT e;
  1161. X        
  1162. X        if (!wsysevent(&e, FALSE)) {
  1163. X            wupdate(syswin);
  1164. X            wflush();
  1165. X            wsysevent(&e, TRUE);
  1166. X        }
  1167. X        e.window= syswin; /* Not filled in by wsys*event();
  1168. X                     needed by teevent(). */
  1169. X            
  1170. X        switch (e.type) {
  1171. X        
  1172. X        case WE_MENU:
  1173. X            if (e.u.m.id != 0) {
  1174. X                wfleep();
  1175. X                break;
  1176. X            }
  1177. X            switch (e.u.m.item) {
  1178. X            
  1179. X            case SUSPEND_PROC:
  1180. X                _wsuspend();
  1181. X                break;
  1182. X            
  1183. X            case REDRAW_SCREEN:
  1184. X                _wredraw();
  1185. X                break;
  1186. X            
  1187. X            default:
  1188. X                if (e.u.m.item >= FIRST_CMD &&
  1189. X                    e.u.m.item <= LAST_CMD)
  1190. X                    wsyscommand(&e);
  1191. X                break;
  1192. X            }
  1193. X            if (e.type != WE_COMMAND)
  1194. X                break;
  1195. X        
  1196. X        /* Fall through from previous case! */
  1197. X        case WE_COMMAND:
  1198. X            switch (e.u.command) {
  1199. X            
  1200. X            case WC_RETURN:
  1201. X            case WC_CANCEL:
  1202. X                ok= e.u.command == WC_RETURN;
  1203. X                stop= TRUE;
  1204. X                break;
  1205. X            
  1206. X            default:
  1207. X                if (!teevent(syste, &e))
  1208. X                    wfleep();
  1209. X                break;
  1210. X            
  1211. X            }
  1212. X            break;
  1213. X        
  1214. X        case WE_CHAR:
  1215. X        case WE_MOUSE_DOWN:
  1216. X        case WE_MOUSE_MOVE:
  1217. X        case WE_MOUSE_UP:
  1218. X            if (!teevent(syste, &e))
  1219. X                wfleep();
  1220. X            break;
  1221. X        
  1222. X        }
  1223. X    } while (!stop);
  1224. X    if (ok) {
  1225. X        strncpy(buf, tegettext(syste), len);
  1226. X        buf[len-1]= EOS;
  1227. X    }
  1228. X    sysmsg= NULL;
  1229. X    wmessage((char *) NULL);
  1230. X    wsetactive(savewin);
  1231. X    return ok;
  1232. X}
  1233. X
  1234. X#ifdef EM
  1235. X/* EuroMath hacks -- I still hop I can get rid of this again... */
  1236. X#define META(c) ((c)|128)
  1237. X#define UNMETA(c) ((c)&~128)
  1238. X#define min(a,b) (a)<(b)?(a):(b)
  1239. Xchar *hack;
  1240. Xint Curr;
  1241. X
  1242. Xwdialog(prompt, buf, len, butt, def)
  1243. Xchar *prompt, *buf, **butt;
  1244. Xint len, def;
  1245. X{
  1246. X    WINDOW *savewin= front;
  1247. X    WINDOW *win= syswin;
  1248. X    bool ok= FALSE;
  1249. X    bool stop= FALSE;
  1250. X    int teleft;
  1251. X    int y=1, i;    
  1252. X    extern char* esc;
  1253. X    extern char *expandCommand();
  1254. X
  1255. X    if(butt==NULL)
  1256. X        return waskstr(prompt, buf, len);
  1257. X
  1258. X    Butt=butt;
  1259. X    Curr=0;
  1260. X/* highlight the default button */
  1261. X    for(i=0;butt[def-1][i];i++) butt[def-1][i]=META(butt[def-1][i]);
  1262. X    wsetactive(win);
  1263. X    wmessage((char *) NULL);
  1264. X    sysmsg= prompt;
  1265. X    teleft= wtextwidth(prompt, -1) + wtextwidth(" ", 1);
  1266. X    if (teleft > columns * 3/4)
  1267. X        teleft= columns * 3/4;
  1268. X    syste= tealloc(syswin, teleft, 0, columns-teleft);
  1269. X    tereplace(syste, strdup(buf));
  1270. X    tesetfocus(syste, 0, 9999);
  1271. X/* calculate the number of buttons */
  1272. X    while(butt[y-1]) {
  1273. X        ++y;
  1274. X    }
  1275. X    --y;
  1276. Xrestart:
  1277. X    do {
  1278. X        EVENT e;
  1279. X        
  1280. X        if (!wsysevent(&e, FALSE)) {
  1281. X            wupdate(syswin);
  1282. X            wflush();
  1283. X            wsysevent(&e, TRUE);
  1284. X        }
  1285. X        e.window= syswin; /* Not filled in by wsys*event();
  1286. X                     needed by teevent(). */
  1287. X            
  1288. X        switch (e.type) {
  1289. X        case WE_MENU:    
  1290. X            if (e.u.m.id != 0) {
  1291. X                wfleep();
  1292. X                break;
  1293. X            }
  1294. X            switch (e.u.m.item) {
  1295. X            
  1296. X            case SUSPEND_PROC:
  1297. X                _wsuspend();
  1298. X                break;
  1299. X            
  1300. X            case REDRAW_SCREEN:
  1301. X                _wredraw();
  1302. X                break;
  1303. X            
  1304. X            default:
  1305. X                if (e.u.m.item >= FIRST_CMD &&
  1306. X                    e.u.m.item <= LAST_CMD)
  1307. X                    wsyscommand(&e);
  1308. X                break;
  1309. X            }
  1310. X            if (e.type != WE_COMMAND)
  1311. X                break;
  1312. X        
  1313. X        /* Fall through from previous case! */
  1314. X        case WE_COMMAND:
  1315. X            switch (e.u.command) {
  1316. X/* the arrow-keys (up & down) are used to escape from the texedit
  1317. X    buffer and select a button from the buttonlist */
  1318. X            case WC_UP:
  1319. X                --Curr;
  1320. X                if(Curr<0)
  1321. X                    Curr=0;
  1322. X                break;
  1323. X            case WC_DOWN:
  1324. X                ++Curr;
  1325. X                if(Curr>y)
  1326. X                    Curr=0;    
  1327. X                break;
  1328. X            case WC_RETURN:
  1329. X            case WC_CANCEL:
  1330. X                ok= e.u.command == WC_RETURN;
  1331. X                stop= TRUE;
  1332. X                break;
  1333. X            
  1334. X            default:
  1335. X                if (Curr > 0)
  1336. X                    wfleep();
  1337. X                else if (!teevent(syste, &e))
  1338. X                    wfleep();
  1339. X                break;
  1340. X            
  1341. X            }
  1342. X            break;
  1343. X        
  1344. X        case WE_CHAR:
  1345. X            if(hack && e.u.character == *esc) {
  1346. X/* this is used by cmdbox(): pressing the `escape' character causes
  1347. Xthe typed in buffer to be expanded */
  1348. X                char *buf2;
  1349. X                tesetfocus(syste,0,9999);
  1350. X                strzcpy(buf,tegettext(syste),min(len,tegetlen(syste)+1));
  1351. X                buf2=expandCommand(hack, buf);
  1352. X                tereplace(syste, buf2);
  1353. X                tesetfocus(syste,0,9999);
  1354. X                break;
  1355. X            }
  1356. X        case WE_MOUSE_DOWN:
  1357. X        case WE_MOUSE_MOVE:
  1358. X        case WE_MOUSE_UP:
  1359. X            if(Curr > 0)
  1360. X                wfleep();
  1361. X            else if (!teevent(syste, &e))
  1362. X                wfleep();
  1363. X            break;
  1364. X        
  1365. X        }
  1366. X    } while (!stop);
  1367. X    if(hack && Curr == 3) {
  1368. X/* button 3 is "EXPAND".  Used by cmdbox() */
  1369. X        char *buf2;
  1370. X        tesetfocus(syste,0,9999);
  1371. X        strzcpy(buf,tegettext(syste),min(len,tegetlen(syste)+1));
  1372. X        buf2=expandCommand(hack, tegettext(syste));
  1373. X        tereplace(syste, buf2);
  1374. X        tesetfocus(syste,0,9999);
  1375. X        ok=stop=FALSE; Curr=0;
  1376. X        goto restart;
  1377. X    }    
  1378. X    if (ok) {
  1379. X        strzcpy(buf, tegettext(syste), min(len, tegetlen(syste)+1));
  1380. X    }
  1381. X    sysmsg= NULL;
  1382. X    wmessage((char *) NULL);
  1383. X    wsetactive(savewin);
  1384. X    if(Curr==0) Curr=def;
  1385. X    Butt=NULL;
  1386. X    for(i=0;butt[def-1][i];i++) butt[def-1][i]=UNMETA(butt[def-1][i]);
  1387. X    _wredraw();
  1388. X    return Curr;
  1389. X}
  1390. X
  1391. X/* this is inserted in the syswin drawproc whenever there are buttons
  1392. Xactive */
  1393. Xdrawbuttons() 
  1394. X{
  1395. Xint y=1;
  1396. Xchar buf[256];
  1397. X
  1398. X    while(Butt[y-1]) {
  1399. X        if(y==Curr) sprintf(buf, "%c %s", META('o'), Butt[y-1]); 
  1400. X        else sprintf(buf, "o %s", Butt[y-1]);
  1401. X        trmputdata(y, y, 0, buf);
  1402. X        ++y;
  1403. X    }
  1404. X    trmputdata(y,y,0,"");
  1405. X}
  1406. X
  1407. X/* additional EuroMath WM routine, called after returning from an
  1408. XEditor-session (OpenTTY) */
  1409. X
  1410. XRedrawAll()
  1411. X{
  1412. X_wredraw();
  1413. X}
  1414. X
  1415. X#endif
  1416. END_OF_FILE
  1417. if test 6713 -ne `wc -c <'Ports/alfa/syswin.c'`; then
  1418.     echo shar: \"'Ports/alfa/syswin.c'\" unpacked with wrong size!
  1419. fi
  1420. # end of 'Ports/alfa/syswin.c'
  1421. fi
  1422. if test -f 'Ports/mac/macwin.h' -a "${1}" != "-c" ; then 
  1423.   echo shar: Will not clobber existing file \"'Ports/mac/macwin.h'\"
  1424. else
  1425. echo shar: Extracting \"'Ports/mac/macwin.h'\" \(6389 characters\)
  1426. sed "s/^X//" >'Ports/mac/macwin.h' <<'END_OF_FILE'
  1427. X/* Source for the precompiled header file "macwin.h" in THINK C.
  1428. X   This file includes other header files and defines symbols and types.
  1429. X   It is included in the project for convenience; it generates no code.
  1430. X   
  1431. X   **********************************************************************
  1432. X   * When you edit this file, you must generate a new "macwin.h":       *
  1433. X   * Choose "Precompile..." from the Source menu and save as "macwin.h" *
  1434. X   * (overwriting the old "macwin.h").                                  *
  1435. X   **********************************************************************
  1436. X   
  1437. X   For Think C version 3.0, define THINK_C_3_0 in "stdwconf.h".
  1438. X   
  1439. X   For MPW, move macwin.c to macwin.h and remove the <MacHeaders>
  1440. X   include below.
  1441. X*/
  1442. X
  1443. X
  1444. X#include <MacHeaders>        /*** REMOVE THIS FOR MPW ***/
  1445. X
  1446. X#include "stdwconf.h"        /* Will set MPW or THINK_C */
  1447. X
  1448. X
  1449. X#ifdef MPW
  1450. X
  1451. X/* Without NO_STDIO, some THINK specific code gets compiled */
  1452. X#define NO_STDIO
  1453. X
  1454. X/* MPW names for Mac include files */
  1455. X#include <Types.h>
  1456. X#include <Quickdraw.h>
  1457. X#include <Windows.h>
  1458. X#include <Controls.h>
  1459. X
  1460. X/* Quickdraw globals aren't really global in MPW */
  1461. X#define QD(var) qd.var
  1462. X
  1463. X/* MPW allows 'static' in forward declarations */
  1464. X#define STATIC static
  1465. X
  1466. X/* MPW passes all Points by value */
  1467. X#define PASSPOINT &
  1468. X
  1469. X/* MPW glue converts most string on the fly.
  1470. X   (XXX I believe you can turn this off now?) */
  1471. X#define CLEVERGLUE
  1472. X
  1473. X#endif
  1474. X
  1475. X
  1476. X#ifdef THINK_C
  1477. X
  1478. X/* You may also define NO_STDIO under THINK C, to avoid pulling in stdio */
  1479. X/* ...and for 4.0, it doesn't work anymore (sigh) */
  1480. X#ifndef THINK_C_3_0
  1481. X#define NO_STDIO
  1482. X#endif
  1483. X
  1484. X/* THINK's <WindowMgr.h> omits two essential constants of the Mac+ ROM */
  1485. X#define zoomDocProc 8
  1486. X#define zoomNoGrow 12
  1487. X
  1488. X/* Pascal-to-C and back string conversion routines have different names */
  1489. X#include <pascal.h>
  1490. X#define p2cstr PtoCstr
  1491. X#define c2pstr CtoPstr    /* XXX actually, used nowhere */
  1492. X
  1493. X/* Quickdraw globals are real globals in THINK C */
  1494. X#define QD(var) (var)
  1495. X
  1496. X/* THINK C can't declare forward functions as static */
  1497. X#define STATIC /**/
  1498. X
  1499. X/* THINK C passes Points by value to some toolbox routines */
  1500. X#define PASSPOINT /**/
  1501. X
  1502. X#endif
  1503. X
  1504. X
  1505. X/* Private include files: */
  1506. X
  1507. X#include "tools.h"
  1508. X#include "stdwin.h"
  1509. X#include "menu.h"
  1510. X
  1511. X
  1512. X#ifdef CLEVERGLUE
  1513. X/* MPW converts C to Pascal strings in the glue */
  1514. X#define PSTRING(str) (str)
  1515. X#else
  1516. X/* THINK C needs a real function to do this (see "pstring.c").
  1517. X   This is different from CtoPstr since it does not do it inline */
  1518. Xextern char *PSTRING _ARGS((char *));
  1519. X#endif
  1520. X
  1521. X
  1522. X/* Window struct. */
  1523. X
  1524. Xstruct _window {
  1525. X    short tag;        /* Window tag, usable as document id */
  1526. X    void (*drawproc)();    /* Draw procedure */
  1527. X    WindowPtr w;        /* Mac Window */
  1528. X    int hcaret, vcaret;    /* Caret position, document coordinates */
  1529. X    bool caret_on;        /* Set if caret currently visible */
  1530. X    TEXTATTR attr;        /* Text attributes */
  1531. X    ControlHandle hbar, vbar;    /* Scroll bars */
  1532. X    int docwidth, docheight;    /* Document size */
  1533. X    int orgh, orgv;        /* Window origin, document coordinates */
  1534. X    struct menubar mbar;    /* List of attached local menus */
  1535. X    unsigned long timer;    /* Tick count for timer event */
  1536. X    CURSOR *cursor;        /* Cursor if not default */
  1537. X};
  1538. X
  1539. Xextern TEXTATTR wattr;        /* Current text attributes */
  1540. X
  1541. X#define TX_INVERSE    0x80    /* Or-ed into style bits */
  1542. X
  1543. X/* Peculiarities of the Macintosh: */
  1544. X
  1545. X#define TICKSPERSECOND    60    /* Clock ticks at 60 Hz (everywhere) */
  1546. X
  1547. X#define MENUBARHEIGHT    20    /* Height of menu bar */
  1548. X#define TITLEBARHEIGHT    18    /* Height of window title bar */
  1549. X#define BAR        15    /* Scroll bar width, minus one pixel */
  1550. X
  1551. X/* ASCII codes generated by special keys: */
  1552. X#define ENTER_KEY    0x03
  1553. X
  1554. X#define LEFT_ARROW    0x1c
  1555. X#define RIGHT_ARROW    0x1d
  1556. X#define UP_ARROW    0x1e
  1557. X#define DOWN_ARROW    0x1f
  1558. X
  1559. X
  1560. X/* Miscellaneous definitions. */
  1561. X
  1562. X#define CLICK_DIST    5    /* Max mouse move within a click */
  1563. X
  1564. X/* Parameters for top left corner choice algorithm: */
  1565. X#define LEFT    20    /* Initial left */
  1566. X#define TOP    40    /* Initial top */
  1567. X#define HINCR    20    /* Increment for left */
  1568. X#define VINCR    16    /* Increment for top */
  1569. X
  1570. X/* Minimal window size (determined by room for scroll bars only): */
  1571. X#define MIN_WIDTH    (2*BAR)
  1572. X#define MIN_HEIGHT    (2*BAR)
  1573. X
  1574. X/* Text drawn in the very left or right margin doesn't look nice.
  1575. X   Therefore, we have a little margin on each side.
  1576. X   Its width is determined here: */
  1577. X#define LSLOP    4    /* Pixels in left margin */
  1578. X#define RSLOP    4    /* Pixels in right margin */
  1579. X
  1580. X/* Global data: */
  1581. Xextern GrafPtr screen;        /* Window Manager's GrafPort */
  1582. Xextern WINDOW *active;        /* Active window, if any */
  1583. Xextern bool _wmenuhilite;    /* Set if menu item highlighted */
  1584. Xextern bool _wm_down;        /* Set if mouse down (in appl. area) */
  1585. X
  1586. X/* Function prototypes: */
  1587. X
  1588. Xvoid dprintf _ARGS((char *fmt, ...));
  1589. X
  1590. Xvoid wsetstyle _ARGS((Style face));
  1591. X
  1592. XWINDOW *whichwin _ARGS((WindowPtr w));
  1593. X
  1594. Xvoid makerect _ARGS((WINDOW *win, Rect *pr,
  1595. X    int left, int top, int right, int bottom));
  1596. Xvoid getwinrect _ARGS((WINDOW *win, Rect *pr));
  1597. X
  1598. Xvoid set_arrow _ARGS((void));
  1599. Xvoid set_applcursor _ARGS((void));
  1600. Xvoid set_watch _ARGS((void));
  1601. Xvoid set_ibeam _ARGS((void));
  1602. Xvoid set_hand _ARGS((void));
  1603. X
  1604. Xvoid makescrollbars _ARGS((WINDOW *win));
  1605. Xvoid movescrollbars _ARGS((WINDOW *win));
  1606. Xvoid hidescrollbars _ARGS((WINDOW *win));
  1607. Xvoid showscrollbars _ARGS((WINDOW *win));
  1608. X
  1609. Xvoid scrollby _ARGS((WINDOW *win, Rect *pr, int dh, int dv));
  1610. Xvoid do_scroll _ARGS((Point *pwhere,
  1611. X    WINDOW *win, ControlHandle bar, int pcode));
  1612. Xvoid dragscroll _ARGS((WINDOW *win, int h, int v, int constrained));
  1613. X
  1614. Xvoid initwattr _ARGS((void));
  1615. X
  1616. Xvoid inval_border _ARGS((WindowPtr w));
  1617. Xvoid valid_border _ARGS((WindowPtr w));
  1618. X
  1619. Xvoid rmlocalmenus _ARGS((WINDOW *win));
  1620. Xvoid addlocalmenus _ARGS((WINDOW *win));
  1621. Xvoid initmbar _ARGS((struct menubar *mp));
  1622. Xvoid killmbar _ARGS((struct menubar *mp));
  1623. Xvoid setup_menus _ARGS((void));
  1624. X
  1625. Xvoid do_about _ARGS((void));
  1626. Xvoid getargcargv _ARGS((int *pargc, char ***pargv));
  1627. Xvoid fullpath _ARGS((char *buf, int wdrefnum, char *file));
  1628. Xchar *getdirname _ARGS((int wdrefnum));
  1629. X
  1630. X
  1631. Xvoid rmcaret _ARGS((WINDOW *win));
  1632. Xvoid showcaret _ARGS((WINDOW *win));
  1633. Xvoid blinkcaret _ARGS((WINDOW *win));
  1634. Xvoid _wresetmouse _ARGS((void));
  1635. X
  1636. Xvoid _wfreeclip _ARGS((void));
  1637. Xbool checktimer _ARGS((EVENT *ep));
  1638. Xvoid autoscroll _ARGS((WINDOW *active, int h, int v));
  1639. Xvoid _wdo_menu _ARGS((EVENT *ep, long menu_item));
  1640. X
  1641. X/* SetRect is much faster this way... */
  1642. X#define SetRect(pr, l, t, r, b) ((pr)->left = (l), (pr)->top = (t), \
  1643. X                (pr)->right = (r), (pr)->bottom = (b))
  1644. END_OF_FILE
  1645. if test 6389 -ne `wc -c <'Ports/mac/macwin.h'`; then
  1646.     echo shar: \"'Ports/mac/macwin.h'\" unpacked with wrong size!
  1647. fi
  1648. # end of 'Ports/mac/macwin.h'
  1649. fi
  1650. if test -f 'Ports/mac/stdwin.c' -a "${1}" != "-c" ; then 
  1651.   echo shar: Will not clobber existing file \"'Ports/mac/stdwin.c'\"
  1652. else
  1653. echo shar: Extracting \"'Ports/mac/stdwin.c'\" \(6341 characters\)
  1654. sed "s/^X//" >'Ports/mac/stdwin.c' <<'END_OF_FILE'
  1655. X/* MAC STDWIN -- BASIC ROUTINES. */
  1656. X
  1657. X#include "macwin.h"
  1658. X#ifdef MPW
  1659. X#include <Fonts.h>
  1660. X#include <Menus.h>
  1661. X#include <TextEdit.h>
  1662. X#include <Dialogs.h>
  1663. X#include <OSUtils.h>
  1664. X#include <SegLoad.h>
  1665. X#endif
  1666. X
  1667. X
  1668. X/* GLOBAL DATA. */
  1669. X
  1670. X            /* XXX choose less obvious names */
  1671. XGrafPtr screen;        /* The Mac Window Manager's GrafPort */
  1672. XTEXTATTR wattr;        /* Current or default text attributes */
  1673. X
  1674. Xstatic int def_left= LEFT;
  1675. Xstatic int def_top= TOP;
  1676. Xstatic int def_width, def_height;
  1677. X
  1678. X
  1679. X/* INITIALIZATION AND TERMINATION. */
  1680. X
  1681. X/* Initialization */
  1682. X
  1683. Xint std_open_hook();
  1684. XSTATIC pascal resume _ARGS((void));
  1685. X
  1686. X/* Initialize, using and updating argc/argv: */
  1687. Xvoid
  1688. Xwinitargs(pargc, pargv)
  1689. X    int *pargc;
  1690. X    char ***pargv;
  1691. X{
  1692. X    wargs(pargc, pargv);
  1693. X    winit();
  1694. X}
  1695. X
  1696. X/* Initialize without touching argc/argv */
  1697. Xvoid
  1698. Xwinit()
  1699. X{
  1700. X#ifndef NO_STDIO
  1701. X    /* Tell the THINK C stdio library we have initialized already */
  1702. X    Stdio_MacInit(TRUE);
  1703. X#endif
  1704. X
  1705. X#ifdef THINK_C
  1706. X#ifndef THINK_C_3_0
  1707. X    /* 
  1708. X       THINK C 4.0 may have done these initializations for us when
  1709. X       the application has already used the console in any way.
  1710. X       Doing them again is not a good idea.
  1711. X       The THINK library avoids initializing the world if it appears
  1712. X       that it has already been initialized, but in that case it
  1713. X       will only allow output (all input requests return EOF).
  1714. X       Thus, the application has two options:
  1715. X       - call winit() or winitargs() first, then use the console
  1716. X         only for (debugging) output; or
  1717. X       - print at least one character to stdout first, then
  1718. X         stdwin menu bar may not function properly.
  1719. X       From inspection of the THINK library source it appears that
  1720. X       when the console is initialized, stdin->std is cleared,
  1721. X       so the test below suffices to skip initializations.
  1722. X    */
  1723. X    if (stdin->std)
  1724. X#endif
  1725. X#endif
  1726. X    {
  1727. X        MaxApplZone();
  1728. X        InitGraf(&QD(thePort));
  1729. X        InitFonts();
  1730. X        InitWindows();
  1731. X        TEInit();
  1732. X        InitDialogs(resume);
  1733. X        InitMenus();
  1734. X        InitCursor();
  1735. X        setup_menus();
  1736. X    }
  1737. X    GetWMgrPort(&screen);
  1738. X    initwattr();
  1739. X#ifdef MPW
  1740. X    set_open_hook(std_open_hook);
  1741. X#endif
  1742. X    wsetdefwinsize(0, 0);
  1743. X    set_watch();
  1744. X}
  1745. X
  1746. Xvoid
  1747. Xwdone()
  1748. X{
  1749. X}
  1750. X
  1751. Xvoid
  1752. Xwgetscrsize(pwidth, pheight)
  1753. X    int *pwidth, *pheight;
  1754. X{
  1755. X    Rect r;
  1756. X    r= screen->portRect;
  1757. X    *pwidth= r.right - r.left;
  1758. X    *pheight= r.bottom - r.top;
  1759. X}
  1760. X
  1761. Xvoid
  1762. Xwgetscrmm(pmmwidth, pmmheight)
  1763. X    int *pmmwidth, *pmmheight;
  1764. X{
  1765. X    Rect r;
  1766. X    r= screen->portRect;
  1767. X    /* XXX Three pixels/mm is an approximation of the truth at most */
  1768. X    *pmmwidth= (r.right - r.left) / 3;
  1769. X    *pmmheight= (r.bottom - r.top) / 3;
  1770. X}
  1771. X
  1772. X/* Routine called by "Resume" button in bomb box (passed to InitDialogs).
  1773. X   I have yet to see a program crash where an attempted exit to the
  1774. X   Finder caused any harm, so I think it's safe.
  1775. X   Anyway, it's tremendously useful during debugging. */
  1776. X
  1777. Xstatic pascal
  1778. Xresume()
  1779. X{
  1780. X    ExitToShell();
  1781. X}
  1782. X
  1783. X/* WINDOWS. */
  1784. X
  1785. X/* Find the WINDOW pointer corresponding to a WindowPtr. */
  1786. X
  1787. XWINDOW *
  1788. Xwhichwin(w)
  1789. X    WindowPtr w;
  1790. X{
  1791. X    if (((WindowPeek)w)->windowKind < userKind)
  1792. X        return NULL; /* Not an application-created window */
  1793. X    else {
  1794. X        WINDOW *win;
  1795. X        
  1796. X        win= (WINDOW *) GetWRefCon(w);
  1797. X        if (win != NULL && win->w == w)
  1798. X            return win;
  1799. X        else
  1800. X            return NULL;
  1801. X    }
  1802. X}
  1803. X
  1804. XWINDOW *
  1805. Xwopen(title, drawproc)
  1806. X    char *title;
  1807. X    void (*drawproc)();
  1808. X{
  1809. X    WINDOW *win= ALLOC(WINDOW);
  1810. X    Rect r;
  1811. X    
  1812. X    if (win == NULL) {
  1813. X        dprintf("wopen: ALLOC failed"); /* XXX */
  1814. X        return NULL;
  1815. X    }
  1816. X
  1817. X    /* Find a nice position for the window. */
  1818. X    if (def_left + def_width + BAR + LSLOP + RSLOP
  1819. X            > screen->portRect.right) {
  1820. X        def_left= LEFT;
  1821. X        CLIPMAX(def_left, screen->portRect.right -
  1822. X            (def_width + BAR + LSLOP + RSLOP));
  1823. X        CLIPMIN(def_left, 0);
  1824. X    }
  1825. X    if (def_top + def_height + BAR > screen->portRect.bottom) {
  1826. X        def_top= TOP;
  1827. X        CLIPMAX(def_top, screen->portRect.bottom -
  1828. X            (def_height + BAR));
  1829. X        CLIPMIN(def_top, MENUBARHEIGHT + TITLEBARHEIGHT);
  1830. X    }
  1831. X    
  1832. X    SetRect(&r, def_left, def_top,
  1833. X        def_left+def_width + BAR + LSLOP + RSLOP,
  1834. X        def_top+def_height + BAR);
  1835. X    def_left += HINCR;
  1836. X    def_top += VINCR;
  1837. X    
  1838. X    win->w= NewWindow((Ptr)NULL, &r, PSTRING(title), TRUE, zoomDocProc,
  1839. X        (WindowPtr)(-1), TRUE, 0L);
  1840. X    SetWRefCon(win->w, (long)win);
  1841. X    
  1842. X    win->tag= 0;
  1843. X    win->drawproc= drawproc;
  1844. X    win->hcaret= win->vcaret= -1;
  1845. X    win->caret_on= FALSE;
  1846. X    win->attr= wattr;
  1847. X    win->hbar= win->vbar= NULL;
  1848. X    win->docwidth= 0;
  1849. X    win->docheight= 0;
  1850. X    win->orgh= -LSLOP;
  1851. X    win->orgv= 0;
  1852. X    win->timer= 0;
  1853. X    win->cursor = NULL;
  1854. X    
  1855. X    initmbar(&win->mbar);
  1856. X    makescrollbars(win);
  1857. X    
  1858. X    return win;
  1859. X}
  1860. X
  1861. Xvoid
  1862. Xwclose(win)
  1863. X    WINDOW *win;
  1864. X{
  1865. X    if (win == active) {
  1866. X        rmlocalmenus(win);
  1867. X        active= NULL;
  1868. X    }
  1869. X    killmbar(&win->mbar);
  1870. X    DisposeWindow(win->w);
  1871. X    FREE(win);
  1872. X}
  1873. X
  1874. Xvoid
  1875. Xwgetwinsize(win, pwidth, pheight)
  1876. X    WINDOW *win;
  1877. X    int *pwidth, *pheight;
  1878. X{
  1879. X    Rect r;
  1880. X    
  1881. X    getwinrect(win, &r);
  1882. X    *pwidth= r.right - r.left - LSLOP - RSLOP;
  1883. X    *pheight= r.bottom - r.top;
  1884. X}
  1885. X
  1886. Xvoid
  1887. Xwsettitle(win, title)
  1888. X    WINDOW *win;
  1889. X    char *title;
  1890. X{
  1891. X    SetWTitle(win->w, PSTRING(title));
  1892. X}
  1893. X
  1894. Xchar *
  1895. Xwgettitle(win)
  1896. X    WINDOW *win;
  1897. X{
  1898. X    static char title[256];
  1899. X    GetWTitle(win->w, title);
  1900. X#ifndef CLEVERGLUE
  1901. X    PtoCstr(title);
  1902. X#endif
  1903. X    return title;
  1904. X}
  1905. X
  1906. Xvoid
  1907. Xwfleep()
  1908. X{
  1909. X    SysBeep(5);
  1910. X}
  1911. X
  1912. Xvoid
  1913. Xwsetmaxwinsize(width, height)
  1914. X    int width, height;
  1915. X{
  1916. X    /* Not supported yet (should be stored in the window struct
  1917. X       and used by do_grow). */
  1918. X    /* XXX This procedure should disappear completely, it was
  1919. X       only invented for the Whitechapel which allocates bitmap
  1920. X       memory to the window when it is first created! */
  1921. X    /* XXX Well, maybe it has some use.  In fact both min and max
  1922. X       window size are sometimes useful... */
  1923. X}
  1924. X
  1925. Xvoid
  1926. Xwsetdefwinpos(h, v)
  1927. X    int h, v;
  1928. X{
  1929. X    /* XXX Sanity checks? Change interaction with wopen()? */
  1930. X    if (h > 0)
  1931. X        def_left = h;
  1932. X    if (v > 0)
  1933. X        def_top = v;
  1934. X}
  1935. X
  1936. Xvoid
  1937. Xwgetdefwinpos(ph, pv)
  1938. X    int *ph, *pv;
  1939. X{
  1940. X    *ph = def_left;
  1941. X    *pv = def_top;
  1942. X}
  1943. X
  1944. Xvoid
  1945. Xwsetdefwinsize(width, height)
  1946. X    int width, height;
  1947. X{
  1948. X    /* XXX Shouldn't this be done by wopen() instead? */
  1949. X    if (width <= 0) {
  1950. X        width= screen->portRect.right * 2/3;
  1951. X        CLIPMAX(width, 512);
  1952. X    }
  1953. X    CLIPMAX(width, screen->portRect.right - BAR - LSLOP - RSLOP);
  1954. X    CLIPMIN(width, MIN_WIDTH);
  1955. X    
  1956. X    if (height <= 0) {
  1957. X        height= screen->portRect.bottom * 2/3;
  1958. X        CLIPMAX(height, 342);
  1959. X    }
  1960. X    CLIPMAX(height, screen->portRect.bottom
  1961. X        - MENUBARHEIGHT - TITLEBARHEIGHT - BAR);
  1962. X    CLIPMIN(height, MIN_HEIGHT);
  1963. X    
  1964. X    def_width= width;
  1965. X    def_height= height;
  1966. X}
  1967. X
  1968. Xvoid
  1969. Xwgetdefwinsize(pwidth, pheight)
  1970. X    int *pwidth, *pheight;
  1971. X{
  1972. X    *pwidth = def_width;
  1973. X    *pheight = def_height;
  1974. X}
  1975. X
  1976. Xvoid
  1977. Xwsetactive(win)
  1978. X    WINDOW *win;
  1979. X{
  1980. X    SelectWindow(win->w);
  1981. X}
  1982. END_OF_FILE
  1983. if test 6341 -ne `wc -c <'Ports/mac/stdwin.c'`; then
  1984.     echo shar: \"'Ports/mac/stdwin.c'\" unpacked with wrong size!
  1985. fi
  1986. # end of 'Ports/mac/stdwin.c'
  1987. fi
  1988. if test -f 'Ports/x11/cursor.c' -a "${1}" != "-c" ; then 
  1989.   echo shar: Will not clobber existing file \"'Ports/x11/cursor.c'\"
  1990. else
  1991. echo shar: Extracting \"'Ports/x11/cursor.c'\" \(5190 characters\)
  1992. sed "s/^X//" >'Ports/x11/cursor.c' <<'END_OF_FILE'
  1993. X/* This was copied from the standard X11R4 client twm and then changed */
  1994. X
  1995. X/*
  1996. X * Copyright 1989 Massachusetts Institute of Technology
  1997. X *
  1998. X * Permission to use, copy, modify, and distribute this software and its
  1999. X * documentation for any purpose and without fee is hereby granted, provided
  2000. X * that the above copyright notice appear in all copies and that both that
  2001. X * copyright notice and this permission notice appear in supporting
  2002. X * documentation, and that the name of M.I.T. not be used in advertising
  2003. X * or publicity pertaining to distribution of the software without specific,
  2004. X * written prior permission.  M.I.T. makes no representations about the
  2005. X * suitability of this software for any purpose.  It is provided "as is"
  2006. X * without express or implied warranty.
  2007. X *
  2008. X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  2009. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  2010. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  2011. X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  2012. X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  2013. X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  2014. X */
  2015. X
  2016. X/***********************************************************************
  2017. X *
  2018. X * $XConsortium: cursor.c,v 1.10 89/12/14 14:52:23 jim Exp $
  2019. X *
  2020. X * cursor creation code
  2021. X *
  2022. X * 05-Apr-89 Thomas E. LaStrange    File created
  2023. X *
  2024. X ***********************************************************************/
  2025. X
  2026. X#include "x11.h"
  2027. X
  2028. Xstatic struct _CursorName {
  2029. X    char        *name;
  2030. X    unsigned int    shape;
  2031. X    Cursor        cursor;
  2032. X} cursor_names[] = {
  2033. X
  2034. X{"X_cursor",        XC_X_cursor,        None},
  2035. X{"arrow",        XC_arrow,        None},
  2036. X{"based_arrow_down",    XC_based_arrow_down,    None},
  2037. X{"based_arrow_up",    XC_based_arrow_up,      None},
  2038. X{"boat",        XC_boat,        None},
  2039. X{"bogosity",        XC_bogosity,        None},
  2040. X{"bottom_left_corner",    XC_bottom_left_corner,  None},
  2041. X{"bottom_right_corner",    XC_bottom_right_corner, None},
  2042. X{"bottom_side",        XC_bottom_side,        None},
  2043. X{"bottom_tee",        XC_bottom_tee,        None},
  2044. X{"box_spiral",        XC_box_spiral,        None},
  2045. X{"center_ptr",        XC_center_ptr,        None},
  2046. X{"circle",        XC_circle,        None},
  2047. X{"clock",        XC_clock,        None},
  2048. X{"coffee_mug",        XC_coffee_mug,        None},
  2049. X{"cross",        XC_cross,        None},
  2050. X{"cross_reverse",    XC_cross_reverse,       None},
  2051. X{"crosshair",        XC_crosshair,        None},
  2052. X{"diamond_cross",    XC_diamond_cross,       None},
  2053. X{"dot",            XC_dot,            None},
  2054. X{"dotbox",        XC_dotbox,        None},
  2055. X{"double_arrow",    XC_double_arrow,    None},
  2056. X{"draft_large",        XC_draft_large,        None},
  2057. X{"draft_small",        XC_draft_small,        None},
  2058. X{"draped_box",        XC_draped_box,        None},
  2059. X{"exchange",        XC_exchange,        None},
  2060. X{"fleur",        XC_fleur,        None},
  2061. X{"gobbler",        XC_gobbler,        None},
  2062. X{"gumby",        XC_gumby,        None},
  2063. X{"hand1",        XC_hand1,        None},
  2064. X{"hand2",        XC_hand2,        None},
  2065. X{"heart",        XC_heart,        None},
  2066. X{"ibeam",        XC_xterm,        None}, /* Mac stdwin compat */
  2067. X{"icon",        XC_icon,        None},
  2068. X{"iron_cross",        XC_iron_cross,        None},
  2069. X{"left_ptr",        XC_left_ptr,        None},
  2070. X{"left_side",        XC_left_side,        None},
  2071. X{"left_tee",        XC_left_tee,        None},
  2072. X{"leftbutton",        XC_leftbutton,        None},
  2073. X{"ll_angle",        XC_ll_angle,        None},
  2074. X{"lr_angle",        XC_lr_angle,        None},
  2075. X{"man",            XC_man,            None},
  2076. X{"middlebutton",    XC_middlebutton,    None},
  2077. X{"mouse",        XC_mouse,        None},
  2078. X{"pencil",        XC_pencil,        None},
  2079. X{"pirate",        XC_pirate,        None},
  2080. X{"plus",        XC_plus,        None},
  2081. X{"question_arrow",    XC_question_arrow,    None},
  2082. X{"right_ptr",        XC_right_ptr,        None},
  2083. X{"right_side",        XC_right_side,        None},
  2084. X{"right_tee",        XC_right_tee,        None},
  2085. X{"rightbutton",        XC_rightbutton,        None},
  2086. X{"rtl_logo",        XC_rtl_logo,        None},
  2087. X{"sailboat",        XC_sailboat,        None},
  2088. X{"sb_down_arrow",    XC_sb_down_arrow,       None},
  2089. X{"sb_h_double_arrow",    XC_sb_h_double_arrow,   None},
  2090. X{"sb_left_arrow",    XC_sb_left_arrow,       None},
  2091. X{"sb_right_arrow",    XC_sb_right_arrow,      None},
  2092. X{"sb_up_arrow",        XC_sb_up_arrow,        None},
  2093. X{"sb_v_double_arrow",    XC_sb_v_double_arrow,   None},
  2094. X{"shuttle",        XC_shuttle,        None},
  2095. X{"sizing",        XC_sizing,        None},
  2096. X{"spider",        XC_spider,        None},
  2097. X{"spraycan",        XC_spraycan,        None},
  2098. X{"star",        XC_star,        None},
  2099. X{"target",        XC_target,        None},
  2100. X{"tcross",        XC_tcross,        None},
  2101. X{"top_left_arrow",    XC_top_left_arrow,      None},
  2102. X{"top_left_corner",    XC_top_left_corner,    None},
  2103. X{"top_right_corner",    XC_top_right_corner,    None},
  2104. X{"top_side",        XC_top_side,        None},
  2105. X{"top_tee",        XC_top_tee,        None},
  2106. X{"trek",        XC_trek,        None},
  2107. X{"ul_angle",        XC_ul_angle,        None},
  2108. X{"umbrella",        XC_umbrella,        None},
  2109. X{"ur_angle",        XC_ur_angle,        None},
  2110. X{"watch",        XC_watch,        None},
  2111. X{"xterm",        XC_xterm,        None},
  2112. X};
  2113. X
  2114. Xstatic
  2115. XNewFontCursor (dpy, cp, str)
  2116. X    Display *dpy;
  2117. X    Cursor *cp;
  2118. X    char *str;
  2119. X{
  2120. X    int i;
  2121. X
  2122. X    for (i = 0; i < sizeof(cursor_names)/sizeof(struct _CursorName); i++)
  2123. X    {
  2124. X    if (strcmp(str, cursor_names[i].name) == 0)
  2125. X    {
  2126. X        if (cursor_names[i].cursor == None)
  2127. X        cursor_names[i].cursor = XCreateFontCursor(dpy,
  2128. X            cursor_names[i].shape);
  2129. X        *cp = cursor_names[i].cursor;
  2130. X        return;
  2131. X    }
  2132. X    }
  2133. X    _wwarning("NewFontCursor: unable to find font cursor \"%s\"", str);
  2134. X    *cp = None;
  2135. X}
  2136. X
  2137. XCURSOR *
  2138. Xwfetchcursor(name)
  2139. X    char *name;
  2140. X{
  2141. X    Cursor c;
  2142. X    NewFontCursor(_wd, &c, name);
  2143. X    if (c == None)
  2144. X        return NULL;
  2145. X    else
  2146. X        return (CURSOR *)c;
  2147. X}
  2148. END_OF_FILE
  2149. if test 5190 -ne `wc -c <'Ports/x11/cursor.c'`; then
  2150.     echo shar: \"'Ports/x11/cursor.c'\" unpacked with wrong size!
  2151. fi
  2152. # end of 'Ports/x11/cursor.c'
  2153. fi
  2154. if test -f 'Ports/x11/event.c' -a "${1}" != "-c" ; then 
  2155.   echo shar: Will not clobber existing file \"'Ports/x11/event.c'\"
  2156. else
  2157. echo shar: Extracting \"'Ports/x11/event.c'\" \(5450 characters\)
  2158. sed "s/^X//" >'Ports/x11/event.c' <<'END_OF_FILE'
  2159. X/* X11 STDWIN -- High levent handling */
  2160. X
  2161. X/* THIS CODE IS A MESS.  SHOULD BE RESTRUCTURED! */
  2162. X
  2163. X#include "x11.h"
  2164. X#include "llevent.h"
  2165. X#include <X11/keysym.h>
  2166. X
  2167. Xstatic WINDOW *active;
  2168. Xstatic WINDOW *prev_active;
  2169. X
  2170. X/* Ensure none of the window pointers refer to the given window --
  2171. X   it's being closed so the pointer becomes invalid. */
  2172. X
  2173. X_w_deactivate(win)
  2174. X    WINDOW *win;
  2175. X{
  2176. X    if (win == active)
  2177. X        active= NULL;
  2178. X    if (win == _w_new_active)
  2179. X        _w_new_active= NULL;
  2180. X    if (win == prev_active)
  2181. X        prev_active= NULL;
  2182. X    if (win == _w_bs.win) {
  2183. X        _w_bs.win= NULL;
  2184. X        _w_bs.down= FALSE;
  2185. X    }
  2186. X}
  2187. X
  2188. XWINDOW *
  2189. X_w_get_last_active()
  2190. X{
  2191. X    if (_w_new_active != NULL)
  2192. X        return _w_new_active;
  2193. X    if (active != NULL)
  2194. X        return active;
  2195. X    if (prev_active != NULL)
  2196. X        return prev_active;
  2197. X    /* No window was ever active. Pick one at random. */
  2198. X    return _w_somewin();
  2199. X}
  2200. X
  2201. XWINDOW *
  2202. Xwgetactive()
  2203. X{
  2204. X    return active;
  2205. X}
  2206. X
  2207. X/* wungetevent may be called from a signal handler.
  2208. X   If this is the case, we must send an event to ourselves
  2209. X   so it is picked up (eventually).
  2210. X   There is really still a race condition:
  2211. X   if wungetevent copies an event into the evsave buffer
  2212. X   when wgetevent is halfway of copying one out, we lose.
  2213. X   This can only be fixed with multiple buffers and I dont
  2214. X   want to think about that now. */
  2215. X
  2216. Xstatic bool in_getevent;
  2217. XEVENT _w_evsave;        /* Accessible by _w_ll_event */
  2218. X
  2219. Xvoid
  2220. Xwungetevent(ep)
  2221. X    EVENT *ep;
  2222. X{
  2223. X    if (ep->type != WE_NULL) {
  2224. X        _w_evsave= *ep;
  2225. X#ifdef PIPEHACK
  2226. X        if (in_getevent) {
  2227. X            if (_wpipe[1] < 0)
  2228. X              _wwarning("wungetevent: can't interrupt wgetevent");
  2229. X            else if (write(_wpipe[1], "x", 1) != 1)
  2230. X              _wwarning("wungetevent: pipe write failed");
  2231. X            else
  2232. X              _wdebug(1, "wungetevent: wrote to pipe");
  2233. X        }
  2234. X#endif
  2235. X    }
  2236. X}
  2237. X
  2238. Xstatic void
  2239. X_wwaitevent(ep, mayblock)
  2240. X    EVENT *ep;
  2241. X    bool mayblock;
  2242. X{
  2243. X    XEvent e;
  2244. X    
  2245. X    in_getevent= TRUE;
  2246. X    
  2247. X    if (_w_evsave.type != WE_NULL) {
  2248. X        *ep= _w_evsave;
  2249. X        _w_evsave.type= WE_NULL;
  2250. X        in_getevent= FALSE;
  2251. X        return;
  2252. X    }
  2253. X    
  2254. X    /* Break out of this loop when we've got an event for the appl.,
  2255. X       or, if mayblock is false, when we would block (in XNextEvent) */
  2256. X    for (;;) {
  2257. X        if (_w_close_this != NULL) {
  2258. X            /* WM_DELETE_WINDOW detected */
  2259. X            ep->type = WE_COMMAND;
  2260. X            ep->window = _w_close_this;
  2261. X            ep->u.command = WC_CLOSE;
  2262. X            _w_close_this = NULL;
  2263. X            break;
  2264. X        }
  2265. X        if (_w_lostselection(ep))
  2266. X            return;
  2267. X        if (_w_keysym != 0) {
  2268. X            if (_w_new_active != active) {
  2269. X                if (active != NULL) {
  2270. X                    ep->type= WE_DEACTIVATE;
  2271. X                    ep->window= prev_active= active;
  2272. X                    active= NULL;
  2273. X                }
  2274. X                else {
  2275. X                    ep->type= WE_ACTIVATE;
  2276. X                    ep->window= active= _w_new_active;
  2277. X                }
  2278. X            }
  2279. X            else {
  2280. X                ep->type= WE_CHAR;
  2281. X                ep->window= active;
  2282. X                ep->u.character= _w_keysym;
  2283. X                change_key_event(ep);
  2284. X                _w_keysym= 0;
  2285. X            }
  2286. X            if (ep->type != WE_NULL)
  2287. X                break;
  2288. X        }
  2289. X        if (_w_bs_changed || _w_moved) {
  2290. X            ep->type= WE_NULL;
  2291. X            switch (_w_bs.isub) {
  2292. X            case MBAR:
  2293. X                _whitmbar(&_w_bs, ep);
  2294. X                break;
  2295. X            case MWIN:
  2296. X                _whitmwin(&_w_bs, ep); /* XXX test */
  2297. X                break;
  2298. X            case HBAR:
  2299. X                _whithbar(&_w_bs, ep);
  2300. X                break;
  2301. X            case VBAR:
  2302. X                _whitvbar(&_w_bs, ep);
  2303. X                break;
  2304. X            case WA:
  2305. X                ep->type= _w_moved ?
  2306. X                        WE_MOUSE_MOVE :
  2307. X                        _w_bs.down ?
  2308. X                            WE_MOUSE_DOWN :
  2309. X                            WE_MOUSE_UP;
  2310. X                ep->window= _w_bs.win;
  2311. X                ep->u.where.h= _w_bs.x;
  2312. X                ep->u.where.v= _w_bs.y;
  2313. X                ep->u.where.button= _w_bs.button;
  2314. X                ep->u.where.clicks= _w_bs.clicks;
  2315. X                ep->u.where.mask= _w_bs.mask;
  2316. X                break;
  2317. X            }
  2318. X            _w_bs_changed= _w_moved= FALSE;
  2319. X            if (ep->type != WE_NULL)
  2320. X                break;
  2321. X        }
  2322. X        if (_w_checktimer(ep, FALSE))
  2323. X            break;
  2324. X        if (XPending(_wd) == 0)
  2325. X            XSync(_wd, FALSE);
  2326. X        if (XPending(_wd) == 0) {
  2327. X            if (_w_new_active != active) {
  2328. X                /* Why is this code duplicated here? */
  2329. X                if (active != NULL) {
  2330. X                    ep->type= WE_DEACTIVATE;
  2331. X                    ep->window= prev_active= active;
  2332. X                    active= NULL;
  2333. X                }
  2334. X                else {
  2335. X                    ep->type= WE_ACTIVATE;
  2336. X                    ep->window= active= _w_new_active;
  2337. X                }
  2338. X                break;
  2339. X            }
  2340. X            if (_w_resized && _w_doresizes(ep))
  2341. X                break;
  2342. X            if (_w_dirty && _w_doupdates(ep))
  2343. X                break;
  2344. X            if (XPending(_wd) == 0 && _w_checktimer(ep, mayblock)
  2345. X                    || !mayblock)
  2346. X                break;
  2347. X        }
  2348. X#ifdef PIPEHACK
  2349. X        if (_w_evsave.type != NULL) {
  2350. X            /* Lots of race conditions here! */
  2351. X            char dummy[256];
  2352. X            int n;
  2353. X            _wdebug(1, "wgetevent: got evt from handler");
  2354. X            *ep= _w_evsave;
  2355. X            _w_evsave.type= WE_NULL;
  2356. X            if ((n= read(_wpipe[0], dummy, sizeof dummy)) <= 0)
  2357. X              _wdebug(1, "wgetevent: read from pipe failed");
  2358. X            else if (n != 1)
  2359. X              _wdebug(0, "wgetevent: got %d bytes from pipe!", n);
  2360. X            break;
  2361. X        }
  2362. X#endif
  2363. X        XNextEvent(_wd, &e);
  2364. X        _w_ll_event(&e);
  2365. X    }
  2366. X    
  2367. X    in_getevent= FALSE;
  2368. X}
  2369. X
  2370. Xbool
  2371. Xwpollevent(ep)
  2372. X    EVENT *ep;
  2373. X{
  2374. X    ep->type = WE_NULL;
  2375. X    _wwaitevent(ep, FALSE);
  2376. X    return ep->type != WE_NULL;
  2377. X}
  2378. X
  2379. Xvoid
  2380. Xwgetevent(ep)
  2381. X    EVENT *ep;
  2382. X{
  2383. X    _wwaitevent(ep, TRUE);
  2384. X}
  2385. X
  2386. Xstatic
  2387. Xchange_key_event(ep)
  2388. X    EVENT *ep;
  2389. X{
  2390. X    if (_w_state & Mod1Mask) {
  2391. X        ep->type= WE_NULL;
  2392. X        _w_menukey(ep->u.character, ep);
  2393. X        return;
  2394. X    }
  2395. X    switch (ep->u.character) {
  2396. X    case XK_Left:
  2397. X        ep->u.command= WC_LEFT;
  2398. X        break;
  2399. X    case XK_Right:
  2400. X        ep->u.command= WC_RIGHT;
  2401. X        break;
  2402. X    case XK_Up:
  2403. X        ep->u.command= WC_UP;
  2404. X        break;
  2405. X    case XK_Down:
  2406. X        ep->u.command= WC_DOWN;
  2407. X        break;
  2408. X    case '\n':
  2409. X    case '\r':
  2410. X        ep->u.command= WC_RETURN;
  2411. X        break;
  2412. X    case '\3':
  2413. X        ep->u.command= WC_CANCEL;
  2414. X        break;
  2415. X    case '\b':
  2416. X    case '\177': /* DEL */
  2417. X        ep->u.command= WC_BACKSPACE;
  2418. X        break;
  2419. X    case '\t':
  2420. X        ep->u.command= WC_TAB;
  2421. X        break;
  2422. X    default:
  2423. X        if (ep->u.character < 0 || ep->u.character > 0177)
  2424. X            ep->type= WE_NULL;
  2425. X        return;
  2426. X    }
  2427. X    ep->type= WE_COMMAND;
  2428. X}
  2429. END_OF_FILE
  2430. if test 5450 -ne `wc -c <'Ports/x11/event.c'`; then
  2431.     echo shar: \"'Ports/x11/event.c'\" unpacked with wrong size!
  2432. fi
  2433. # end of 'Ports/x11/event.c'
  2434. fi
  2435. echo shar: End of archive 13 \(of 19\).
  2436. cp /dev/null ark13isdone
  2437. MISSING=""
  2438. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
  2439.     if test ! -f ark${I}isdone ; then
  2440.     MISSING="${MISSING} ${I}"
  2441.     fi
  2442. done
  2443. if test "${MISSING}" = "" ; then
  2444.     echo You have unpacked all 19 archives.
  2445.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2446. else
  2447.     echo You still need to unpack the following archives:
  2448.     echo "        " ${MISSING}
  2449. fi
  2450. ##  End of shell archive.
  2451. exit 0
  2452.