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

  1. From: guido@cwi.nl (Guido van Rossum)
  2. Newsgroups: alt.sources
  3. Subject: STDWIN 0.9.5, Part 18/19
  4. Message-ID: <3082@charon.cwi.nl>
  5. Date: 4 Mar 91 11:58:36 GMT
  6.  
  7. Archive-name: stdwin/part18
  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 18 (of 19)."
  16. # Contents:  Appls/dpv/dpvoutput.h Appls/dpv/r3symbol
  17. #   Appls/test/hello.c Appls/test/kuifje Appls/test/test4.c
  18. #   Appls/test/test5.c Appls/test/testlocalmenus.c
  19. #   Appls/test/testpollevent.c Appls/test/thand.c Appls/test/vtdemo.c
  20. #   Conf/proto.arch.68000 Conf/proto.arch.xxx Conf/proto.os.sony
  21. #   Conf/proto.os.sysv Conf/proto.os.xxx Conf/proto.port.xxx
  22. #   Doc/macros.ms Gen/waskfile.c H/_ARGS.h H/editwin.h H/vtrm.h
  23. #   Packs/textedit/wprintf.c Packs/vt/vtimpl.h Packs/vt/vtputs.c
  24. #   Ports/alfa/measure.c Ports/alfa/scroll.c Ports/mac/argcargv.c
  25. #   Ports/mac/fullpath.c Ports/mac_mpw/Makefile
  26. #   Ports/mac_mpw/intercept.h Ports/vtrm/vtrm.h Ports/x11/caret.c
  27. #   Ports/x11/cutbuffer.c Ports/x11/llevent.h Tools/strdup.c
  28. # Wrapped by guido@voorn.cwi.nl on Mon Mar  4 12:37:36 1991
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'Appls/dpv/dpvoutput.h' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'Appls/dpv/dpvoutput.h'\"
  32. else
  33. echo shar: Extracting \"'Appls/dpv/dpvoutput.h'\" \(1076 characters\)
  34. sed "s/^X//" >'Appls/dpv/dpvoutput.h' <<'END_OF_FILE'
  35. X/* dpv -- ditroff previewer.  Definitions for output. */
  36. X
  37. Xextern char    *devname;    /* Device for which output is prepared */
  38. X
  39. Xextern WINDOW    *win;        /* output window */
  40. X
  41. Xextern int    showpage;    /* internal page to show in window */
  42. X                /* defined in dpvcontrol.c */
  43. Xextern int    prevpage;    /* previous page shown (for '-' command) */
  44. X
  45. Xextern long    hscale, hdiv;    /* Horizontal scaling factors */
  46. Xextern long    vscale, vdiv;    /* Vertical scaling factors */
  47. X
  48. X/* Scaling method */
  49. X#define HWIN(h) ((int)(((h)*hscale+hdiv/2)/hdiv))
  50. X#define VWIN(v) ((int)(((v)*vscale+vdiv/2)/vdiv))
  51. X#define HWINDOW HWIN(hpos)
  52. X#define VWINDOW VWIN(vpos)
  53. X
  54. X/* Variables used by put1 macro below, and by recheck function */
  55. X
  56. Xextern int    doit;        /* nonzero if output makes sense */
  57. Xextern int    vwindow;    /* precomputed vpos*vscale/vdiv - baseline */
  58. Xextern int    baseline;    /* wbaseline() of current font */
  59. Xextern int    lineheight;    /* wlineheight() of current font */
  60. Xextern int    topdraw, botdraw;    /* window area to draw */
  61. X
  62. X/* Macro to output one character */
  63. X
  64. X#define put1(c) if (!doit) ; else wdrawchar(HWINDOW, vwindow, c)
  65. END_OF_FILE
  66. if test 1076 -ne `wc -c <'Appls/dpv/dpvoutput.h'`; then
  67.     echo shar: \"'Appls/dpv/dpvoutput.h'\" unpacked with wrong size!
  68. fi
  69. # end of 'Appls/dpv/dpvoutput.h'
  70. fi
  71. if test -f 'Appls/dpv/r3symbol' -a "${1}" != "-c" ; then 
  72.   echo shar: Will not clobber existing file \"'Appls/dpv/r3symbol'\"
  73. else
  74. echo shar: Extracting \"'Appls/dpv/r3symbol'\" \(1261 characters\)
  75. sed "s/^X//" >'Appls/dpv/r3symbol' <<'END_OF_FILE'
  76. XoA - 0x22
  77. XoE - 0x24
  78. Xcn - 0x27
  79. X** - 0x2A
  80. Xpl - 0x2B
  81. Xmi - 0x2D
  82. Xsl - 0x2F
  83. Xeq - 0x3D
  84. X=~ - 0x40
  85. X*A - 0x41
  86. X*B - 0x42
  87. X*X - 0x43
  88. X*D - 0x44
  89. X*E - 0x45
  90. X*F - 0x46
  91. X*G - 0x47
  92. X*Y - 0x48
  93. X*I - 0x49
  94. X*K - 0x4B
  95. X*L - 0x4C
  96. X*M - 0x4D
  97. X*N - 0x4E
  98. X*O - 0x4F
  99. X*P - 0x50
  100. X*H - 0x51
  101. X*R - 0x52
  102. X*S - 0x53
  103. X*T - 0x54
  104. X*U - 0x55
  105. Xts - 0x56
  106. X*W - 0x57
  107. X*C - 0x58
  108. X*Q - 0x59
  109. X*Z - 0x5A
  110. Xul - 0x5F
  111. Xrn - 0x60
  112. X*a - 0x61
  113. X*b - 0x62
  114. X*x - 0x63
  115. X*d - 0x64
  116. X*e - 0x65
  117. X*f - 0x66
  118. X*g - 0x67
  119. X*y - 0x68
  120. X*i - 0x69
  121. X*f - 0x6A
  122. X*k - 0x6B
  123. X*l - 0x6C
  124. X*m - 0x6D
  125. X*n - 0x6E
  126. X*o - 0x6F
  127. X*p - 0x70
  128. X*h - 0x71
  129. X*r - 0x72
  130. X*s - 0x73
  131. X*t - 0x74
  132. X*u - 0x75
  133. X*w - 0x77
  134. X*c - 0x78
  135. X*q - 0x79
  136. X*z - 0x7A
  137. Xor - 0x7C
  138. Xap - 0x7E
  139. X
  140. Xfm - 0xa2
  141. X<= - 0xa3
  142. Xsl - 0xa4
  143. Xif - 0xa5
  144. X$D - 0xa6
  145. Xbs - 0xa9
  146. Xlr - 0xaB
  147. X<- - 0xaC
  148. Xua - 0xaD
  149. X-> - 0xaE
  150. Xda - 0xaF
  151. Xde - 0xb0
  152. X+- - 0xb1
  153. X>= - 0xb3
  154. Xmu - 0xb4
  155. Xpt - 0xb5
  156. Xpd - 0xb6
  157. Xbu - 0xb7
  158. Xdi - 0xb8
  159. X!= - 0xb9
  160. X== - 0xbA
  161. X~= - 0xbB
  162. Xbr - 0xbD
  163. XAh - 0xc0
  164. Xc* - 0xc4
  165. Xc+ - 0xc5
  166. Xes - 0xc6
  167. Xca - 0xc7
  168. Xcu - 0xc8
  169. Xsp - 0xc9
  170. Xip - 0xcA
  171. Xsb - 0xcC
  172. Xib - 0xcD
  173. Xmo - 0xcE
  174. Xnm - 0xcF
  175. Xan - 0xd0
  176. Xgr - 0xd1
  177. Xrg - 0xd2
  178. Xco - 0xd3
  179. Xsr - 0xd6
  180. Xno - 0xd8
  181. XAN - 0xd9
  182. XOR - 0xdA
  183. X<> - 0xdB
  184. XDl - 0xdC
  185. XDu - 0xdD
  186. XDr - 0xdE
  187. XDd - 0xdF
  188. Xfo - 0xe1
  189. Xlc - 0xe9
  190. Xlf - 0xeB
  191. Xlt - 0xeC
  192. Xlk - 0xeD
  193. Xlb - 0xeE
  194. Xbv - 0xeF
  195. Xbs - 0xf0
  196. Xfc - 0xf1
  197. Xis - 0xf2
  198. Xrc - 0xf9
  199. Xrf - 0xfB
  200. Xrt - 0xfC
  201. Xrk - 0xfD
  202. Xrb - 0xfE
  203. END_OF_FILE
  204. if test 1261 -ne `wc -c <'Appls/dpv/r3symbol'`; then
  205.     echo shar: \"'Appls/dpv/r3symbol'\" unpacked with wrong size!
  206. fi
  207. # end of 'Appls/dpv/r3symbol'
  208. fi
  209. if test -f 'Appls/test/hello.c' -a "${1}" != "-c" ; then 
  210.   echo shar: Will not clobber existing file \"'Appls/test/hello.c'\"
  211. else
  212. echo shar: Extracting \"'Appls/test/hello.c'\" \(989 characters\)
  213. sed "s/^X//" >'Appls/test/hello.c' <<'END_OF_FILE'
  214. X/* The "Hello, world" koan according to David Rosenthal,
  215. X   recoded for STDWIN.
  216. X   Requirements: print "Hello, world" centered in a window,
  217. X   recented after window resizes, redraw after window exposures.
  218. X   Check error returns. */
  219. X
  220. X#include "stdwin.h"
  221. X
  222. Xchar *string= "Hello, world";
  223. X
  224. Xint text_h, text_v;
  225. X
  226. Xplacetext(win)
  227. X    WINDOW *win;
  228. X{
  229. X    int width, height;
  230. X    wgetwinsize(win, &width, &height);
  231. X    text_v= (height - wlineheight()) / 2;
  232. X    text_h= (width - wtextwidth(string, -1)) / 2;
  233. X}
  234. X
  235. Xdrawproc(win, left, top, right, bottom)
  236. X    WINDOW *win;
  237. X{
  238. X    wdrawtext(text_h, text_v, string, -1);
  239. X}
  240. X
  241. Xmain(argc, argv)
  242. X    int argc;
  243. X    char **argv;
  244. X{
  245. X    WINDOW *win;
  246. X    winitargs(&argc, &argv);
  247. X    win= wopen("Hello", drawproc);
  248. X    
  249. X    if (win != 0) {
  250. X        placetext(win);
  251. X        for (;;) {
  252. X            EVENT e;
  253. X            wgetevent(&e);
  254. X            if (e.type == WE_CLOSE ||
  255. X                    e.type == WE_COMMAND &&
  256. X                    (e.u.command == WC_CLOSE ||
  257. X                     e.u.command == WC_CANCEL))
  258. X                break;
  259. X            if (e.type == WE_SIZE)
  260. X                placetext(win);
  261. X        }
  262. X    }
  263. X    
  264. X    wdone();
  265. X    exit(0);
  266. X}
  267. END_OF_FILE
  268. if test 989 -ne `wc -c <'Appls/test/hello.c'`; then
  269.     echo shar: \"'Appls/test/hello.c'\" unpacked with wrong size!
  270. fi
  271. # end of 'Appls/test/hello.c'
  272. fi
  273. if test -f 'Appls/test/kuifje' -a "${1}" != "-c" ; then 
  274.   echo shar: Will not clobber existing file \"'Appls/test/kuifje'\"
  275. else
  276. echo shar: Extracting \"'Appls/test/kuifje'\" \(1056 characters\)
  277. sed "s/^X//" >'Appls/test/kuifje' <<'END_OF_FILE'
  278. X0x0000,0x0920,0x0000,
  279. X0x0000,0x0920,0x0000,
  280. X0x0000,0x0930,0x0000,
  281. X0x0000,0x0D90,0x0000,
  282. X0x0000,0x0490,0x0000,
  283. X0x0000,0x0490,0x0000,
  284. X0x0000,0x05B0,0x0000,
  285. X0x0000,0x0D20,0x0000,
  286. X0x0000,0x0920,0x0000,
  287. X0x0000,0x393C,0x0000,
  288. X0x0000,0xE006,0x0000,
  289. X0x0001,0x884B,0x0000,
  290. X0x0003,0x4851,0x8000,
  291. X0x0006,0x2000,0xC000,
  292. X0x0004,0x0C6C,0x6000,
  293. X0x000C,0x6C60,0x2000,
  294. X0x0008,0x0000,0x3000,
  295. X0x0008,0x0000,0x1000,
  296. X0x0008,0x007F,0x1000,
  297. X0x0008,0x0005,0x9000,
  298. X0x000C,0x00FF,0x1000,
  299. X0x0006,0x0000,0x1000,
  300. X0x0032,0x07F0,0x3000,
  301. X0x0193,0x03E0,0x2400,
  302. X0x00D9,0x01C0,0x6480,
  303. X0x0049,0x8080,0xC500,
  304. X0x006C,0xC001,0x8000,
  305. X0x0026,0x6003,0x06C0,
  306. X0x0033,0x3FFF,0xFE00,
  307. X0x0019,0x0000,0x0400,
  308. X0x000D,0x3000,0x0400,
  309. X0x0004,0x3000,0x0400,
  310. X0x0004,0x0000,0x0400,
  311. X0x0000,0x0000,0x0C00,
  312. X0x0000,0x0000,0x0800,
  313. X0x0000,0x0000,0x1800,
  314. X0x0000,0x0000,0x7000,
  315. X0x0000,0x0007,0xC000,
  316. X0x0000,0x00FC,0x0000,
  317. X0x0000,0x0380,0x0000,
  318. X0x0000,0x0600,0x0000,
  319. X0x0000,0x0400,0x0000,
  320. X0x0000,0x0400,0x0000,
  321. X0x0000,0x0C00,0x0000,
  322. X0x0000,0x0800,0x0000,
  323. X0x0000,0x0800,0x0000,
  324. X0x0000,0x0800,0x0000,
  325. X0x0000,0x0800,0x0000,
  326. END_OF_FILE
  327. if test 1056 -ne `wc -c <'Appls/test/kuifje'`; then
  328.     echo shar: \"'Appls/test/kuifje'\" unpacked with wrong size!
  329. fi
  330. # end of 'Appls/test/kuifje'
  331. fi
  332. if test -f 'Appls/test/test4.c' -a "${1}" != "-c" ; then 
  333.   echo shar: Will not clobber existing file \"'Appls/test/test4.c'\"
  334. else
  335. echo shar: Extracting \"'Appls/test/test4.c'\" \(1097 characters\)
  336. sed "s/^X//" >'Appls/test/test4.c' <<'END_OF_FILE'
  337. X/* Menu test - a text-edit window  */
  338. X
  339. X#include "stdwin.h"
  340. X
  341. XTEXTEDIT *tb;
  342. X
  343. Xvoid
  344. Xdrawproc(win, l, t, r, b)
  345. X    WINDOW *win;
  346. X{
  347. X    tedraw(tb);
  348. X}
  349. X
  350. Xmain(argc, argv)
  351. X    int argc;
  352. X    char **argv;
  353. X{
  354. X    WINDOW *win;
  355. X    MENU *mp;
  356. X    int width, height;
  357. X    int stop= 0;
  358. X    
  359. X    winitargs(&argc, &argv);
  360. X    if (argc >= 3) {
  361. X        int h= atoi(argv[1]), v= atoi(argv[2]);
  362. X        wsetdefwinpos(h, v);
  363. X    }
  364. X    
  365. X    mp= wmenucreate(1, "File");
  366. X    wmenuadditem(mp, "Quit", 'Q');
  367. X    
  368. X    win= wopen("Menu+textedit", drawproc);
  369. X    wgetwinsize(win, &width, &height);
  370. X    wsetdocsize(win, width, height);
  371. X    
  372. X    tb= tealloc(win, 0, 0, width);
  373. X    tereplace(tb, "Hello, world\n--Guido van Rossum");
  374. X    
  375. X    do {
  376. X        EVENT e;
  377. X        wgetevent(&e);
  378. X        if (teevent(tb, &e)) {
  379. X            wsetdocsize(win, width, height= tegetbottom(tb));
  380. X            continue;
  381. X        }
  382. X        switch (e.type) {
  383. X        
  384. X        case WE_COMMAND:
  385. X            if (e.u.command == WC_CLOSE ||
  386. X                e.u.command == WC_CANCEL)
  387. X                stop= 1;
  388. X            break;
  389. X        
  390. X        case WE_CLOSE:
  391. X            stop= 1;
  392. X            break;
  393. X        
  394. X        case WE_MENU:
  395. X            if (e.u.m.id == 1 && e.u.m.item == 0)
  396. X                stop= 1;
  397. X            break;
  398. X        
  399. X        }
  400. X    } while (!stop);
  401. X
  402. X     tefree(tb);
  403. X    wclose(win);
  404. X    wmenudelete(mp);
  405. X    wdone();
  406. X    
  407. X    exit(0);
  408. X}
  409. END_OF_FILE
  410. if test 1097 -ne `wc -c <'Appls/test/test4.c'`; then
  411.     echo shar: \"'Appls/test/test4.c'\" unpacked with wrong size!
  412. fi
  413. # end of 'Appls/test/test4.c'
  414. fi
  415. if test -f 'Appls/test/test5.c' -a "${1}" != "-c" ; then 
  416.   echo shar: Will not clobber existing file \"'Appls/test/test5.c'\"
  417. else
  418. echo shar: Extracting \"'Appls/test/test5.c'\" \(1337 characters\)
  419. sed "s/^X//" >'Appls/test/test5.c' <<'END_OF_FILE'
  420. X/* Debugging test -- print events and details */
  421. X
  422. X#include "stdwin.h"
  423. X
  424. Xvoid
  425. Xdrawproc(win, l, t, r, b)
  426. X    WINDOW *win;
  427. X{
  428. X    printf("drawproc called\n");
  429. X    wdrawtext(0, 0, "Hello, world", -1);
  430. X}
  431. X
  432. Xchar *evname[] = {
  433. X    "null",
  434. X    "activate",
  435. X    "char",
  436. X    "command",
  437. X    "mouse_down",
  438. X    "mouse_move",
  439. X    "mouse_up",
  440. X    "menu",
  441. X    "size",
  442. X    "(move)",
  443. X    "draw",
  444. X    "timer",
  445. X    "deactivate",
  446. X    0
  447. X};
  448. X
  449. Xchar *cmname[] = {
  450. X    "(null)",
  451. X    "close",
  452. X    "left",
  453. X    "right",
  454. X    "up",
  455. X    "down",
  456. X    "cancel",
  457. X    "backspace",
  458. X    "tab",
  459. X    "return",
  460. X    0
  461. X};
  462. X
  463. Xmain(argc, argv)
  464. X    int argc;
  465. X    char **argv;
  466. X{
  467. X    WINDOW *win;
  468. X    winitargs(&argc, &argv);
  469. X    win= wopen("Hello test", drawproc);
  470. X    for (;;) {
  471. X        EVENT e;
  472. X        wgetevent(&e);
  473. X        switch (e.type) {
  474. X        case WE_MOUSE_DOWN:
  475. X        case WE_MOUSE_MOVE:
  476. X        case WE_MOUSE_UP:
  477. X            printf("%s event: b=%d, h=%d, v=%d\n",
  478. X                evname[e.type], e.u.where.button,
  479. X                e.u.where.h, e.u.where.v);
  480. X            break;
  481. X        case WE_COMMAND:
  482. X            printf("command event (%s)\n", cmname[e.u.command]);
  483. X            break;
  484. X        case WE_CHAR:
  485. X            printf("char event ('%c', 0x%02x)\n",
  486. X                e.u.character, e.u.character & 0xff);
  487. X            break;
  488. X        default:
  489. X            printf("%s event\n", evname[e.type]);
  490. X            break;
  491. X        }
  492. X        if (e.type == WE_CHAR && e.u.character == 'q')
  493. X            break;
  494. X        if (e.type == WE_CLOSE ||
  495. X            e.type == WE_COMMAND &&
  496. X            (e.u.command == WC_CLOSE || e.u.command == WC_CANCEL))
  497. X            break;
  498. X    }
  499. X    wclose(win);
  500. X    wdone();
  501. X    exit(0);
  502. X}
  503. END_OF_FILE
  504. if test 1337 -ne `wc -c <'Appls/test/test5.c'`; then
  505.     echo shar: \"'Appls/test/test5.c'\" unpacked with wrong size!
  506. fi
  507. # end of 'Appls/test/test5.c'
  508. fi
  509. if test -f 'Appls/test/testlocalmenus.c' -a "${1}" != "-c" ; then 
  510.   echo shar: Will not clobber existing file \"'Appls/test/testlocalmenus.c'\"
  511. else
  512. echo shar: Extracting \"'Appls/test/testlocalmenus.c'\" \(1002 characters\)
  513. sed "s/^X//" >'Appls/test/testlocalmenus.c' <<'END_OF_FILE'
  514. X#include "stdwin.h"
  515. X
  516. X#include <strings.h>
  517. X
  518. Xmain(argc, argv)
  519. X    char **argv;
  520. X{
  521. X    winit(&argc, &argv);
  522. X    showargs(argc, argv);
  523. X    localtest();
  524. X    wdone();
  525. X}
  526. X
  527. Xshowargs(argc, argv)
  528. X    char **argv;
  529. X{
  530. X    char buf[100];
  531. X    char *p;
  532. X    int i;
  533. X    
  534. X    sprintf(buf, "argc=%d", argc);
  535. X    p = buf;
  536. X    for (i = 0; i < argc; ++i) {
  537. X        p = strchr(p, '\0');
  538. X        sprintf(p, " argv[%d]=\"%s\"", i, argv[i]);
  539. X    }
  540. X    wmessage(buf);
  541. X}
  542. X
  543. Xlocaltest()
  544. X{
  545. X    WINDOW *u, *v, *w;
  546. X    MENU *m, *n, *o;
  547. X    int wincount = 3;
  548. X    
  549. X    wmenusetdeflocal(1);
  550. X    
  551. X    m = wmenucreate(1, "Menu1");
  552. X    wmenuadditem(m, "Item1", -1);
  553. X    n = wmenucreate(2, "Menu2");
  554. X    wmenuadditem(n, "Item2", -1);
  555. X    o = wmenucreate(3, "Menu3");
  556. X    wmenuadditem(o, "Item3", -1);
  557. X    
  558. X    u = wopen("Win1", 0L);
  559. X    v = wopen("Win2", 0L);
  560. X    w = wopen("Win3", 0L);
  561. X    
  562. X    wmenuattach(u, m);
  563. X    wmenuattach(v, n);
  564. X    wmenuattach(w, o);
  565. X    
  566. X    for (;;) {
  567. X        EVENT e;
  568. X        wgetevent(&e);
  569. X        if (e.type == WE_CLOSE ||
  570. X            e.type == WE_COMMAND && e.u.command == WC_CLOSE) {
  571. X            wclose(e.window);
  572. X            --wincount;
  573. X            if (wincount == 0)
  574. X                break;
  575. X        }
  576. X    }
  577. X}
  578. END_OF_FILE
  579. if test 1002 -ne `wc -c <'Appls/test/testlocalmenus.c'`; then
  580.     echo shar: \"'Appls/test/testlocalmenus.c'\" unpacked with wrong size!
  581. fi
  582. # end of 'Appls/test/testlocalmenus.c'
  583. fi
  584. if test -f 'Appls/test/testpollevent.c' -a "${1}" != "-c" ; then 
  585.   echo shar: Will not clobber existing file \"'Appls/test/testpollevent.c'\"
  586. else
  587. echo shar: Extracting \"'Appls/test/testpollevent.c'\" \(1208 characters\)
  588. sed "s/^X//" >'Appls/test/testpollevent.c' <<'END_OF_FILE'
  589. X#include <stdio.h>
  590. X#include "stdwin.h"
  591. X
  592. Xvoid drawproc(); /* Forward */
  593. X
  594. XEVENT ev;
  595. X
  596. Xmain(argc, argv)
  597. X    int argc;
  598. X    char **argv;
  599. X{
  600. X    WINDOW *win;
  601. X    
  602. X    winitargs(&argc, &argv);
  603. X    win = wopen("Test poll event", drawproc);
  604. X    for (;;) {
  605. X        if (wpollevent(&ev)) {
  606. X            if (ev.type == WE_CLOSE ||
  607. X                ev.type == WE_COMMAND && ev.u.command == WC_CLOSE)
  608. X                break;
  609. X            wbegindrawing(win);
  610. X            werase(0, 0, 1000, 1000);
  611. X            drawproc(win, 0, 0, 1000, 1000);
  612. X            wenddrawing(win);
  613. X        }
  614. X        else {
  615. X            wbegindrawing(win);
  616. X            animate();
  617. X            wenddrawing(win);
  618. X        }
  619. X    }
  620. X    wdone();
  621. X    exit(0);
  622. X}
  623. X
  624. Xvoid
  625. Xdrawproc(win, left, top, right, bottom)
  626. X    WINDOW *win;
  627. X    int left, top, right, bottom;
  628. X{
  629. X    char buf[100];
  630. X    
  631. X    switch (ev.type) {
  632. X    
  633. X    case WE_MOUSE_DOWN:
  634. X    case WE_MOUSE_MOVE:
  635. X    case WE_MOUSE_UP:
  636. X        sprintf(buf,
  637. X            "MOUSE EVENT %d, h=%d, v=%d, button=%d, clicks=%d",
  638. X            ev.type, ev.u.where.h, ev.u.where.v,
  639. X            ev.u.where.button, ev.u.where.clicks);
  640. X        break;
  641. X    
  642. X    case WE_CHAR:
  643. X        sprintf(buf, "CHAR '%c' (%d)", ev.u.character, ev.u.character);
  644. X        break;
  645. X    
  646. X    default:
  647. X        sprintf(buf, "TYPE %d", ev.type);
  648. X        break;
  649. X    
  650. X    }
  651. X    wdrawtext(0, 0, buf, -1);
  652. X}
  653. X
  654. Xanimate()
  655. X{
  656. X    static int h;
  657. X    int v = 20;
  658. X    
  659. X    werase(h, v, h+5, v+5);
  660. X    h = (h+1) % 400;
  661. X    wpaint(h, v, h+5, v+5);
  662. X}
  663. END_OF_FILE
  664. if test 1208 -ne `wc -c <'Appls/test/testpollevent.c'`; then
  665.     echo shar: \"'Appls/test/testpollevent.c'\" unpacked with wrong size!
  666. fi
  667. # end of 'Appls/test/testpollevent.c'
  668. fi
  669. if test -f 'Appls/test/thand.c' -a "${1}" != "-c" ; then 
  670.   echo shar: Will not clobber existing file \"'Appls/test/thand.c'\"
  671. else
  672. echo shar: Extracting \"'Appls/test/thand.c'\" \(1033 characters\)
  673. sed "s/^X//" >'Appls/test/thand.c' <<'END_OF_FILE'
  674. X/* Test wungetevent from signal handler */
  675. X
  676. X#include "stdwin.h"
  677. X#include <signal.h>
  678. X
  679. X#define SPECIAL 1000
  680. X
  681. XTEXTEDIT *tb;
  682. X
  683. Xvoid
  684. Xdrawproc(win, l, t, r, b)
  685. X    WINDOW *win;
  686. X{
  687. X    tedraw(tb);
  688. X}
  689. X
  690. Xint
  691. Xhandler() {
  692. X    EVENT e;
  693. X    e.type= WE_COMMAND;
  694. X    e.u.command= SPECIAL;
  695. X    wungetevent(&e);
  696. X}
  697. X
  698. Xmain(argc, argv)
  699. X    int argc;
  700. X    char **argv;
  701. X{
  702. X    WINDOW *win;
  703. X    int width, height;
  704. X    
  705. X    winit();
  706. X    signal(SIGINT, handler);
  707. X    if (argc >= 3) {
  708. X        int h= atoi(argv[1]), v= atoi(argv[2]);
  709. X        wsetdefwinpos(h, v);
  710. X    }
  711. X    
  712. X    win= wopen("Textedit", drawproc);
  713. X    wgetwinsize(win, &width, &height);
  714. X    wsetdocsize(win, width, height);
  715. X    
  716. X    tb= tealloc(win, 0, 0, width);
  717. X    tereplace(tb, "Hello, world\n--Guido van Rossum");
  718. X    
  719. X    for (;;) {
  720. X        EVENT e;
  721. X        wgetevent(&e);
  722. X        if (e.type == WE_CLOSE)
  723. X            break;
  724. X        if (e.type == WE_COMMAND) {
  725. X            if (e.u.command == WC_CLOSE ||
  726. X                e.u.command == WC_CANCEL)
  727. X                break;
  728. X            else if (e.u.command == SPECIAL) {
  729. X                wmessage("Got event from handler");
  730. X                continue;
  731. X            }
  732. X        }
  733. X        (void) teevent(tb, &e);
  734. X    }
  735. X    tefree(tb);
  736. X    wclose(win);
  737. X    wdone();
  738. X    exit(0);
  739. X}
  740. END_OF_FILE
  741. if test 1033 -ne `wc -c <'Appls/test/thand.c'`; then
  742.     echo shar: \"'Appls/test/thand.c'\" unpacked with wrong size!
  743. fi
  744. # end of 'Appls/test/thand.c'
  745. fi
  746. if test -f 'Appls/test/vtdemo.c' -a "${1}" != "-c" ; then 
  747.   echo shar: Will not clobber existing file \"'Appls/test/vtdemo.c'\"
  748. else
  749. echo shar: Extracting \"'Appls/test/vtdemo.c'\" \(1027 characters\)
  750. sed "s/^X//" >'Appls/test/vtdemo.c' <<'END_OF_FILE'
  751. X#include "stdwin.h"
  752. X#include "vt.h"
  753. X
  754. Xmain() {
  755. X    VT *vt;
  756. X    winit();
  757. X    wsetdefwinsize(80*wcharwidth('0'), 24*wlineheight());
  758. X    vt= vtopen("VT", 24, 80, 100); /* Should check outcome */
  759. X    vtautosize(vt);
  760. X    vtsetnlcr(vt, 1); /* Map LF ro CR LF */
  761. X    vtansiputs(vt, "Hello, world\n", -1);
  762. X    eventloop();
  763. X    wdone();
  764. X    exit(0);
  765. X}
  766. X
  767. Xeventloop(vt) VT *vt; {
  768. X    for (;;) {
  769. X        EVENT e;
  770. X        wgetevent(&e);
  771. X        switch (e.type) {
  772. X        case WE_SIZE:
  773. X            vtautosize(vt); /* Should check outcome */
  774. X            break;
  775. X        case WE_CHAR:
  776. X            { char buf[2];
  777. X              buf[0]= e.u.character;
  778. X              vtansiputs(vt, buf, 1);
  779. X              break; }
  780. X        case WE_MOUSE_DOWN:
  781. X            vtsetcursor(vt,
  782. X                        e.u.where.v / vtcheight(vt),
  783. X                        e.u.where.h / vtcwidth(vt));
  784. X            break;
  785. X        case WE_COMMAND:
  786. X            switch (e.u.command) {
  787. X            case WC_CLOSE:                              return;
  788. X            case WC_RETURN: vtansiputs(vt, "\n", 1);    break;
  789. X            case WC_BACKSPACE: vtansiputs(vt, "\b", 1); break;
  790. X            case WC_TAB: vtansiputs(vt, "\t", 1);       break;
  791. X            }
  792. X            break;
  793. X        case WE_CLOSE:
  794. X            return;
  795. X        }
  796. X    }
  797. X}
  798. END_OF_FILE
  799. if test 1027 -ne `wc -c <'Appls/test/vtdemo.c'`; then
  800.     echo shar: \"'Appls/test/vtdemo.c'\" unpacked with wrong size!
  801. fi
  802. # end of 'Appls/test/vtdemo.c'
  803. fi
  804. if test -f 'Conf/proto.arch.68000' -a "${1}" != "-c" ; then 
  805.   echo shar: Will not clobber existing file \"'Conf/proto.arch.68000'\"
  806. else
  807. echo shar: Extracting \"'Conf/proto.arch.68000'\" \(973 characters\)
  808. sed "s/^X//" >'Conf/proto.arch.68000' <<'END_OF_FILE'
  809. X
  810. X#
  811. X# Definitions for 68000 architecture
  812. X#
  813. X
  814. X# Define the name of this architecture here.
  815. X# This is used as a subdirectory name where all the objects for this
  816. X# architecture live: $(TOP)/Build/$(ARCH)
  817. X#
  818. X# Note that there is the silent assumption that there is only one O.S.
  819. X# per architecture.  We'll have to invent composite architecture names,
  820. X# or insert an extra level in the build tree, if this becomes false...
  821. X#
  822. XARCH=        68000
  823. X
  824. X# Define the name of the script used to update the dependencies in
  825. X# the Makefile.
  826. X# Choices are:
  827. X#    slowmkdep -- always works (as far as I know)
  828. X#    fastmkdep -- used cc -M, which isn't always available
  829. X#    makedepend -- Todd Brunhoff's superfast tool (comes with X11)
  830. X#                  (This needs -Dunix because of configure.h)
  831. X# You may also place this definition in the proto.os.* file if you
  832. X# know a method works for every architecture supported by that OS.
  833. X#
  834. X#MKDEP=        $(CONF)/slowmkdep
  835. X#MKDEP=        $(CONF)/fastmkdep
  836. X#MKDEP=        makedepend -Dunix
  837. X
  838. END_OF_FILE
  839. if test 973 -ne `wc -c <'Conf/proto.arch.68000'`; then
  840.     echo shar: \"'Conf/proto.arch.68000'\" unpacked with wrong size!
  841. fi
  842. # end of 'Conf/proto.arch.68000'
  843. fi
  844. if test -f 'Conf/proto.arch.xxx' -a "${1}" != "-c" ; then 
  845.   echo shar: Will not clobber existing file \"'Conf/proto.arch.xxx'\"
  846. else
  847. echo shar: Extracting \"'Conf/proto.arch.xxx'\" \(976 characters\)
  848. sed "s/^X//" >'Conf/proto.arch.xxx' <<'END_OF_FILE'
  849. X
  850. X#
  851. X# Definitions pertaining to architecture XXX
  852. X#
  853. X
  854. X# Define the name of this architecture here.
  855. X# This is used as a subdirectory name where all the objects for this
  856. X# architecture live: $(TOP)/Build/$(ARCH)
  857. X#
  858. X# Note that there is the silent assumption that there is only one O.S.
  859. X# per architecture.  We'll have to invent composite architecture names,
  860. X# or insert an extra level in the build tree, if this becomes false...
  861. X#
  862. XARCH=        XXX
  863. X
  864. X# Define the name of the script used to update the dependencies in
  865. X# the Makefile.
  866. X# Choices are:
  867. X#    slowmkdep -- always works (as far as I know)
  868. X#    fastmkdep -- used cc -M, which isn't always available
  869. X#    makedepend -- Todd Brunhoff's superfast tool (comes with X11)
  870. X#                  (This needs -Dunix because of configure.h)
  871. X# You may also place this definition in the proto.os.* file if you
  872. X# know a method works for every architecture supported by that OS.
  873. X#
  874. XMKDEP=        $(CONF)/slowmkdep
  875. XMKDEP=        $(CONF)/fastmkdep
  876. XMKDEP=        makedepend -Dunix
  877. X
  878. END_OF_FILE
  879. if test 976 -ne `wc -c <'Conf/proto.arch.xxx'`; then
  880.     echo shar: \"'Conf/proto.arch.xxx'\" unpacked with wrong size!
  881. fi
  882. # end of 'Conf/proto.arch.xxx'
  883. fi
  884. if test -f 'Conf/proto.os.sony' -a "${1}" != "-c" ; then 
  885.   echo shar: Will not clobber existing file \"'Conf/proto.os.sony'\"
  886. else
  887. echo shar: Extracting \"'Conf/proto.os.sony'\" \(1049 characters\)
  888. sed "s/^X//" >'Conf/proto.os.sony' <<'END_OF_FILE'
  889. X
  890. X#
  891. X# Definitions for Sony News workstation
  892. X#
  893. X
  894. X# The name of this O.S.
  895. X#
  896. XOS=        sony
  897. X
  898. X# Choose ONE of the following definitions of RANLIB.
  899. X# BSD-based systems will need ranlib to be called after a library is
  900. X# changed.
  901. X#
  902. XRANLIB=        ranlib            # for BSD
  903. X
  904. X# Define the name of the script used to update the dependencies in
  905. X# the Makefile.
  906. X# Choices are:
  907. X#    slowmkdep -- always works (as far as I know)
  908. X#    fastmkdep -- uses cc -M, which isn't always available
  909. X#    makedepend -- Todd Brunhoff's superfast tool (comes with X11)
  910. X#                  (This needs -Dunix because of configure.h)
  911. X# You may also place this definition in the proto.arch.* file if no
  912. X# method works for every architecture supported by this OS.
  913. X#
  914. X#MKDEP=        $(CONF)/slowmkdep
  915. XMKDEP=        $(CONF)/fastmkdep
  916. X#MKDEP=        makedepend -Dunix
  917. X
  918. X# Define the system libraries to link with programs that use termcap and X11
  919. X# (In some cases these are architecture-dependent)
  920. X#
  921. XLIBTERMCAP=    -ltermcap
  922. XLIBX11=        -lX11
  923. X
  924. X# Other OS-specific choices (-I flags, -D flags, compiler options)
  925. X#
  926. XOSINCLS=    
  927. XOSDEFS=        
  928. XOSOPTS=        
  929. END_OF_FILE
  930. if test 1049 -ne `wc -c <'Conf/proto.os.sony'`; then
  931.     echo shar: \"'Conf/proto.os.sony'\" unpacked with wrong size!
  932. fi
  933. # end of 'Conf/proto.os.sony'
  934. fi
  935. if test -f 'Conf/proto.os.sysv' -a "${1}" != "-c" ; then 
  936.   echo shar: Will not clobber existing file \"'Conf/proto.os.sysv'\"
  937. else
  938. echo shar: Extracting \"'Conf/proto.os.sysv'\" \(756 characters\)
  939. sed "s/^X//" >'Conf/proto.os.sysv' <<'END_OF_FILE'
  940. X
  941. X#
  942. X# Definitions pertaining to (modern versions of) System V
  943. X#
  944. X# Disclaimer: this was only tested on a Silicon Graphics under IRIX 3.2
  945. X#
  946. X
  947. X# The name of this O.S.
  948. X#
  949. XOS=        sysv
  950. X
  951. X# SYSV-based systems don't have ranlib; the value 'true' makes Make happy.
  952. X#
  953. XRANLIB=        true            # for SYSV
  954. X
  955. X# Defines to make various bits of code happy:
  956. X#    -DSYSV is the general test for System V.
  957. X#    -Datt is used at least by some X internal headers (and what else?)
  958. X#    And, of course, index and rindex are called strchr and strrchr.
  959. X#
  960. XOSDEFS=        -DSYSV -Datt -Dindex=strchr -Drindex=strrchr
  961. X
  962. X# The mkdep using cc -M will work for any architecture (I hope)
  963. X#
  964. XMKDEP=        $(CONF)/fastmkdep
  965. X
  966. X# The system libraries to link with programs that use termcap and X11
  967. X# are in proto.arch.* instead.
  968. X
  969. END_OF_FILE
  970. if test 756 -ne `wc -c <'Conf/proto.os.sysv'`; then
  971.     echo shar: \"'Conf/proto.os.sysv'\" unpacked with wrong size!
  972. fi
  973. # end of 'Conf/proto.os.sysv'
  974. fi
  975. if test -f 'Conf/proto.os.xxx' -a "${1}" != "-c" ; then 
  976.   echo shar: Will not clobber existing file \"'Conf/proto.os.xxx'\"
  977. else
  978. echo shar: Extracting \"'Conf/proto.os.xxx'\" \(1170 characters\)
  979. sed "s/^X//" >'Conf/proto.os.xxx' <<'END_OF_FILE'
  980. X
  981. X#
  982. X# Definitions pertaining to operating system XXX
  983. X#
  984. X
  985. X# Define the name of this O.S. here.
  986. X#
  987. XOS=        XXX
  988. X
  989. X# Choose ONE of the following definitions of RANLIB.
  990. X# BSD-based systems will need ranlib to be called after a library is
  991. X# changed.
  992. X# SYSV-based systems don't have ranlib; the value 'true' makes Make happy.
  993. X#
  994. XRANLIB=        ranlib            # for BSD
  995. XRANLIB=        true            # for SYSV
  996. X
  997. X# Define the name of the script used to update the dependencies in
  998. X# the Makefile.
  999. X# Choices are:
  1000. X#    slowmkdep -- always works (as far as I know)
  1001. X#    fastmkdep -- uses cc -M, which isn't always available
  1002. X#    makedepend -- Todd Brunhoff's superfast tool (comes with X11)
  1003. X#                  (This needs -Dunix because of configure.h)
  1004. X# You may also place this definition in the proto.arch.* file if no
  1005. X# method works for every architecture supported by this OS.
  1006. X#
  1007. XMKDEP=        $(CONF)/slowmkdep
  1008. XMKDEP=        $(CONF)/fastmkdep
  1009. XMKDEP=        makedepend -Dunix
  1010. X
  1011. X# Define the system libraries to link with programs that use termcap and X11
  1012. X# (In some cases these are architecture-dependent)
  1013. X#
  1014. XLIBTERMCAP=    -ltermcap
  1015. XLIBX11=        -lX11
  1016. X
  1017. X# Other OS-specific choices (-I flags, -D flags, compiler options)
  1018. X#
  1019. XOSINCLS=    
  1020. XOSDEFS=        
  1021. XOSOPTS=        
  1022. END_OF_FILE
  1023. if test 1170 -ne `wc -c <'Conf/proto.os.xxx'`; then
  1024.     echo shar: \"'Conf/proto.os.xxx'\" unpacked with wrong size!
  1025. fi
  1026. # end of 'Conf/proto.os.xxx'
  1027. fi
  1028. if test -f 'Conf/proto.port.xxx' -a "${1}" != "-c" ; then 
  1029.   echo shar: Will not clobber existing file \"'Conf/proto.port.xxx'\"
  1030. else
  1031. echo shar: Extracting \"'Conf/proto.port.xxx'\" \(1032 characters\)
  1032. sed "s/^X//" >'Conf/proto.port.xxx' <<'END_OF_FILE'
  1033. X
  1034. X#
  1035. X# Definitions pertaining to the port to the XXX window system
  1036. X#
  1037. X
  1038. X# NB: You are not expected to port STDWIN -- this has already been done.
  1039. X# This prototype file is provided mostly to document the definitions
  1040. X# exported from the various proto.port.* files, and as a template for
  1041. X# the STDWIN implementer.  And, of course, if you really WANT to port
  1042. X# stdwin to a new window system or look-and-feel (NeWS, or SunTools, or
  1043. X# OpenLook), you're welcome -- just check with the author of STDWIN
  1044. X# first to see if somebody else isn't planning to do the same.
  1045. X
  1046. X# Define the name of this port.
  1047. X# This is used as a subdirectory name where all the objects for this
  1048. X# port for a given architecture live: $(TOP)/Build/$(ARCH)/$(PORT)
  1049. X#
  1050. XPORT=        XXX
  1051. X
  1052. X# Libraries to link with for the X11 port.
  1053. X# Most of this is boilerplate, only the PORTSYSLIBS part depends on
  1054. X# what your system requires.
  1055. X#
  1056. XPORTOWNLIBS=    $(PORTBUILD)/lib/lib.a
  1057. XPORTSYSLIBS=    -lXXX
  1058. XPORTLIBS=    $(PORTOWNLIBS) $(PORTSYSLIBS)
  1059. X
  1060. X# NB: -lXXX is really OS- or site-specific as well, sigh.
  1061. END_OF_FILE
  1062. if test 1032 -ne `wc -c <'Conf/proto.port.xxx'`; then
  1063.     echo shar: \"'Conf/proto.port.xxx'\" unpacked with wrong size!
  1064. fi
  1065. # end of 'Conf/proto.port.xxx'
  1066. fi
  1067. if test -f 'Doc/macros.ms' -a "${1}" != "-c" ; then 
  1068.   echo shar: Will not clobber existing file \"'Doc/macros.ms'\"
  1069. else
  1070. echo shar: Extracting \"'Doc/macros.ms'\" \(1074 characters\)
  1071. sed "s/^X//" >'Doc/macros.ms' <<'END_OF_FILE'
  1072. X.\"
  1073. X.\" Macro definitions and other settings
  1074. X.\" ------------------------------------
  1075. X.\"
  1076. X.\"    The Constant Width font is whatever is mounted at font position 5.
  1077. X.\"    XXX This is not effective, -ms overrides it (in .TL?),
  1078. X.\"    but the effect is the same.
  1079. X.\"
  1080. X.fp 5 CW
  1081. X.\"
  1082. X.\"    Constant width font - use .cW like .I or .R or .B 
  1083. X.\"       When using nroff this translates to .I.
  1084. X.\"
  1085. X.de cW
  1086. X.if t \{\
  1087. X.    ie \\n(.$ \&\f5\\$1\fP\\$2
  1088. X.    el .ft 5
  1089. X.\}
  1090. X.if n .I \\$1 \\$2
  1091. X..
  1092. X.\"
  1093. X.\"    Inline constant width macros -- use like \*<this\*> to get a
  1094. X.\"    word or two in constant width.  Equivalent to .cW.
  1095. X.\"
  1096. X.ds < \&\f5
  1097. X.ds > \fP
  1098. X.\"
  1099. X.\"    Code segment macros -- use .sC to  start a code segment and .eC
  1100. X.\"    to end it.  Argument to .sC (L, I or B) is passed on to .DS.
  1101. X.\"    Tabs are set 8 spaces apart.
  1102. X.\"
  1103. X.de sC
  1104. X.DS \\$1 \\$2
  1105. X.cW
  1106. X.ta \w'\0\0\0\0\0\0\0\0'u +\w'\0\0\0\0\0\0\0\0'u
  1107. X..
  1108. X.de eC
  1109. X.R
  1110. X.DE
  1111. X..
  1112. X.\"
  1113. X.\"    Change the point size and spacing to something more radable:
  1114. X.\"
  1115. X.nr PS 12
  1116. X.nr VS 14
  1117. X.\"
  1118. X.\"    Some string definitions specific to Python documents:
  1119. X.\"
  1120. X.ds Py \f2Python\fP
  1121. X.ds Ux \s-2UNIX\s0
  1122. END_OF_FILE
  1123. if test 1074 -ne `wc -c <'Doc/macros.ms'`; then
  1124.     echo shar: \"'Doc/macros.ms'\" unpacked with wrong size!
  1125. fi
  1126. # end of 'Doc/macros.ms'
  1127. fi
  1128. if test -f 'Gen/waskfile.c' -a "${1}" != "-c" ; then 
  1129.   echo shar: Will not clobber existing file \"'Gen/waskfile.c'\"
  1130. else
  1131. echo shar: Extracting \"'Gen/waskfile.c'\" \(1241 characters\)
  1132. sed "s/^X//" >'Gen/waskfile.c' <<'END_OF_FILE'
  1133. X/* STDWIN -- UNIVERSAL WASKFILE. */
  1134. X
  1135. X#include "tools.h"
  1136. X#include "filedefs.h"
  1137. X#include "stdwin.h"
  1138. X
  1139. X/* Ask for a file name; default is initial contents of buf.
  1140. X   Checks are made that the name typed is sensible:
  1141. X   if 'new' is TRUE, it should be writable or creatable,
  1142. X   and if it already exists confirmation is asked;
  1143. X   if 'new' is FALSE, it should exist. */
  1144. X
  1145. Xbool
  1146. Xwaskfile(prompt, buf, len, new)
  1147. X    char *prompt;
  1148. X    char *buf;
  1149. X    int len;
  1150. X    bool new;
  1151. X{
  1152. X    for (;;) {
  1153. X        if (!waskstr(prompt, buf, len) || buf[0] == EOS)
  1154. X            return FALSE;
  1155. X        if (new) {
  1156. X            if (access(buf, NOMODE) >= 0) {    /* Existing file */
  1157. X                if (access(buf, WMODE) >= 0) {
  1158. X                    switch (waskync("Overwrite? [ny]", 0)) {
  1159. X                    case -1:    return FALSE;
  1160. X                    case 1:        return TRUE;
  1161. X                    }
  1162. X                    wmessage("Try again.");
  1163. X                }
  1164. X                else
  1165. X                    wmessage("No write permission.");
  1166. X            }
  1167. X            else {
  1168. X                char *p= strrchr(buf, SEP);
  1169. X                if (p == NULL) {
  1170. X                    if (access(CURDIR, WMODE) >= 0)
  1171. X                        return TRUE;
  1172. X                }
  1173. X                else {
  1174. X                    *p= EOS;
  1175. X                    if (access(buf, WMODE) >= 0) {
  1176. X                        *p= SEP;
  1177. X                        return TRUE;
  1178. X                    }
  1179. X                }
  1180. X                wmessage("Can't create file.");
  1181. X            }
  1182. X        }
  1183. X        else {
  1184. X            if (access(buf, RMODE) >= 0)
  1185. X                return TRUE;
  1186. X            wmessage("File not found.");
  1187. X        }
  1188. X        wfleep();
  1189. X        break;
  1190. X    }
  1191. X    return FALSE;
  1192. X}
  1193. END_OF_FILE
  1194. if test 1241 -ne `wc -c <'Gen/waskfile.c'`; then
  1195.     echo shar: \"'Gen/waskfile.c'\" unpacked with wrong size!
  1196. fi
  1197. # end of 'Gen/waskfile.c'
  1198. fi
  1199. if test -f 'H/_ARGS.h' -a "${1}" != "-c" ; then 
  1200.   echo shar: Will not clobber existing file \"'H/_ARGS.h'\"
  1201. else
  1202. echo shar: Extracting \"'H/_ARGS.h'\" \(1138 characters\)
  1203. sed "s/^X//" >'H/_ARGS.h' <<'END_OF_FILE'
  1204. X/* Define _ARGS(x) as either x or () depending on an educated guess
  1205. X   on the presence of support for prototypes in the compiler.
  1206. X   The idea is that you declare function with prototypes as follows:
  1207. X       extern char *malloc _ARGS((unsigned int));
  1208. X   Watch the double parentheses (you'll quickly get used to them).
  1209. X   Use _ARGS((void)) to declare a function with no arguments.
  1210. X   Use things like _ARGS((char *, ...)) to declare printf-like functions.
  1211. X   
  1212. X   As a free extra, the macro HAVE_PROTOTYPES is defined if and only if
  1213. X   prototypes are supported, and the macro 'const' is defined as empty
  1214. X   if prototypes are not supported (and also if THINK_C is defined).
  1215. X*/
  1216. X
  1217. X#ifndef _ARGS
  1218. X
  1219. X#ifdef __STDC__
  1220. X#define HAVE_PROTOTYPES
  1221. X#endif
  1222. X
  1223. X#ifdef THINK_C
  1224. X#undef HAVE_PROTOTYPES
  1225. X#define HAVE_PROTOTYPES
  1226. X#endif
  1227. X
  1228. X#ifdef sgi
  1229. X#ifdef mips
  1230. X#define HAVE_PROTOTYPES
  1231. X#endif
  1232. X#endif
  1233. X
  1234. X#ifdef HAVE_PROTOTYPES
  1235. X#define _ARGS(x) x
  1236. X#else
  1237. X#define _ARGS(x) ()
  1238. X#endif
  1239. X
  1240. X#ifndef HAVE_PROTOTYPES
  1241. X#define const /*empty*/
  1242. X#else /* HAVE_PROTOTYPES */
  1243. X#ifdef THINK_C
  1244. X#undef const
  1245. X#define const /*empty*/
  1246. X#endif /* THINK_C */
  1247. X#endif /* HAVE_PROTOTYPES */
  1248. X
  1249. X#endif /* _ARGS */
  1250. END_OF_FILE
  1251. if test 1138 -ne `wc -c <'H/_ARGS.h'`; then
  1252.     echo shar: \"'H/_ARGS.h'\" unpacked with wrong size!
  1253. fi
  1254. # end of 'H/_ARGS.h'
  1255. fi
  1256. if test -f 'H/editwin.h' -a "${1}" != "-c" ; then 
  1257.   echo shar: Will not clobber existing file \"'H/editwin.h'\"
  1258. else
  1259. echo shar: Extracting \"'H/editwin.h'\" \(1077 characters\)
  1260. sed "s/^X//" >'H/editwin.h' <<'END_OF_FILE'
  1261. X/* Text Edit Window Package */
  1262. X
  1263. Xtypedef struct editwin {
  1264. X    /* Fields can be read by the caller but shouldn't be changed */
  1265. X    WINDOW *win;
  1266. X    TEXTEDIT *tp;
  1267. X    char *filename;
  1268. X    char /*tbool*/ saved;
  1269. X} EDITWIN;
  1270. X
  1271. XEDITWIN *ewfind _ARGS((WINDOW *));
  1272. Xint ewcount _ARGS((void));
  1273. XEDITWIN *ewcreate _ARGS((char *));
  1274. XEDITWIN *ewnew _ARGS((void));
  1275. XEDITWIN *ewopen _ARGS((void));
  1276. X/*bool*/int ewclose _ARGS((EDITWIN *));
  1277. X/*bool*/int ewsave _ARGS((EDITWIN *));
  1278. X/*bool*/int ewsaveas _ARGS((EDITWIN *));
  1279. X/*bool*/int ewsavecopy _ARGS((EDITWIN *));
  1280. X/*bool*/int ewsaveprompt _ARGS((EDITWIN *, char *, /*bool*/int));
  1281. X/*bool*/int ewrevert _ARGS((EDITWIN *));
  1282. X/*bool*/int ewreadfile _ARGS((EDITWIN *, char *));
  1283. Xvoid ewsetdimensions _ARGS((EDITWIN *));
  1284. X/*bool*/int ewwritefile _ARGS((EDITWIN *, char *));
  1285. X/*bool*/int ewevent _ARGS((EDITWIN *, EVENT *, /*bool*/int *));
  1286. X/*bool*/int ewsaveall _ARGS((void));
  1287. X/*bool*/int ewcloseall _ARGS((void));
  1288. Xvoid ewreplace _ARGS((EDITWIN *, char *));
  1289. Xvoid ewundo _ARGS((EDITWIN *));        /* Not implemented */
  1290. Xvoid ewcopy _ARGS((EDITWIN *));
  1291. Xvoid ewpaste _ARGS((EDITWIN *));
  1292. END_OF_FILE
  1293. if test 1077 -ne `wc -c <'H/editwin.h'`; then
  1294.     echo shar: \"'H/editwin.h'\" unpacked with wrong size!
  1295. fi
  1296. # end of 'H/editwin.h'
  1297. fi
  1298. if test -f 'H/vtrm.h' -a "${1}" != "-c" ; then 
  1299.   echo shar: Will not clobber existing file \"'H/vtrm.h'\"
  1300. else
  1301. echo shar: Extracting \"'H/vtrm.h'\" \(809 characters\)
  1302. sed "s/^X//" >'H/vtrm.h' <<'END_OF_FILE'
  1303. X/*
  1304. X * Terminal capabilities.  These correspond to bits set by trmstart in its
  1305. X * parameter flags parameter.
  1306. X */
  1307. X
  1308. X#define HAS_STANDOUT    1    /* Terminal has inverse video or underline */
  1309. X#define CAN_SCROLL    2    /* Terminal can insert/delete lines */
  1310. X#define CAN_OPTIMISE    4    /* Terminal can insert/delete characters */
  1311. X#define CAN_SENSE    8    /* Terminal can send cursor position */
  1312. X
  1313. X/*
  1314. X * Error codes returned by trmstart.
  1315. X */
  1316. X
  1317. X#define TE_OK        0    /* No errors */
  1318. X#define TE_TWICE    1    /* Trmstart called again */
  1319. X#define TE_NOTERM    2    /* $TERM not set or empty */
  1320. X#define TE_BADTERM    3    /* $TERM not found in termcap database */
  1321. X#define TE_DUMB        4    /* Terminal too dumb */
  1322. X#define TE_NOTTY    5    /* Stdout not a tty device */
  1323. X#define TE_NOMEM    6    /* Can't get enough memory */
  1324. X#define TE_OTHER    7    /* This and higher are reserved errors */
  1325. END_OF_FILE
  1326. if test 809 -ne `wc -c <'H/vtrm.h'`; then
  1327.     echo shar: \"'H/vtrm.h'\" unpacked with wrong size!
  1328. fi
  1329. # end of 'H/vtrm.h'
  1330. fi
  1331. if test -f 'Packs/textedit/wprintf.c' -a "${1}" != "-c" ; then 
  1332.   echo shar: Will not clobber existing file \"'Packs/textedit/wprintf.c'\"
  1333. else
  1334. echo shar: Extracting \"'Packs/textedit/wprintf.c'\" \(1040 characters\)
  1335. sed "s/^X//" >'Packs/textedit/wprintf.c' <<'END_OF_FILE'
  1336. X#include "stdwin.h"
  1337. X
  1338. X/* "Printf to a window", with (h, v) and return value like wdrawtext.
  1339. X   Use only in a draw procedure or between wbegindrawing/wenddrawing. */
  1340. X
  1341. Xvoid
  1342. Xwprintf(h, v, fmt, rest_of_arguments)
  1343. X    int h, v;
  1344. X    char *fmt;
  1345. X{
  1346. X    char buf[1000];
  1347. X    int len;
  1348. X    int width;
  1349. X    
  1350. X    vsprintf(buf, fmt, &rest_of_arguments);
  1351. X    len = strlen(buf);
  1352. X    width = wtextwidth(buf, len);
  1353. X    wdrawtext(h, v, buf, len);
  1354. X}
  1355. X
  1356. X/* "Centered printf to a window": like wprintf but allows centered text.
  1357. X   The first parameter, align, is a percentage: a value of 0 prints
  1358. X   at the right of h, a value of 50 centers around h, a value of 100
  1359. X   aligns the end of the text at h.
  1360. X   The v coordinate always indicates the top of the text.
  1361. X   Return value is the h coordinate at the right end of the text. */
  1362. X
  1363. Xvoid
  1364. Xwcprintf(align, h, v, fmt, rest_of_arguments)
  1365. X    int align;
  1366. X    int h, v;
  1367. X    char *fmt;
  1368. X{
  1369. X    char buf[1000];
  1370. X    int len;
  1371. X    int width;
  1372. X    
  1373. X    vsprintf(buf, fmt, &rest_of_arguments);
  1374. X    len = strlen(buf);
  1375. X    width = wtextwidth(buf, len);
  1376. X    wdrawtext(h - align*width/100, v, buf, len);
  1377. X}
  1378. END_OF_FILE
  1379. if test 1040 -ne `wc -c <'Packs/textedit/wprintf.c'`; then
  1380.     echo shar: \"'Packs/textedit/wprintf.c'\" unpacked with wrong size!
  1381. fi
  1382. # end of 'Packs/textedit/wprintf.c'
  1383. fi
  1384. if test -f 'Packs/vt/vtimpl.h' -a "${1}" != "-c" ; then 
  1385.   echo shar: Will not clobber existing file \"'Packs/vt/vtimpl.h'\"
  1386. else
  1387. echo shar: Extracting \"'Packs/vt/vtimpl.h'\" \(1403 characters\)
  1388. sed "s/^X//" >'Packs/vt/vtimpl.h' <<'END_OF_FILE'
  1389. X/* Assorted things used by the VT implementation */
  1390. X
  1391. X/* Include files */
  1392. X
  1393. X#include "tools.h"
  1394. X#include "stdwin.h"
  1395. X#include "vt.h"
  1396. X
  1397. X/* Names for control characters */
  1398. X
  1399. X#define ESC    '\033'
  1400. X#define CR    '\r'
  1401. X#define LF    '\012'    /* Can't use \n or EOL because of MPW on Macintosh */
  1402. X#define BS    '\b'
  1403. X#define BEL    '\007'
  1404. X#define TAB    '\t'
  1405. X#define FF    '\014'
  1406. X
  1407. X/* Macro to check for non-control character */
  1408. X
  1409. X#define PRINTABLE(c)    isprint(c)
  1410. X
  1411. X/* Debugging facilities */
  1412. X
  1413. X/* If you want static functions visible for adb, pass '-DSTATIC=static'
  1414. X   to the cc compiler. */
  1415. X#ifndef STATIC
  1416. X#define STATIC static
  1417. X#endif
  1418. X
  1419. X/* Macro D() to turn off code in NDEBUG mode or if debugging is off */
  1420. X#ifdef NDEBUG
  1421. X#define D(stmt) 0
  1422. X#else
  1423. X/* XXX Dependency on 'debugging' declared in calling application */
  1424. Xextern int debugging;
  1425. X#define D(stmt) if (!debugging) { } else stmt
  1426. X#endif
  1427. X
  1428. X/* In Amoeba, MON_EVENT() can be used to keep cheap performance statistics */
  1429. X#ifndef MON_EVENT
  1430. X#define MON_EVENT(msg) do { } while (0) /* Funny syntax to work inside 'if' */
  1431. X#endif
  1432. X
  1433. X/* Functions used internally */
  1434. X/* XXX Ought to have names beginning with _vt */
  1435. X
  1436. Xvoid vtcirculate _ARGS((VT *vt, int r1, int r2, int n));
  1437. Xvoid vtchange _ARGS((VT *vt, int r1, int c1, int r2, int c2));
  1438. Xvoid vtshow _ARGS((VT *vt, int r1, int c1, int r2, int c2));
  1439. Xvoid vtscroll _ARGS((VT *vt, int r1, int c1, int r2, int c2, int dr, int dc));
  1440. Xvoid vtsync _ARGS((VT *vt));
  1441. END_OF_FILE
  1442. if test 1403 -ne `wc -c <'Packs/vt/vtimpl.h'`; then
  1443.     echo shar: \"'Packs/vt/vtimpl.h'\" unpacked with wrong size!
  1444. fi
  1445. # end of 'Packs/vt/vtimpl.h'
  1446. fi
  1447. if test -f 'Packs/vt/vtputs.c' -a "${1}" != "-c" ; then 
  1448.   echo shar: Will not clobber existing file \"'Packs/vt/vtputs.c'\"
  1449. else
  1450. echo shar: Extracting \"'Packs/vt/vtputs.c'\" \(1282 characters\)
  1451. sed "s/^X//" >'Packs/vt/vtputs.c' <<'END_OF_FILE'
  1452. X/* A simple output function, emulating a "dumb tty" */
  1453. X
  1454. X#include "vtimpl.h"
  1455. X
  1456. Xvoid
  1457. Xvtputs(vt, text)
  1458. X    register VT *vt;
  1459. X    register char *text;
  1460. X{
  1461. X#ifndef NDEBUG
  1462. X    if (text == NULL)
  1463. X        vtpanic("vtputs with NULL text");
  1464. X#endif
  1465. X    while (*text != EOS) {
  1466. X        if (PRINTABLE(*text)) {
  1467. X            register char *end = text;
  1468. X            do {
  1469. X                text++;
  1470. X            } while (PRINTABLE(*text));
  1471. X            vtputstring(vt, text, (int) (end-text));
  1472. X            text = end;
  1473. X        }
  1474. X        else switch (*text++) {
  1475. X        
  1476. X        case BEL:    /* Make some noise */
  1477. X            wfleep();
  1478. X            break;
  1479. X        
  1480. X        case BS:    /* Move 1 left */
  1481. X            /* Rely on vtsetcursor's clipping */
  1482. X            vtsetcursor(vt, vt->cur_row, vt->cur_col - 1);
  1483. X            /* Don't erase --
  1484. X               that's part of intelligent echoing */
  1485. X            break;
  1486. X        
  1487. X        case TAB:    /* Move to next tab stop */
  1488. X            /* Rely on vtsetcursor's clipping */
  1489. X            vtsetcursor(vt, vt->cur_row,
  1490. X                (vt->cur_col & ~7) + 8);
  1491. X            /* Normalize cursor (may cause scroll!) */
  1492. X            vtputstring(vt, "", 0);
  1493. X            break;
  1494. X        
  1495. X        case LF:    /* Move cursor down in same column */
  1496. X            vtsetcursor(vt, vt->cur_row + 1, vt->cur_col);
  1497. X            /* Normalize cursor (may cause scroll!) */
  1498. X            vtputstring(vt, "", 0);
  1499. X            break;
  1500. X        
  1501. X        case FF:    /* Start over */
  1502. X            vtreset(vt);
  1503. X            break;
  1504. X        
  1505. X        case CR:    /* Back to col 0 on same line */
  1506. X            vtsetcursor(vt, vt->cur_row, 0);
  1507. X            break;
  1508. X        
  1509. X        }
  1510. X    }
  1511. X    vtsync(vt);
  1512. X}
  1513. END_OF_FILE
  1514. if test 1282 -ne `wc -c <'Packs/vt/vtputs.c'`; then
  1515.     echo shar: \"'Packs/vt/vtputs.c'\" unpacked with wrong size!
  1516. fi
  1517. # end of 'Packs/vt/vtputs.c'
  1518. fi
  1519. if test -f 'Ports/alfa/measure.c' -a "${1}" != "-c" ; then 
  1520.   echo shar: Will not clobber existing file \"'Ports/alfa/measure.c'\"
  1521. else
  1522. echo shar: Extracting \"'Ports/alfa/measure.c'\" \(743 characters\)
  1523. sed "s/^X//" >'Ports/alfa/measure.c' <<'END_OF_FILE'
  1524. X/* STANDARD WINDOWS -- TEXT MEASURING. */
  1525. X
  1526. X#include "alfa.h"
  1527. X
  1528. Xint
  1529. Xwlineheight()
  1530. X{
  1531. X    return 1;
  1532. X}
  1533. X
  1534. Xint
  1535. Xwbaseline()
  1536. X{
  1537. X    return 1;
  1538. X}
  1539. X
  1540. X#define CHARWIDTH(c) ((c) < ' ' ? 2 : (c) < 0177 ? 1 : (c) < 0200 ? 2 : 4)
  1541. X
  1542. Xint
  1543. Xwtextwidth(str, len)
  1544. X    char *str;
  1545. X    int len;
  1546. X{
  1547. X    int i;
  1548. X    int w= 0;
  1549. X    
  1550. X    if (len < 0)
  1551. X        len= strlen(str);
  1552. X    for (i= 0; i < len; ++i) {
  1553. X        unsigned char c= str[i];
  1554. X        w += CHARWIDTH(c);
  1555. X    }
  1556. X    return w;
  1557. X}
  1558. X
  1559. Xint
  1560. Xwcharwidth(c)
  1561. X    int c;
  1562. X{
  1563. X    c &= 0xff;
  1564. X    return CHARWIDTH(c);
  1565. X}
  1566. X
  1567. Xint
  1568. Xwtextbreak(str, len, width)
  1569. X    char *str;
  1570. X    int len;
  1571. X    int width;
  1572. X{
  1573. X    int i;
  1574. X    
  1575. X    if (len < 0)
  1576. X        len= strlen(str);
  1577. X    for (i= 0; i < len && width > 0; ++i) {
  1578. X        unsigned char c= str[i];
  1579. X        width -= CHARWIDTH(c);
  1580. X        if (width < 0)
  1581. X            break; /* Before incrementing i! */
  1582. X    }
  1583. X    return i;
  1584. X}
  1585. END_OF_FILE
  1586. if test 743 -ne `wc -c <'Ports/alfa/measure.c'`; then
  1587.     echo shar: \"'Ports/alfa/measure.c'\" unpacked with wrong size!
  1588. fi
  1589. # end of 'Ports/alfa/measure.c'
  1590. fi
  1591. if test -f 'Ports/alfa/scroll.c' -a "${1}" != "-c" ; then 
  1592.   echo shar: Will not clobber existing file \"'Ports/alfa/scroll.c'\"
  1593. else
  1594. echo shar: Extracting \"'Ports/alfa/scroll.c'\" \(1199 characters\)
  1595. sed "s/^X//" >'Ports/alfa/scroll.c' <<'END_OF_FILE'
  1596. X/* Scrolling.
  1597. X   This is not meant to scroll the window with respect to the document
  1598. X   (that's done with wshow), but to say that a change has occurred
  1599. X   in the indicated rectangle for which a full update can be avoided
  1600. X   by scrolling its content by (dh, dv).
  1601. X   If we can't do such scrolls, we'll call wchange instead. */
  1602. X
  1603. X#include "alfa.h"
  1604. X
  1605. X/*ARGSUSED*/
  1606. Xvoid
  1607. Xwscroll(win, left, top, right, bottom, dh, dv)
  1608. X    WINDOW *win;
  1609. X    int left, top;
  1610. X    int right, bottom;
  1611. X    int dh, dv;
  1612. X{
  1613. X    /* if (dh != 0 || left > 0 || right < columns) {
  1614. X        wchange(win, left, top, right, bottom);
  1615. X        return;
  1616. X    }*/
  1617. X    /* Convert to screen coordinates: */
  1618. X    top -= win->offset;
  1619. X    bottom -= win->offset;
  1620. X    /* Clip to window: */
  1621. X    if (top < win->top)
  1622. X        top= win->top;
  1623. X    if (bottom > win->bottom)
  1624. X        bottom= win->bottom;
  1625. X    /* Do the scroll: */
  1626. X    if (top < bottom) {
  1627. X        dv= -dv;
  1628. X        trmscrollup(top, bottom-1, dv);
  1629. X        /* Set the rectangle filled with 'empty' now: */
  1630. X        if (dv < 0) {
  1631. X            if (top-dv < bottom)
  1632. X                bottom= top-dv;
  1633. X        }
  1634. X        else {
  1635. X            if (bottom-dv > top)
  1636. X                top= bottom-dv;
  1637. X        }
  1638. X        /*
  1639. X        wchange(win, left, top+win->offset,
  1640. X            right, bottom+win->offset);
  1641. X        */
  1642. X        wchange(win, left, win->top+win->offset,
  1643. X            right, win->bottom+win->offset);
  1644. X    }
  1645. X}
  1646. END_OF_FILE
  1647. if test 1199 -ne `wc -c <'Ports/alfa/scroll.c'`; then
  1648.     echo shar: \"'Ports/alfa/scroll.c'\" unpacked with wrong size!
  1649. fi
  1650. # end of 'Ports/alfa/scroll.c'
  1651. fi
  1652. if test -f 'Ports/mac/argcargv.c' -a "${1}" != "-c" ; then 
  1653.   echo shar: Will not clobber existing file \"'Ports/mac/argcargv.c'\"
  1654. else
  1655. echo shar: Extracting \"'Ports/mac/argcargv.c'\" \(1179 characters\)
  1656. sed "s/^X//" >'Ports/mac/argcargv.c' <<'END_OF_FILE'
  1657. X/* MAC STDWIN -- GET ARGC/ARGV. */
  1658. X
  1659. X/* Copy the arguments passed from the finder into argc/argv.
  1660. X   Neither MPW nor THINK C does this, making argc/argv pretty
  1661. X   useless.  By using winitargs(&argc, &argv) you get the arguments
  1662. X   that you expect.  When called to print, a "-p" flag is passed
  1663. X   before the first argument.
  1664. X*/
  1665. X
  1666. X#include "macwin.h"
  1667. X#ifdef MPW
  1668. X#include <SegLoad.h>
  1669. X#endif
  1670. X#ifdef THINK_C
  1671. X#include <SegmentLdr.h>
  1672. X#endif
  1673. X
  1674. Xvoid
  1675. Xwargs(pargc, pargv)
  1676. X    int *pargc;
  1677. X    char ***pargv;
  1678. X{
  1679. X    L_DECLARE(argc, argv, char *);
  1680. X    char apname[256];
  1681. X    char buf[256];
  1682. X    short aprefnum;
  1683. X    Handle apparam;
  1684. X    short message;
  1685. X    short count;
  1686. X    short i;
  1687. X    
  1688. X    GetAppParms(apname, &aprefnum, &apparam);
  1689. X#ifndef CLEVERGLUE
  1690. X    PtoCstr(apname);
  1691. X#endif
  1692. X    L_APPEND(argc, argv, char *, strdup(apname));
  1693. X    
  1694. X    CountAppFiles(&message, &count);
  1695. X    if (message == appPrint) { /* Must have braces around L_*! */
  1696. X        L_APPEND(argc, argv, char *, "-p");
  1697. X    }
  1698. X    
  1699. X    for (i = 1; i <= count; ++i) {
  1700. X        AppFile thefile;
  1701. X        GetAppFiles(i, &thefile);
  1702. X        fullpath(buf, thefile.vRefNum,
  1703. X            p2cstr((char*)&thefile.fName));
  1704. X        L_APPEND(argc, argv, char *, strdup(buf));
  1705. X    }
  1706. X    
  1707. X    L_APPEND(argc, argv, char *, NULL);
  1708. X    *pargc = argc - 1;
  1709. X    *pargv = argv;
  1710. X}
  1711. END_OF_FILE
  1712. if test 1179 -ne `wc -c <'Ports/mac/argcargv.c'`; then
  1713.     echo shar: \"'Ports/mac/argcargv.c'\" unpacked with wrong size!
  1714. fi
  1715. # end of 'Ports/mac/argcargv.c'
  1716. fi
  1717. if test -f 'Ports/mac/fullpath.c' -a "${1}" != "-c" ; then 
  1718.   echo shar: Will not clobber existing file \"'Ports/mac/fullpath.c'\"
  1719. else
  1720. echo shar: Extracting \"'Ports/mac/fullpath.c'\" \(1332 characters\)
  1721. sed "s/^X//" >'Ports/mac/fullpath.c' <<'END_OF_FILE'
  1722. X/* GET FULL PATHNAME OF A FILE. */
  1723. X
  1724. X#include "macwin.h"
  1725. X
  1726. X#ifdef MPW
  1727. X#include <Files.h>
  1728. X#endif
  1729. X#ifdef THINK_C
  1730. X#include <HFS.h>
  1731. X#endif
  1732. X
  1733. X/* Mac file system parameters */
  1734. X#define MAXPATH 256    /* Max path name length+1 */
  1735. X#define SEP ':'        /* Separator in path names */
  1736. X#define ROOTID 2    /* DirID of a volume's root directory */
  1737. X
  1738. X/* Macro to find out whether we can do HFS-only calls: */
  1739. X#define FSFCBLen (* (short *) 0x3f6)
  1740. X#define hfsrunning() (FSFCBLen > 0)
  1741. X
  1742. Xchar *
  1743. Xgetdirname(dir)
  1744. X    int dir; /* WDRefNum */
  1745. X{
  1746. X    union {
  1747. X        HFileInfo f;
  1748. X        DirInfo d;
  1749. X        WDPBRec w;
  1750. X        VolumeParam v;
  1751. X    } pb;
  1752. X    static char cwd[2*MAXPATH];
  1753. X    unsigned char namebuf[MAXPATH];
  1754. X    short err;
  1755. X    long dirid= 0;
  1756. X    char *next= cwd + sizeof cwd - 1;
  1757. X    int len;
  1758. X    
  1759. X    if (!hfsrunning())
  1760. X        return "";
  1761. X    
  1762. X    for (;;) {
  1763. X        pb.d.ioNamePtr= namebuf;
  1764. X        pb.d.ioVRefNum= dir;
  1765. X        pb.d.ioFDirIndex= -1;
  1766. X        pb.d.ioDrDirID= dirid;
  1767. X        err= PBGetCatInfo(&pb.d, FALSE);
  1768. X        if (err != noErr) {
  1769. X            dprintf("PBCatInfo err %d", err);
  1770. X            return NULL;
  1771. X        }
  1772. X        *--next= SEP;
  1773. X        len= namebuf[0];
  1774. X        /* XXX There is no overflow check on cwd here! */
  1775. X        strncpy(next -= len, (char *)namebuf+1, len);
  1776. X        if (pb.d.ioDrDirID == ROOTID)
  1777. X            break;
  1778. X        dirid= pb.d.ioDrParID;
  1779. X    }
  1780. X    return next;
  1781. X}
  1782. X
  1783. Xvoid
  1784. Xfullpath(buf, wdrefnum, file)
  1785. X    char *buf;
  1786. X    int wdrefnum;
  1787. X    char *file;
  1788. X{
  1789. X    strcpy(buf, getdirname(wdrefnum));
  1790. X    strcat(buf, file);
  1791. X}
  1792. END_OF_FILE
  1793. if test 1332 -ne `wc -c <'Ports/mac/fullpath.c'`; then
  1794.     echo shar: \"'Ports/mac/fullpath.c'\" unpacked with wrong size!
  1795. fi
  1796. # end of 'Ports/mac/fullpath.c'
  1797. fi
  1798. if test -f 'Ports/mac_mpw/Makefile' -a "${1}" != "-c" ; then 
  1799.   echo shar: Will not clobber existing file \"'Ports/mac_mpw/Makefile'\"
  1800. else
  1801. echo shar: Extracting \"'Ports/mac_mpw/Makefile'\" \(909 characters\)
  1802. sed "s/^X//" >'Ports/mac_mpw/Makefile' <<'END_OF_FILE'
  1803. X# Makefile for stdwin, generated under Unix
  1804. X
  1805. XSOURCES= 6
  1806. X    about.c 6
  1807. X    argcargv.c 6
  1808. X    caret.c 6
  1809. X    cursor.c 6
  1810. X    dialog.c 6
  1811. X    dprintf.c 6
  1812. X    draw.c 6
  1813. X    event.c 6
  1814. X    fullpath.c 6
  1815. X    menu.c 6
  1816. X    pstring.c 6
  1817. X    scrap.c 6
  1818. X    scroll.c 6
  1819. X    stdwin.c 6
  1820. X    strdup.c 6
  1821. X    timer.c 6
  1822. X    wtextbreak.c 6
  1823. X
  1824. XHEADERS= 6
  1825. X    macwin.h 6
  1826. X    menu.h 6
  1827. X
  1828. XOBJECTS= 6
  1829. X    about.c.o 6
  1830. X    argcargv.c.o 6
  1831. X    caret.c.o 6
  1832. X    cursor.c.o 6
  1833. X    dialog.c.o 6
  1834. X    dprintf.c.o 6
  1835. X    draw.c.o 6
  1836. X    event.c.o 6
  1837. X    fullpath.c.o 6
  1838. X    getopt.c.o 6
  1839. X    menu.c.o 6
  1840. X    pstring.c.o 6
  1841. X    scrap.c.o 6
  1842. X    scroll.c.o 6
  1843. X    set_open_hook.c.o 6
  1844. X    stdwin.c.o 6
  1845. X    strdup.c.o 6
  1846. X    timer.c.o 6
  1847. X    wtextbreak.c.o 6
  1848. X
  1849. XCOptions= -i : -i ::h:
  1850. X
  1851. Xlib.o D {OBJECTS}
  1852. X    Lib -o lib.o -sn Main=STDWIN {OBJECTS}
  1853. X
  1854. Xclean D {OBJECTS}
  1855. X    delete {OBJECTS}
  1856. X
  1857. XSysLibes= 6
  1858. X    {CLibraries}CInterface.o 6
  1859. X    {CLibraries}CRuntime.o 6
  1860. X    {CLibraries}CSANELib.o 6
  1861. X    {CLibraries}StdClib.o
  1862. X
  1863. Xtest2 D test2.c.o lib.o
  1864. X    Link -o test2 -t APPL -c xxxx -p test2.c.o lib.o {SysLibes}
  1865. END_OF_FILE
  1866. echo shar: 48 control characters may be missing from \"'Ports/mac_mpw/Makefile'\"
  1867. if test 909 -ne `wc -c <'Ports/mac_mpw/Makefile'`; then
  1868.     echo shar: \"'Ports/mac_mpw/Makefile'\" unpacked with wrong size!
  1869. fi
  1870. # end of 'Ports/mac_mpw/Makefile'
  1871. fi
  1872. if test -f 'Ports/mac_mpw/intercept.h' -a "${1}" != "-c" ; then 
  1873.   echo shar: Will not clobber existing file \"'Ports/mac_mpw/intercept.h'\"
  1874. else
  1875. echo shar: Extracting \"'Ports/mac_mpw/intercept.h'\" \(1250 characters\)
  1876. sed "s/^X//" >'Ports/mac_mpw/intercept.h' <<'END_OF_FILE'
  1877. X/* The structure of the 'device switch' used by the standard I/O library.
  1878. X   It is possible to install your own versions of selected routines
  1879. X   by storing function pointers into this table.  The structure of
  1880. X   the control block for the dev_write function is also given.
  1881. X
  1882. X   Careful! this information was gathered by disassembling parts
  1883. X   of the library.  There are no guarantees that the same code will
  1884. X   work in future versions of MPW.
  1885. X   Part of it has been tested with versions 1.0B1 and 1.0B2. */
  1886. X
  1887. Xtypedef int (*funcptr)();    /* Pointer to integer function */
  1888. X
  1889. Xstruct device {
  1890. X    long    dev_name;    /* 'FSYS', 'CONS' or 'SYST' */
  1891. X    funcptr    dev_faccess;
  1892. X    funcptr dev_close;
  1893. X    funcptr dev_read;
  1894. X    funcptr dev_write;
  1895. X    funcptr dev_ioctl;
  1896. X};
  1897. X
  1898. Xextern struct device _StdDevs[];
  1899. X
  1900. X#define DEV_FSYS 0
  1901. X#define DEV_CONS 1
  1902. X#define DEV_SYST 2
  1903. X
  1904. X/* Control block for dev_write (arg 1 is a pointer to this).
  1905. X   You might guess that dev_read is similar. */
  1906. X
  1907. Xstruct controlblock {
  1908. X    long io_filler1;    /* Flags? */
  1909. X    long io_filler2;    /* Some pointer */
  1910. X    long io_filler3;    /* Zero */
  1911. X    long io_nbytes;        /* Number of bytes to write */
  1912. X                /* (Reset this to zero after writing) */
  1913. X    char *io_data;        /* Start of data buffer */
  1914. X};
  1915. X
  1916. X#define IO_OK 0            /* Return value from dev_write */
  1917. END_OF_FILE
  1918. if test 1250 -ne `wc -c <'Ports/mac_mpw/intercept.h'`; then
  1919.     echo shar: \"'Ports/mac_mpw/intercept.h'\" unpacked with wrong size!
  1920. fi
  1921. # end of 'Ports/mac_mpw/intercept.h'
  1922. fi
  1923. if test -f 'Ports/vtrm/vtrm.h' -a "${1}" != "-c" ; then 
  1924.   echo shar: Will not clobber existing file \"'Ports/vtrm/vtrm.h'\"
  1925. else
  1926. echo shar: Extracting \"'Ports/vtrm/vtrm.h'\" \(887 characters\)
  1927. sed "s/^X//" >'Ports/vtrm/vtrm.h' <<'END_OF_FILE'
  1928. X/*
  1929. X * Terminal capabilities.  These correspond to bits set by trmstart in its
  1930. X * parameter flags parameter.
  1931. X */
  1932. X
  1933. X#define HAS_STANDOUT    1    /* Terminal has inverse video or underline */
  1934. X#define CAN_SCROLL    2    /* Terminal can insert/delete lines */
  1935. X#define CAN_OPTIMISE    4    /* Terminal can insert/delete characters */
  1936. X#define CAN_SENSE    8    /* Terminal can send cursor position */
  1937. X
  1938. X/*
  1939. X * Error codes returned by trmstart.
  1940. X */
  1941. X
  1942. X#define TE_OK        0    /* No errors */
  1943. X#define TE_TWICE    1    /* Trmstart called again */
  1944. X#define TE_NOTERM    2    /* $TERM not set or empty */
  1945. X#define TE_BADTERM    3    /* $TERM not found in termcap database */
  1946. X#define TE_DUMB        4    /* Terminal too dumb */
  1947. X#define TE_NOTTY    5    /* Stdout not a tty device */
  1948. X#define TE_NOMEM    6    /* Can't get enough memory */
  1949. X#define TE_OTHER    7    /* This and higher are reserved errors */
  1950. X
  1951. X/*
  1952. X * Function to explain why trmstart() failed.
  1953. X */
  1954. X
  1955. Xextern char *trmwhy();
  1956. END_OF_FILE
  1957. if test 887 -ne `wc -c <'Ports/vtrm/vtrm.h'`; then
  1958.     echo shar: \"'Ports/vtrm/vtrm.h'\" unpacked with wrong size!
  1959. fi
  1960. # end of 'Ports/vtrm/vtrm.h'
  1961. fi
  1962. if test -f 'Ports/x11/caret.c' -a "${1}" != "-c" ; then 
  1963.   echo shar: Will not clobber existing file \"'Ports/x11/caret.c'\"
  1964. else
  1965. echo shar: Extracting \"'Ports/x11/caret.c'\" \(868 characters\)
  1966. sed "s/^X//" >'Ports/x11/caret.c' <<'END_OF_FILE'
  1967. X/* X11 STDWIN -- caret operations */
  1968. X
  1969. X#include "x11.h"
  1970. X
  1971. Xvoid
  1972. Xwsetcaret(win, h, v)
  1973. X    WINDOW *win;
  1974. X    int h, v;
  1975. X{
  1976. X    _whidecaret(win);
  1977. X    if (h < 0 || v < 0)
  1978. X        h= v= -1;
  1979. X    win->careth= h;
  1980. X    win->caretv= v;
  1981. X    _wshowcaret(win);
  1982. X}
  1983. X
  1984. Xvoid
  1985. Xwnocaret(win)
  1986. X    WINDOW *win;
  1987. X{
  1988. X    _whidecaret(win);
  1989. X    win->careth= win->caretv= -1;
  1990. X}
  1991. X
  1992. X_wshowcaret(win)
  1993. X    WINDOW *win;
  1994. X{
  1995. X    if (!win->caretshown && win->careth >= 0 && win->caretv >= 0) {
  1996. X        wbegindrawing(win);
  1997. X        _winvertcaret(win);
  1998. X        wenddrawing(win);
  1999. X        win->caretshown= TRUE;
  2000. X    }
  2001. X}
  2002. X
  2003. X_whidecaret(win)
  2004. X    WINDOW *win;
  2005. X{
  2006. X    if (win->caretshown) {
  2007. X        win->caretshown= FALSE;
  2008. X        wbegindrawing(win);
  2009. X        _winvertcaret(win);
  2010. X        wenddrawing(win);
  2011. X    }
  2012. X}
  2013. X
  2014. X_winvertcaret(win)
  2015. X    WINDOW *win;
  2016. X{
  2017. X    /* Call this between w{begin,end}drawing only! */
  2018. X    
  2019. X    int left= win->careth, top= win->caretv;
  2020. X    int right= left+1, bottom= top + wlineheight();
  2021. X    winvert(left, top, right, bottom);
  2022. X}
  2023. END_OF_FILE
  2024. if test 868 -ne `wc -c <'Ports/x11/caret.c'`; then
  2025.     echo shar: \"'Ports/x11/caret.c'\" unpacked with wrong size!
  2026. fi
  2027. # end of 'Ports/x11/caret.c'
  2028. fi
  2029. if test -f 'Ports/x11/cutbuffer.c' -a "${1}" != "-c" ; then 
  2030.   echo shar: Will not clobber existing file \"'Ports/x11/cutbuffer.c'\"
  2031. else
  2032. echo shar: Extracting \"'Ports/x11/cutbuffer.c'\" \(867 characters\)
  2033. sed "s/^X//" >'Ports/x11/cutbuffer.c' <<'END_OF_FILE'
  2034. X/* Cut Buffer Interface */
  2035. X
  2036. X#include "x11.h"
  2037. X
  2038. Xvoid
  2039. Xwsetcutbuffer(ibuffer, data, len)
  2040. X    int ibuffer;
  2041. X    char *data;
  2042. X    int len;
  2043. X{
  2044. X    XStoreBuffer(_wd, data, len, ibuffer);
  2045. X}
  2046. X
  2047. Xchar *
  2048. Xwgetcutbuffer(ibuffer, len_return)
  2049. X    int ibuffer;
  2050. X    int *len_return;
  2051. X{
  2052. X    static char *lastdata;
  2053. X    if (lastdata != NULL)
  2054. X        free(lastdata);
  2055. X    lastdata= XFetchBuffer(_wd, len_return, ibuffer);
  2056. X    if (lastdata != NULL) {
  2057. X        lastdata= realloc(lastdata, *len_return+1);
  2058. X        if (lastdata != NULL)
  2059. X            lastdata[*len_return] = EOS;
  2060. X    }
  2061. X    return lastdata;
  2062. X}
  2063. X
  2064. Xvoid
  2065. Xwrotatecutbuffers(n)
  2066. X    int n;
  2067. X{
  2068. X    static int been_here;
  2069. X    if (!been_here) {
  2070. X        /* XRotateBuffers fails if not all 8 buffers have been
  2071. X           stored into.  Make sure they are all defined. */
  2072. X        int i;
  2073. X        for (i = 0; i < 8; i++) {
  2074. X            int len;
  2075. X            if (wgetcutbuffer(i, &len) == NULL)
  2076. X                wsetcutbuffer(i, "", 0);
  2077. X        }
  2078. X        been_here = 1;
  2079. X    }
  2080. X    XRotateBuffers(_wd, n);
  2081. X}
  2082. END_OF_FILE
  2083. if test 867 -ne `wc -c <'Ports/x11/cutbuffer.c'`; then
  2084.     echo shar: \"'Ports/x11/cutbuffer.c'\" unpacked with wrong size!
  2085. fi
  2086. # end of 'Ports/x11/cutbuffer.c'
  2087. fi
  2088. if test -f 'Ports/x11/llevent.h' -a "${1}" != "-c" ; then 
  2089.   echo shar: Will not clobber existing file \"'Ports/x11/llevent.h'\"
  2090. else
  2091. echo shar: Extracting \"'Ports/x11/llevent.h'\" \(745 characters\)
  2092. sed "s/^X//" >'Ports/x11/llevent.h' <<'END_OF_FILE'
  2093. X/* X11 STDWIN -- Variables set by low-level event handling */
  2094. X
  2095. Xextern WINDOW *_w_new_active;    /* New active window */
  2096. Xextern struct button_state _w_bs; /* Mouse button state */
  2097. Xextern KeySym _w_keysym;    /* Keysym of last non-modifier key pressed */
  2098. Xextern int _w_state;        /* Modifiers in effect at key press */
  2099. X
  2100. Xextern bool _w_moved;        /* Set if button moved */
  2101. Xextern bool _w_bs_changed;    /* Set if button up/down state changed */
  2102. Xextern bool _w_dirty;        /* Set if any window needs a redraw */
  2103. Xextern bool _w_resized;        /* Set if any window resized */
  2104. Xextern Time _w_lasttime;    /* Set to last timestamp seen */
  2105. Xextern bool _w_focused;        /* Set between FocusIn and FocsOut events */
  2106. Xextern WINDOW *_w_close_this;    /* Window to close (WM_DELETE_WINDOW) */
  2107. END_OF_FILE
  2108. if test 745 -ne `wc -c <'Ports/x11/llevent.h'`; then
  2109.     echo shar: \"'Ports/x11/llevent.h'\" unpacked with wrong size!
  2110. fi
  2111. # end of 'Ports/x11/llevent.h'
  2112. fi
  2113. if test -f 'Tools/strdup.c' -a "${1}" != "-c" ; then 
  2114.   echo shar: Will not clobber existing file \"'Tools/strdup.c'\"
  2115. else
  2116. echo shar: Extracting \"'Tools/strdup.c'\" \(196 characters\)
  2117. sed "s/^X//" >'Tools/strdup.c' <<'END_OF_FILE'
  2118. X#include "tools.h"
  2119. X
  2120. Xchar *
  2121. Xstrdup(str)
  2122. X    const char *str;
  2123. X{
  2124. X    if (str != NULL) {
  2125. X        register char *copy = malloc(strlen(str) + 1);
  2126. X        if (copy != NULL)
  2127. X            return strcpy(copy, str);
  2128. X    }
  2129. X    return NULL;
  2130. X}
  2131. END_OF_FILE
  2132. if test 196 -ne `wc -c <'Tools/strdup.c'`; then
  2133.     echo shar: \"'Tools/strdup.c'\" unpacked with wrong size!
  2134. fi
  2135. # end of 'Tools/strdup.c'
  2136. fi
  2137. echo shar: End of archive 18 \(of 19\).
  2138. cp /dev/null ark18isdone
  2139. MISSING=""
  2140. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
  2141.     if test ! -f ark${I}isdone ; then
  2142.     MISSING="${MISSING} ${I}"
  2143.     fi
  2144. done
  2145. if test "${MISSING}" = "" ; then
  2146.     echo You have unpacked all 19 archives.
  2147.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2148. else
  2149.     echo You still need to unpack the following archives:
  2150.     echo "        " ${MISSING}
  2151. fi
  2152. ##  End of shell archive.
  2153. exit 0
  2154.