home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2976 < 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 15/19
  4. Message-ID: <3079@charon.cwi.nl>
  5. Date: 4 Mar 91 11:58:24 GMT
  6.  
  7. Archive-name: stdwin/part15
  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 15 (of 19)."
  16. # Contents:  Appls/dpv/figtest Doc/man/dpv.man H/tools.h
  17. #   Packs/textedit/text.h Ports/alfa/alfa.h Ports/alfa/keymap.c
  18. #   Ports/mac/cursor.c Ports/mac/menu.c Ports/mac_mpw/set_open_hook.c
  19. #   Ports/msdos/dir.c Ports/x11/amtimer.c Ports/x11/font.c
  20. #   Ports/x11/x11.h
  21. # Wrapped by guido@voorn.cwi.nl on Mon Mar  4 12:37:33 1991
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'Appls/dpv/figtest' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'Appls/dpv/figtest'\"
  25. else
  26. echo shar: Extracting \"'Appls/dpv/figtest'\" \(3144 characters\)
  27. sed "s/^X//" >'Appls/dpv/figtest' <<'END_OF_FILE'
  28. X.lf 1 fstree.fig
  29. X.\"    fstree.fig    1.4    88/03/25
  30. X... -2 -2.375 1.75 0.125
  31. X... 0.000i 2.500i 3.750i 0.000i
  32. X.nr 00 \n(.u
  33. X.nf
  34. X.PS 2.500i 3.750i 
  35. X.lf 28
  36. X\h'2.375i'\v'0.125i'\v'.2m'\h'-\w'/'u/2u'/\h'-\w'/'u/2u'
  37. X.sp -1
  38. X\h'2.000i'\v'0.125i'\D'e0.750i 0.250i'
  39. X.sp -1
  40. X\h'3.375i'\v'0.875i'\v'.2m'\h'-\w'vmunix'u/2u'vmunix\h'-\w'vmunix'u/2u'
  41. X.sp -1
  42. X\h'3.000i'\v'1.000i'\D'l0.000i -0.250i'
  43. X.sp -1
  44. X\h'3.000i'\v'0.750i'\D'l0.750i 0.000i'
  45. X.sp -1
  46. X\h'3.750i'\v'0.750i'\D'l0.000i 0.250i'
  47. X.sp -1
  48. X\h'3.750i'\v'1.000i'\D'l-0.750i 0.000i'
  49. X.sp -1
  50. X\h'2.640i'\v'0.213i'\D'l0.734i 0.536i'
  51. X.sp -1
  52. X\h'3.279i'\v'0.711i'\D'l0.095i 0.038i'
  53. X.sp -1
  54. X\h'3.309i'\v'0.670i'\D'l0.066i 0.079i'
  55. X.sp -1
  56. X\h'1.375i'\v'0.875i'\v'.2m'\h'-\w'usr'u/2u'usr\h'-\w'usr'u/2u'
  57. X.sp -1
  58. X\h'1.000i'\v'0.875i'\D'e0.750i 0.250i'
  59. X.sp -1
  60. X\h'2.109i'\v'0.213i'\D'l-0.734i 0.536i'
  61. X.sp -1
  62. X\h'1.441i'\v'0.670i'\D'l-0.066i 0.079i'
  63. X.sp -1
  64. X\h'1.470i'\v'0.711i'\D'l-0.095i 0.038i'
  65. X.sp -1
  66. X\h'0.375i'\v'1.625i'\v'.2m'\h'-\w'foo'u/2u'foo\h'-\w'foo'u/2u'
  67. X.sp -1
  68. X\v'1.750i'\D'l0.000i -0.250i'
  69. X.sp -1
  70. X\v'1.500i'\D'l0.750i 0.000i'
  71. X.sp -1
  72. X\h'0.750i'\v'1.500i'\D'l0.000i 0.250i'
  73. X.sp -1
  74. X\h'0.750i'\v'1.750i'\D'l-0.750i 0.000i'
  75. X.sp -1
  76. X\h'1.109i'\v'0.963i'\D'l-0.734i 0.536i'
  77. X.sp -1
  78. X\h'0.441i'\v'1.420i'\D'l-0.066i 0.079i'
  79. X.sp -1
  80. X\h'0.470i'\v'1.461i'\D'l-0.095i 0.038i'
  81. X.sp -1
  82. X\h'1.375i'\v'1.625i'\v'.2m'\h'-\w'bin'u/2u'bin\h'-\w'bin'u/2u'
  83. X.sp -1
  84. X\h'1.000i'\v'1.625i'\D'e0.750i 0.250i'
  85. X.sp -1
  86. X\h'1.375i'\v'1.000i'\D'l0.000i 0.500i'
  87. X.sp -1
  88. X\h'1.350i'\v'1.400i'\D'l0.025i 0.100i'
  89. X.sp -1
  90. X\h'1.400i'\v'1.400i'\D'l-0.025i 0.100i'
  91. X.sp -1
  92. X\h'0.375i'\v'2.375i'\v'.2m'\h'-\w'ls'u/2u'ls\h'-\w'ls'u/2u'
  93. X.sp -1
  94. X\v'2.500i'\D'l0.000i -0.250i'
  95. X.sp -1
  96. X\v'2.250i'\D'l0.750i 0.000i'
  97. X.sp -1
  98. X\h'0.750i'\v'2.250i'\D'l0.000i 0.250i'
  99. X.sp -1
  100. X\h'0.750i'\v'2.500i'\D'l-0.750i 0.000i'
  101. X.sp -1
  102. X\h'1.109i'\v'1.713i'\D'l-0.734i 0.536i'
  103. X.sp -1
  104. X\h'0.441i'\v'2.170i'\D'l-0.066i 0.079i'
  105. X.sp -1
  106. X\h'0.470i'\v'2.211i'\D'l-0.095i 0.038i'
  107. X.sp -1
  108. X\h'1.375i'\v'2.375i'\v'.2m'\h'-\w'vi'u/2u'vi\h'-\w'vi'u/2u'
  109. X.sp -1
  110. X\h'1.000i'\v'2.500i'\D'l0.000i -0.250i'
  111. X.sp -1
  112. X\h'1.000i'\v'2.250i'\D'l0.750i 0.000i'
  113. X.sp -1
  114. X\h'1.750i'\v'2.250i'\D'l0.000i 0.250i'
  115. X.sp -1
  116. X\h'1.750i'\v'2.500i'\D'l-0.750i 0.000i'
  117. X.sp -1
  118. X\h'1.375i'\v'1.750i'\D'l0.000i 0.500i'
  119. X.sp -1
  120. X\h'1.350i'\v'2.150i'\D'l0.025i 0.100i'
  121. X.sp -1
  122. X\h'1.400i'\v'2.150i'\D'l-0.025i 0.100i'
  123. X.sp -1
  124. X\h'2.375i'\v'1.625i'\v'.2m'\h'-\w'staff'u/2u'staff\h'-\w'staff'u/2u'
  125. X.sp -1
  126. X\h'2.000i'\v'1.625i'\D'e0.750i 0.250i'
  127. X.sp -1
  128. X\h'1.640i'\v'0.963i'\D'l0.734i 0.536i'
  129. X.sp -1
  130. X\h'2.279i'\v'1.461i'\D'l0.095i 0.038i'
  131. X.sp -1
  132. X\h'2.309i'\v'1.420i'\D'l0.066i 0.079i'
  133. X.sp -1
  134. X\h'2.375i'\v'2.375i'\v'.2m'\h'-\w'mckusick'u/2u'mckusick\h'-\w'mckusick'u/2u'
  135. X.sp -1
  136. X\h'2.000i'\v'2.375i'\D'e0.750i 0.250i'
  137. X.sp -1
  138. X\h'2.375i'\v'1.750i'\D'l0.000i 0.500i'
  139. X.sp -1
  140. X\h'2.350i'\v'2.150i'\D'l0.025i 0.100i'
  141. X.sp -1
  142. X\h'2.400i'\v'2.150i'\D'l-0.025i 0.100i'
  143. X.sp -1
  144. X\h'3.375i'\v'2.375i'\v'.2m'\h'-\w'karels'u/2u'karels\h'-\w'karels'u/2u'
  145. X.sp -1
  146. X\h'3.000i'\v'2.375i'\D'e0.750i 0.250i'
  147. X.sp -1
  148. X\h'2.640i'\v'1.713i'\D'l0.734i 0.536i'
  149. X.sp -1
  150. X\h'3.279i'\v'2.211i'\D'l0.095i 0.038i'
  151. X.sp -1
  152. X\h'3.309i'\v'2.170i'\D'l0.066i 0.079i'
  153. X.sp -1
  154. X.sp 1+2.500i
  155. X.PE
  156. X.if \n(00 .fi
  157. X.lf 28
  158. END_OF_FILE
  159. if test 3144 -ne `wc -c <'Appls/dpv/figtest'`; then
  160.     echo shar: \"'Appls/dpv/figtest'\" unpacked with wrong size!
  161. fi
  162. # end of 'Appls/dpv/figtest'
  163. fi
  164. if test -f 'Doc/man/dpv.man' -a "${1}" != "-c" ; then 
  165.   echo shar: Will not clobber existing file \"'Doc/man/dpv.man'\"
  166. else
  167. echo shar: Extracting \"'Doc/man/dpv.man'\" \(3458 characters\)
  168. sed "s/^X//" >'Doc/man/dpv.man' <<'END_OF_FILE'
  169. X.TH DPV 1
  170. X.SH NAME
  171. Xdpv \- ditroff output previewer
  172. X.SH SYNOPSIS
  173. X.B dpv
  174. X[
  175. X.B \-d
  176. X]
  177. X[
  178. X.BI + page
  179. X]
  180. X.I file
  181. X.SH DESCRIPTION
  182. X.I Dpv
  183. Xis a previewer for
  184. X.IR ditroff (1)
  185. Xoutput.
  186. XThere must be exactly one file argument, specifying a file produced by
  187. Xditroff.
  188. XThe
  189. X.B \-d
  190. Xoption turns some debugging output on (if compiled in).
  191. XThe
  192. X.BI + page
  193. Xoption selects the initial page to display (default 1).
  194. X.SH MENUS
  195. XThere are two menus.
  196. XThe
  197. X.B Control
  198. Xmenu contains commands to move around in the file, and a Quit command to
  199. Xleave the program.
  200. XThe
  201. X.B Print
  202. Xmenu contains commands to spool the file to various printers queues.
  203. XSome checks are made that the file is compatible with the printer.
  204. X.SH KEYBOARD CONTROL
  205. XThe following characters typed at the keyboard are interpreted as commands.
  206. XA number
  207. X.I N
  208. Xfollowed by a Carriage Return moves to page
  209. X.I N.
  210. XCarriage Return without preceding number moves one page forward.
  211. X`.' with preceding number is equivalent to Carriage Return;
  212. Xwithout preceding number it redraws the current page.
  213. X`N' moves to the next page, `P' moves to the previous page.
  214. XA number
  215. X.I N
  216. Xfollowed by `N' or `P' moves
  217. X.I N
  218. Xpages forward or backward.
  219. XUp arrow and backspace are equivalent to `P';
  220. X`+', down arrow and space are equivalent to `N'.
  221. X`-' is a toggle: it jumps to the previous page that was shown.
  222. X`^' or `F' moves to the first page; `$' or `L' to the last.
  223. X`G' without preceding number also moves to the last page;
  224. Xwith a preceding number
  225. X.I N
  226. Xit moves to page
  227. X.I N.
  228. X`Q' quits from the program.
  229. XLower case letters are equivalent to their upper case counterparts.
  230. X.SH DIAGNOSTICS
  231. XComplaints about missing files, unknown fonts and what have you are
  232. Xwritten to stderr.
  233. X.SH FILES
  234. Xfunnytab, /usr/local/lib/funnytab, /userfs3/amoeba/lib/funnytab
  235. X\- funny character translation table search path
  236. X.SH SEE ALSO
  237. Xditroff(1)
  238. X.SH AUTHOR
  239. XGuido van Rossum
  240. X.SH BUGS
  241. XMay crash on malformed input (not generated by ditroff).
  242. X.br
  243. XArcs and splines are replaced by straight lines (because I don't have
  244. Xthe necessary mathematics at hand), so output from
  245. X.IR pic (1)
  246. Xor other graphics preprocessors may be unrecognizable.
  247. X.br
  248. XDoesn't know all funny characters.
  249. XUnknown characters are silently suppressed.
  250. X.br
  251. XDoesn't know all fonts, or all sizes.
  252. XUnknown fonts and sizes are replaced by known ones.
  253. X.br
  254. XThe current X11 version uses Adobe bitmap fonts which don't match very
  255. Xwell with the width tables for the Harris.
  256. X.br
  257. XCharacter and line spacing are scaled, but it believes that it should
  258. Xuse characters in the point sizes specified in the input.
  259. XThis may cause the output to look a bit cramped.
  260. X.br
  261. XIt assumes page numbers always start at 1; it doesn't know about the
  262. Xtrue page numbers (even though these are present in the ditroff output).
  263. X.br
  264. XThere should be an argument to specify an alternate funny character
  265. Xtranslation table file.
  266. X.br
  267. XThe font translation table should be read from a file as well.
  268. X.br
  269. XIf it can't find the funny character translation table file, it should
  270. Xfall back on a reasonable default.
  271. X.br
  272. XThe Print menu is very CWI-specific; it, too should be customizable
  273. Xinstead of being wired in.
  274. X.br
  275. XErrors in the input are handled ungracefully.
  276. X.br
  277. XSTDWIN prints a warning to stderr for every font change if a font in the
  278. Xtranslation table doesn't exist (e.g., if you are using the X11 Release
  279. X3 version of dpv with a Release 2 server, or vice versa; or if you have
  280. Xbotched your font directory or font path).  needless to say this can be
  281. Xannoying.
  282. END_OF_FILE
  283. if test 3458 -ne `wc -c <'Doc/man/dpv.man'`; then
  284.     echo shar: \"'Doc/man/dpv.man'\" unpacked with wrong size!
  285. fi
  286. # end of 'Doc/man/dpv.man'
  287. fi
  288. if test -f 'H/tools.h' -a "${1}" != "-c" ; then 
  289.   echo shar: Will not clobber existing file \"'H/tools.h'\"
  290. else
  291. echo shar: Extracting \"'H/tools.h'\" \(3277 characters\)
  292. sed "s/^X//" >'H/tools.h' <<'END_OF_FILE'
  293. X/* Useful includes, definitions etc. */
  294. X
  295. X#include "stdwconf.h"    /* Figure out on which system we are */
  296. X#include "_ARGS.h"    /* Define _ARGS() macro appropriately */
  297. X
  298. X
  299. X/****************************/
  300. X/* Auto-configuration tests */
  301. X/****************************/
  302. X
  303. X#ifdef __STDC__
  304. X#define VOID_PTR
  305. X#define HAVE_STDLIB
  306. X#endif
  307. X
  308. X#ifdef THINK_C
  309. X#ifdef THINK_C_3_0
  310. X#define NO_STRING_H
  311. X#else
  312. X#define HAVE_STDLIB
  313. X#endif
  314. X#endif
  315. X
  316. X#ifdef THINK_C
  317. X#define VOID_PTR
  318. X#endif
  319. X
  320. X#ifdef SYSV
  321. X#define VOID_PTR
  322. X#endif
  323. X
  324. X
  325. X/*********************/
  326. X/* Universal pointer */
  327. X/*********************/
  328. X
  329. X#ifdef VOID_PTR
  330. X#define UNIVPTR void *
  331. X#else
  332. X#define UNIVPTR char *
  333. X#endif
  334. X
  335. X
  336. X/*************/
  337. X/* C library */
  338. X/*************/
  339. X
  340. X#include <stdio.h>
  341. X#include <ctype.h>
  342. X#include <errno.h>
  343. X
  344. X#ifdef NO_STRING_H
  345. X/* Systems that don't have <string.h> should at least have <strings.h> */
  346. X#include <strings.h>
  347. X#else
  348. X#include <string.h>
  349. X#endif
  350. X
  351. X#ifdef NO_STRCHR
  352. X/* Systems that don't have str(r)chr should at least have (r)index */
  353. X#define strchr index
  354. X#define strrchr rindex
  355. X#endif
  356. X
  357. X#ifdef NO_MEMCPY
  358. X/* Systems that don't have memcpy/memcmp should at least have bcopy/bcmp */
  359. X#define memcpy(dest, src, n)    bcopy(src, dest, n)
  360. X#define memcmp(a, b, cnt)    bcmp(a, b, cnt)
  361. X#endif
  362. X
  363. X#ifdef THINK_C
  364. X#ifdef THINK_C_3_0
  365. X#include <proto.h>
  366. X#endif
  367. X#endif
  368. X
  369. X
  370. X#ifdef HAVE_STDLIB
  371. X
  372. X#include <stdlib.h>
  373. X
  374. X#else
  375. X
  376. XUNIVPTR malloc _ARGS((size_t));
  377. XUNIVPTR calloc _ARGS((size_t, size_t));
  378. XUNIVPTR realloc _ARGS((UNIVPTR, size_t));
  379. X
  380. X#ifndef NO_VOID_FREE
  381. Xvoid free _ARGS((UNIVPTR));
  382. X#endif
  383. X
  384. X#ifndef NO_VOID_EXIT
  385. Xvoid exit _ARGS((int));
  386. X#endif
  387. X
  388. Xchar *getenv _ARGS((char *));
  389. X
  390. X#endif /* !HAVE_STDLIB */
  391. X
  392. X/* According to the C Standard, errno may be a macro on systems with
  393. X   multiple threads.  But on older systems, it may not be declared at
  394. X   all in <errno.h>.  So we declare it here, except if it is a macro. */
  395. X
  396. X#ifndef errno
  397. Xextern int errno;
  398. X#endif
  399. X
  400. X
  401. X/*************************************/
  402. X/* Miscellaneous useful declarations */
  403. X/*************************************/
  404. X
  405. X/* Interface to getopt(): */
  406. Xextern int optind;
  407. Xextern char *optarg;
  408. Xint getopt _ARGS((int, char **, char *));
  409. X
  410. X/* Boolean data type: */
  411. X#define bool int    /* For single variable, argument or return value */
  412. X#define tbool char    /* Tiny bool, used in structs or arrays */
  413. X#define FALSE 0
  414. X#define TRUE 1
  415. X
  416. X/* Character shorthands: */
  417. X#define EOS '\0'
  418. X#define EOL '\n'
  419. X
  420. X/* Copy string to malloc'ed memory: */
  421. Xchar *strdup _ARGS((const char *));
  422. X
  423. X/* Other useful macros: */
  424. X
  425. X#define CNTRL(x) ((x) & 0x1f) /* Usage: CNTRL('X') */
  426. X
  427. X#define ABS(x) ((x) < 0 ? -(x) : (x))
  428. X
  429. X#ifndef MIN
  430. X#define MIN(a, b) ((a) < (b) ? (a) : (b))
  431. X#endif
  432. X#ifndef MAX
  433. X#define MAX(a, b) ((a) > (b) ? (a) : (b))
  434. X#endif
  435. X
  436. X#define CLIPMIN(var, min) if ((var) >= (min)) ; else (var)= (min)
  437. X#define CLIPMAX(var, max) if ((var) <= (max)) ; else (var)= (max)
  438. X
  439. X/* Memory allocation macros: */
  440. X
  441. X#define ALLOC(type) ((type*) malloc(sizeof(type)))
  442. X#define FREE(p) if ((p) != 0) { free((UNIVPTR)p); p = 0; } else /*empty*/
  443. X
  444. X/* Array (re)allocation macros.
  445. X   RESIZE yields nonzero if the realloc succeeded. */
  446. X
  447. X#define NALLOC(type, n) ((type*) malloc((unsigned)(n) * sizeof(type)))
  448. X#define RESIZE(var, type, n) \
  449. X    (var= (type *) realloc((UNIVPTR)var, (n) * sizeof(type)))
  450. X
  451. X/* Dynamic array macros: */
  452. X
  453. X#include "lists.h"
  454. END_OF_FILE
  455. if test 3277 -ne `wc -c <'H/tools.h'`; then
  456.     echo shar: \"'H/tools.h'\" unpacked with wrong size!
  457. fi
  458. # end of 'H/tools.h'
  459. fi
  460. if test -f 'Packs/textedit/text.h' -a "${1}" != "-c" ; then 
  461.   echo shar: Will not clobber existing file \"'Packs/textedit/text.h'\"
  462. else
  463. echo shar: Extracting \"'Packs/textedit/text.h'\" \(4138 characters\)
  464. sed "s/^X//" >'Packs/textedit/text.h' <<'END_OF_FILE'
  465. X/* Text Edit, definitions */
  466. X
  467. X/* Include header files */
  468. X#include "stdwin.h"    /* Window interface */
  469. X#include "tools.h"    /* Lots of useful goodies */
  470. X
  471. X#ifndef LSC
  472. X#define NDEBUG        /* Turn off all debugging code */
  473. X#endif
  474. X
  475. X#define RESERVE 256    /* Increment for gap growth */
  476. X#define STARTINCR 20    /* Increment for start array growth; must be >= 1 */
  477. X
  478. X/* Typedefs (for documentation only) */
  479. Xtypedef int focpos;    /* Logical offset (not affected by gap) */
  480. Xtypedef int bufpos;    /* Buffer offset (taking gap into account) */
  481. Xtypedef int lineno;    /* Index into start array */
  482. Xtypedef int coord;    /* Used to declare pairs of coordinates */
  483. Xtypedef coord hcoord;    /* Hor. coordinate */
  484. Xtypedef coord vcoord;    /* Ver. coordinate */
  485. X
  486. Xstruct _textedit {
  487. X    /* Drawing environment */
  488. X    WINDOW *win;
  489. X    coord left, top, right, bottom;
  490. X    hcoord width;    /* == right-left */
  491. X    TEXTATTR attr;    /* Text attributes */
  492. X    vcoord vspace;    /* Vertical spacing (line height) */
  493. X    hcoord tabsize;    /* Spacing of horizontal tabs */
  494. X    
  495. X    /* Text and focus representation */
  496. X    char *buf;    /* Text buffer */
  497. X    bufpos buflen;    /* Size of buffer */
  498. X    bufpos gap;    /* Start of gap */
  499. X    int gaplen;    /* Gap length */
  500. X    focpos foc;    /* Text selection focus start */
  501. X    int foclen;    /* Focus length */
  502. X    bufpos *start;    /* Array of screen line starts */
  503. X    lineno nlines;    /* Number of lines */
  504. X    lineno nstart;    /* Number of elements of start (must be > nlines) */
  505. X    hcoord aim;    /* Where vertical arrows should (try to) go */
  506. X    focpos anchor;    /* Anchor position of focus drag */
  507. X    focpos anchor2;    /* Other end of anchor */
  508. X    tbool focprev;    /* Set if foc between lines belongs to prev line */
  509. X    tbool hilite;    /* Set if focus area shown inverted */
  510. X    tbool mdown;    /* Set if mouse down */
  511. X    tbool dclick;    /* Set if mouse down in double click */
  512. X    tbool drawing;    /* FALSE if no window operations */
  513. X    tbool active;    /* FALSE to inhibit highlighting and caret */
  514. X    
  515. X    /* To optimize single char inserts */
  516. X    tbool opt_valid;    /* Set if following data is valid */
  517. X    tbool opt_in_first_word;/* Focus is in first word of line */
  518. X    lineno opt_i;        /* Line where focus is */
  519. X    coord opt_h, opt_v;    /* Caret position in window */
  520. X    hcoord opt_avail;    /* White pixels at end of line */
  521. X    hcoord opt_end;        /* End of line or next tab stop */
  522. X    
  523. X    /* NB: aim, opt_h, opt_v are in window coordinates,
  524. X           i.e., tp->left or tp->top has already been added */
  525. X};
  526. X
  527. X/* Constants */
  528. X#define UNDEF        (-1)    /* Undefined value, e.g., for aim */
  529. X
  530. X/* NB: All macros below use a variable 'tp' pointing to the textedit struct */
  531. X
  532. X/* Shorthands */
  533. X#define zfocend        (tp->foc+tp->foclen)
  534. X#define zgapend        (tp->gap+tp->gaplen)
  535. X
  536. X/* Transformations between focpos and bufpos values */
  537. X#define zaddgap(f)    ((f) < tp->gap ? (f) : (f)+tp->gaplen)
  538. X#define zsubgap(pos)    ((pos) <= tp->gap ? (pos) : \
  539. X             (pos) <= zgapend ? tp->gap : (pos)-tp->gaplen)
  540. X
  541. X/* ++ and -- operators for bufpos variables */
  542. X#define zincr(p)    (++*(p) == tp->gap ? (*(p) += tp->gaplen) : *(p))
  543. X#define zdecr(p)    (*(p) == zgapend ? (*(p) = tp->gap - 1) : --*(p))
  544. X
  545. X/* +1 and -1 operators for same */
  546. X#define znext(p)    ((p) == tp->gap-1 ? zgapend : (p)+1)
  547. X#define zprev(p)    ((p) == zgapend ? (tp->gap-1) : (p)-1)
  548. X
  549. X/* Access characters at/before positions */
  550. X#define zcharat(p)    (tp->buf[p])
  551. X#define zcharbefore(p)    (tp->buf[zprev(p)])
  552. X
  553. X/* Tab stop calculation */
  554. X#define znexttab(w) ((((w)+tp->tabsize) / tp->tabsize) * tp->tabsize)
  555. X
  556. X/* Functions that don't return int */
  557. XTEXTEDIT *tesetup();
  558. Xchar *zmalloc();
  559. Xchar *zrealloc();
  560. X
  561. X/* Debugging help */
  562. X
  563. X#ifndef NDEBUG
  564. X
  565. X#ifndef __LINE__
  566. X#define __LINE__ 0
  567. X#endif
  568. X
  569. X/* General assertion (NB: type command-period to dprintf to halt) */
  570. X#define zassert(n) ((n) || dprintf("line %d: zassert(n) failed", __LINE__))
  571. X
  572. X/* Check the validity of a buffer offset */
  573. X#define zcheckpos(p) \
  574. X    ((p)>=0 && (p)<=tp->buflen && ((p)<tp->gap || (p)>=zgapend) || \
  575. X        dprintf("line %d: zcheckpos(p=%d) buf[%d] gap=%d+%d", \
  576. X            __LINE__, p, tp->buflen, tp->gap, tp->gaplen))
  577. X
  578. X/* Sanity checking routine for entire state */
  579. X#define zcheck() techeck(tp, __LINE__)
  580. X
  581. X#else /* NDEBUG */
  582. X
  583. X#define zassert(n)    /*empty*/
  584. X#define zcheckpos(pos)    /*empty*/
  585. X#define zcheck()    /*empty*/
  586. X
  587. X#endif /* NDEBUG */
  588. END_OF_FILE
  589. if test 4138 -ne `wc -c <'Packs/textedit/text.h'`; then
  590.     echo shar: \"'Packs/textedit/text.h'\" unpacked with wrong size!
  591. fi
  592. # end of 'Packs/textedit/text.h'
  593. fi
  594. if test -f 'Ports/alfa/alfa.h' -a "${1}" != "-c" ; then 
  595.   echo shar: Will not clobber existing file \"'Ports/alfa/alfa.h'\"
  596. else
  597. echo shar: Extracting \"'Ports/alfa/alfa.h'\" \(3643 characters\)
  598. sed "s/^X//" >'Ports/alfa/alfa.h' <<'END_OF_FILE'
  599. X/* TERMCAP STDWIN -- INTERNAL HEADER FILE */
  600. X
  601. X/* BEWARE: CONFUSED COORDINATE CONVENTIONS.
  602. X   The VTRM package, used here for terminal output,
  603. X   puts the y coordinate first.
  604. X   The stdwin package itself puts the x coordinate first
  605. X   (but instead of (x, y), it uses (h, v)).
  606. X   Also, when VTRM specifies a range of lines, the second number
  607. X   is the last line included.  In stdwin, the second number is
  608. X   the first position NOT included. */
  609. X
  610. X#include "tools.h"
  611. X#include "stdwin.h"
  612. X#include "menu.h"
  613. X#include "vtrm.h"
  614. X
  615. Xstruct _window {
  616. X    short tag;        /* Window tag, usable as document id */
  617. X    short open;        /* Set if this struct window is in use */
  618. X    char *title;        /* Title string */
  619. X    void (*drawproc)();    /* Draw procedure */
  620. X    short top;        /* Top line on screen */
  621. X    short bottom;        /* Bottom line on screen + 1 */
  622. X    int offset;        /* Diff. between doc. and screen line no's */
  623. X    int curh, curv;        /* Text cursor position (doc. coord.) */
  624. X    TEXTATTR attr;        /* Text attributes */
  625. X    struct menubar mbar;    /* Collection of local menus */
  626. X    long timer;        /* Absolute timer value (see timer.c) */
  627. X    short resized;        /* Nonzero when resize event pending */
  628. X};
  629. X
  630. X/* Note on the meaning of the 'offset' field:
  631. X   to convert from screen coordinates to document coordinates: add offset;
  632. X   from document coordinates to screen coordinates: subtract offset. */
  633. X
  634. X/* Data structures describing windows. */
  635. X
  636. X#define MAXWINDOWS    20
  637. X#define MAXLINES    120
  638. X
  639. Xextern WINDOW winlist[MAXWINDOWS];
  640. Xextern char uptodate[MAXLINES];
  641. Xextern WINDOW *wasfront, *front, *syswin;
  642. Xextern int lines, columns;
  643. Xextern TEXTATTR wattr;
  644. X
  645. X/* KEY MAPPING. */
  646. X
  647. X/* The primary key map is a 256-entry array indexed by the first
  648. X   character received.  Secondary key maps are lists terminated with a
  649. X   type field containing SENTINEL.
  650. X   The maps use the same data structure so they can be processed
  651. X   by the same routine. */
  652. X
  653. Xstruct keymap {
  654. X    unsigned char key;    /* Character for which this entry holds */
  655. X    unsigned char type;    /* Entry type */
  656. X    unsigned char id;    /* Id and item of menu shortcut */
  657. X    unsigned char item;    /* Also parameter for other types */
  658. X};
  659. X
  660. X/* Entry types: */
  661. X#define ORDINARY    0    /* Report char as itself */
  662. X#define SECONDARY    1    /* Proceed to secondary keymap [id] */
  663. X#define SHORTCUT    2    /* Menu shortcut */
  664. X#define SENTINEL    127    /* End of secondary key map */
  665. X
  666. Xextern struct keymap _wprimap[256];
  667. Xextern struct keymap **_wsecmap;
  668. X
  669. X#define SECMAPSIZE 128
  670. X
  671. X/* The system menu (menu id 0) has a few entries for window manipulation,
  672. X   followed by entries corresponding to WE_COMMAND subcodes.
  673. X   WC_CLOSE happens to be the first of those, and corresponds
  674. X   with CLOSE_WIN. */
  675. X
  676. X/* Item numbers in system menu: */
  677. X#define PREV_WIN    0
  678. X#define NEXT_WIN    1
  679. X#define CLOSE_WIN    2
  680. X
  681. X/* Offsets between WE_COMMAND subcodes and item numbers in system menu: */
  682. X#define FIRST_CMD    (CLOSE_WIN - WC_CLOSE)
  683. X#define LAST_CMD    99
  684. X
  685. X/* There are also some codes that have a shortcut and a special interpretation
  686. X   but no entry in the system menu: */
  687. X#define SUSPEND_PROC    100
  688. X#define REDRAW_SCREEN    101
  689. X#define MOUSE_DOWN    102
  690. X#define MOUSE_UP    104
  691. X#define LITERAL_NEXT    105
  692. X
  693. X#define MENU_CALL    127    /* Start interactive menu selection */
  694. X
  695. Xvoid wsyscommand();
  696. Xbool wsysevent();
  697. Xvoid wmenuselect();
  698. Xvoid wdrawtitle();
  699. Xvoid wnewshortcuts();
  700. Xvoid wgoto();
  701. Xvoid _wselnext();
  702. Xvoid _wselprev();
  703. Xvoid _wredraw();
  704. Xvoid _wsuspend();
  705. Xvoid getbindings();
  706. Xvoid initsyswin();
  707. Xvoid drawmenubar();
  708. Xvoid drawlocalmenubar();
  709. Xvoid _wreshuffle();
  710. Xvoid _wnewtitle();
  711. Xvoid wsysdraw();
  712. Xvoid killmenubar();
  713. Xvoid initmenubar();
  714. Xvoid gettckeydefs();
  715. Xvoid getttykeydefs();
  716. Xvoid wsetmetakey();
  717. Xvoid menubarchanged();
  718. Xvoid menuselect();
  719. Xvoid _wlitnext();
  720. END_OF_FILE
  721. if test 3643 -ne `wc -c <'Ports/alfa/alfa.h'`; then
  722.     echo shar: \"'Ports/alfa/alfa.h'\" unpacked with wrong size!
  723. fi
  724. # end of 'Ports/alfa/alfa.h'
  725. fi
  726. if test -f 'Ports/alfa/keymap.c' -a "${1}" != "-c" ; then 
  727.   echo shar: Will not clobber existing file \"'Ports/alfa/keymap.c'\"
  728. else
  729. echo shar: Extracting \"'Ports/alfa/keymap.c'\" \(3076 characters\)
  730. sed "s/^X//" >'Ports/alfa/keymap.c' <<'END_OF_FILE'
  731. X/* STDWIN -- KEY MAPPING TABLES. */
  732. X
  733. X#include "alfa.h"
  734. X
  735. X#define CTLX_MAP    1
  736. X#define ESC_MAP        2
  737. X#define PC_MAP        3
  738. X
  739. X/* The key map is set up to provide shortcuts for the system menu. */
  740. X
  741. Xstruct keymap _wprimap[256]= {
  742. X#ifdef MSDOS
  743. X    /* ^@ */ { 0, SECONDARY, PC_MAP, 0},    /* ^@ map */
  744. X#else /* !MSDOS */
  745. X    /* ^@ */ { 0, ORDINARY, 0, 0},
  746. X#endif
  747. X    /* ^A */ { 1, ORDINARY, 0, 0},
  748. X    /* ^B */ { 2, SHORTCUT, 0, FIRST_CMD+WC_LEFT},
  749. X    /* ^C */ { 3, SHORTCUT, 0, FIRST_CMD+WC_CANCEL},
  750. X    /* ^D */ { 4, ORDINARY, 0, 0},
  751. X    /* ^E */ { 5, ORDINARY, 0, 0},
  752. X    /* ^F */ { 6, SHORTCUT, 0, FIRST_CMD+WC_RIGHT},
  753. X    /* ^G */ { 7, SHORTCUT, 0, MOUSE_DOWN},
  754. X    /* ^H */ { 8, SHORTCUT, 0, FIRST_CMD+WC_BACKSPACE},
  755. X    /* ^I */ { 9, SHORTCUT, 0, FIRST_CMD+WC_TAB},
  756. X    /* ^J */ {10, SHORTCUT, 0, FIRST_CMD+WC_RETURN},
  757. X    /* ^K */ {11, ORDINARY, 0, 0},
  758. X    /* ^L */ {12, SHORTCUT, 0, REDRAW_SCREEN},
  759. X    /* ^M */ {13, SHORTCUT, 0, FIRST_CMD+WC_RETURN},
  760. X    /* ^N */ {14, SHORTCUT, 0, FIRST_CMD+WC_DOWN},
  761. X    /* ^O */ {15, ORDINARY, 0, 0},
  762. X    /* ^P */ {16, SHORTCUT, 0, FIRST_CMD+WC_UP},
  763. X    /* ^Q */ {17, ORDINARY, 0, 0},
  764. X    /* ^R */ {18, SHORTCUT, 0, REDRAW_SCREEN},
  765. X    /* ^S */ {19, ORDINARY, 0, 0},
  766. X    /* ^T */ {20, ORDINARY, 0, 0},
  767. X    /* ^U */ {21, ORDINARY, 0, 0},
  768. X    /* ^V */ {22, SHORTCUT, 0, LITERAL_NEXT},
  769. X    /* ^W */ {23, ORDINARY, 0, 0},
  770. X    /* ^X */ {24, SECONDARY, CTLX_MAP, 0},    /* ^X map */
  771. X    /* ^Y */ {25, ORDINARY, 0, 0},
  772. X    /* ^Z */ {26, SHORTCUT, 0, SUSPEND_PROC},
  773. X    /* ^[ */ {27, SECONDARY, ESC_MAP, 0},    /* ESC map */
  774. X    /* ^\ */ {28, ORDINARY, 0, 0},
  775. X    /* ^] */ {29, ORDINARY, 0, 0},
  776. X    /* ^^ */ {30, ORDINARY, 0, 0},
  777. X    /* ^_ */ {31, ORDINARY, 0, 0},
  778. X    
  779. X    /* Followed by 224 entries with type == ORDINARY. */
  780. X    
  781. X    /* NB: DEL (0177) should be mapped to BS_KEY. */
  782. X};
  783. X
  784. Xstatic struct keymap dummy_map[]= {
  785. X    {0, SENTINEL, 0, 0}
  786. X};
  787. X
  788. Xstatic struct keymap ctlx_map[]= {
  789. X    {'N', SHORTCUT, 0, NEXT_WIN},
  790. X    {'P', SHORTCUT, 0, PREV_WIN},
  791. X    {'D', SHORTCUT, 0, CLOSE_WIN},
  792. X    {'\003', SHORTCUT, 0, CLOSE_WIN},    /* ^X-^C */
  793. X    {0, SENTINEL, 0, 0}
  794. X};
  795. X
  796. Xstatic struct keymap esc_map[]= {
  797. X    {'\033', SHORTCUT, 0, MENU_CALL},    /* ESC-ESC */
  798. X    {'\007', SHORTCUT, 0, MOUSE_UP},    /* ESC-^G */
  799. X    {0, SENTINEL, 0, 0}
  800. X};
  801. X
  802. X#ifdef MSDOS
  803. Xstatic struct keymap pc_map[]= {
  804. X    /* {0003, ORDINARY, 0, 0}, */ /* ^@ should map to true ^@ */
  805. X    {0107, SHORTCUT, 0, FIRST_CMD+WC_HOME},
  806. X    {0110, SHORTCUT, 0, FIRST_CMD+WC_UP},
  807. X    {0113, SHORTCUT, 0, FIRST_CMD+WC_LEFT},
  808. X    {0115, SHORTCUT, 0, FIRST_CMD+WC_RIGHT},
  809. X    {0120, SHORTCUT, 0, FIRST_CMD+WC_DOWN},
  810. X    {0111, SHORTCUT, 0, FIRST_CMD+WC_PAGE_UP},
  811. X    {0117, SHORTCUT, 0, FIRST_CMD+WC_END},
  812. X    {0121, SHORTCUT, 0, FIRST_CMD+WC_PAGE_DOWN},
  813. X    {0123, SHORTCUT, 0, FIRST_CMD+WC_CLEAR},
  814. X    {0163, SHORTCUT, 0, FIRST_CMD+WC_META_LEFT},
  815. X    {0164, SHORTCUT, 0, FIRST_CMD+WC_META_RIGHT},
  816. X    {0165, SHORTCUT, 0, FIRST_CMD+WC_META_END},
  817. X    {0166, SHORTCUT, 0, FIRST_CMD+WC_META_PAGE_DOWN},
  818. X    {0167, SHORTCUT, 0, FIRST_CMD+WC_META_HOME},
  819. X    {0204, SHORTCUT, 0, FIRST_CMD+WC_META_PAGE_UP},
  820. X    {0, SENTINEL, 0, 0}
  821. X};
  822. X#endif /* MSDOS */
  823. X
  824. Xstatic struct keymap *sec_map_list[SECMAPSIZE]= {
  825. X    dummy_map,
  826. X    ctlx_map,
  827. X    esc_map,
  828. X#ifdef MSDOS
  829. X    pc_map,
  830. X#endif
  831. X};
  832. X
  833. Xstruct keymap **_wsecmap= sec_map_list;
  834. END_OF_FILE
  835. if test 3076 -ne `wc -c <'Ports/alfa/keymap.c'`; then
  836.     echo shar: \"'Ports/alfa/keymap.c'\" unpacked with wrong size!
  837. fi
  838. # end of 'Ports/alfa/keymap.c'
  839. fi
  840. if test -f 'Ports/mac/cursor.c' -a "${1}" != "-c" ; then 
  841.   echo shar: Will not clobber existing file \"'Ports/mac/cursor.c'\"
  842. else
  843. echo shar: Extracting \"'Ports/mac/cursor.c'\" \(3231 characters\)
  844. sed "s/^X//" >'Ports/mac/cursor.c' <<'END_OF_FILE'
  845. X/* MAC STDWIN -- MOUSE CURSORS. */
  846. X
  847. X/* XXX Shouldn't named resources override the defaults? */
  848. X
  849. X#include "macwin.h"
  850. X#ifdef MPW
  851. X#include <ToolUtils.h>
  852. X#endif
  853. X#ifdef THINK_C
  854. X#include <ToolboxUtil.h>
  855. X#endif
  856. X
  857. Xextern CursPtr handcursorptr;
  858. X
  859. X/* Fetch a cursor by name.  This really returns a resource handle,
  860. X   cast to the mythical type CURSOR *.
  861. X   If no resource by that name exists, some standard cursors may
  862. X   be returned. */
  863. X
  864. XCURSOR *
  865. Xwfetchcursor(name)
  866. X    char *name;
  867. X{
  868. X    CursHandle h = (CursHandle) GetNamedResource('CURS', name);
  869. X    if (h == NULL) {
  870. X        if (strcmp(name, "ibeam") == 0)
  871. X            h = GetCursor(iBeamCursor);
  872. X        else if (strcmp(name, "cross") == 0)
  873. X            h = GetCursor(crossCursor);
  874. X        else if (strcmp(name, "plus") == 0)
  875. X            h = GetCursor(plusCursor);
  876. X        else if (strcmp(name, "watch") == 0)
  877. X            h = GetCursor(watchCursor);
  878. X        else if (strcmp(name, "arrow") == 0) {
  879. X            /* The arrow is not a resource but a quickdraw global.
  880. X               Fake a handle with a static variable. */
  881. X            static CursPtr arrowptr;
  882. X            arrowptr = &QD(arrow);
  883. X            h = &arrowptr;
  884. X        }
  885. X        else if (strcmp(name, "hand") == 0) {
  886. X            /* The hand is hardcoded below */
  887. X            h = &handcursorptr;
  888. X        }
  889. X    }
  890. X    return (CURSOR *)h;
  891. X}
  892. X
  893. Xvoid
  894. Xwsetwincursor(win, cursor)
  895. X    WINDOW *win;
  896. X    CURSOR *cursor;
  897. X{
  898. X    win->cursor = cursor;
  899. X    if (win == active)
  900. X        set_applcursor();
  901. X}
  902. X
  903. X/* Set the mouse cursor shape to the standard arrow.
  904. X   This shape is used when the program is ready for input without
  905. X   having the active window. */
  906. X
  907. Xvoid
  908. Xset_arrow()
  909. X{
  910. X/*XXX    SetCursor(&QD(arrow)); */
  911. X    InitCursor();
  912. X}
  913. X
  914. X/* Set the mouse cursor shape to the standard watch.
  915. X   This shape is used when a long task is being performed.
  916. X   In practice always between two calls to wgetevent()
  917. X   except when the mouse is down.
  918. X   Note: this call is ignored when the application has
  919. X   specified a cursor for the window; in this case it
  920. X   is up to the application to set an arrow when it goes
  921. X   away for a long time. */
  922. X
  923. Xvoid
  924. Xset_watch()
  925. X{
  926. X    if (active == NULL || active->cursor == NULL)
  927. X        SetCursor(*GetCursor(watchCursor));
  928. X}
  929. X
  930. X/* Set the cursor to the standard cursor for the active window.
  931. X   If there is no active window, use an arrow.
  932. X   If a cursor is specified for the active window, use that,
  933. X   otherwise use a default.
  934. X   The default is normally a crosshair but can be changed by
  935. X   setting the global variable _w_cursor to a cursor ID. */
  936. X
  937. Xint _w_cursor= crossCursor;
  938. X
  939. Xvoid
  940. Xset_applcursor()
  941. X{
  942. X    if (active == NULL)
  943. X        set_arrow();
  944. X    else if (active->cursor == NULL)
  945. X        SetCursor(*GetCursor(_w_cursor));
  946. X    else {
  947. X        CursHandle h = (CursHandle) active->cursor;
  948. X        if (*h == NULL)
  949. X            LoadResource((Handle)h);
  950. X        SetCursor(*h);
  951. X    }
  952. X}
  953. X
  954. X/* Set the mouse cursor shape to a little hand icon.
  955. X   This shape is used when scroll-dragging the document. */
  956. X
  957. Xstatic Cursor handcursor= {
  958. X    {    /* Data: */
  959. X        0x0180, 0x1a70, 0x2648, 0x264a, 
  960. X        0x124d, 0x1249, 0x6809, 0x9801, 
  961. X        0x8802, 0x4002, 0x2002, 0x2004, 
  962. X        0x1004, 0x0808, 0x0408, 0x0408,
  963. X    },
  964. X    {    /* Mask: */
  965. X        0x0180, 0x1bf0, 0x3ff8, 0x3ffa, 
  966. X        0x1fff, 0x1fff, 0x7fff, 0xffff, 
  967. X        0xfffe, 0x7ffe, 0x3ffe, 0x3ffc, 
  968. X        0x1ffc, 0x0ff8, 0x07f8, 0x07f8,
  969. X    },
  970. X    {8, 8}    /* Hotspot */
  971. X};
  972. X
  973. Xstatic CursPtr handcursorptr = &handcursor; /* For wfetchcursor */
  974. X
  975. Xvoid
  976. Xset_hand()
  977. X{
  978. X    SetCursor(&handcursor);
  979. X}
  980. END_OF_FILE
  981. if test 3231 -ne `wc -c <'Ports/mac/cursor.c'`; then
  982.     echo shar: \"'Ports/mac/cursor.c'\" unpacked with wrong size!
  983. fi
  984. # end of 'Ports/mac/cursor.c'
  985. fi
  986. if test -f 'Ports/mac/menu.c' -a "${1}" != "-c" ; then 
  987.   echo shar: Will not clobber existing file \"'Ports/mac/menu.c'\"
  988. else
  989. echo shar: Extracting \"'Ports/mac/menu.c'\" \(4227 characters\)
  990. sed "s/^X//" >'Ports/mac/menu.c' <<'END_OF_FILE'
  991. X/* MAC STDWIN -- MENUS. */
  992. X
  993. X/* XXX Ought to find a way to allow the THINK C console menus
  994. X   to work when the console is active */
  995. X
  996. X#include "macwin.h"
  997. X#ifdef MPW
  998. X#include <Fonts.h>
  999. X#include <Menus.h>
  1000. X#include <ToolUtils.h>
  1001. X#endif
  1002. X#ifdef THINK_C
  1003. X#include <MenuMgr.h>
  1004. X#endif
  1005. X
  1006. X#define MENUID(mp) ((*((MenuHandle)(mp)))->menuID)
  1007. X
  1008. Xbool _wmenuhilite;        /* Set if HiliteMenu(0) needed */
  1009. X
  1010. Xstatic bool deflocal= FALSE;    /* Default menu state */
  1011. X
  1012. Xstatic int firstlocal;        /* First local menu in menu bar */
  1013. X
  1014. X/* Function prototypes */
  1015. X
  1016. XSTATIC void addtobar _ARGS((struct menubar *mbp, MENU *mp));
  1017. XSTATIC void delfrombar _ARGS((struct menubar *mbp, MENU *mp));
  1018. X
  1019. Xstatic void
  1020. Xaddtobar(mbp, mp)
  1021. X    struct menubar *mbp;
  1022. X    MENU *mp;
  1023. X{
  1024. X    int i;
  1025. X    
  1026. X    for (i= 0; i < mbp->nmenus; ++i) {
  1027. X        if (mp == mbp->menulist[i])
  1028. X            return; /* Already attached */
  1029. X    }
  1030. X    L_APPEND(mbp->nmenus, mbp->menulist, MENU *, mp);
  1031. X}
  1032. X
  1033. Xstatic void
  1034. Xdelfrombar(mbp, mp)
  1035. X    struct menubar *mbp;
  1036. X    MENU *mp;
  1037. X{
  1038. X    int i;
  1039. X    
  1040. X    for (i= 0; i < mbp->nmenus; ++i) {
  1041. X        if (mp == mbp->menulist[i]) {
  1042. X            L_REMOVE(mbp->nmenus, mbp->menulist, MENU *, i);
  1043. X            break;
  1044. X        }
  1045. X    }
  1046. X}
  1047. X
  1048. XMENU *
  1049. Xwmenucreate(id, title)
  1050. X    int id;
  1051. X    char *title;
  1052. X{
  1053. X    MENU *mp= (MENU *)NewMenu(id, PSTRING(title));
  1054. X    
  1055. X    if (!deflocal) {
  1056. X        InsertMenu(mp, firstlocal);
  1057. X        DrawMenuBar();
  1058. X    }
  1059. X    return mp;
  1060. X}
  1061. X
  1062. Xvoid
  1063. Xwmenudelete(mp)
  1064. X    MENU *mp;
  1065. X{
  1066. X    WindowPtr w;
  1067. X    
  1068. X    for (w= FrontWindow(); w != NULL;
  1069. X        w= (WindowPtr)((WindowPeek)w)->nextWindow) {
  1070. X        WINDOW *win= whichwin(w);
  1071. X        if (win != NULL)
  1072. X            delfrombar(&win->mbar, mp);
  1073. X    }
  1074. X    DeleteMenu(MENUID(mp));
  1075. X    DrawMenuBar();
  1076. X    DisposeMenu(mp);
  1077. X}
  1078. X
  1079. Xint
  1080. Xwmenuadditem(mp, text, shortcut)
  1081. X    MENU *mp;
  1082. X    char *text;
  1083. X    int shortcut;
  1084. X{
  1085. X    char buf[256];
  1086. X    int item;
  1087. X    
  1088. X    if (text == NULL || *text == EOS)
  1089. X        strcpy(buf, "(-");
  1090. X    else
  1091. X        strcpy(buf, "x");
  1092. X    if (shortcut >= 0) {
  1093. X        char *p= buf + strlen(buf);
  1094. X        *p++= '/';
  1095. X        *p++= shortcut;
  1096. X        *p= EOS;
  1097. X    }
  1098. X    AppendMenu(mp, PSTRING(buf));
  1099. X    item= CountMItems(mp);
  1100. X    if (text != NULL && *text != EOS)
  1101. X        SetItem(mp, item, PSTRING(text));
  1102. X    return item-1;
  1103. X}
  1104. X
  1105. Xvoid
  1106. Xwmenusetitem(mp, item, text)
  1107. X    MENU *mp;
  1108. X    int item;
  1109. X    char *text;
  1110. X{
  1111. X    ++item;
  1112. X    if (text == NULL || *text == EOS)
  1113. X        DisableItem(mp, item);
  1114. X    else {
  1115. X        EnableItem(mp, item);
  1116. X        SetItem(mp, item, PSTRING(text));
  1117. X    }
  1118. X}
  1119. X
  1120. Xvoid
  1121. Xwmenuenable(mp, item, flag)
  1122. X    MENU *mp;
  1123. X    int item;
  1124. X    int flag;
  1125. X{
  1126. X    ++item;
  1127. X    if (flag)
  1128. X        EnableItem(mp, item);
  1129. X    else
  1130. X        DisableItem(mp, item);
  1131. X}
  1132. Xvoid
  1133. Xwmenucheck(mp, item, flag)
  1134. X    MENU *mp;
  1135. X    int item;
  1136. X    int flag;
  1137. X{
  1138. X    ++item;
  1139. X    CheckItem(mp, item, flag);
  1140. X}
  1141. X
  1142. Xvoid
  1143. Xwmenuattach(win, mp)
  1144. X    WINDOW *win;
  1145. X    MENU *mp;
  1146. X{
  1147. X    addtobar(&win->mbar, mp);
  1148. X    if (win == active) {
  1149. X        InsertMenu(mp, 0);
  1150. X        DrawMenuBar();
  1151. X    }
  1152. X}
  1153. X
  1154. Xvoid
  1155. Xwmenudetach(win, mp)
  1156. X    WINDOW *win;
  1157. X    MENU *mp;
  1158. X{
  1159. X    delfrombar(&win->mbar, mp);
  1160. X    if (win == active) {
  1161. X        DeleteMenu(MENUID(mp));
  1162. X        DrawMenuBar();
  1163. X    }
  1164. X}
  1165. X
  1166. Xvoid
  1167. Xwmenusetdeflocal(local)
  1168. X    bool local;
  1169. X{
  1170. X    deflocal= local;
  1171. X}
  1172. X
  1173. X/* Interface routines for the rest of the library. */
  1174. X
  1175. Xvoid
  1176. Xinitmbar(mb)
  1177. X    struct menubar *mb;
  1178. X{
  1179. X    L_INIT(mb->nmenus, mb->menulist);
  1180. X}
  1181. X
  1182. Xvoid
  1183. Xkillmbar(mb)
  1184. X    struct menubar *mb;
  1185. X{
  1186. X    L_DEALLOC(mb->nmenus, mb->menulist);
  1187. X}
  1188. X
  1189. Xvoid
  1190. Xaddlocalmenus(win)
  1191. X    WINDOW *win;
  1192. X{
  1193. X    int i;
  1194. X    
  1195. X    firstlocal= 0;
  1196. X    for (i= 0; i < win->mbar.nmenus; ++i) {
  1197. X        if (firstlocal == 0)
  1198. X            firstlocal= MENUID(win->mbar.menulist[i]);
  1199. X        InsertMenu(win->mbar.menulist[i], 0);
  1200. X    }
  1201. X    if (i > 0)
  1202. X        DrawMenuBar();
  1203. X}
  1204. X
  1205. Xvoid
  1206. Xrmlocalmenus(win)
  1207. X    WINDOW *win;
  1208. X{
  1209. X    int i;
  1210. X    
  1211. X    firstlocal= 0;
  1212. X    for (i= 0; i < win->mbar.nmenus; ++i)
  1213. X        DeleteMenu(MENUID(win->mbar.menulist[i]));
  1214. X    if (i > 0)
  1215. X        DrawMenuBar();
  1216. X}
  1217. X
  1218. Xvoid
  1219. X_wdo_menu(ep, menu_item)
  1220. X    EVENT *ep;
  1221. X    long menu_item;
  1222. X{
  1223. X    int id= HiWord(menu_item);
  1224. X    int item= LoWord(menu_item);
  1225. X    
  1226. X    if (id == 0)
  1227. X        return;
  1228. X    if (id == APPLE_MENU) {
  1229. X        if (item == 1)
  1230. X            do_about();
  1231. X        else {
  1232. X            char name[256];
  1233. X            GetItem(GetMHandle(id), item, name);
  1234. X            (void) OpenDeskAcc(name);
  1235. X        }
  1236. X        HiliteMenu(0);
  1237. X    }
  1238. X    else {
  1239. X        ep->type= WE_MENU;
  1240. X        ep->u.m.id= id;
  1241. X        ep->u.m.item= item-1;
  1242. X        _wmenuhilite= TRUE;
  1243. X    }
  1244. X}
  1245. X
  1246. X/* Call this routine exactly once to initialize the Apple menu. */
  1247. X
  1248. Xchar *about_item= "About STDWIN...";
  1249. X
  1250. Xvoid
  1251. Xsetup_menus()
  1252. X{
  1253. X    static char applename[2]= {appleMark, EOS};
  1254. X    MenuHandle m;
  1255. X    
  1256. X    m= (MenuHandle)wmenucreate(APPLE_MENU, applename);
  1257. X    AppendMenu(m, PSTRING(about_item));
  1258. X    AppendMenu(m, PSTRING("(-"));
  1259. X    AddResMenu(m, 'DRVR');
  1260. X}
  1261. END_OF_FILE
  1262. if test 4227 -ne `wc -c <'Ports/mac/menu.c'`; then
  1263.     echo shar: \"'Ports/mac/menu.c'\" unpacked with wrong size!
  1264. fi
  1265. # end of 'Ports/mac/menu.c'
  1266. fi
  1267. if test -f 'Ports/mac_mpw/set_open_hook.c' -a "${1}" != "-c" ; then 
  1268.   echo shar: Will not clobber existing file \"'Ports/mac_mpw/set_open_hook.c'\"
  1269. else
  1270. echo shar: Extracting \"'Ports/mac_mpw/set_open_hook.c'\" \(3316 characters\)
  1271. sed "s/^X//" >'Ports/mac_mpw/set_open_hook.c' <<'END_OF_FILE'
  1272. X/* A procedure to install a hook in the MPW C 'open' library function.
  1273. X   This is useful because you may want to create files automatically
  1274. X   with type 'TEXT' without having to change all the 'open' or 'fopen'
  1275. X   calls in a large C program you are trying to port.  A standard hook
  1276. X   procedure for this purpose is also provided.   
  1277. X
  1278. X   Call:
  1279. X       set_open_hook(proc);
  1280. X   This installs the hook proc, or restores the default situation if
  1281. X   proc is NULL.
  1282. X   The hook procedure will be called immediately *after* a successful
  1283. X   open call, with the following parameters:
  1284. X       proc(filename, oflag, fd)
  1285. X        char *filename;        The file name
  1286. X        int oflag;        Mode passed to open
  1287. X        int fd;            Return value from open
  1288. X
  1289. X   Note: this only works when the program is linked as an application
  1290. X   (type APPL); for tools (type MPST) the device switch is located
  1291. X   in the Shell's memory.
  1292. X   
  1293. X   Careful! this information was gathered by disassembling parts
  1294. X   of the library.
  1295. X   There are no guarantees that the same code will work in future
  1296. X   versions of MPW.  It has been tested with version 1.0B2. */
  1297. X
  1298. X#include <fcntl.h>
  1299. X
  1300. X#include <Types.h>
  1301. X#include <Files.h>
  1302. X
  1303. X#include "intercept.h"
  1304. X
  1305. X#define ERRFLAG 0x40000000
  1306. X
  1307. Xstatic ProcPtr open_hook;
  1308. X
  1309. X/* The hook for faccess, installed in the device switch.
  1310. X   This will be called with cmd == F_OPEN from 'open',
  1311. X   but also from 'faccess', with other values for cmd.
  1312. X   The open_hook is only called if cmd == F_OPEN.
  1313. X   It is not necessary to check whether open_hook is NULL,
  1314. X   since we are only installed after open_hook is set non-NULL. */
  1315. X
  1316. Xstatic long
  1317. Xmy_faccess(file, cmd, arg)
  1318. X    char *file;
  1319. X    int cmd;
  1320. X    short *arg;
  1321. X{
  1322. X    long res= _fsFAccess(file, cmd, arg);
  1323. X    
  1324. X    if (cmd == F_OPEN && !(res&ERRFLAG)) {
  1325. X        (void) (*open_hook)(file, *arg, (int)res);
  1326. X    }
  1327. X    return res;
  1328. X}
  1329. X
  1330. X/* Standard open hook, to set type and creator of created files.
  1331. X   It will not change existing non-zero type or creator fields.
  1332. X   It returns an error code even though this is ignored by the
  1333. X   calling routine; you might want to call it yourself in a more
  1334. X   fancyful hook, and test the error code.
  1335. X   This routine can be customized by changing 'std_type' or
  1336. X   'std_creator'. */
  1337. X
  1338. XOSType std_type=    'TEXT';
  1339. XOSType std_creator=    'MPS ';
  1340. X
  1341. Xint
  1342. Xstd_open_hook(file, mode, fd)
  1343. X    char *file;
  1344. X    int mode;
  1345. X    int fd;
  1346. X{
  1347. X    FInfo info;
  1348. X    int err= noErr;
  1349. X    
  1350. X    switch (mode & 03) {
  1351. X    
  1352. X    case O_RDWR:
  1353. X    case O_WRONLY:
  1354. X        err= GetFInfo(file, 0, &info);
  1355. X        if (err != noErr)
  1356. X            return err;
  1357. X        if (info.fdType == 0) {
  1358. X            info.fdType= std_type;
  1359. X            ++err; /* Use 'err' as a flag to call SetFInfo */
  1360. X        }
  1361. X        if (info.fdCreator == 0) {
  1362. X            info.fdCreator= std_creator;
  1363. X            ++err;
  1364. X        }
  1365. X        if (err != noErr)
  1366. X            err= SetFInfo(file, 0, &info);
  1367. X    
  1368. X    }
  1369. X    return err;
  1370. X}
  1371. X
  1372. X/* The procedure to install the hook.
  1373. X   Note: this assumes nobody else is also installing hooks
  1374. X   for faccess, otherwise we would have to save and restore
  1375. X   the old function, instead of blindly assuming _fsFAccess. */
  1376. X
  1377. Xset_open_hook(hook)
  1378. X    ProcPtr hook;
  1379. X{
  1380. X    if (hook == NULL)
  1381. X        _StdDevs[DEV_FSYS].dev_faccess= _fsFAccess;
  1382. X    else {
  1383. X        open_hook= hook;
  1384. X        _StdDevs[DEV_FSYS].dev_faccess= my_faccess;
  1385. X    }
  1386. X}
  1387. X
  1388. X/* A trivial test program will be included if you #define MAIN: */
  1389. X
  1390. X#ifdef MAIN
  1391. X
  1392. X#include <stdio.h>
  1393. X
  1394. Xextern int std_open_hook();
  1395. X
  1396. Xmain()
  1397. X{
  1398. X    set_open_hook(std_open_hook);
  1399. X    fclose(fopen("ABC", "a"));
  1400. X}
  1401. X
  1402. X#endif
  1403. END_OF_FILE
  1404. if test 3316 -ne `wc -c <'Ports/mac_mpw/set_open_hook.c'`; then
  1405.     echo shar: \"'Ports/mac_mpw/set_open_hook.c'\" unpacked with wrong size!
  1406. fi
  1407. # end of 'Ports/mac_mpw/set_open_hook.c'
  1408. fi
  1409. if test -f 'Ports/msdos/dir.c' -a "${1}" != "-c" ; then 
  1410.   echo shar: Will not clobber existing file \"'Ports/msdos/dir.c'\"
  1411. else
  1412. echo shar: Extracting \"'Ports/msdos/dir.c'\" \(3239 characters\)
  1413. sed "s/^X//" >'Ports/msdos/dir.c' <<'END_OF_FILE'
  1414. X/*
  1415. X * MS-DOS version of UNIX directory access package.
  1416. X * (opendir, readdir, closedir).
  1417. X */
  1418. X
  1419. X#include <sys/types.h>
  1420. X#include <sys/stat.h>
  1421. X#include <errno.h>
  1422. X#include <dos.h>
  1423. Xextern int errno;
  1424. X#define MAXPATH 64
  1425. X
  1426. X#include "dir.h"
  1427. Xstatic char *firstf();
  1428. Xstatic char *nextf();
  1429. X
  1430. Xtypedef int bool;
  1431. X#define TRUE 1
  1432. X#define FALSE 0
  1433. X#define EOS '\0'
  1434. X#define NULL 0
  1435. X
  1436. Xstatic char dirpath[MAXPATH+1]= "";
  1437. Xstatic bool busy= FALSE;
  1438. X
  1439. X/*
  1440. X * Open a directory.
  1441. X * This MS-DOS version allows only one directory to be open at a time.
  1442. X * The path must exist and be a directory.
  1443. X * Then it only saves the file name and returns a pointer to it.
  1444. X */
  1445. X
  1446. Xchar *
  1447. Xopendir(path)
  1448. X    char *path;
  1449. X{
  1450. X    struct stat buffer;
  1451. X
  1452. X    if (dirpath[0] != EOS) {
  1453. X         errno= EMFILE;
  1454. X         return NULL; /* Only one directory can be open at a time */
  1455. X    }
  1456. X    if (stat(path, &buffer) == -1)
  1457. X        return NULL; /* Directory doesn't exist */
  1458. X    if ((buffer.st_mode & S_IFMT) != S_IFDIR) {
  1459. X        errno= ENOENT;
  1460. X        return NULL; /* Not a directory */
  1461. X    }
  1462. X    strcpy(dirpath, path);
  1463. X    path= dirpath + strlen(dirpath);
  1464. X    if (path > dirpath && path[-1] != ':' && path[-1] != '/' &&
  1465. X            path[-1] != '\\')
  1466. X        *path++ = '\\';
  1467. X    strcpy(path, "*.*");
  1468. X    busy= FALSE; /* Tell readdir this is the first time */
  1469. X    return dirpath;
  1470. X}
  1471. X
  1472. X/*
  1473. X * Close a directory.
  1474. X * We must clear the first char of dirpath to signal opendir that
  1475. X * no directory is open.
  1476. X */
  1477. X
  1478. Xclosedir(dirp)
  1479. X    char *dirp;
  1480. X{
  1481. X    dirp[0]= EOS;
  1482. X}
  1483. X
  1484. X/*
  1485. X * Read the next directory entry.
  1486. X */
  1487. X
  1488. Xstruct direct *
  1489. Xreaddir(dp)
  1490. X    char *dp;
  1491. X{
  1492. X    static struct direct buffer;
  1493. X    char *p;
  1494. X
  1495. X    if (!busy)
  1496. X        p= firstf(dp);
  1497. X    else
  1498. X        p= nextf();
  1499. X    busy= (p != NULL);
  1500. X    if (!busy)
  1501. X        return NULL;
  1502. X    strcpy(buffer.d_name, p);
  1503. X    buffer.d_namlen= strlen(p);
  1504. X    return &buffer;
  1505. X}
  1506. X
  1507. X
  1508. X/*
  1509. X * Low-level implementation -- access to DOS system calls FIRST and NEXT.
  1510. X */
  1511. X
  1512. Xstatic char dta[64]; /* Device Transfer Area */
  1513. X
  1514. X/* File attributes */
  1515. X#define READONLY    0x01
  1516. X#define HIDDEN        0x02
  1517. X#define SYSTEM        0x04
  1518. X#define VOLUMEID    0x08
  1519. X#define DIRECTORY    0x10
  1520. X#define ARCHIVE        0x20
  1521. X
  1522. X#define MATCHATTR    (HIDDEN|SYSTEM|DIRECTORY)
  1523. X
  1524. Xstatic char *
  1525. Xfirstf(pat)
  1526. X    char *pat;
  1527. X{
  1528. X    int flags;
  1529. X    union REGS regs;
  1530. X    struct SREGS segregs;
  1531. X
  1532. X    setdta(dta);
  1533. X
  1534. X    segread(&segregs);
  1535. X    regs.h.ah = 0x4e;
  1536. X    regs.x.cx = MATCHATTR;
  1537. X#ifdef M_I86LM /* Large Model -- far pointers */
  1538. X    regs.x.dx = FP_OFF(pat);
  1539. X    segregs.ds = FP_SEG(pat);
  1540. X#else
  1541. X    regs.x.dx = (int) pat;
  1542. X#endif
  1543. X    flags= intdosx(®s, ®s, &segregs);
  1544. X    if (regs.x.cflag)
  1545. X    return NULL;
  1546. X    fixfile();
  1547. X    return dta + 30;
  1548. X}
  1549. X
  1550. Xstatic char *
  1551. Xnextf()
  1552. X{
  1553. X    int flags;
  1554. X    union REGS regs;
  1555. X
  1556. X    setdta(dta);
  1557. X
  1558. X    regs.h.ah = 0x4f;
  1559. X    flags= intdos(®s, ®s);
  1560. X    if (regs.x.cflag)
  1561. X    return NULL;
  1562. X    fixfile();
  1563. X    return dta + 30;
  1564. X}
  1565. X
  1566. X/*
  1567. X * Convert the file name in the Device Transfer Area to lower case.
  1568. X */
  1569. X
  1570. Xstatic
  1571. Xfixfile()
  1572. X{
  1573. X    char *cp;
  1574. X
  1575. X    for (cp= dta+30; *cp != EOS; ++cp)
  1576. X        *cp= tolower(*cp);
  1577. X}
  1578. X
  1579. X/*
  1580. X * Tell MS-DOS where the Device Transfer Area is.
  1581. X */
  1582. X
  1583. Xstatic
  1584. Xsetdta(dta)
  1585. X    char *dta;
  1586. X{
  1587. X    union REGS regs;
  1588. X    struct SREGS segregs;
  1589. X
  1590. X    segread(&segregs);
  1591. X    regs.h.ah = 0x1a;
  1592. X#ifdef M_I86LM /* Large Model -- far pointers */
  1593. X    regs.x.dx = FP_OFF(dta);
  1594. X    segregs.ds = FP_SEG(dta);
  1595. X#else
  1596. X    regs.x.dx = (int) dta;
  1597. X#endif
  1598. X    intdosx(®s, ®s, &segregs);
  1599. X}
  1600. END_OF_FILE
  1601. if test 3239 -ne `wc -c <'Ports/msdos/dir.c'`; then
  1602.     echo shar: \"'Ports/msdos/dir.c'\" unpacked with wrong size!
  1603. fi
  1604. # end of 'Ports/msdos/dir.c'
  1605. fi
  1606. if test -f 'Ports/x11/amtimer.c' -a "${1}" != "-c" ; then 
  1607.   echo shar: Will not clobber existing file \"'Ports/x11/amtimer.c'\"
  1608. else
  1609. echo shar: Extracting \"'Ports/x11/amtimer.c'\" \(3675 characters\)
  1610. sed "s/^X//" >'Ports/x11/amtimer.c' <<'END_OF_FILE'
  1611. X/* Amoeba-specific timer code. */
  1612. X
  1613. X#include "x11.h"
  1614. X
  1615. X#include <amoeba.h>
  1616. X#include <semaphore.h>
  1617. X
  1618. Xinterval sys_milli();
  1619. X
  1620. X/* Although win->timer and the second parameter of wsettimer() are in
  1621. X   deciseconds, *all* other values are in milliseconds. */
  1622. X
  1623. Xstatic interval nexttimer;
  1624. X
  1625. X/* Compute a new value for nexttimer.
  1626. X   This is the system time (in msec.) when the first event should go
  1627. X   off, or 0 if there are no scheduled timer events.
  1628. X   Return the relevant window as a convenience. */
  1629. X
  1630. Xstatic WINDOW *
  1631. Xsetnexttimer()
  1632. X{
  1633. X    WINDOW *win = _wnexttimer();
  1634. X    
  1635. X    if (win == NULL)
  1636. X        nexttimer = 0;
  1637. X    else
  1638. X        nexttimer = win->timer * 100;
  1639. X    _wdebug(4, "setnexttimer: nexttimer at %d for %x", nexttimer, win);
  1640. X    return win;
  1641. X}
  1642. X
  1643. X/* Set the timer for a given window at now + deciseconds;
  1644. X   or discard the timer if deciseconds is zero. */
  1645. X
  1646. Xvoid
  1647. Xwsettimer(win, deciseconds)
  1648. X    WINDOW *win;
  1649. X    int deciseconds;
  1650. X{
  1651. X    _wdebug(3, "wsettimer: deciseconds=%d", deciseconds);
  1652. X    win->timer = 0;
  1653. X    if (deciseconds > 0)
  1654. X        win->timer = deciseconds + sys_milli() / 100;
  1655. X    _wdebug(3, "wsettimer(%d): timer set to %d", deciseconds, win->timer);
  1656. X    (void) setnexttimer();
  1657. X}
  1658. X
  1659. X/* Return an interval until the next timer, or -1 if no timers.
  1660. X   This is suitable to pass directly to mu_trylock() etc. */
  1661. X
  1662. Xinterval
  1663. Xnextdelay()
  1664. X{
  1665. X    interval now;
  1666. X    
  1667. X    if (nexttimer == 0)
  1668. X        return -1; /* No timer events */
  1669. X    now = sys_milli();
  1670. X    if (nexttimer <= now)
  1671. X        return 0; /* Immediate timer event */
  1672. X    return nexttimer - now; /* Milliseconds until timer event */
  1673. X}
  1674. X
  1675. X/* Check if a timer has gone off, and if so, generate an appropriate event.
  1676. X   This can be called at any time, but for efficiency reasons it should
  1677. X   only be called when an alarm has actually gone off.
  1678. X   If an alarm has gone off, it will always be found by this function. */
  1679. X
  1680. Xstatic bool
  1681. Xdotimer(ep)
  1682. X    EVENT *ep;
  1683. X{
  1684. X    WINDOW *win;
  1685. X    interval next;
  1686. X    
  1687. X    win = setnexttimer();
  1688. X    if (win == NULL) {
  1689. X        _wdebug(1, "dotimer: no event found (spurious call)");
  1690. X        return FALSE;
  1691. X    }
  1692. X    next = nextdelay();
  1693. X    if (next < 0) {
  1694. X        /* Shouldn't happen -- setnexttimer should have been NULL */
  1695. X        _wdebug(0, "dotimer: nextdelay() < 0 ???");
  1696. X        return FALSE;
  1697. X    }
  1698. X    if (next == 0) {
  1699. X        _wdebug(3, "dotimer: reporting timer event");
  1700. X        ep->type = WE_TIMER;
  1701. X        ep->window = win;
  1702. X        win->timer = 0;
  1703. X        (void) setnexttimer();
  1704. X        return TRUE;
  1705. X    }
  1706. X    else {
  1707. X        _wdebug(1, "dotimer: it is not yet time");
  1708. X        return FALSE;
  1709. X    }
  1710. X}
  1711. X
  1712. X/* Check for timer events, return TRUE if one found.
  1713. X   If a timer event is due now, return it immediately.
  1714. X   Otherwise, if mayblock is FALSE, return FALSE immediately.
  1715. X   Otherwise, block until either an X event is available or the next
  1716. X   timer event happens (in which case it is returned).
  1717. X*/
  1718. X
  1719. Xbool
  1720. X_w_checktimer(ep, mayblock)
  1721. X    EVENT *ep;
  1722. X    bool mayblock;
  1723. X{
  1724. X    for (;;) {
  1725. X        interval delay;
  1726. X        int status;
  1727. X        
  1728. X        delay = nextdelay();
  1729. X        if (delay == 0) {
  1730. X            if (dotimer(ep))
  1731. X                return TRUE;
  1732. X        }
  1733. X        if (!mayblock)
  1734. X            return FALSE;
  1735. X        /* Block until next X event or next timer event */
  1736. X        status = XamBlock(_wd, delay);
  1737. X        _wdebug(4, "_w_checktimer: status %d", status);
  1738. X        if (status > 0) {
  1739. X            _wdebug(3, "_w_checktimer: external event, status %d",
  1740. X                                status);
  1741. X            ep->type = WE_EXTERN;
  1742. X            ep->window = NULL;
  1743. X            ep->u.command = status;
  1744. X            return TRUE;
  1745. X        }
  1746. X        if (status == 0) {
  1747. X            _wdebug(3, "_w_checktimer: X event");
  1748. X            return FALSE;
  1749. X        }
  1750. X        _wdebug(3, "_w_checktimer: timer went off");
  1751. X        /* Negative return means timer went off
  1752. X           (or interrupted system call) */
  1753. X    }
  1754. X}
  1755. X
  1756. Xsemaphore *_wsema; /* Global, used by winit() */
  1757. X
  1758. X/* Interface to specify the semaphore used by XamBlock().
  1759. X   *** This must be called before calling winit[new]() !!! ***
  1760. X   */
  1761. X
  1762. Xvoid
  1763. Xwsetsema(ps)
  1764. X    semaphore *ps;
  1765. X{
  1766. X    _wsema = ps;
  1767. X}
  1768. END_OF_FILE
  1769. if test 3675 -ne `wc -c <'Ports/x11/amtimer.c'`; then
  1770.     echo shar: \"'Ports/x11/amtimer.c'\" unpacked with wrong size!
  1771. fi
  1772. # end of 'Ports/x11/amtimer.c'
  1773. fi
  1774. if test -f 'Ports/x11/font.c' -a "${1}" != "-c" ; then 
  1775.   echo shar: Will not clobber existing file \"'Ports/x11/font.c'\"
  1776. else
  1777. echo shar: Extracting \"'Ports/x11/font.c'\" \(3646 characters\)
  1778. sed "s/^X//" >'Ports/x11/font.c' <<'END_OF_FILE'
  1779. X/* X11 STDWIN -- font manipulation */
  1780. X
  1781. X#include "x11.h"
  1782. X
  1783. XTEXTATTR wattr;        /* Global text attributes */
  1784. X
  1785. X/* Setting text drawing parameters. */
  1786. X
  1787. Xvoid
  1788. Xwsetplain()
  1789. X{
  1790. X    wattr.style= PLAIN;
  1791. X}
  1792. X
  1793. Xvoid
  1794. Xwsethilite()
  1795. X{
  1796. X    wattr.style |= HILITE;
  1797. X}
  1798. X
  1799. Xvoid
  1800. Xwsetinverse()
  1801. X{
  1802. X    wattr.style |= INVERSE;
  1803. X}
  1804. X
  1805. Xvoid
  1806. Xwsetitalic()
  1807. X{
  1808. X    wattr.style |= ITALIC;
  1809. X}
  1810. X
  1811. Xvoid
  1812. Xwsetbold()
  1813. X{
  1814. X    wattr.style |= BOLD;
  1815. X}
  1816. X
  1817. Xvoid
  1818. Xwsetbolditalic()
  1819. X{
  1820. X    wattr.style |= BOLD|ITALIC;
  1821. X}
  1822. X
  1823. Xvoid
  1824. Xwsetunderline()
  1825. X{
  1826. X    wattr.style |= UNDERLINE;
  1827. X}
  1828. X
  1829. Xvoid
  1830. Xwsetfont(fontname)
  1831. X    char *fontname;
  1832. X{
  1833. X    wattr.font= fontnum(fontname);
  1834. X    _wfontswitch();
  1835. X}
  1836. X
  1837. Xvoid
  1838. Xwsetsize(pointsize)
  1839. X    int pointsize;
  1840. X{
  1841. X    /* Ignored for now; must be present for compatibility */
  1842. X}
  1843. X
  1844. Xvoid
  1845. Xwgettextattr(attr)
  1846. X    TEXTATTR *attr;
  1847. X{
  1848. X    *attr= wattr;
  1849. X}
  1850. X
  1851. Xvoid
  1852. Xwsettextattr(attr)
  1853. X    TEXTATTR *attr;
  1854. X{
  1855. X    wattr= *attr;
  1856. X    _wfontswitch();
  1857. X}
  1858. X
  1859. X/* Font administration */
  1860. X
  1861. Xstruct font {
  1862. X    char *name;        /* Font name, (lower case), NULL if unknown */
  1863. X    XFontStruct *info;    /* Text measuring info */
  1864. X};
  1865. X
  1866. Xstatic int nfonts;
  1867. Xstatic struct font *fontlist;
  1868. X
  1869. X/* Initialize the font stuff */
  1870. X
  1871. X_winitfonts()
  1872. X{
  1873. X    struct font stdfont, menufont;
  1874. X    
  1875. X    /* Get the user-specified or server default font */
  1876. X    
  1877. X    stdfont.name= _wgetdefault("font", "Font");
  1878. X    if (stdfont.name != NULL) {
  1879. X        stdfont.info= XLoadQueryFont(_wd, stdfont.name);
  1880. X        if (stdfont.info != NULL) {
  1881. X            stdfont.name= strdup(stdfont.name);
  1882. X        }
  1883. X        else {
  1884. X            _wwarning(
  1885. X              "_winitfonts: can't load font %s; using server default",
  1886. X              stdfont.name);
  1887. X            stdfont.name= NULL;
  1888. X        }
  1889. X    }
  1890. X    if (stdfont.name == NULL) {
  1891. X        stdfont.info= XQueryFont(_wd, DefaultGCOfScreen(_ws)->gid);
  1892. X        if (stdfont.info == NULL)
  1893. X            _wfatal("_winitfonts: no server default font");
  1894. X        stdfont.info->fid= 0;
  1895. X    }
  1896. X    L_APPEND(nfonts, fontlist, struct font, stdfont);
  1897. X    _wmf= _wf= stdfont.info;
  1898. X    
  1899. X    /* Get the user-specified default menu font.
  1900. X       If no user-specified default, use the the standard font. */
  1901. X    
  1902. X    menufont.name= _wgetdefault("menuFont", "Font");
  1903. X    if (menufont.name != NULL) {
  1904. X        menufont.info= XLoadQueryFont(_wd, menufont.name);
  1905. X        if (menufont.info != NULL) {
  1906. X            menufont.name= strdup(menufont.name);
  1907. X            L_APPEND(nfonts, fontlist, struct font, menufont);
  1908. X            _wmf= menufont.info;
  1909. X        }
  1910. X        else {
  1911. X            _wwarning(
  1912. X              "_winitfonts: can't load font %s; using server default",
  1913. X              menufont.name);
  1914. X        }
  1915. X    }
  1916. X}
  1917. X
  1918. X/* Start using the font from 'wattr' */
  1919. X
  1920. X_wfontswitch()
  1921. X{
  1922. X    if (wattr.font < 0 || wattr.font >= nfonts)
  1923. X        _werror("_wfontswitch: wattr.font out of range");
  1924. X    else {
  1925. X        _wf= fontlist[wattr.font].info;
  1926. X        _wgcfontswitch();
  1927. X    }
  1928. X}
  1929. X
  1930. X/* Return the font number for a given font name.
  1931. X   If not already in the font list, add it.
  1932. X   Return 0 (the number of the system font) if the font doesn't exist. */
  1933. X
  1934. Xstatic int
  1935. Xfontnum(name)
  1936. X    char *name;
  1937. X{
  1938. X    struct font newfont;
  1939. X    char lcname[256];
  1940. X    int i;
  1941. X    
  1942. X    if (name == NULL || name[0] == EOS)
  1943. X        return 0; /* Use standard font */
  1944. X    
  1945. X    makelower(lcname, name);
  1946. X    for (i= 0; i < nfonts; ++i) {
  1947. X        if (fontlist[i].name != NULL &&
  1948. X            strcmp(fontlist[i].name, lcname) == 0)
  1949. X            return i;
  1950. X    }
  1951. X    newfont.info= XLoadQueryFont(_wd, lcname);
  1952. X    if (newfont.info == NULL) {
  1953. X        static nwarn; /* Limit the number of warnings */
  1954. X        if (nwarn++ < 10)
  1955. X            _wwarning("fontnum: font %s not found; using default",
  1956. X                lcname);
  1957. X        return 0; /* Not found; use system font */
  1958. X    }
  1959. X    _wdebug(1, "fontnum: new font %s", lcname);
  1960. X    newfont.name= strdup(lcname);
  1961. X    L_APPEND(nfonts, fontlist, struct font, newfont);
  1962. X    return i;
  1963. X}
  1964. X
  1965. X/* Copy a string like strcpy, converting to lower case in the process */
  1966. X
  1967. Xstatic
  1968. Xmakelower(dest, src)
  1969. X    char *dest, *src;
  1970. X{
  1971. X    char c;
  1972. X    while ((c= *src++) != EOS) {
  1973. X        if (isupper(c))
  1974. X            c= tolower(c);
  1975. X        *dest++ = c;
  1976. X    }
  1977. X    *dest= EOS;
  1978. X}
  1979. END_OF_FILE
  1980. if test 3646 -ne `wc -c <'Ports/x11/font.c'`; then
  1981.     echo shar: \"'Ports/x11/font.c'\" unpacked with wrong size!
  1982. fi
  1983. # end of 'Ports/x11/font.c'
  1984. fi
  1985. if test -f 'Ports/x11/x11.h' -a "${1}" != "-c" ; then 
  1986.   echo shar: Will not clobber existing file \"'Ports/x11/x11.h'\"
  1987. else
  1988. echo shar: Extracting \"'Ports/x11/x11.h'\" \(4161 characters\)
  1989. sed "s/^X//" >'Ports/x11/x11.h' <<'END_OF_FILE'
  1990. X/* X11 STDWIN -- private definitions */
  1991. X
  1992. X/* Includes */
  1993. X#include "tools.h"
  1994. X#include "stdwin.h"
  1995. X#include "style.h"        /* For wattr */
  1996. X
  1997. X/* Includes from X11 */
  1998. X#include <X11/Xlib.h>
  1999. X#include <X11/Xutil.h>
  2000. X#include <X11/Xresource.h>
  2001. X#include <X11/Xatom.h>
  2002. X#include <X11/cursorfont.h>
  2003. X
  2004. X/* Additional system includes */
  2005. X#include <sys/time.h>
  2006. X
  2007. X#define IBORDER        1    /* Border width of (most) internal windows */
  2008. X
  2009. X/* Menu item */
  2010. Xstruct item {
  2011. X    char *text;
  2012. X    char *sctext;
  2013. X    short shortcut;
  2014. X    tbool enabled;
  2015. X    tbool checked;
  2016. X};
  2017. X
  2018. X/* Menu definition */
  2019. Xstruct _menu {
  2020. X    int id;
  2021. X    char *title;
  2022. X    int nitems;
  2023. X    struct item *itemlist;
  2024. X}; /* == MENU from <stdwin.h> */
  2025. X
  2026. X/* Window or subwindow essential data */
  2027. Xstruct windata {
  2028. X    Window wid;        /* X Window id */
  2029. X                /* The parent is implicit in the use */
  2030. X    int x, y;        /* Origin w/ respect to parent */
  2031. X    int width, height;    /* Width and height */
  2032. X    short border;        /* Border width */
  2033. X    tbool dirty;        /* Set if update pending */
  2034. X                /* Some windows also have an update area */
  2035. X};
  2036. X
  2037. X#define NSUBS 7            /* Number of subwindows */
  2038. X
  2039. X/* Window struct */
  2040. Xstruct _window {
  2041. X    short tag;        /* Must be first member and must be short! */
  2042. X    void (*drawproc)();    /* Draw procedure */
  2043. X    struct {
  2044. X        int width, height;
  2045. X    } doc;            /* Document dimension */
  2046. X    int careth, caretv;    /* Caret position; (-1, -1) if no caret */
  2047. X    bool caretshown;    /* Is the caret currently on display? */
  2048. X    long timer;        /* Deciseconds till next alarm */
  2049. X    TEXTATTR attr;        /* Text attributes */
  2050. X    
  2051. X    struct windata subw[NSUBS];    /* Subwindows */
  2052. X    
  2053. X    unsigned long fgo, bgo; /* pixel values for all but WA */
  2054. X    unsigned long fga, bga;    /* pixel values for WA */
  2055. X    
  2056. X    GC gc;            /* Graphics Context for all but WA */
  2057. X    GC gca;            /* Graphics Context for WA */
  2058. X    
  2059. X    Region inval;        /* Invalid area in WA window */
  2060. X
  2061. X    int nmenus;        /* Number of menus */
  2062. X    MENU **menulist;    /* List of attached menus (incl. global) */
  2063. X    int curmenu;
  2064. X    int curitem;
  2065. X    
  2066. X    tbool resized;        /* True if WE_SIZE event pending */
  2067. X}; /* == WINDOW from <stdwin.h> */
  2068. X
  2069. X/* Shorthands for subwindow array access.
  2070. X   Order is important! --for wopen() */
  2071. X#define WO    0
  2072. X#define MBAR    1
  2073. X#define VBAR    2
  2074. X#define HBAR    3
  2075. X#define WI    4
  2076. X#define WA    5
  2077. X#define MWIN    6
  2078. X
  2079. X#define wo    subw[WO]    /* Outer window (direct child of root)  */
  2080. X#define mbar    subw[MBAR]    /* Menu bar (child of wo) */
  2081. X#define vbar    subw[VBAR]    /* Scroll bars (children of wo) */
  2082. X#define hbar    subw[HBAR]    /* " */
  2083. X#define wi    subw[WI]    /* Inner window (child of wo) */
  2084. X#define wa    subw[WA]    /* Application window (child of wi) */
  2085. X#define mwin    subw[MWIN]    /* Currently visible menu */
  2086. X
  2087. X/* Button state record */
  2088. Xstruct button_state {
  2089. X    bool down;        /* We think a button is down */
  2090. X    int button;        /* Which button */
  2091. X    int mask;        /* Buttons down (1|2|4) */
  2092. X    int clicks;        /* Click status */
  2093. X    long time;        /* Time stamp, milliseconds */
  2094. X    WINDOW *win;        /* The WINDOW where it applies */
  2095. X    Window w;        /* SubWindow id */
  2096. X    int isub;        /* Subwindow index */
  2097. X    int x, y;        /* Current position */
  2098. X    int xdown, ydown;    /* Position of initial press */
  2099. X};
  2100. X
  2101. X/* Private globals */
  2102. Xextern Display *_wd;        /* general.c */
  2103. Xextern Screen *_ws;        /* general.c */
  2104. Xextern XFontStruct *_wf;    /* general.c */
  2105. Xextern XFontStruct *_wmf;    /* general.c */
  2106. Xextern int _wpipe[2];        /* general.c */
  2107. Xextern char *_wprogname;    /* general.c */
  2108. Xextern int _wdebuglevel;    /* errors.c */
  2109. Xextern int _wtracelevel;    /* errors.c */
  2110. X
  2111. X/* Interned atoms */
  2112. Xextern Atom _wm_protocols;
  2113. Xextern Atom _wm_delete_window;
  2114. Xextern Atom _wm_take_focus;
  2115. X
  2116. X/* Externals used to communicate hints to wopen() */
  2117. Xextern char *_whostname;
  2118. Xextern char *_wm_command;
  2119. Xextern int _wm_command_len;
  2120. X
  2121. X/* Functions not returning int */
  2122. XWINDOW *_wsetup();        /* window.c */
  2123. XWINDOW *_whichwin();        /* window.c */
  2124. XWINDOW *_wnexttimer();        /* window.c */
  2125. XGC _wgcreate();            /* window.c */
  2126. Xunsigned long _wgetpixel();    /* window.c */
  2127. XWINDOW *_w_get_last_active();    /* event.c */
  2128. XWINDOW *_w_somewin();        /* window.c */
  2129. XPixmap _w_gray();        /* window.c */
  2130. Xchar *_wgetdefault();        /* general.c */
  2131. Xvoid _w_setgrayborder();    /* window.c */
  2132. Xvoid _wsetmasks();        /* window.c */
  2133. X
  2134. X/* Function _wcreate has an extra parameter now */
  2135. X#define _wcreate(wp, parent, cursor, map, fg, bg) \
  2136. X    _wcreate1(wp, parent, cursor, map, fg, bg, 0)
  2137. END_OF_FILE
  2138. if test 4161 -ne `wc -c <'Ports/x11/x11.h'`; then
  2139.     echo shar: \"'Ports/x11/x11.h'\" unpacked with wrong size!
  2140. fi
  2141. # end of 'Ports/x11/x11.h'
  2142. fi
  2143. echo shar: End of archive 15 \(of 19\).
  2144. cp /dev/null ark15isdone
  2145. MISSING=""
  2146. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
  2147.     if test ! -f ark${I}isdone ; then
  2148.     MISSING="${MISSING} ${I}"
  2149.     fi
  2150. done
  2151. if test "${MISSING}" = "" ; then
  2152.     echo You have unpacked all 19 archives.
  2153.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2154. else
  2155.     echo You still need to unpack the following archives:
  2156.     echo "        " ${MISSING}
  2157. fi
  2158. ##  End of shell archive.
  2159. exit 0
  2160.