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

  1. From: guido@cwi.nl (Guido van Rossum)
  2. Newsgroups: alt.sources
  3. Subject: STDWIN 0.9.5, Part 17/19
  4. Message-ID: <3081@charon.cwi.nl>
  5. Date: 4 Mar 91 11:58:32 GMT
  6.  
  7. Archive-name: stdwin/part17
  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 17 (of 19)."
  16. # Contents:  Appls/bed/mmenu.c Appls/dpv/README Appls/dpv/dpv.c
  17. #   Appls/dpv/funnytab Appls/dpv/trans Appls/klok/bsdsetdate.c
  18. #   Appls/miniedit/regsub.c Appls/test/multiwin.c Conf/makemakefile
  19. #   Conf/mkmf Conf/proto.conf Gen/wdrawpar.c Gen/wtextbreak.c
  20. #   H/stdwtext.h Packs/textedit/textdbg.c Ports/alfa/To.do
  21. #   Ports/mac/dprintf.c Ports/mac/scrap.c Ports/mac/timer.c
  22. #   Ports/vtrm/DIST/README Ports/x11/error.c Tools/getopt.c
  23. # Wrapped by guido@voorn.cwi.nl on Mon Mar  4 12:37:35 1991
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'Appls/bed/mmenu.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'Appls/bed/mmenu.c'\"
  27. else
  28. echo shar: Extracting \"'Appls/bed/mmenu.c'\" \(1938 characters\)
  29. sed "s/^X//" >'Appls/bed/mmenu.c' <<'END_OF_FILE'
  30. X#include "bed.h"
  31. X#include "menu.h"
  32. X
  33. Xint    state = PENCIL_ITEM ;
  34. X
  35. Xextern MENU    *pmmenu ;
  36. Xextern MENU    *popmenu ;
  37. X
  38. Xextern bool    drawline ;
  39. X
  40. Xextern bool    drawcircle ;
  41. X
  42. Xextern bool    selrect ;
  43. Xextern int    sr_left ;
  44. Xextern int    sr_top ;
  45. Xextern int    sr_right ;
  46. Xextern int    sr_bottom ;
  47. X
  48. Xextern void    invertbit () ;
  49. X
  50. Xvoid
  51. Xdo_mode_menu (ep)
  52. X    EVENT    *ep ;
  53. X{
  54. X    int    i ;
  55. X
  56. X    switch (ep->u.m.item) {
  57. X    case PENCIL_ITEM :
  58. X        if (drawline) {
  59. X            plotline (invertbit, FALSE) ;
  60. X            drawline = FALSE ;
  61. X        }
  62. X        else if (drawcircle) {
  63. X            plotcircle (invertbit, FALSE) ;
  64. X            drawcircle = FALSE ;
  65. X        }
  66. X        else if (selrect) {
  67. X            drawselrect (sr_left, sr_top, sr_right, sr_bottom) ;
  68. X            selrect = FALSE ;
  69. X        }
  70. X
  71. X        wmenucheck (pmmenu, state, FALSE) ;
  72. X        wmenucheck (pmmenu, PENCIL_ITEM, TRUE) ;
  73. X        state = PENCIL_ITEM ;
  74. X        break ;
  75. X    case LINE_ITEM :
  76. X        if (drawcircle) {
  77. X            plotcircle (invertbit, FALSE) ;
  78. X            drawcircle = FALSE ;
  79. X        }
  80. X        else if (selrect) {
  81. X            drawselrect (sr_left, sr_top, sr_right, sr_bottom) ;
  82. X            selrect = FALSE ;
  83. X        }
  84. X
  85. X        wmenucheck (pmmenu, state, FALSE) ;
  86. X        wmenucheck (pmmenu, LINE_ITEM, TRUE) ;
  87. X        state = LINE_ITEM ;
  88. X        break ;
  89. X    case CIRCLE_ITEM :
  90. X        if (drawline) {
  91. X            plotline (invertbit, FALSE) ;
  92. X            drawline = FALSE ;
  93. X        }
  94. X        else if (selrect) {
  95. X            drawselrect (sr_left, sr_top, sr_right, sr_bottom) ;
  96. X            selrect = FALSE ;
  97. X        }
  98. X
  99. X        wmenucheck (pmmenu, state, FALSE) ;
  100. X        wmenucheck (pmmenu, CIRCLE_ITEM, TRUE) ;
  101. X        state = CIRCLE_ITEM ;
  102. X        break ;
  103. X    case SELECT_ITEM :
  104. X        if (drawline) {
  105. X            plotline (invertbit, FALSE) ;
  106. X            drawline = FALSE ;
  107. X        }
  108. X        else if (drawcircle) {
  109. X            plotcircle (invertbit, FALSE) ;
  110. X            drawcircle = FALSE ;
  111. X        }
  112. X
  113. X        wmenucheck (pmmenu, state, FALSE) ;
  114. X        wmenucheck (pmmenu, SELECT_ITEM, TRUE) ;
  115. X        state = SELECT_ITEM ;
  116. X        break ;
  117. X    }
  118. X
  119. X    if (state == SELECT_ITEM) {
  120. X        for (i = TRANS_MAJ_ITEM ; i <= FLIP_VERT_ITEM ; ++i)
  121. X            wmenuenable (popmenu, i, TRUE) ;
  122. X    }
  123. X    else {
  124. X        for (i = TRANS_MAJ_ITEM ; i <= FLIP_VERT_ITEM ; ++i)
  125. X            wmenuenable (popmenu, i, FALSE) ;
  126. X    }
  127. X}
  128. END_OF_FILE
  129. if test 1938 -ne `wc -c <'Appls/bed/mmenu.c'`; then
  130.     echo shar: \"'Appls/bed/mmenu.c'\" unpacked with wrong size!
  131. fi
  132. # end of 'Appls/bed/mmenu.c'
  133. fi
  134. if test -f 'Appls/dpv/README' -a "${1}" != "-c" ; then 
  135.   echo shar: Will not clobber existing file \"'Appls/dpv/README'\"
  136. else
  137. echo shar: Extracting \"'Appls/dpv/README'\" \(2323 characters\)
  138. sed "s/^X//" >'Appls/dpv/README' <<'END_OF_FILE'
  139. XName:        dpv -- Ditroff previewer using STDWIN
  140. XAuthor:        Guido van Rossum
  141. XStarted:    Jan 12 1988
  142. X
  143. XDitroff output describes pages to be typeset (see comments in the source
  144. Xfor a description).
  145. XPages are started by 'p' commands.
  146. XEach page is a contiguous segment of the file, but operations within a
  147. Xpage can contain arbitrary vertical movements.  I have made the decision
  148. Xnot to display the entire file as one document, since this would limit
  149. Xus to approx. 32 pages (given a practical limit on STDWIN documents of
  150. X32K pixels, and an average screen height of 1K pixels).
  151. XTo allow reasonably efficient displaying, we need to remember the file
  152. Xoffsets where each page starts in the input, and the state of the
  153. Xditroff engine at the start of the page (font etc.).  Thus, we must make
  154. Xa pre-scan of the input to compute this info; after that, the draw
  155. Xprocedure only needs to read the particular page being displayed.
  156. X(Note that it would be easy enough to change the interface so that all
  157. Xpages are mapped to a single document.)
  158. XAs an optimization, we actually don't pre-scan the entire file when the
  159. Xprogram starts up; rather, when a page is first displayed the pre-scan
  160. Xinformation is computed as a by-product of the displaying process.
  161. XThere are two page numbering schemes: internally, the pages are always
  162. Xnumbered 0, 1, ..., with 0 being the configuration data (everything that
  163. Xcomes before the first 'p' command).  Externally, page numbers are taken
  164. Xfrom the argument to the 'p' command.
  165. X
  166. XState to remember for each page start:
  167. X- mounted fonts ('x f' command)
  168. X- character height and slant ('x H' and 'x S' commands) (not used?)
  169. X- current font and size
  170. X
  171. XThe following state, although it can be reset using 'x' commands, is
  172. Xassumed to be set once and for all on page 0:
  173. X- device name ('x T' command)
  174. X- resolution ('x r' command)
  175. X
  176. XFormally, one should also remember the stack of state records
  177. Xmanipulated by '{' and '}' commands; I assume these are used only by
  178. Xpictures, and the stack is empty at page boundaries.
  179. X
  180. XTO DO:
  181. X
  182. XPrint special chars as what they should look like, instead of as their
  183. Xditroff names.
  184. X
  185. XUse real troff fonts.  This requires a translation between ASCII codes
  186. Xoutput by ditroff and character codes in the font.  Perhaps the fonts
  187. Xshould be stored different, so that for ASCII at least no mapping is
  188. Xnecessary.
  189. END_OF_FILE
  190. if test 2323 -ne `wc -c <'Appls/dpv/README'`; then
  191.     echo shar: \"'Appls/dpv/README'\" unpacked with wrong size!
  192. fi
  193. # end of 'Appls/dpv/README'
  194. fi
  195. if test -f 'Appls/dpv/dpv.c' -a "${1}" != "-c" ; then 
  196.   echo shar: Will not clobber existing file \"'Appls/dpv/dpv.c'\"
  197. else
  198. echo shar: Extracting \"'Appls/dpv/dpv.c'\" \(1986 characters\)
  199. sed "s/^X//" >'Appls/dpv/dpv.c' <<'END_OF_FILE'
  200. X/* dpv -- ditroff previewer.  Main program. */
  201. X
  202. X#include "dpv.h"
  203. X
  204. Xint    dbg;        /* Amount of debugging output wanted */
  205. Xint    windowarn;    /* Set if errors must go to dialog box */
  206. X
  207. Xchar   *progname= "dpv"; /* Program name if not taken from argv[0] */
  208. X
  209. X/* Main program.  Scan arguments and call other routines. */
  210. X
  211. Xmain(argc, argv)
  212. X    int argc;
  213. X    char **argv;
  214. X{
  215. X    int firstpage;
  216. X    
  217. X    winitargs(&argc, &argv);
  218. X    
  219. X    if (argc > 0 && *argv != NULL && **argv != EOS) {
  220. X        progname= rindex(argv[0], '/');
  221. X        if (progname != NULL)
  222. X            ++progname;
  223. X        else
  224. X            progname= argv[0];
  225. X    }
  226. X    
  227. X    for (;;) {
  228. X        int c;
  229. X        
  230. X        c= getopt(argc, argv, "df:t:P:");
  231. X        if (c == EOF)
  232. X            break;
  233. X        switch (c) {
  234. X        
  235. X        case 'f':    /* Alternate funnytab file */
  236. X            funnyfile = optarg;
  237. X            break;
  238. X        
  239. X        case 't':    /* Alternative font translations file */
  240. X            readtrans(optarg);
  241. X            break;
  242. X        
  243. X        case 'd':    /* Ask for debugging output */
  244. X            ++dbg; /* Use -dd to increment debug level */
  245. X            break;
  246. X        
  247. X        case 'P':    /* Add printer definition */
  248. X            addprinter(optarg);
  249. X            break;
  250. X        
  251. X        default:
  252. X            usage();
  253. X            /*NOTREACHED*/
  254. X        
  255. X        }
  256. X    }
  257. X    
  258. X    if (optind < argc && argv[optind][0] == '+') {
  259. X        if (argv[optind][1] == EOS ||
  260. X            argv[optind][1] == '$')
  261. X            firstpage= 32000;
  262. X        else
  263. X            firstpage= atoi(argv[optind] + 1);
  264. X        ++optind;
  265. X    }
  266. X    else
  267. X        firstpage= 1;
  268. X    
  269. X    if (optind+1 != argc || strcmp(argv[optind], "-") == 0)
  270. X        usage();
  271. X    
  272. X    windowarn= 1; /* From now on, use dialog box for warnings */
  273. X    
  274. X    preview(argv[optind], firstpage);
  275. X    
  276. X    exit(0);
  277. X}
  278. X
  279. Xusage()
  280. X{
  281. X    error(ABORT,
  282. X"usage: %s [-d] [-f funnytab] [-t translationsfile] [-P printer] [+page] file",
  283. X        progname);
  284. X}
  285. X
  286. X/*VARARGS2*/
  287. Xerror(f, s, a1, a2, a3, a4, a5, a6, a7)
  288. X    int f;
  289. X    char *s;
  290. X{
  291. X    if (f != WARNING || !windowarn) { /* Use stderr */
  292. X        if (f != 0)
  293. X            wdone();
  294. X        fprintf(stderr, "%s: ", progname);
  295. X        fprintf(stderr, s, a1, a2, a3, a4, a5, a6, a7);
  296. X        fprintf(stderr, "\n");
  297. X        if (f != 0)
  298. X            exit(f);
  299. X    }
  300. X    else { /* use dialog box */
  301. X        char buf[256];
  302. X        sprintf(buf, s, a1, a2, a3, a4, a5, a6, a7);
  303. X        wmessage(buf);
  304. X    }
  305. X}
  306. END_OF_FILE
  307. if test 1986 -ne `wc -c <'Appls/dpv/dpv.c'`; then
  308.     echo shar: \"'Appls/dpv/dpv.c'\" unpacked with wrong size!
  309. fi
  310. # end of 'Appls/dpv/dpv.c'
  311. fi
  312. if test -f 'Appls/dpv/funnytab' -a "${1}" != "-c" ; then 
  313.   echo shar: Will not clobber existing file \"'Appls/dpv/funnytab'\"
  314. else
  315. echo shar: Extracting \"'Appls/dpv/funnytab'\" \(2307 characters\)
  316. sed "s/^X//" >'Appls/dpv/funnytab' <<'END_OF_FILE'
  317. XoA    r3symbol    0x22
  318. XoE    r3symbol    0x24
  319. Xcn    r3symbol    0x27
  320. X**    r3symbol    0x2A
  321. Xpl    r3symbol    0x2B
  322. Xmi    r3symbol    0x2D
  323. Xsl    r3symbol    0x2F
  324. Xeq    r3symbol    0x3D
  325. X=~    r3symbol    0x40
  326. X*A    r3symbol    0x41
  327. X*B    r3symbol    0x42
  328. X*X    r3symbol    0x43
  329. X*D    r3symbol    0x44
  330. X*E    r3symbol    0x45
  331. X*F    r3symbol    0x46
  332. X*G    r3symbol    0x47
  333. X*Y    r3symbol    0x48
  334. X*I    r3symbol    0x49
  335. X*K    r3symbol    0x4B
  336. X*L    r3symbol    0x4C
  337. X*M    r3symbol    0x4D
  338. X*N    r3symbol    0x4E
  339. X*O    r3symbol    0x4F
  340. X*P    r3symbol    0x50
  341. X*H    r3symbol    0x51
  342. X*R    r3symbol    0x52
  343. X*S    r3symbol    0x53
  344. X*T    r3symbol    0x54
  345. X*U    r3symbol    0x55
  346. Xts    r3symbol    0x56
  347. X*W    r3symbol    0x57
  348. X*C    r3symbol    0x58
  349. X*Q    r3symbol    0x59
  350. X*Z    r3symbol    0x5A
  351. Xul    r3symbol    0x5F
  352. Xrn    r3symbol    0x60
  353. X*a    r3symbol    0x61
  354. X*b    r3symbol    0x62
  355. X*x    r3symbol    0x63
  356. X*d    r3symbol    0x64
  357. X*e    r3symbol    0x65
  358. X*f    r3symbol    0x66
  359. X*g    r3symbol    0x67
  360. X*y    r3symbol    0x68
  361. X*i    r3symbol    0x69
  362. X*f    r3symbol    0x6A
  363. X*k    r3symbol    0x6B
  364. X*l    r3symbol    0x6C
  365. X*m    r3symbol    0x6D
  366. X*n    r3symbol    0x6E
  367. X*o    r3symbol    0x6F
  368. X*p    r3symbol    0x70
  369. X*h    r3symbol    0x71
  370. X*r    r3symbol    0x72
  371. X*s    r3symbol    0x73
  372. X*t    r3symbol    0x74
  373. X*u    r3symbol    0x75
  374. X*w    r3symbol    0x77
  375. X*c    r3symbol    0x78
  376. X*q    r3symbol    0x79
  377. X*z    r3symbol    0x7A
  378. Xor    r3symbol    0x7C
  379. Xap    r3symbol    0x7E
  380. X
  381. Xfm    r3symbol    0xa2
  382. X<=    r3symbol    0xa3
  383. Xsl    r3symbol    0xa4
  384. Xif    r3symbol    0xa5
  385. X$D    r3symbol    0xa6
  386. Xbs    r3symbol    0xa9
  387. Xlr    r3symbol    0xaB
  388. X<-    r3symbol    0xaC
  389. Xua    r3symbol    0xaD
  390. X->    r3symbol    0xaE
  391. Xda    r3symbol    0xaF
  392. Xde    r3symbol    0xb0
  393. X+-    r3symbol    0xb1
  394. X>=    r3symbol    0xb3
  395. Xmu    r3symbol    0xb4
  396. Xpt    r3symbol    0xb5
  397. Xpd    r3symbol    0xb6
  398. Xbu    r3symbol    0xb7
  399. Xdi    r3symbol    0xb8
  400. X!=    r3symbol    0xb9
  401. X==    r3symbol    0xbA
  402. X~=    r3symbol    0xbB
  403. Xbr    r3symbol    0xbD
  404. XAh    r3symbol    0xc0
  405. Xc*    r3symbol    0xc4
  406. Xc+    r3symbol    0xc5
  407. Xes    r3symbol    0xc6
  408. Xca    r3symbol    0xc7
  409. Xcu    r3symbol    0xc8
  410. Xsp    r3symbol    0xc9
  411. Xip    r3symbol    0xcA
  412. Xsb    r3symbol    0xcC
  413. Xib    r3symbol    0xcD
  414. Xmo    r3symbol    0xcE
  415. Xnm    r3symbol    0xcF
  416. Xan    r3symbol    0xd0
  417. Xgr    r3symbol    0xd1
  418. Xrg    r3symbol    0xd2
  419. Xco    r3symbol    0xd3
  420. Xsr    r3symbol    0xd6
  421. Xno    r3symbol    0xd8
  422. XAN    r3symbol    0xd9
  423. XOR    r3symbol    0xdA
  424. X<>    r3symbol    0xdB
  425. XDl    r3symbol    0xdC
  426. XDu    r3symbol    0xdD
  427. XDr    r3symbol    0xdE
  428. XDd    r3symbol    0xdF
  429. Xfo    r3symbol    0xe1
  430. Xlc    r3symbol    0xe9
  431. Xlf    r3symbol    0xeB
  432. Xlt    r3symbol    0xeC
  433. Xlk    r3symbol    0xeD
  434. Xlb    r3symbol    0xeE
  435. Xbv    r3symbol    0xeF
  436. Xbs    r3symbol    0xf0
  437. Xfc    r3symbol    0xf1
  438. Xis    r3symbol    0xf2
  439. Xrc    r3symbol    0xf9
  440. Xrf    r3symbol    0xfB
  441. Xrt    r3symbol    0xfC
  442. Xrk    r3symbol    0xfD
  443. Xrb    r3symbol    0xfE
  444. Xff    -    "ff"
  445. Xfi    -    "fi"
  446. Xfl    -    "fl"
  447. XFi    -    "ffi"
  448. XFl    -    "ffl"
  449. XAE    -    "AE"
  450. XOE    -    "OE"
  451. Xae    -    "ae"
  452. Xoe    -    "oe"
  453. X\-    -    "-"
  454. X\_    -    "_"
  455. Xhy    -    "-"
  456. Xru    -    "_"
  457. Xem    -    "-"
  458. Xaa    -    "'"
  459. Xga    -    "`"
  460. Xct    -    "c"
  461. END_OF_FILE
  462. if test 2307 -ne `wc -c <'Appls/dpv/funnytab'`; then
  463.     echo shar: \"'Appls/dpv/funnytab'\" unpacked with wrong size!
  464. fi
  465. # end of 'Appls/dpv/funnytab'
  466. fi
  467. if test -f 'Appls/dpv/trans' -a "${1}" != "-c" ; then 
  468.   echo shar: Will not clobber existing file \"'Appls/dpv/trans'\"
  469. else
  470. echo shar: Extracting \"'Appls/dpv/trans'\" \(2127 characters\)
  471. sed "s/^X//" >'Appls/dpv/trans' <<'END_OF_FILE'
  472. X# Font translation tables for dpv for X11 R3 and R4
  473. X# -------------------------------------------------
  474. X
  475. X# This will work for both -Tpsc and -Thar.
  476. X
  477. X# PostScript font names
  478. X# ---------------------
  479. X
  480. XR    -*-times-medium-r-*--%d-*
  481. XI    -*-times-medium-i-*--%d-*
  482. XB    -*-times-bold-r-*--%d-*
  483. XBI    -*-times-bold-i-*--%d-*
  484. X
  485. XH    -*-helvetica-medium-r-*--%d-*
  486. XHO    -*-helvetica-medium-o-*--%d-*
  487. XHB    -*-helvetica-bold-r-*--%d-*
  488. XHD    -*-helvetica-bold-o-*--%d-*
  489. X
  490. XC    -*-courier-medium-r-*--%d-*    
  491. XCO    -*-courier-medium-o-*--%d-*
  492. XCB    -*-courier-bold-r-*--%d-*
  493. XCD    -*-courier-bold-o-*--%d-*
  494. X
  495. X# CW is a common alias for C
  496. XCW    -*-courier-medium-r-*--%d-*    
  497. X
  498. X# CWI Harris font names (also R, I, B, BI)
  499. X# ----------------------------------------
  500. X
  501. X# Vega light, Vega, Vega medium (Helvetica look-alike)
  502. XVl    -*-helvetica-medium-r-*--%d-*
  503. Xvl    -*-helvetica-medium-o-*--%d-*
  504. XV    -*-helvetica-medium-r-*--%d-*
  505. Xv    -*-helvetica-medium-o-*--%d-*
  506. XVm    -*-helvetica-bold-r-*--%d-*
  507. Xvm    -*-helvetica-bold-o-*--%d-*
  508. X
  509. X# Baskerville (see also small caps)
  510. Xbr    -*-times-medium-r-*--%d-*
  511. Xbi    -*-times-medium-i-*--%d-*
  512. Xbb    -*-times-bold-r-*--%d-*
  513. XbI    -*-times-bold-i-*--%d-*
  514. X
  515. X# Century Schoolbook
  516. Xcr    -*-new?century?schoolbook-medium-r-*--%d-*
  517. Xci    -*-new?century?schoolbook-medium-i-*--%d-*
  518. Xcb    -*-new?century?schoolbook-bold-r-*--%d-*
  519. XcI    -*-new?century?schoolbook-bold-i-*--%d-*
  520. X
  521. X# Laurel
  522. Xlr    -*-times-medium-r-*--%d-*
  523. Xli    -*-times-medium-i-*--%d-*
  524. Xlb    -*-times-bold-r-*--%d-*
  525. XlI    -*-times-bold-i-*--%d-*
  526. X
  527. X# Funny fonts mapped to Helvetica, so at least they differ from Times
  528. XG3    -*-helvetica-medium-r-*--%d-*        # German no 3
  529. Xfs    -*-helvetica-medium-r-*--%d-*        # French Script
  530. XRS    -*-helvetica-medium-o-*--%d-*        # Rose Script
  531. XSO    -*-helvetica-bold-r-*--%d-*        # Scitype Open
  532. X
  533. X# OCR-B (line printer font, only available in a few sizes)
  534. Xlp    -*-courier-bold-r-*--%d-* 8 10 12
  535. X
  536. X# Small caps fonts mapped to normal fonts
  537. XRs    -*-times-medium-r-*--%d-*        # Times
  538. XBs    -*-times-bold-r-*--%d-*            # Times bold
  539. Xbs    -*-times-medium-r-*--%d-*        # Baskerville
  540. XbS    -*-times-bold-r-*--%d-*            # Baskerville bold
  541. X
  542. X# Font used by funny character translation
  543. X# ----------------------------------------
  544. X
  545. Xr3symbol    *-*-symbol-medium-r-*--%d-*
  546. END_OF_FILE
  547. if test 2127 -ne `wc -c <'Appls/dpv/trans'`; then
  548.     echo shar: \"'Appls/dpv/trans'\" unpacked with wrong size!
  549. fi
  550. # end of 'Appls/dpv/trans'
  551. fi
  552. if test -f 'Appls/klok/bsdsetdate.c' -a "${1}" != "-c" ; then 
  553.   echo shar: Will not clobber existing file \"'Appls/klok/bsdsetdate.c'\"
  554. else
  555. echo shar: Extracting \"'Appls/klok/bsdsetdate.c'\" \(1755 characters\)
  556. sed "s/^X//" >'Appls/klok/bsdsetdate.c' <<'END_OF_FILE'
  557. X/* Set the date and time -- 4.3 BSD Unix version */
  558. X
  559. X#ifndef sun
  560. X/* This is not needed on SunOS 4.03 (what about higher SunOS'es?). */
  561. X#include <time.h>
  562. X#endif
  563. X#include <sys/time.h>
  564. X
  565. X#define isleap(y) ((y)%4 == 0 && ((y)%100 != 0 || (y)%400 == 0))
  566. X
  567. X/* Convert a struct tm to seconds since Jan. 1, 1970.
  568. X   This knows nothing about time zones or daylight saving time. */
  569. X
  570. Xstatic unsigned long
  571. Xtm2tv(tp)
  572. X    struct tm *tp;
  573. X{
  574. X    static short mdays[12]=
  575. X        {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  576. X    unsigned long s= 0;
  577. X    int y, m, d;
  578. X    
  579. X    for (y= 1970; y < tp->tm_year + 1900; ++y) {
  580. X        s += 365;
  581. X        if (isleap(y))
  582. X            ++s;
  583. X    }
  584. X    mdays[1]= 28 + isleap(y); /* Months have origin 0 */
  585. X    for (m= 0; m < tp->tm_mon; ++m)
  586. X        s += mdays[m];
  587. X    s += tp->tm_mday - 1;
  588. X    return ((s*24 + tp->tm_hour)*60 + tp->tm_min)*60 /*+ tp->tm_sec*/;
  589. X}
  590. X
  591. X/* Set the date and time from a struct tm.
  592. X   The Input time is in local time.
  593. X   If 'minchange' is zero, minutes and seconds are not taken
  594. X   from the input but from the current system time. */
  595. X
  596. Xsetdatetime(tp, minchange)
  597. X    struct tm *tp;
  598. X    int minchange; /* nonzero if we must reset minutes and seconds, too */
  599. X{
  600. X    struct timeval tv;
  601. X    struct timezone tz;
  602. X    unsigned long t;
  603. X    
  604. X    t= tm2tv(tp);                /* t is local time */
  605. X    if (gettimeofday(&tv, &tz) != 0)
  606. X        return -1;
  607. X    if (tp->tm_isdst)
  608. X        t -= 3600;            /* t is local time less DST */
  609. X    t += tz.tz_minuteswest*60;        /* t is GMT time */
  610. X    if (minchange)
  611. X        t= t/60 * 60;            /* Clear seconds */
  612. X    else
  613. X        t= t/3600 * 3600 + tv.tv_sec % 3600; /* Use current min/sec */
  614. X    tv.tv_sec= t;
  615. X    if (settimeofday(&tv, &tz) != 0)
  616. X        return -1;
  617. X    return 0;
  618. X}
  619. X
  620. X#ifdef SYSV
  621. X
  622. X/* XXX How do you set the date/time on system V? */
  623. X
  624. Xint
  625. Xsettimeofday(ptv, ptz)
  626. X    struct timeval *ptv;
  627. X    struct timezone *ptz;
  628. X{
  629. X    return -1;
  630. X}
  631. X
  632. X#endif
  633. END_OF_FILE
  634. if test 1755 -ne `wc -c <'Appls/klok/bsdsetdate.c'`; then
  635.     echo shar: \"'Appls/klok/bsdsetdate.c'\" unpacked with wrong size!
  636. fi
  637. # end of 'Appls/klok/bsdsetdate.c'
  638. fi
  639. if test -f 'Appls/miniedit/regsub.c' -a "${1}" != "-c" ; then 
  640.   echo shar: Will not clobber existing file \"'Appls/miniedit/regsub.c'\"
  641. else
  642. echo shar: Extracting \"'Appls/miniedit/regsub.c'\" \(2150 characters\)
  643. sed "s/^X//" >'Appls/miniedit/regsub.c' <<'END_OF_FILE'
  644. X/*
  645. X * regsub
  646. X *
  647. X *    Copyright (c) 1986 by University of Toronto.
  648. X *    Written by Henry Spencer.  Not derived from licensed software.
  649. X#ifdef MULTILINE
  650. X *    Changed by Guido van Rossum, CWI, Amsterdam
  651. X *    for multi-line support.
  652. X#endif
  653. X *
  654. X *    Permission is granted to anyone to use this software for any
  655. X *    purpose on any computer system, and to redistribute it freely,
  656. X *    subject to the following restrictions:
  657. X *
  658. X *    1. The author is not responsible for the consequences of use of
  659. X *        this software, no matter how awful, even if they arise
  660. X *        from defects in it.
  661. X *
  662. X *    2. The origin of this software must not be misrepresented, either
  663. X *        by explicit claim or by omission.
  664. X *
  665. X *    3. Altered versions must be plainly marked as such, and must not
  666. X *        be misrepresented as being the original software.
  667. X */
  668. X#include <stdio.h>
  669. X#include "regexp.h"
  670. X#include "regmagic.h"
  671. X
  672. X#ifndef CHARBITS
  673. X#define    UCHARAT(p)    ((int)*(unsigned char *)(p))
  674. X#else
  675. X#define    UCHARAT(p)    ((int)*(p)&CHARBITS)
  676. X#endif
  677. X
  678. X/*
  679. X - regsub - perform substitutions after a regexp match
  680. X */
  681. Xvoid
  682. Xregsub(prog, source, dest)
  683. Xregexp *prog;
  684. Xchar *source;
  685. Xchar *dest;
  686. X{
  687. X    register char *src;
  688. X    register char *dst;
  689. X    register char c;
  690. X    register int no;
  691. X    register int len;
  692. X    extern char *strncpy();
  693. X
  694. X    if (prog == NULL || source == NULL || dest == NULL) {
  695. X        regerror("NULL parm to regsub");
  696. X        return;
  697. X    }
  698. X    if (UCHARAT(prog->program) != MAGIC) {
  699. X        regerror("damaged regexp fed to regsub");
  700. X        return;
  701. X    }
  702. X
  703. X    src = source;
  704. X    dst = dest;
  705. X    while ((c = *src++) != '\0') {
  706. X        if (c == '&')
  707. X            no = 0;
  708. X        else if (c == '\\' && '0' <= *src && *src <= '9')
  709. X            no = *src++ - '0';
  710. X        else
  711. X            no = -1;
  712. X
  713. X        if (no < 0) {    /* Ordinary character. */
  714. X            if (c == '\\' && (*src == '\\' || *src == '&'))
  715. X                c = *src++;
  716. X#ifdef MULTILINE
  717. X            else if (c == '\\' && *src == 'n') {
  718. X                c = '\n';
  719. X                src++;
  720. X            }
  721. X#endif
  722. X            *dst++ = c;
  723. X        } else if (prog->startp[no] != NULL && prog->endp[no] != NULL) {
  724. X            len = prog->endp[no] - prog->startp[no];
  725. X            (void) strncpy(dst, prog->startp[no], len);
  726. X            dst += len;
  727. X            if (len != 0 && *(dst-1) == '\0') {    /* strncpy hit NUL. */
  728. X                regerror("damaged match string");
  729. X                return;
  730. X            }
  731. X        }
  732. X    }
  733. X    *dst++ = '\0';
  734. X}
  735. END_OF_FILE
  736. if test 2150 -ne `wc -c <'Appls/miniedit/regsub.c'`; then
  737.     echo shar: \"'Appls/miniedit/regsub.c'\" unpacked with wrong size!
  738. fi
  739. # end of 'Appls/miniedit/regsub.c'
  740. fi
  741. if test -f 'Appls/test/multiwin.c' -a "${1}" != "-c" ; then 
  742.   echo shar: Will not clobber existing file \"'Appls/test/multiwin.c'\"
  743. else
  744. echo shar: Extracting \"'Appls/test/multiwin.c'\" \(2145 characters\)
  745. sed "s/^X//" >'Appls/test/multiwin.c' <<'END_OF_FILE'
  746. X/* Multiple windows, menus */
  747. X
  748. X#include "stdwin.h"
  749. X
  750. X#define NW 10            /* Max # of windows */
  751. X
  752. Xstruct {
  753. X    WINDOW *win;
  754. X    TEXTEDIT *tb;
  755. X    int bottom;
  756. X} wlist[NW];            /* Window list */
  757. X
  758. Xdrawproc(win, l, tl, r, b)
  759. X    WINDOW *win;
  760. X{
  761. X    int i= wgettag(win);
  762. X    tedraw(wlist[i].tb);
  763. X}
  764. X
  765. Xnewwin()
  766. X{
  767. X    int i;
  768. X    
  769. X    for (i= 0; i < NW; ++i) {
  770. X        if (wlist[i].win == 0) {
  771. X            char title[20];
  772. X            int width, height;
  773. X            WINDOW *win;
  774. X            sprintf(title, "Untitled-%d", i);
  775. X            wlist[i].win= win= wopen(title, drawproc);
  776. X            wsettag(win, i);
  777. X            wgetwinsize(win, &width, &height);
  778. X            wlist[i].tb= tealloc(win, 0, 0, width);
  779. X            wlist[i].bottom= tegetbottom(wlist[i].tb);
  780. X            wsetdocsize(win, width, wlist[i].bottom);
  781. X            return;
  782. X        }
  783. X    }
  784. X    
  785. X    wmessage("Can't open another window");
  786. X}
  787. X
  788. Xclosewin(win)
  789. X    WINDOW *win;
  790. X{
  791. X    int i= wgettag(win);
  792. X    tefree(wlist[i].tb);
  793. X    wclose(wlist[i].win);
  794. X    wlist[i].win= 0;
  795. X}
  796. X
  797. Xmain(argc, argv)
  798. X    int argc;
  799. X    char **argv;
  800. X{
  801. X    MENU *mp;
  802. X    int inew, iquit;
  803. X    int stop= 0;
  804. X    
  805. X    winitargs(&argc, &argv);
  806. X    
  807. X    mp= wmenucreate(1, "File");
  808. X    inew= wmenuadditem(mp, "New", 'N');
  809. X    (void) wmenuadditem(mp, "", -1);
  810. X    iquit= wmenuadditem(mp, "Quit", 'Q');
  811. X    
  812. X    newwin();        /* Initial window */
  813. X    
  814. X    while (!stop) {
  815. X        EVENT e;
  816. X        
  817. X        wgetevent(&e);
  818. X        
  819. X        if (e.window != 0) {
  820. X            int i= wgettag(e.window);
  821. X            if (teevent(wlist[i].tb, &e)) {
  822. X                /*if (tegetbottom(wlist[i].tb) !=
  823. X                        wlist[i].bottom)*/
  824. X                wsetdocsize(wlist[i].win,
  825. X                    tegetright(wlist[i].tb),
  826. X                    tegetbottom(wlist[i].tb));
  827. X                continue;
  828. X            }
  829. X        }
  830. X        
  831. X        switch (e.type) {
  832. X        
  833. X        case WE_MENU:
  834. X            switch (e.u.m.id) {
  835. X            case 1:
  836. X                if (e.u.m.item == inew)
  837. X                    newwin();
  838. X                else if (e.u.m.item == iquit)
  839. X                    stop= 1;
  840. X                break;
  841. X            }
  842. X            break;
  843. X        
  844. X        case WE_COMMAND:
  845. X            switch (e.u.command) {
  846. X            
  847. X            case WC_CLOSE:
  848. X                closewin(e.window);
  849. X                break;
  850. X            
  851. X            }
  852. X            break;
  853. X        
  854. X        case WE_CLOSE:
  855. X            closewin(e.window);
  856. X            break;
  857. X
  858. X        case WE_SIZE:
  859. X            {
  860. X                int i= wgettag(e.window);
  861. X                int width, height;
  862. X                wgetwinsize(e.window, &width, &height);
  863. X                temove(wlist[i].tb, 0, 0, width);
  864. X                wlist[i].bottom= tegetbottom(wlist[i].tb);
  865. X                wsetdocsize(wlist[i].win,
  866. X                    width, wlist[i].bottom);
  867. X            }
  868. X            break;
  869. X        }
  870. X    }
  871. X    
  872. X    wdone();
  873. X    exit(0);
  874. X}
  875. X
  876. END_OF_FILE
  877. if test 2145 -ne `wc -c <'Appls/test/multiwin.c'`; then
  878.     echo shar: \"'Appls/test/multiwin.c'\" unpacked with wrong size!
  879. fi
  880. # end of 'Appls/test/multiwin.c'
  881. fi
  882. if test -f 'Conf/makemakefile' -a "${1}" != "-c" ; then 
  883.   echo shar: Will not clobber existing file \"'Conf/makemakefile'\"
  884. else
  885. echo shar: Extracting \"'Conf/makemakefile'\" \(2213 characters\)
  886. sed "s/^X//" >'Conf/makemakefile' <<'END_OF_FILE'
  887. X#!/bin/sh
  888. X
  889. X# makemakefile - create a Makefile
  890. X
  891. XPROGNAME=`basename $0`
  892. XUSAGE="usage: $PROGNAME topdir os arch port srcdir builddir"
  893. X
  894. X# Check and get arguments
  895. X#
  896. Xcase $# in
  897. X6)    ;;
  898. X*)  echo "$USAGE" 1>&2
  899. X    echo '  <src> may be relative to <top>' 1>&2
  900. X    echo '  <build> may be relative to <top>/Build/<arch>/<port>' 1>&2
  901. X    exit 2
  902. X    ;;
  903. Xesac
  904. X
  905. XTOPDIR=$1; shift
  906. XOS=$1; shift
  907. XARCH=$1; shift
  908. XPORT=$1; shift
  909. XSRCDIR=$1; shift
  910. XBLDDIR=$1; shift
  911. X
  912. X
  913. X# Set derived pathnames
  914. X
  915. XCONFDIR=$TOPDIR/Conf
  916. X
  917. Xcase $SRCDIR in
  918. X/*)    ;;
  919. X*)    SRCDIR=$TOPDIR/$SRCDIR;;
  920. Xesac
  921. X
  922. Xcase $BLDDIR in
  923. X/*)    ;;
  924. X*)    BLDDIR=$TOPDIR/Build/$ARCH/$PORT/$BLDDIR;;
  925. Xesac
  926. X
  927. XOSPROTO=$CONFDIR/proto.os.$OS
  928. XARCHPROTO=$CONFDIR/proto.arch.$ARCH
  929. XPORTPROTO=$CONFDIR/proto.port.$PORT
  930. XCONFPROTO=$CONFDIR/proto.conf
  931. XSRCPROTO=$SRCDIR/Make.proto
  932. X
  933. X# Make sure the source prototype exists, else there's no use in proceeding.
  934. X# This test is made to avoid creating junk build directories.
  935. X# (Missing other files are detected by the cat command.)
  936. X
  937. Xif test ! -f $SRCPROTO
  938. Xthen
  939. X    echo "$PROGNAME: can't find Makefile prototype $SRCPROTO" 1>&2
  940. X    exit 1
  941. Xfi
  942. X
  943. X# Make sure the build directory exists, create it if necessary
  944. X# (only one level deep though!)
  945. X#
  946. Xif test -d $BLDDIR
  947. Xthen
  948. X    :
  949. Xelse
  950. X    echo "$PROGNAME: creating new build directory $BLDDIR" 1>&2
  951. X    mkdir $BLDDIR ||
  952. X    { echo "$PROGNAME: can't create build directory $BLDDIR" 1>&2; exit 1;}
  953. Xfi
  954. X
  955. X
  956. X# Now begin doing the real work
  957. X#
  958. XPRELUDE="$OSPROTO $ARCHPROTO $PORTPROTO $CONFPROTO $SRCPROTO"
  959. X
  960. XBOOTMAKE=$BLDDIR/Mf.boot
  961. Xecho "$PROGNAME: creating bootstrap Makefile ..." 1>&2
  962. X
  963. X{ echo "TOP=$TOPDIR" &&
  964. X  cat $PRELUDE;
  965. X} >$BOOTMAKE ||
  966. X{ echo "$PROGNAME: can't create bootstrap Makefile $BOOTMAKE" 1>&2; exit 1; }
  967. X
  968. XTEMPMAKE=$BLDDIR/Mf.temp
  969. Xecho "$PROGNAME: creating temp Makefile ..." 1>&2
  970. X
  971. X{ echo "TOP=$TOPDIR" &&
  972. X  cat $PRELUDE &&
  973. X  make -f $BOOTMAKE _bootstrap; } >$TEMPMAKE ||
  974. X{ echo "$PROGNAME: can't create temp Makefile $TEMPMAKE" 1>&2; exit 1; }
  975. X
  976. XMAKEFILE=$BLDDIR/Makefile
  977. Xecho "$PROGNAME: moving temp Makefile to Makefile ..." 1>&2
  978. X
  979. Xif test -f $MAKEFILE
  980. Xthen
  981. X    BACKUP=$MAKEFILE.bak
  982. X    echo "$PROGNAME: NB: moving previous Makefile to backup" 1>&2
  983. X    rm -f $BACKUP
  984. X    mv $MAKEFILE $BACKUP
  985. Xfi
  986. X
  987. Xmv $TEMPMAKE $MAKEFILE &&
  988. Xecho "$PROGNAME: done." 1>&2
  989. END_OF_FILE
  990. if test 2213 -ne `wc -c <'Conf/makemakefile'`; then
  991.     echo shar: \"'Conf/makemakefile'\" unpacked with wrong size!
  992. fi
  993. chmod +x 'Conf/makemakefile'
  994. # end of 'Conf/makemakefile'
  995. fi
  996. if test -f 'Conf/mkmf' -a "${1}" != "-c" ; then 
  997.   echo shar: Will not clobber existing file \"'Conf/mkmf'\"
  998. else
  999. echo shar: Extracting \"'Conf/mkmf'\" \(1567 characters\)
  1000. sed "s/^X//" >'Conf/mkmf' <<'END_OF_FILE'
  1001. X#! /bin/sh
  1002. X# mkmf - friendly interface to makemakefile
  1003. X
  1004. XPROGNAME=`basename $0`
  1005. XUSAGE="usage: $PROGNAME [-a arch] [-o os] [-t topdir] [-p port] [application];
  1006. X    if no application specified, a port makefile is created,
  1007. X    else an application makefile is created."
  1008. X
  1009. XTOP=`(cd ..; pwd)`
  1010. X
  1011. XPORT=x11
  1012. X
  1013. Xif ARCH=`(arch) 2>/dev/null`
  1014. Xthen
  1015. X    case $ARCH in
  1016. X    sun[34])    OS=sunos;;
  1017. X    sgi)        OS=sysv;;
  1018. X    esac
  1019. Xelif ARCH=`(machine) 2>/dev/null`
  1020. Xthen
  1021. X    case $ARCH in
  1022. X    vax|mips)    OS=ultrix;;
  1023. X    tahoe)        OS=bsd;;
  1024. X    esac
  1025. Xfi
  1026. X
  1027. Xwhile :
  1028. Xdo
  1029. X    case $1 in
  1030. X    -a)    ARCH=$2; shift; shift;;
  1031. X    -o)    OS=$2; shift; shift;;
  1032. X    -p)    PORT=$2; shift; shift;;
  1033. X    -t)    TOP=$2; shift; shift;;
  1034. X    -*)    echo "$USAGE" 1>&2; exit 2;;
  1035. X    *)    break;;
  1036. X    esac
  1037. Xdone
  1038. X
  1039. Xcase $OS in
  1040. X'')    echo "Sorry, can't guess operating system, use -o"; exit 2;;
  1041. Xesac
  1042. X
  1043. Xcase $ARCH in
  1044. X'')    echo "Sorry, can't guess architecture, use -a" 1>&2; exit 2;;
  1045. Xesac
  1046. X
  1047. X# Create top level in the Build tree if necessary
  1048. X
  1049. Xif test ! -d $TOP/Build
  1050. Xthen
  1051. X    echo "Create $TOP/Build? [ny]"
  1052. X    read reply
  1053. X    case $reply in
  1054. X    [yY]*)    mkdir $TOP/Build || exit;;
  1055. X    *)    exit;;
  1056. X    esac
  1057. Xfi
  1058. X
  1059. Xif test ! -d $TOP/Build/$ARCH
  1060. Xthen
  1061. X    echo "Create $TOP/Build/$ARCH? [ny]"
  1062. X    read reply
  1063. X    case $reply in
  1064. X    [yY]*)    mkdir $TOP/Build/$ARCH || exit;;
  1065. X    *)    exit;;
  1066. X    esac
  1067. Xfi
  1068. X
  1069. Xif test ! -d $TOP/Build/$ARCH/$PORT
  1070. Xthen
  1071. X    echo "Create $TOP/Build/$ARCH/$PORT? [ny]"
  1072. X    read reply
  1073. X    case $reply in
  1074. X    [yY]*)    mkdir $TOP/Build/$ARCH/$PORT || exit;;
  1075. X    *)    exit;;
  1076. X    esac
  1077. Xfi
  1078. X
  1079. Xcase $# in
  1080. X0)    set -x; makemakefile $TOP $OS $ARCH $PORT Ports/$PORT lib;;
  1081. X1)    set -x; makemakefile $TOP $OS $ARCH $PORT Appls/$1 $1;;
  1082. X*)    echo "$USAGE" 1>&2; exit 2;;
  1083. Xesac
  1084. END_OF_FILE
  1085. if test 1567 -ne `wc -c <'Conf/mkmf'`; then
  1086.     echo shar: \"'Conf/mkmf'\" unpacked with wrong size!
  1087. fi
  1088. chmod +x 'Conf/mkmf'
  1089. # end of 'Conf/mkmf'
  1090. fi
  1091. if test -f 'Conf/proto.conf' -a "${1}" != "-c" ; then 
  1092.   echo shar: Will not clobber existing file \"'Conf/proto.conf'\"
  1093. else
  1094. echo shar: Extracting \"'Conf/proto.conf'\" \(1658 characters\)
  1095. sed "s/^X//" >'Conf/proto.conf' <<'END_OF_FILE'
  1096. X
  1097. X#
  1098. X# Definitions pertaining to all configurations
  1099. X#
  1100. X
  1101. X# Names for all the top-level subdirectories of the stdwin tree
  1102. XAPPLS=        $(TOP)/Appls
  1103. XBUILD=        $(TOP)/Build
  1104. XCONF=        $(TOP)/Conf
  1105. XH=        $(TOP)/H
  1106. XPACKS=        $(TOP)/Packs
  1107. XPORTS=        $(TOP)/Ports
  1108. XTOOLS=        $(TOP)/Tools
  1109. X
  1110. X# Names for subdirectories of $(PORTS)
  1111. XALFA=        $(PORTS)/alfa
  1112. XX11=        $(PORTS)/x11
  1113. XGEN=        $(TOP)/Gen
  1114. XVTRM=        $(PORTS)/vtrm
  1115. XVTRM_ALL=    $(PORTS)/vtrm/uxtty.c $(PORTS)/vtrm/vtrm.c
  1116. X
  1117. X# Names for subdirectories of $(PACKS)
  1118. XTEXTEDIT=    $(TOP)/Packs/textedit
  1119. XVT=        $(TOP)/Packs/vt
  1120. X
  1121. X# Names for all sources files to the textedit package --
  1122. X# this is used to include them in each port's library
  1123. XTEXTEDIT_PACK=    $(TEXTEDIT)/*.c
  1124. XVT_PACK=    $(VT)/vt*.c
  1125. X
  1126. X# Build directory -- one for each port
  1127. XPORTBUILD=    $(TOP)/Build/$(ARCH)/$(PORT)
  1128. X
  1129. X# C flags (include directories, definitions, options) used at all times
  1130. XCONFINCLS=    -I$(H)
  1131. XCONFDEFS=    
  1132. XCONFOPTS=    -g    # XXX should be OS or arch specific!
  1133. XCONFLIBS=    
  1134. X
  1135. X# Construct CFLAGS from various sources
  1136. X# XXX does the order matter?
  1137. XINCLS=        $(OSINCLS) $(ARCHINCLS) $(PORTINCLS) $(CONFINCLS) $(SRCINCLS)
  1138. XDEFS=        $(OSDEFS) $(ARCHDEFS) $(PORTDEFS) $(CONFDEFS) $(SRCDEFS)
  1139. XOPTS=        $(OSOPTS) $(ARCHOPTS) $(PORTOPTS) $(CONFOPTS) $(SRCOPTS)
  1140. XCPPFLAGS=    $(INCLS) $(DEFS)
  1141. XCFLAGS=        $(CPPFLAGS) $(OPTS)
  1142. X
  1143. X# Construct LIBS to link application with from various sources
  1144. X# XXX what is the right order?
  1145. XLIBS=        $(SRCLIBS) $(PORTLIBS) $(OSLIBS) $(ARCHLIBS) $(CONFLIBS)
  1146. X
  1147. X# Ensure that "all" is the first target defined in this Makefile
  1148. Xall:
  1149. X
  1150. X
  1151. X# Standard targets
  1152. X
  1153. X# Target to add dependency rules to the Makefile (in place!)
  1154. Xdepend:
  1155. X        $(MKDEP) $(CFLAGS) $(SRCS)
  1156. X
  1157. X# XXX There should be standard targets tags, clean, etc.
  1158. X
  1159. END_OF_FILE
  1160. if test 1658 -ne `wc -c <'Conf/proto.conf'`; then
  1161.     echo shar: \"'Conf/proto.conf'\" unpacked with wrong size!
  1162. fi
  1163. # end of 'Conf/proto.conf'
  1164. fi
  1165. if test -f 'Gen/wdrawpar.c' -a "${1}" != "-c" ; then 
  1166.   echo shar: Will not clobber existing file \"'Gen/wdrawpar.c'\"
  1167. else
  1168. echo shar: Extracting \"'Gen/wdrawpar.c'\" \(1576 characters\)
  1169. sed "s/^X//" >'Gen/wdrawpar.c' <<'END_OF_FILE'
  1170. X/* STDWIN -- PARAGRAPH DRAWING OPERATIONS.
  1171. X   N.B. This is portable to other implementations of stdwin. */
  1172. X
  1173. X#include "stdwin.h"
  1174. X#include "tools.h"
  1175. X
  1176. X/* Draw a paragraph of text.
  1177. X   An EOL forces a new line, otherwise lines are broken at spaces
  1178. X   (if at all possible).
  1179. X   Parameters are the top left corner, the width, the text and its length.
  1180. X   Return value is the v coordinate of the bottom line.
  1181. X   (Note that an empty string is drawn as one blank line.) */
  1182. X
  1183. Xint
  1184. Xwdrawpar(left, top, text, width)
  1185. X    int left, top;
  1186. X    char *text;
  1187. X    int width;
  1188. X{
  1189. X    return _wdrawpar(left, top, text, width, TRUE);
  1190. X}
  1191. X
  1192. X/* Measure the height of a paragraph of text, when drawn with wdrawpar. */
  1193. X
  1194. Xint
  1195. Xwparheight(text, width)
  1196. X    char *text;
  1197. X    int width;
  1198. X{
  1199. X    return _wdrawpar(0, 0, text, width, FALSE);
  1200. X}
  1201. X
  1202. X/* Routine to do the dirty work for the above two. */
  1203. X
  1204. Xstatic int
  1205. X_wdrawpar(left, top, text, width, draw)
  1206. X    int left, top;
  1207. X    char *text;
  1208. X    int width;
  1209. X    bool draw;
  1210. X{
  1211. X    int len= strlen(text);
  1212. X    int len1= 0; /* Len1 counts characters until next EOL */
  1213. X    
  1214. X    while (len1 < len && text[len1] != EOL)
  1215. X        ++len1;
  1216. X    for (;;) {
  1217. X        int n= wtextbreak(text, len1, width);
  1218. X        if (n < len1) {
  1219. X            char *cp= text+n;
  1220. X            while (cp > text && *cp != ' ')
  1221. X                --cp;
  1222. X            if (cp > text)
  1223. X                n= cp-text;
  1224. X        }
  1225. X        if (draw)
  1226. X            (void) wdrawtext(left, top, text, n);
  1227. X        top += wlineheight();
  1228. X        text += n;
  1229. X        len -= n;
  1230. X        len1 -= n;
  1231. X        while (len1 > 0 && *text == ' ') {
  1232. X            ++text;
  1233. X            --len;
  1234. X            --len1;
  1235. X        }
  1236. X        if (len1 == 0) {
  1237. X            if (len == 0)
  1238. X                break;
  1239. X            ++text;
  1240. X            --len;
  1241. X            while (len1 < len && text[len1] != EOL)
  1242. X                ++len1;
  1243. X        }
  1244. X    }
  1245. X    return top;
  1246. X}
  1247. END_OF_FILE
  1248. if test 1576 -ne `wc -c <'Gen/wdrawpar.c'`; then
  1249.     echo shar: \"'Gen/wdrawpar.c'\" unpacked with wrong size!
  1250. fi
  1251. # end of 'Gen/wdrawpar.c'
  1252. fi
  1253. if test -f 'Gen/wtextbreak.c' -a "${1}" != "-c" ; then 
  1254.   echo shar: Will not clobber existing file \"'Gen/wtextbreak.c'\"
  1255. else
  1256. echo shar: Extracting \"'Gen/wtextbreak.c'\" \(1688 characters\)
  1257. sed "s/^X//" >'Gen/wtextbreak.c' <<'END_OF_FILE'
  1258. X/* STDWIN -- TEXT BREAK ROUTINE. */
  1259. X
  1260. X#include "stdwin.h"
  1261. X
  1262. X/* Portable version of wtextbreak(); use on systems where such an
  1263. X   operation is not an available primitive and wtextwidth has a high
  1264. X   overhead per call.
  1265. X   This function makes an educated guess and then uses linear
  1266. X   interpolation to find the exact answer.
  1267. X   It assumes that the textwidth function is additive (if not, but
  1268. X   almost, a final adjustment pass could be added). */
  1269. X
  1270. Xint
  1271. Xwtextbreak(str, len, width)
  1272. X    char *str;
  1273. X    int len;
  1274. X    int width;
  1275. X{
  1276. X    int en= wcharwidth('n');    /* Estimated average char width */
  1277. X                    /* NB: adapted below in the loop! */
  1278. X    int max;            /* Maximum answer */
  1279. X    int min= 0;            /* Minimum answer */
  1280. X    int wmin= 0;            /* Corresponding string width */
  1281. X    
  1282. X    if (len < 0)
  1283. X        len= strlen(str);
  1284. X    max= len;
  1285. X    
  1286. X    /* Invariants:
  1287. X       'min' characters fit, 'max+1' characters don't.
  1288. X       Ergo: we can stop when min == max. */
  1289. X    
  1290. X    while (min < max) {
  1291. X        /* Guess a number of chars beyond min. */
  1292. X        int guess= (width - wmin)/en;
  1293. X        int wguess;
  1294. X        if (guess <= 0)
  1295. X            guess= 1;
  1296. X        else if (min+guess > max)
  1297. X            guess= max-min;
  1298. X        wguess= wtextwidth(str+min, guess); /* Width increment */
  1299. X        if (wguess > 0)
  1300. X            en= (wguess + guess - 1) / guess;
  1301. X        guess += min;
  1302. X        wguess += wmin;
  1303. X        if (wguess > width) {
  1304. X            max= guess-1;
  1305. X        }
  1306. X        else /* wguess <= width */ {
  1307. X            min= guess;
  1308. X            wmin= wguess;
  1309. X        }
  1310. X    }
  1311. X
  1312. X#ifdef TEXT_NOT_ADDITIVE
  1313. X    /* Initially, min==max.  See if min should be smaller. */
  1314. X    while (min > 0 && wtextwidth(str, min) > width) {
  1315. X        --min;
  1316. X    }
  1317. X    if (min == max) {
  1318. X        /* Previous loop didn't decrease min.
  1319. X           See if we can increase it... */
  1320. X        while (max < len && wtextwidth(str, ++max) <= width) {
  1321. X            ++min;
  1322. X        }
  1323. X    }
  1324. X#endif
  1325. X    
  1326. X    return min;
  1327. X}
  1328. END_OF_FILE
  1329. if test 1688 -ne `wc -c <'Gen/wtextbreak.c'`; then
  1330.     echo shar: \"'Gen/wtextbreak.c'\" unpacked with wrong size!
  1331. fi
  1332. # end of 'Gen/wtextbreak.c'
  1333. fi
  1334. if test -f 'H/stdwtext.h' -a "${1}" != "-c" ; then 
  1335.   echo shar: Will not clobber existing file \"'H/stdwtext.h'\"
  1336. else
  1337. echo shar: Extracting \"'H/stdwtext.h'\" \(1803 characters\)
  1338. sed "s/^X//" >'H/stdwtext.h' <<'END_OF_FILE'
  1339. X/* STDWIN TEXTEDIT PACKAGE INTERFACE */
  1340. X
  1341. X/* This file is only ever included by "stdwin.h" */
  1342. X
  1343. X#define TEXTEDIT struct _textedit
  1344. X
  1345. XTEXTEDIT *tealloc _ARGS((WINDOW *win, int left, int top, int width));
  1346. XTEXTEDIT *tecreate _ARGS((WINDOW *win,
  1347. X    int left, int top, int right, int bottom));
  1348. Xvoid tefree _ARGS((TEXTEDIT *tp));
  1349. Xvoid tedestroy _ARGS((TEXTEDIT *tp));
  1350. Xvoid tesetactive _ARGS((TEXTEDIT *tp, /*bool*/int active));
  1351. X
  1352. Xvoid tedraw _ARGS((TEXTEDIT *tp));
  1353. Xvoid tedrawnew _ARGS((TEXTEDIT *tp,
  1354. X    int left, int top, int right, int bottom));
  1355. Xvoid temove _ARGS((TEXTEDIT *tp, int left, int top, int width));
  1356. Xvoid temovenew _ARGS((TEXTEDIT *tp,
  1357. X    int left, int top, int right, int bottom));
  1358. X
  1359. Xvoid tesetfocus _ARGS((TEXTEDIT *tp, int foc1, int foc2));
  1360. Xvoid tereplace _ARGS((TEXTEDIT *tp, char *str));
  1361. Xvoid tesetbuf _ARGS((TEXTEDIT *tp, char *buf, int buflen));
  1362. X
  1363. Xvoid tearrow _ARGS((TEXTEDIT *tp, int code));
  1364. Xvoid tebackspace _ARGS((TEXTEDIT *tp));
  1365. X/*bool*/int teclicknew _ARGS((TEXTEDIT *tp, int h, int v, /*bool*/int extend, /*bool*/int dclick));
  1366. X/*bool*/int tedoubleclick _ARGS((TEXTEDIT *tp, int h, int v));
  1367. X/*bool*/int teevent _ARGS((TEXTEDIT *tp, EVENT *ep));
  1368. X
  1369. X#define teclick(tp, h, v) teclicknew(tp, h, v, FALSE)
  1370. X#define teclickextend(tp, h, v) teclicknew(tp, h, v, TRUE)
  1371. X
  1372. Xchar *tegettext _ARGS((TEXTEDIT *tp));
  1373. Xint tegetlen _ARGS((TEXTEDIT *tp));
  1374. Xint tegetnlines _ARGS((TEXTEDIT *tp));
  1375. Xint tegetfoc1 _ARGS((TEXTEDIT *tp));
  1376. Xint tegetfoc2 _ARGS((TEXTEDIT *tp));
  1377. Xint tegetleft _ARGS((TEXTEDIT *tp));
  1378. Xint tegettop _ARGS((TEXTEDIT *tp));
  1379. Xint tegetright _ARGS((TEXTEDIT *tp));
  1380. Xint tegetbottom _ARGS((TEXTEDIT *tp));
  1381. X
  1382. X/* Text paragraph drawing functions: */
  1383. X
  1384. Xint wdrawpar _ARGS((int h, int v, char *text, int width));
  1385. X    /* Returns new v coord. */
  1386. Xint wparheight _ARGS((char *text, int width));
  1387. X    /* Returns height */
  1388. END_OF_FILE
  1389. if test 1803 -ne `wc -c <'H/stdwtext.h'`; then
  1390.     echo shar: \"'H/stdwtext.h'\" unpacked with wrong size!
  1391. fi
  1392. # end of 'H/stdwtext.h'
  1393. fi
  1394. if test -f 'Packs/textedit/textdbg.c' -a "${1}" != "-c" ; then 
  1395.   echo shar: Will not clobber existing file \"'Packs/textedit/textdbg.c'\"
  1396. else
  1397. echo shar: Extracting \"'Packs/textedit/textdbg.c'\" \(2218 characters\)
  1398. sed "s/^X//" >'Packs/textedit/textdbg.c' <<'END_OF_FILE'
  1399. X/* Text Edit, debugging code */
  1400. X
  1401. X#include "text.h"
  1402. X
  1403. X#ifndef macintosh
  1404. X
  1405. X/*VARARGS1*/
  1406. Xdprintf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
  1407. X    char *fmt;
  1408. X{
  1409. X    printf("\r\n");
  1410. X    printf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
  1411. X    printf("\r\n");
  1412. X}
  1413. X
  1414. X#endif
  1415. X
  1416. X#ifndef NDEBUG
  1417. X
  1418. X/* Check the world's consistency */
  1419. X
  1420. Xtecheck(tp, line)
  1421. X    TEXTEDIT *tp;
  1422. X    int line;
  1423. X{
  1424. X    lineno i;
  1425. X
  1426. X#define zck(n) ((n) || dprintf("zck(n) line %d", line))
  1427. X    
  1428. X    zck(tp->nlines >= 1);
  1429. X    
  1430. X    zck(tp->start[0] == zaddgap(0));
  1431. X    zck(tp->start[tp->nlines] == tp->buflen);
  1432. X    
  1433. X    zck(0 <= tp->gap);
  1434. X    zck(0 <= tp->gaplen);
  1435. X    zck(zgapend <= tp->buflen);
  1436. X    
  1437. X    zck(0 <= tp->foc);
  1438. X    zck(0 <= tp->foclen);
  1439. X    zck(zfocend <= tp->buflen-tp->gaplen);
  1440. X    
  1441. X    for (i= 0; i < tp->nlines; ++i) {
  1442. X        if (i < tp->nlines-1)
  1443. X            { zck(tp->start[i] < tp->start[i+1]); }
  1444. X        else
  1445. X            { zck(tp->start[i] <= tp->start[tp->nlines]); }
  1446. X        zck(tp->start[i] < tp->gap || zgapend <= tp->start[i]);
  1447. X    }
  1448. X
  1449. X#undef zck
  1450. X
  1451. X}
  1452. X
  1453. X#if 0
  1454. X
  1455. X/* Dump the world's state to the screen (call from drawproc) */
  1456. X
  1457. Xzdebug(left, top, right, bottom)
  1458. X{
  1459. X    int h, v;
  1460. X    int i, j;
  1461. X    
  1462. X    h= 0, v= 15*wlh; if (v >= bottom) return;
  1463. X    zprintf(h, v, "buflen=%d nlines=%d foc=%d foclen=%d gap=%d gaplen=%d.",
  1464. X        buflen, nlines, foc, foclen, gap, gaplen);
  1465. X    h= 0, v += wlh; if (v >= bottom) return;
  1466. X    for (i= 0; i <= nlines; ++i) {
  1467. X        h= zprintf(h, v, "%d:%d ", i, start[i]);
  1468. X    }
  1469. X    h= 0, v += wlh; if (v >= bottom) return;
  1470. X    for (i= 0; i <= buflen; ++i) {
  1471. X        h= zprintf(h, v, "%c",
  1472. X            i == zaddgap(foc) ?
  1473. X                (foclen == 0 ? '|' : '[') :
  1474. X                (i == zaddgap(focend) ? ']' : ' '));
  1475. X        if (i >= buflen)
  1476. X            break;
  1477. X        if (i >= gap && i < gapend)
  1478. X            h= zprintf(h, v, "**");
  1479. X        else
  1480. X            h= zprintf(h, v, "%02x", buf[i] & 0xff);
  1481. X    }
  1482. X    h= 0, v += wlh; if (v >= bottom) return;
  1483. X    for (i= 0; i <= buflen; ++i) {
  1484. X        for (j= 0; j <= nlines; ++j)
  1485. X            if (i == start[j])
  1486. X                break;
  1487. X        if (j <= nlines)
  1488. X            h= zprintf(h, v, "%-3d", j);
  1489. X        else
  1490. X            h= zprintf(h, v, "   ");
  1491. X    }
  1492. X}
  1493. X
  1494. X/* Printf into the window (could be of general use).
  1495. X   NB: doesn't recognize \n */
  1496. X
  1497. Xstatic
  1498. Xzprintf(h, v, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
  1499. X    int h, v;
  1500. X    char *fmt;
  1501. X{
  1502. X    char buf[256];
  1503. X    sprintf(buf, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
  1504. X    return wdrawtext(h, v, buf, -1);
  1505. X}
  1506. X
  1507. X#endif
  1508. X
  1509. X#endif /* !NDEBUG */
  1510. END_OF_FILE
  1511. if test 2218 -ne `wc -c <'Packs/textedit/textdbg.c'`; then
  1512.     echo shar: \"'Packs/textedit/textdbg.c'\" unpacked with wrong size!
  1513. fi
  1514. # end of 'Packs/textedit/textdbg.c'
  1515. fi
  1516. if test -f 'Ports/alfa/To.do' -a "${1}" != "-c" ; then 
  1517.   echo shar: Will not clobber existing file \"'Ports/alfa/To.do'\"
  1518. else
  1519. echo shar: Extracting \"'Ports/alfa/To.do'\" \(1462 characters\)
  1520. sed "s/^X//" >'Ports/alfa/To.do' <<'END_OF_FILE'
  1521. XComplain about bad arguments (esp. window pointers) instead of ignoring
  1522. Xthem
  1523. X
  1524. XDon't scroll so much beyond end of window (in wshow?)
  1525. X
  1526. XTextedit highlights disappear when they are redrawn after a menu covered
  1527. Xsome text but *not* the highlight
  1528. X
  1529. XFix wreshuffle to minimize redrawing
  1530. X
  1531. XFix scrollupdate to minimize redrawing
  1532. X
  1533. XMaintain a stack of active windows so active window after a delete is
  1534. Xless surprising
  1535. X
  1536. XDon't grow windows beyond their document size
  1537. X
  1538. XLet wmessage wait for CR to acknowledge?
  1539. X
  1540. XDreams:
  1541. X
  1542. XGeneralized key bindings read from a startup file
  1543. X
  1544. X~ and $ expansion and file name completion in waskfile
  1545. X(or write a tiny directory browser?)
  1546. X
  1547. X
  1548. XChages to stdwin by Euromath project?
  1549. X
  1550. Xdraw.c        bogus! fix to scrollupdate;
  1551. X        some comments added
  1552. X
  1553. Xstdwin.c    added wgetwinpos and wgetorigin;
  1554. X        support for resize events;
  1555. X        don't force showing the caret;
  1556. X        don't reset the 'front' window when closing non-front;
  1557. X        Lambert's attempts at imporving _wreshuffle???
  1558. X
  1559. X
  1560. XOf the following changes I am not sure yet:
  1561. X
  1562. Xmenu.c        changed standard menu title and contents;
  1563. X        fixed minor bugs;
  1564. X        and what else?  (lots changed)
  1565. X
  1566. Xscroll.c    only change is to comment out a fallback on wchange in
  1567. X        wscroll when there is horizontal scrolling or not the
  1568. X        entire window width is affected.  do we need this?
  1569. X
  1570. Xsyswin.c    added wdialog which is like waskstr with an additional
  1571. X        multiple-choice list of options (???) (why couldn't this
  1572. X        be done as a normal stdwin window?);
  1573. X        added RedrawAll
  1574. END_OF_FILE
  1575. if test 1462 -ne `wc -c <'Ports/alfa/To.do'`; then
  1576.     echo shar: \"'Ports/alfa/To.do'\" unpacked with wrong size!
  1577. fi
  1578. # end of 'Ports/alfa/To.do'
  1579. fi
  1580. if test -f 'Ports/mac/dprintf.c' -a "${1}" != "-c" ; then 
  1581.   echo shar: Will not clobber existing file \"'Ports/mac/dprintf.c'\"
  1582. else
  1583. echo shar: Extracting \"'Ports/mac/dprintf.c'\" \(2129 characters\)
  1584. sed "s/^X//" >'Ports/mac/dprintf.c' <<'END_OF_FILE'
  1585. X/* A simple debugging routine, assuming you've got QuickDraw,
  1586. X   windows and menus running.
  1587. X   It can be called with up to 10 printf arguments.
  1588. X
  1589. X   It beeps, draws a message over the menu bar,
  1590. X   and waits for a key or mouse down event.
  1591. X   If Command-Period is detected, it calls ExitToShell,
  1592. X   to allow an emergency exit from a looping program.
  1593. X
  1594. X   Warning: there are some side effects on the window manager's port,
  1595. X   such as pen parameters and clipping.
  1596. X   The printed string shouldn't exceed 255 chars.
  1597. X*/
  1598. X
  1599. X#include "macwin.h"
  1600. X
  1601. X#ifdef MPW
  1602. X#include <Events.h>
  1603. X#include <Menus.h>
  1604. X#include <OSUtils.h>
  1605. X#include <SegLoad.h>
  1606. X#endif
  1607. X
  1608. Xvoid
  1609. Xdprintf(fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
  1610. X    char *fmt;
  1611. X{
  1612. X    char buf[256];
  1613. X    GrafPtr saveport;
  1614. X    GrafPtr screen;
  1615. X    Rect r;
  1616. X    
  1617. X    SysBeep(2);
  1618. X    sprintf(buf, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
  1619. X    GetPort(&saveport);
  1620. X    GetWMgrPort(&screen);
  1621. X    SetPort(screen);
  1622. X    r= screen->portRect;
  1623. X    r.bottom= 19; /* Height of menu bar, less border line */
  1624. X    ClipRect(&r);
  1625. X    PenNormal();
  1626. X    /* Reset more parameters, such as text font? */
  1627. X    EraseRect(&r);
  1628. X    MoveTo(5, 15); /* Left margin and base line */
  1629. X#ifndef CLEVERGLUE
  1630. X    CtoPstr(buf);
  1631. X#endif
  1632. X    DrawString(buf);
  1633. X    
  1634. X    /* Wait for mouse or key down event.
  1635. X       Include auto key events so a flood of dprintf
  1636. X       calls can be skipped quickly by holding a key. */
  1637. X    for (;;) {
  1638. X        EventRecord e;
  1639. X        
  1640. X        if (GetNextEvent(keyDownMask|autoKeyMask|mDownMask, &e)) {
  1641. X            if (e.what == keyDown &&
  1642. X                (e.message & charCodeMask) == '.' &&
  1643. X                (e.modifiers & cmdKey))
  1644. X                ExitToShell();
  1645. X            if ((e.what == keyDown || e.what == autoKey) &&
  1646. X                ((e.message & charCodeMask) == '\r' ||
  1647. X                 (e.message & charCodeMask) == '\3')
  1648. X                || e.what == mouseDown)
  1649. X                break;
  1650. X        }
  1651. X    }
  1652. X    
  1653. X    /* Restore the situation, more or less. */
  1654. X    SetPort(saveport);
  1655. X    DrawMenuBar();
  1656. X}
  1657. X
  1658. X#ifdef UNUSED
  1659. X
  1660. X/* Print the extent of the stack. */
  1661. X
  1662. X#define CurStackBase    (* (long*)0x908)
  1663. X#define ApplZone    (* (long*)0x2AA)
  1664. X#define ApplLimit    (* (long*)0x130)
  1665. X
  1666. Xprstack(where)
  1667. X    char *where;
  1668. X{
  1669. X    dprintf("ApplZone=%d, ApplLimit=%d, CurStackBase=%d, SP=%d",
  1670. X        ApplZone, ApplLimit, CurStackBase, &where);
  1671. X}
  1672. X
  1673. X#endif /*UNUSED*/
  1674. END_OF_FILE
  1675. if test 2129 -ne `wc -c <'Ports/mac/dprintf.c'`; then
  1676.     echo shar: \"'Ports/mac/dprintf.c'\" unpacked with wrong size!
  1677. fi
  1678. # end of 'Ports/mac/dprintf.c'
  1679. fi
  1680. if test -f 'Ports/mac/scrap.c' -a "${1}" != "-c" ; then 
  1681.   echo shar: Will not clobber existing file \"'Ports/mac/scrap.c'\"
  1682. else
  1683. echo shar: Extracting \"'Ports/mac/scrap.c'\" \(2210 characters\)
  1684. sed "s/^X//" >'Ports/mac/scrap.c' <<'END_OF_FILE'
  1685. X/* Macintosh Scrap (Clipboard) Interface */
  1686. X
  1687. X#include "macwin.h"
  1688. X#ifdef MPW
  1689. X#include <Scrap.h>
  1690. X#include <Memory.h>
  1691. X#endif
  1692. X#ifdef THINK_C
  1693. X#include <ScrapMgr.h>
  1694. X#include <MemoryMgr.h>
  1695. X#endif
  1696. X
  1697. Xstatic Handle hclip;
  1698. Xstatic long lenclip;
  1699. X
  1700. X/* _wfreeclip is called from wgetevent and from wsetclip. */
  1701. X
  1702. Xvoid
  1703. X_wfreeclip()
  1704. X{
  1705. X    if (hclip != NULL) {
  1706. X        HUnlock(hclip);
  1707. X        DisposHandle(hclip);
  1708. X        hclip= NULL;
  1709. X    }
  1710. X}
  1711. X
  1712. Xchar *
  1713. Xwgetclip()
  1714. X{
  1715. X    long offset;
  1716. X    
  1717. X    /* NB if the use of hclip or lenclip changes,
  1718. X       also change wgetcutbuffer() below !!! */
  1719. X    
  1720. X    if (hclip == NULL)
  1721. X        hclip= NewHandle(1L);
  1722. X    else
  1723. X        HUnlock(hclip);
  1724. X    lenclip= GetScrap(hclip, 'TEXT', &offset);
  1725. X    if (lenclip < 0)
  1726. X        return NULL;
  1727. X    SetHandleSize(hclip, lenclip+1);
  1728. X    HLock(hclip);
  1729. X    (*hclip)[lenclip]= EOS;
  1730. X#ifndef CLEVERGLUE
  1731. X    {
  1732. X    /* Convert imported \r into \n */
  1733. X        char *p= *hclip;
  1734. X        while ((p= strchr(p, '\r')) != NULL)
  1735. X            *p++ = '\n';
  1736. X    }
  1737. X#endif
  1738. X    return *hclip;
  1739. X}
  1740. X
  1741. Xvoid
  1742. Xwsetclip(p, len)
  1743. X    char *p;
  1744. X    int len;
  1745. X{
  1746. X    int err;
  1747. X#ifndef CLEVERGLUE
  1748. X    /* Convert \n into \r before exporting.  Must make a copy, shit! */
  1749. X    char *q= malloc(len+1);
  1750. X    if (q != NULL) {
  1751. X        strncpy(q, p, len);
  1752. X        q[len]= EOS;
  1753. X        p= q;
  1754. X        while ((p= strchr(p, '\n')) != NULL)
  1755. X            *p++ = '\r';
  1756. X        p= q;
  1757. X    }
  1758. X    /* If there's no memory, export with \n's left in... */
  1759. X#endif
  1760. X    _wfreeclip();
  1761. X    err= ZeroScrap();
  1762. X    if (err != 0) dprintf("wsetclip: ZeroScrap error %d", err);
  1763. X    err= PutScrap((long)len, 'TEXT', p);
  1764. X    if (err != 0) dprintf("wsetclip: PutScrap error %d", err);
  1765. X#ifndef CLEVERGLUE
  1766. X    if (q != NULL)
  1767. X        free(q);
  1768. X#endif
  1769. X}
  1770. X
  1771. X/* For "compatibility" with X11 STDWIN: */
  1772. X
  1773. Xint
  1774. Xwsetselection(win, sel, data, len)
  1775. X    WINDOW *win;
  1776. X    int sel;
  1777. X    char *data;
  1778. X    int len;
  1779. X{
  1780. X    return 0;
  1781. X}
  1782. X
  1783. Xchar *
  1784. Xwgetselection(sel, plen)
  1785. X    int sel;
  1786. X    int *plen;
  1787. X{
  1788. X    return NULL;
  1789. X}
  1790. X
  1791. Xvoid
  1792. Xwresetselection(sel)
  1793. X    int sel;
  1794. X{
  1795. X}
  1796. X
  1797. Xvoid
  1798. Xwsetcutbuffer(ibuffer, data, len)
  1799. X    int ibuffer;
  1800. X    char *data;
  1801. X    int len;
  1802. X{
  1803. X    if (ibuffer == 0)
  1804. X        wsetclip(data, len);
  1805. X}
  1806. X
  1807. Xchar *
  1808. Xwgetcutbuffer(ibuffer, plen)
  1809. X    int ibuffer;
  1810. X    int *plen;
  1811. X{
  1812. X    if (ibuffer != 0)
  1813. X        return NULL;
  1814. X    if (wgetclip() == NULL)
  1815. X        return NULL;
  1816. X    /* This knows about the implementation of wgetclip() */
  1817. X    *plen = lenclip; /* NB: long --> int, may truncate... */
  1818. X    return *hclip;
  1819. X}
  1820. X
  1821. Xvoid
  1822. Xwrotatecutbuffers(n)
  1823. X    int n;
  1824. X{
  1825. X}
  1826. END_OF_FILE
  1827. if test 2210 -ne `wc -c <'Ports/mac/scrap.c'`; then
  1828.     echo shar: \"'Ports/mac/scrap.c'\" unpacked with wrong size!
  1829. fi
  1830. # end of 'Ports/mac/scrap.c'
  1831. fi
  1832. if test -f 'Ports/mac/timer.c' -a "${1}" != "-c" ; then 
  1833.   echo shar: Will not clobber existing file \"'Ports/mac/timer.c'\"
  1834. else
  1835. echo shar: Extracting \"'Ports/mac/timer.c'\" \(1933 characters\)
  1836. sed "s/^X//" >'Ports/mac/timer.c' <<'END_OF_FILE'
  1837. X/* MAC STDWIN -- TIMER. */
  1838. X
  1839. X/* XXX The timer mechanism should be coupled less strongly with the
  1840. X   stdwin implementation -- stdwin should support a single timer,
  1841. X   while thin layers on top could implement various timer strategies. */
  1842. X
  1843. X#include "macwin.h"
  1844. X#ifdef MPW
  1845. X#include <Events.h>
  1846. X#endif
  1847. X
  1848. Xstatic unsigned long nexttimer;
  1849. X
  1850. X/* Set a window's timer.
  1851. X   The second parameter is the number of deciseconds from now
  1852. X   when the timer is to go off, or 0 to clear the timer.
  1853. X   When the timer goes off (or sometime later),
  1854. X   a WE_TIMER event will be delivered.
  1855. X   As a service to 'checktimer' below, a NULL window parameter
  1856. X   is ignored, but causes the 'nexttimer' value to be recalculated.
  1857. X   (The inefficient simplicity of the code here is due to MINIX,
  1858. X   with some inventions of my own.) */
  1859. X
  1860. Xvoid
  1861. Xwsettimer(win, deciseconds)
  1862. X    WINDOW *win;
  1863. X    int deciseconds;
  1864. X{
  1865. X    WindowPeek w;
  1866. X    
  1867. X    nexttimer= 0;
  1868. X    if (win != NULL) {
  1869. X        if (deciseconds == 0)
  1870. X            win->timer= 0;
  1871. X        else {
  1872. X            nexttimer= win->timer= TickCount() +
  1873. X                deciseconds*(TICKSPERSECOND/10);
  1874. X        }
  1875. X    }
  1876. X    for (w= (WindowPeek)FrontWindow(); w != NULL; w= w->nextWindow) {
  1877. X        win= whichwin((WindowPtr)w);
  1878. X        if (win != NULL && win->timer != 0) {
  1879. X            if (nexttimer == 0 || win->timer < nexttimer)
  1880. X                nexttimer= win->timer;
  1881. X        }
  1882. X    }
  1883. X}
  1884. X
  1885. X/* Check if a timer went off.
  1886. X   If so, return TRUE and set the event record correspondingly;
  1887. X   otherwise, return FALSE. */
  1888. X
  1889. Xbool
  1890. Xchecktimer(ep)
  1891. X    EVENT *ep;
  1892. X{
  1893. X    WindowPtr w;
  1894. X    WINDOW *win;
  1895. X    unsigned long now;
  1896. X    
  1897. X    if (nexttimer == 0) {
  1898. X        return FALSE;
  1899. X    }
  1900. X    now= TickCount();
  1901. X    if (now < nexttimer) {
  1902. X        return FALSE;
  1903. X    }
  1904. X    ep->type= WE_NULL;
  1905. X    ep->window= NULL;
  1906. X    for (w= FrontWindow(); w != NULL;
  1907. X        w= (WindowPtr)((WindowPeek)w)->nextWindow) {
  1908. X        win= whichwin(w);
  1909. X        if (win != NULL && win->timer != 0) {
  1910. X            if (win->timer <= now) {
  1911. X                ep->type= WE_TIMER;
  1912. X                ep->window= win;
  1913. X                now= win->timer;
  1914. X            }
  1915. X        }
  1916. X    }
  1917. X    wsettimer(ep->window, 0);
  1918. X    return ep->type == WE_TIMER;
  1919. X}
  1920. END_OF_FILE
  1921. if test 1933 -ne `wc -c <'Ports/mac/timer.c'`; then
  1922.     echo shar: \"'Ports/mac/timer.c'\" unpacked with wrong size!
  1923. fi
  1924. # end of 'Ports/mac/timer.c'
  1925. fi
  1926. if test -f 'Ports/vtrm/DIST/README' -a "${1}" != "-c" ; then 
  1927.   echo shar: Will not clobber existing file \"'Ports/vtrm/DIST/README'\"
  1928. else
  1929. echo shar: Extracting \"'Ports/vtrm/DIST/README'\" \(1635 characters\)
  1930. sed "s/^X//" >'Ports/vtrm/DIST/README' <<'END_OF_FILE'
  1931. XTHIS IS VTRM
  1932. X============
  1933. X
  1934. XVTRM is a terminal control package, with two implementations: one for Unix
  1935. X(only well-tested on 4.2/4.3 BSD, but supposedly running under System 5
  1936. Xas well, as long as there is a termcap database), and one for MS-DOS, to
  1937. Xbe compiled with the Microsoft C compiler (tested only with version 3.0).
  1938. XThis is a "curses replacement", which does not mean it is a curses
  1939. Xreimplementation: the interface is totally different, only the purpose
  1940. Xis more or less the same: to shield an application program from the
  1941. Xnitty-gritty detail of cursor navigation, inverse video, scrolling, etc.
  1942. XThere are also a few routines for CBREAK-mode input.
  1943. X
  1944. XUNPACKING NOTES
  1945. X
  1946. XThe shars yield six files:
  1947. X    README        (this file)
  1948. X    pag.c        (a trivial application using the package)
  1949. X    vtrmdoc.ms    (an attempt at documentation)
  1950. X    trm.h        (common header file)
  1951. X    ptrm.c        (MS-DOS version)
  1952. X    vtrm.c_1
  1953. X    vtrm.c_2
  1954. XThe latter two should be pasted together to get a file named vtrm.c:
  1955. X    cat vtrm.c_[12] >vtrm.c
  1956. X
  1957. XAUTHORS
  1958. X
  1959. XThis software was written by:
  1960. X
  1961. X    Timo Krijnen and Guido van Rossum
  1962. X    CWI, dept. AA
  1963. X    Kruislaan 413
  1964. X    1089 SJ  Amsterdam
  1965. X    The Netherlands
  1966. X
  1967. X    Electronic mail: timo@cwi.nl,  guido@cwi.nl
  1968. X    Phone: ... 20 - 592 4138.
  1969. X
  1970. XCOPYRIGHT
  1971. X
  1972. XThis software is copyright (c) 1986 by Stichting Mathematisch Centrum,
  1973. XAmsterdam, The Netherlands.  Its use is allowed freely for
  1974. Xnon-commercial purposes only.  Use at your own risk: SMC does not take
  1975. Xresponsibility for the proper functioning of the software or for damage
  1976. Xcaused by its use.  Redistribution is allowed for non-commercial
  1977. Xpurposes only, and only unchanged, in its entirety, and including this
  1978. Xcopyright notice.
  1979. END_OF_FILE
  1980. if test 1635 -ne `wc -c <'Ports/vtrm/DIST/README'`; then
  1981.     echo shar: \"'Ports/vtrm/DIST/README'\" unpacked with wrong size!
  1982. fi
  1983. # end of 'Ports/vtrm/DIST/README'
  1984. fi
  1985. if test -f 'Ports/x11/error.c' -a "${1}" != "-c" ; then 
  1986.   echo shar: Will not clobber existing file \"'Ports/x11/error.c'\"
  1987. else
  1988. echo shar: Extracting \"'Ports/x11/error.c'\" \(1992 characters\)
  1989. sed "s/^X//" >'Ports/x11/error.c' <<'END_OF_FILE'
  1990. X/* X11 STDWIN -- error and debugging messages */
  1991. X
  1992. X#include "x11.h"
  1993. X
  1994. X
  1995. X/* Undocumented globals to reduce the output volume */
  1996. X
  1997. Xbool _wnoerrors;        /* Suppress errors and warnings if set */
  1998. Xbool _wnowarnings;        /* Suppress warnings if set */
  1999. Xint _wtracelevel;        /* Amount of trace output wanted */
  2000. Xint _wdebuglevel;        /* Amount of debug output wanted */
  2001. X
  2002. X
  2003. X/* Fatal error message aborting the program (use for unrecoverable errors) */
  2004. X
  2005. X/*VARARGS1*/
  2006. X_wfatal(str, arg1, arg2, arg3, arg4)
  2007. X    char *str;
  2008. X{
  2009. X    fprintf(stderr, "%s: fatal error: ", _wprogname);
  2010. X    fprintf(stderr, str, arg1, arg2, arg3, arg4);
  2011. X    fprintf(stderr, "\n");
  2012. X    exit(1);
  2013. X    /*NOTREACHED*/
  2014. X}
  2015. X
  2016. X
  2017. X/* Error message (use for recoverable serious errors) */
  2018. X
  2019. X/*VARARGS1*/
  2020. X_werror(str, arg1, arg2, arg3, arg4)
  2021. X    char *str;
  2022. X{
  2023. X    if (!_wnoerrors || _wdebuglevel > 0 || _wtracelevel > 0) {
  2024. X        fprintf(stderr, "%s: error: ", _wprogname);
  2025. X        fprintf(stderr, str, arg1, arg2, arg3, arg4);
  2026. X        fprintf(stderr, "\n");
  2027. X    }
  2028. X}
  2029. X
  2030. X
  2031. X/* Warning message (use for informative messages) */
  2032. X
  2033. X/*VARARGS1*/
  2034. X_wwarning(str, arg1, arg2, arg3, arg4)
  2035. X    char *str;
  2036. X{
  2037. X    if (!_wnoerrors && !_wnowarnings || 
  2038. X        _wdebuglevel > 0 || _wtracelevel > 0) {
  2039. X        fprintf(stderr, "%s: warning: ", _wprogname);
  2040. X        fprintf(stderr, str, arg1, arg2, arg3, arg4);
  2041. X        fprintf(stderr, "\n");
  2042. X    }
  2043. X}
  2044. X
  2045. X
  2046. X/* Trace message (use to trace user-level routine calls) */
  2047. X
  2048. X/*VARARGS2*/
  2049. X_wtrace(level, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  2050. X    int level;
  2051. X    char *str;
  2052. X{
  2053. X    if (_wtracelevel >= level) {
  2054. X        fprintf(stderr, "%s: trace %d: ", _wprogname, level);
  2055. X        fprintf(stderr, str,
  2056. X            arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  2057. X        fprintf(stderr, "\n");
  2058. X    }
  2059. X}
  2060. X
  2061. X
  2062. X/* Debug message (use for misc. debugging output) */
  2063. X
  2064. X/*VARARGS2*/
  2065. X_wdebug(level, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  2066. X    int level;
  2067. X    char *str;
  2068. X{
  2069. X    if (_wdebuglevel >= level) {
  2070. X        fprintf(stderr, "%s: debug %d: ", _wprogname, level);
  2071. X        fprintf(stderr, str,
  2072. X            arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  2073. X        fprintf(stderr, "\n");
  2074. X    }
  2075. X}
  2076. END_OF_FILE
  2077. if test 1992 -ne `wc -c <'Ports/x11/error.c'`; then
  2078.     echo shar: \"'Ports/x11/error.c'\" unpacked with wrong size!
  2079. fi
  2080. # end of 'Ports/x11/error.c'
  2081. fi
  2082. if test -f 'Tools/getopt.c' -a "${1}" != "-c" ; then 
  2083.   echo shar: Will not clobber existing file \"'Tools/getopt.c'\"
  2084. else
  2085. echo shar: Extracting \"'Tools/getopt.c'\" \(1532 characters\)
  2086. sed "s/^X//" >'Tools/getopt.c' <<'END_OF_FILE'
  2087. X/*LINTLIBRARY*/
  2088. X
  2089. X#include "configure.h"
  2090. X
  2091. X#ifdef THINK_C
  2092. X#define SYSV
  2093. X#endif
  2094. X
  2095. X#ifdef SYSV
  2096. X#define index strchr
  2097. X#endif
  2098. X
  2099. X#ifdef unix
  2100. X#define NULL    0
  2101. X#define EOF    (-1)
  2102. X#define ERR(s, c)    if(opterr){\
  2103. X    extern int strlen(), write();\
  2104. X    char errbuf[2];\
  2105. X    errbuf[0] = c; errbuf[1] = '\n';\
  2106. X    (void) write(2, argv[0], (int)strlen(argv[0]));\
  2107. X    (void) write(2, s, (int)strlen(s));\
  2108. X    (void) write(2, errbuf, 2);}
  2109. X#else
  2110. X/* Not unix -- assume <stdio.h> works, don't expect write(2). */
  2111. X#include <stdio.h>
  2112. X#define ERR(str, chr)    if(opterr){\
  2113. X    fprintf(stderr, "%s%s%c\n", argv[0], str, chr); }
  2114. X#endif
  2115. X
  2116. Xextern int strcmp();
  2117. Xextern char *index();
  2118. X
  2119. Xint    opterr = 1;
  2120. Xint    optind = 1;
  2121. Xint    optopt;
  2122. Xchar    *optarg;
  2123. X
  2124. Xint
  2125. Xgetopt(argc, argv, opts)
  2126. Xint    argc;
  2127. Xchar    **argv, *opts;
  2128. X{
  2129. X    static int sp = 1;
  2130. X    register int c;
  2131. X    register char *cp;
  2132. X
  2133. X    if(sp == 1)
  2134. X        if(optind >= argc ||
  2135. X           argv[optind][0] != '-' || argv[optind][1] == '\0')
  2136. X            return(EOF);
  2137. X        else if(strcmp(argv[optind], "--") == NULL) {
  2138. X            optind++;
  2139. X            return(EOF);
  2140. X        }
  2141. X    optopt = c = argv[optind][sp];
  2142. X    if(c == ':' || (cp=index(opts, c)) == NULL) {
  2143. X        ERR(": illegal option -- ", c);
  2144. X        if(argv[optind][++sp] == '\0') {
  2145. X            optind++;
  2146. X            sp = 1;
  2147. X        }
  2148. X        return('?');
  2149. X    }
  2150. X    if(*++cp == ':') {
  2151. X        if(argv[optind][sp+1] != '\0')
  2152. X            optarg = &argv[optind++][sp+1];
  2153. X        else if(++optind >= argc) {
  2154. X            ERR(": option requires an argument -- ", c);
  2155. X            sp = 1;
  2156. X            return('?');
  2157. X        } else
  2158. X            optarg = argv[optind++];
  2159. X        sp = 1;
  2160. X    } else {
  2161. X        if(argv[optind][++sp] == '\0') {
  2162. X            sp = 1;
  2163. X            optind++;
  2164. X        }
  2165. X        optarg = NULL;
  2166. X    }
  2167. X    return(c);
  2168. X}
  2169. END_OF_FILE
  2170. if test 1532 -ne `wc -c <'Tools/getopt.c'`; then
  2171.     echo shar: \"'Tools/getopt.c'\" unpacked with wrong size!
  2172. fi
  2173. # end of 'Tools/getopt.c'
  2174. fi
  2175. echo shar: End of archive 17 \(of 19\).
  2176. cp /dev/null ark17isdone
  2177. MISSING=""
  2178. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
  2179.     if test ! -f ark${I}isdone ; then
  2180.     MISSING="${MISSING} ${I}"
  2181.     fi
  2182. done
  2183. if test "${MISSING}" = "" ; then
  2184.     echo You have unpacked all 19 archives.
  2185.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2186. else
  2187.     echo You still need to unpack the following archives:
  2188.     echo "        " ${MISSING}
  2189. fi
  2190. ##  End of shell archive.
  2191. exit 0
  2192.