summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/window
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-17 21:41:51 +0000
committerKarl Berry <karl@freefriends.org>2006-01-17 21:41:51 +0000
commit487ca4806cc046076293cf6cc5fbba0db282bac7 (patch)
tree847b412ab5158dd7bdd7ed7e5a4cc3fbca94be32 /Build/source/texk/web2c/window
parenta3d3111bfe26b8e5f5bc6049dfb2a4ca2edc7881 (diff)
texk 1
git-svn-id: svn://tug.org/texlive/trunk@1485 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/window')
-rw-r--r--Build/source/texk/web2c/window/ChangeLog313
-rw-r--r--Build/source/texk/web2c/window/Makefile.in37
-rw-r--r--Build/source/texk/web2c/window/README2
-rw-r--r--Build/source/texk/web2c/window/amiga.c363
-rw-r--r--Build/source/texk/web2c/window/depend.mak0
-rw-r--r--Build/source/texk/web2c/window/depend.mk182
-rw-r--r--Build/source/texk/web2c/window/epsf.c176
-rw-r--r--Build/source/texk/web2c/window/hp2627.c252
-rw-r--r--Build/source/texk/web2c/window/mftalk.c273
-rw-r--r--Build/source/texk/web2c/window/next.c177
-rw-r--r--Build/source/texk/web2c/window/regis.c105
-rw-r--r--Build/source/texk/web2c/window/suntools.c214
-rw-r--r--Build/source/texk/web2c/window/tek.c143
-rw-r--r--Build/source/texk/web2c/window/trap.c50
-rw-r--r--Build/source/texk/web2c/window/uniterm.c184
-rw-r--r--Build/source/texk/web2c/window/win32.c415
-rw-r--r--Build/source/texk/web2c/window/win32.mak48
-rw-r--r--Build/source/texk/web2c/window/x11-Xlib.c280
-rw-r--r--Build/source/texk/web2c/window/x11-Xt.c370
19 files changed, 3584 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/window/ChangeLog b/Build/source/texk/web2c/window/ChangeLog
new file mode 100644
index 00000000000..912afb29899
--- /dev/null
+++ b/Build/source/texk/web2c/window/ChangeLog
@@ -0,0 +1,313 @@
+2005-06-26 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in: Replace ac_include with kpse_include. From Peter
+ Breitenlohner.
+
+2003-01-24 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * mftalk.c: Use SIGCHLD, not SIGCLD (but fall back if necessary).
+ Reported by hubertf@netbsd.org.
+
+2001-11-25 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * x11-Xt.c (mf_checkextent): Add prototype.
+ (mf_optiondesclist): The pointers in the argument list are XPointers,
+ not XtPointers.
+
+2001-11-19 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * x11-Xt.c (mf_newpixmap): Add prototype to declaration.
+
+1999-02-06 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * trap.c (mf_trap_initscreen, mf_trap_updatescreen): Use P1H macro
+ in definition.
+
+ * win32.c (InitGui): Oops, removed one __cdecl too many. From
+ Fabrice.
+
+1999-02-04 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * win32.c (InitGui, LoopMsg): Remove __cdecl, from Fabrice.
+
+1999-01-13 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * Makefile.in: Rename kpathsea.make to kpathsea.mk.
+
+1999-01-10 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * x11-Xlib.c: Do not define input and output because of conflicts.
+
+ * tek.c: Don't redefine TRUE and FALSE.
+
+ * mftalk.c: Include kpathsea/variable.h.
+
+ * Makefile.in: Change of ../make/*.make to ../make/*.mk.
+
+Tue Jun 30 19:47:37 1998 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * uniterm.c (mf_uniterm_paintrow): transspect -> transspec.
+
+Mon Mar 23 19:04:03 1998 Olaf Weber <olaf@infovore.xs4all.nl>
+
+ * mftalk.c (mf_mftalk_initscreen): Correction from Mathias
+ Herberts.
+
+Wed Feb 11 17:19:54 1998 Olaf Weber <infovore@xs4all.nl>
+
+ * epsf.c: New version from Mathias Herberts.
+
+Tue Feb 10 21:10:20 1998 Olaf Weber <infovore@xs4all.nl>
+
+ * mftalk.c: Patches to improve handling of pipes, after Mathias
+ Herberts.
+
+ * epsf.c: Pseudo-window EPS server contributed by Mathias Herberts
+ <herberts@infini.fr>
+
+ * Makefile.in: Add epsf.o to objects.
+
+Fri Jan 23 14:59:22 1998 Olaf Weber <infovore@xs4all.nl>
+
+ * win32.c: Patches from Fabrice Popineau.
+
+Sat Jan 17 09:45:20 1998 Olaf Weber <infovore@xs4all.nl>
+
+ * mftalk.c (app_type): Wrong prototype.
+ (mf_talk_initscreen): We use the calling sequence of execl, not
+ execve. Undefine input and output, as these are macros on some
+ machines. From Mathias Herberts <Mathias.Herberts@irisa.fr>
+
+Thu Nov 13 19:17:42 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * next.c (mf_next_paintrow): Forgot to add the P4C macro name.
+
+Fri Oct 24 13:42:15 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * trap.c: By way of boilerplating, cast to long, not int, for
+ printing.
+
+ * win32.c, x11-Xlib.c, x11-Xt.c, uniterm.c trap.c, tek.c,
+ suntools.c, regis.c, next.c, mftalk.c, hp2627.c, amiga.c:
+ Prototypes for the mf_*_{blankrectangle,paintrow} functions.
+
+Mon Oct 20 08:48:51 1997 Olaf Weber <infovore@xs4all.nl>
+
+ * Makefile.in [objects]: Add win32.o.
+
+ * trap.c: Insert casts to ensure that the arguments to fprintf
+ match the format.
+
+ * win32.c: Nef file, adds support for win32 graphical output.
+ From Fabrice Popineau.
+
+Thu Feb 13 16:13:13 1997 Karl Berry <karl@cs.umb.edu>
+
+ * x11-Xt.c (wchar_t) [FOIL_X_WCHAR_T]: Had polarity of #if test wrong.
+ From: Olaf Weber <Olaf.Weber@cwi.nl>.
+
+Mon Jan 20 17:30:15 1997 Karl Berry <karl@cs.umb.edu>
+
+ * Version 7.0.
+
+Tue Dec 3 15:10:13 1996 Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
+
+ * Makefile.in (prog_cflags): Oops, the previous change didn't work.
+ Have to set this to -I.. -I$(srcdir)/.. $(x_cppflags).
+
+Tue Dec 3 00:19:27 1996 Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
+
+ * Makefile.in (prog_cflags): Set this to $(x_cppflags) so that
+ the X include path will eventually end up in ALL_CPPFLAGS.
+
+Tue Dec 3 00:19:27 1996 Ulrik Vieth <vieth@thphy.uni-duesseldorf.de>
+
+ * Makefile.in (prog_cflags): Set this to $(x_cppflags) so that
+ the X include path will eventually end up in ALL_CPPFLAGS.
+
+Mon Aug 5 16:30:17 1996 Karl Berry <karl@cs.umb.edu>
+
+ * x11-Xlib.c (mf_x11_initscreen): tvect - 1 should be just tvect.
+ From DEK et al.
+
+Fri Jul 26 15:47:50 1996 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in: Remove co.make.
+
+Wed May 15 16:58:01 1996 Karl Berry <karl@cs.umb.edu>
+
+ * mftalk.c: Doc fix.
+
+Tue Feb 13 16:10:54 1996 Karl Berry <karl@cs.umb.edu>
+
+ * x11-Xt.c: Missing close-comment.
+
+ * Makefile.in: Include rdepend.make.
+
+Fri Dec 29 17:15:38 1995 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in: misc.make is now clean.make.
+
+Sat Nov 18 17:11:26 1995 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in (distclean): New target to remove x11.c. From Peter
+ Dyballa.
+
+Thu Nov 16 16:28:22 1995 Karl Berry <karl@cs.umb.edu>
+
+ * amiga.c: Replacement file.
+ * trap.c (EXTERN): Define as extern, just as with the rest of the
+ modules. From Andreas Scherer.
+
+Mon Oct 9 16:51:17 1995 Karl Berry <karl@cs.umb.edu>
+
+ * Makefile.in (x11.c): Use $(srcdir). From Simon.
+
+Fri Jul 21 15:48:25 1995 Karl Berry <karl@cs.umb.edu>
+
+ * mftalk.c: The FSF has a new address.
+
+Tue Jul 18 15:16:15 1995 Karl Berry <karl@cs.umb.edu>
+
+ * mftalk.c (app_type): Don't just fail under Unix.
+
+Tue Jun 13 11:37:37 1995 Karl Berry <karl@cs.umb.edu>
+
+ * x11-Xt.c (mf_x11_paintrow): Use tvect, not tvect - 1.
+ From: FUKUI Rei <fkr@tooyoo1.l.u-tokyo.ac.jp>.
+
+MFwindow:
+Fri Jul 29 11:50:19 1994 Karl Berry (karl@cs.umb.edu)
+
+ * x11-Xt.c: Make the default be to *not* foil X's wchar_t.
+
+Mon Feb 21 17:49:30 1994 Karl Berry (karl@cs.umb.edu)
+
+ * x11-Xt.c: Include systypes.h for still more wchar_t kludgery.
+
+Wed Feb 2 11:01:09 1994 Karl Berry (karl@cs.umb.edu)
+
+ * Version 6.1.
+
+Tue Feb 1 11:24:11 1994 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in: Change ../../$(srcdir) to $(srcdir)/../.. throughout.
+
+Mon Jan 24 07:28:00 1994 Karl Berry (karl@cs.umb.edu)
+
+ * Version 6.0.
+
+Sun Jan 23 16:25:58 1994 Karl Berry (karl@cs.umb.edu)
+
+ * x11-Xt.c (wchar_t): No, remove that condition.
+
+Fri Dec 24 13:15:07 1993 Karl Berry (karl@sorrel.hq.ileaf.com)
+
+ * x11.c (wchar_t) [! __INT_WCHAR_T_H]: Conditionalize for aviion.
+
+|Tue Dec 21 19:33:59 1993 Karl Berry (karl@cs.umb.edu)
+
+ * x11-Xt.c (X_WCHAR): Define.
+
+Sat Dec 18 14:55:59 1993 Karl Berry (karl@cs.umb.edu)
+
+ * x11.c (wchar_t): Define this to a nonsense symbol, to avoid
+ redefinitions.
+
+Sat Dec 4 11:42:36 1993 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in (xincludedir): This is now x_include_flags.
+
+Sun Nov 14 16:19:13 1993 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in: Don't need kpathsea definitions?
+
+Thu Nov 11 15:51:55 1993 Karl Berry (karl@cs.umb.edu)
+
+ * x11-Xt.c: Merge changes from Rainer for the Alpha and reformat.
+
+Sat Nov 6 13:18:07 1993 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in (objs): Add next.o and regis.o.
+ * next.c, regis.c: New file from joe@rilgp.tamri.com.
+
+Sun Oct 3 13:27:35 1993 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in (*clean): Include standard targets.
+
+Fri May 21 14:23:06 1993 Karl Berry (karl@cs.umb.edu)
+
+ * x11-Xt.c (mf_x11_updatescreen): Remove unused variable `event'.
+ (mf_max_x, etc.) [MF_XT_DEBUG]: Conditionalize declaration.
+
+Sun May 9 10:44:35 1993 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in (CPPFLAGS): Add -I for kpathsea.
+
+Fri Apr 9 16:22:17 1993 Karl Berry (karl@cs.umb.edu)
+
+ * x11-Xt.c (_GCC_WCHAR_T): Define.
+
+Sat Mar 13 11:26:57 1993 Karl Berry (karl@cs.umb.edu)
+
+ * uniterm.c (tek_dummy): Rename to uniterm_dummy, to avoid warning.
+
+Fri Feb 12 07:29:19 1993 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in (xincludedir): Include $(xincludedir).
+
+Sun Jan 3 13:30:10 1993 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in (distclean): Remove Makefile.
+
+Sat Dec 19 18:57:02 1992 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in ({sun,x11}.c): New targets.
+
+Sun Dec 13 14:27:15 1992 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in (c-sources): New target.
+
+Sat Dec 12 15:10:49 1992 Karl Berry (karl@cs.umb.edu)
+
+ * Makefile.in: Rewrite from Makefile.
+
+Sun Oct 18 13:48:49 1992 Karl Berry (karl@cs.umb.edu)
+
+ * tek.c (bcopy, bzero) [SYSV]: Remove these; they're already
+ defined in c-memstr.h.
+
+Sun Jul 5 07:29:40 1992 Karl Berry (karl@hayley)
+
+ * sun-sunview.c: give return types to all fns.
+
+ * sun-sunview.c (mf_sun_initscreen): avoid line >= 80 chars.
+ * uniterm.c (mf_uniterm_paintrow): likewise.
+ * sun-xview.c (mf_xview_updatescreen): likewise.
+
+Fri Jul 3 11:22:47 1992 Karl Berry (karl@hayley)
+
+ * Makefile (CFLAGS): define as -g.
+ (CPPFLAGS): new var.
+ (.c.o): use it.
+ (distclean): synonym for realclean.
+
+ * sun-sunview.c: changes from Pierre (like the following).
+ * sun-gfx.c: rename from sun-suntools.c.
+ * sun-xview.c: new file.
+ * sun.c: remove and remake as a link to sun-sunview.c.
+
+Fri Mar 20 16:53:52 1992 Karl Berry (karl at hayley)
+
+ * Makefile (mostlyclean): new name for `clean'.
+ (clean): what `realclean' used to be.
+ (realclean): nothing to do anymore.
+ (install): install the program.
+
+Fri Jan 24 09:21:15 1992 Karl Berry (karl at hayley)
+
+ * Makefile (cflags): don't include -I../config.
+
+Sun Jan 12 12:53:24 1992 Karl Berry (karl at hayley)
+
+ * Makefile (CFLAGS): include config, two levels up.
diff --git a/Build/source/texk/web2c/window/Makefile.in b/Build/source/texk/web2c/window/Makefile.in
new file mode 100644
index 00000000000..0dade114ab2
--- /dev/null
+++ b/Build/source/texk/web2c/window/Makefile.in
@@ -0,0 +1,37 @@
+# Makefile for the Metafont window support library.
+
+kpse_include ../make/common.mk
+kpse_include ../make/library.mk
+kpse_include kpathsea.mk
+
+x_cppflags = @X_CFLAGS@
+library = window
+
+# Extra library-specific compiler options.
+prog_cflags = -I.. -I$(srcdir)/.. $(x_cppflags)
+
+objects = amiga.o epsf.o hp2627.o mftalk.o next.o regis.o suntools.o tek.o \
+trap.o uniterm.o win32.o x11.o
+
+default all: $(library).a
+$(library).a: $(objects)
+ rm -f $@
+ $(AR) $(ARFLAGS) $@ $(objects)
+ $(RANLIB) $@
+
+# It doesn't matter much what this default is, since if anything was
+# enabled configure would hopefully have found it.
+x11.c:
+ rm -f $@
+ $(LN) $(srcdir)/x11-Xt.c $@
+
+Makefile: Makefile.in ../config.status
+ cd .. && $(SHELL) config.status
+
+kpse_include ../make/clean.mk
+
+distclean::
+ rm -f x11.c
+
+kpse_include ../make/rdepend.mk
+kpse_include window/depend.mk
diff --git a/Build/source/texk/web2c/window/README b/Build/source/texk/web2c/window/README
new file mode 100644
index 00000000000..5384bc8b59e
--- /dev/null
+++ b/Build/source/texk/web2c/window/README
@@ -0,0 +1,2 @@
+This directory contains the support for Metafont's online graphics.
+The various pieces are used and invoked from lib/texmfmp.c.
diff --git a/Build/source/texk/web2c/window/amiga.c b/Build/source/texk/web2c/window/amiga.c
new file mode 100644
index 00000000000..ec686795066
--- /dev/null
+++ b/Build/source/texk/web2c/window/amiga.c
@@ -0,0 +1,363 @@
+/*
+ * AMIGA.C: This is the Graphics Window interface to MetaFont for online
+ * displays on the Commodore Amiga. This file was written by Edmund Mergl
+ * for his Amiga port of TeX 3.1 and MetaFont 2.7 from the original Unix
+ * sources (see Fish Disks 611-616).
+ *
+ * Some modifications and improvements were made since 1993 by Andreas and
+ * Stefan Scherer, Abt-Wolf-Strasse 17, 96215 Lichtenfels, Germany. The
+ * most recent entries from top to bottom always superseed their ancestors,
+ * just read this as a bit of history:
+ *
+ * August 12, 1993:
+ *
+ * - We use the `memory hack', so the values for `screenwidth'
+ * and `screendepth' are to be found in `mfmemory.config'. The
+ * display height should be set to an InterLace value, this will
+ * be dealt with by `lacefactor' (see below).
+ *
+ * - The display window is no longer resizeable, because no
+ * `screenupdate' is called and the picture is destroyed.
+ *
+ * - Based on ideas by Stefan Becker used in his famous MetaFont port
+ * to the Amiga of 1991 (see Fish Disk 486) there is a variable
+ * `scalefactor', which can be set to a (small) positiv integer in
+ * `mfmemory.config'. This results in a reduced size of the displayed
+ * characters, so that large font pictures can be drawn on
+ * small-sized screens (although some distortions are possible).
+ *
+ * - By replacing `Move' and `Draw' with `WritePixelLine' and friends
+ * the speed of the display was heavily increased.
+ *
+ * - The display screen is totally controlled by `screenwidth' and
+ * `screendepth' from `mfmemory.config', when you set `screen_rows'
+ * and `screen_cols' both to the maximum value `4095' in your local
+ * device modes file. MetaFont takes the smaller of these pairs.
+ *
+ * - `blankrectangle' *always* set the complete display window to the
+ * background color, not only the area specified by `left', `right',
+ * `top', and `bottom'. These MetaFont coordinates are now obeyed.
+ *
+ * September 11, 1993:
+ *
+ * - The changes for `Computers and Typesetting -- Volume A-E' provided
+ * by Addison-Wesley Publishing Company resulted in MetaFont 2.71.
+ * This caused a change in the window title.
+ *
+ * October 22, 1993:
+ *
+ * - The official version 2.71 has the same window title. :-)
+ *
+ * January 28, 1994:
+ *
+ * - Although SAS/C has an AutoOpen feature for Amiga libraries,
+ * it is better to define the library bases explicitly.
+ *
+ * February 15, 1995:
+ *
+ * - Here's my new address:
+ * Andreas Scherer, Rolandstraße 16, 52070 Aachen, Germany.
+ * <scherer@genesis.informatik.rwth-aachen.de> (Internet).
+ * - Make `amiga.c' compliant with the syntax of the other modules
+ * in the Web2C 6.1 distribution.
+ *
+ * February 19, 1995:
+ *
+ * - `close_all()' must not have arguments, because we want to
+ * link it into the `atexit()' function list.
+ * - To distinguish this version from the old distribution, the
+ * window title is modified.
+ *
+ * March 23, 1995:
+ *
+ * - MetaFont has the new version number 2.718.
+ *
+ * April 9, 1995:
+ *
+ * - rename `screenheight' to `screendepth' for consistency.
+ *
+ * October 10, 1995:
+ *
+ * - Yet another change in my address, now it's a UNIX CIP pool:
+ * <scherer@physik.rwth-aachen.de>
+ * - Cleanup for the new web2c release.
+ */
+
+#define EXTERN extern
+
+#include "../mfd.h"
+
+#ifdef AMIGAWIN /* Whole file */
+
+#include <proto/exec.h>
+#include <proto/graphics.h>
+#include <proto/intuition.h>
+
+struct GfxBase *GfxBase;
+struct IntuitionBase *IntuitionBase;
+
+struct Screen *Scr;
+struct Window *Win;
+
+struct BitMap tempbm;
+struct RastPort temprp;
+
+UBYTE *linearray;
+
+int scaledwidth = 0;
+int scaledheight = 0;
+
+#ifndef scalefactor
+#define scalefactor 1
+#endif
+
+/*
+ * The configuration `mf.mcf' of AmiWeb2C holds values for `screenwidth'
+ * and `screendepth' that always refer to an InterLace screen. In case
+ * you open the display on a non-InterLaced screen, only half the lines
+ * are shown to you. This is automatically done by reading the screen
+ * information and setting `lacefactor'.
+ */
+int lacefactor;
+
+#define BACKGROUNDCOLOR 0
+#define PENCOLOR 1
+
+#define PUBSCREEN 0
+
+/*
+ * Allocating memory for the array used in `WritePixelLine' needs
+ * WORD-aligned arguments.
+ */
+#define ALIGN_SIXTEEN_BIT(A) ((((A)+15)/16)*16)
+#ifndef min
+#define min(a,b) ((a)<(b)?(a):(b))
+#endif
+
+/*
+ * CLOSE_ALL: Clean up on MetaFont termination. This routine has to be
+ * called just before leaving the program, which is done automatically
+ * when it gets entered into the `atexit' function list. (See below.)
+ */
+void close_all(void)
+{
+ if (linearray) free(linearray);
+ if (tempbm.Planes[0]) FreeRaster(tempbm.Planes[0], scaledwidth, 1);
+ if (Win) CloseWindow(Win);
+ if (GfxBase) CloseLibrary((struct Library *)GfxBase);
+ if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
+
+} /* close_all() */
+
+/*
+ * INITSCREEN: Initialize the physical display window on the WorkBench
+ * screen of the Commodore Amiga. Open the necessary libraries and open
+ * the window according to `screenwidth' and `screendepth' as given in
+ * the configuration file `mf.mcf'. For this purpose, the
+ * `OpenWindowTagList' routine was replaced with `OpenWindowTags'.
+ * The `WFLG_SIZEGADGET' window flag has been removed; resizing the
+ * window kills the picture and never triggered an `updatescreen'.
+ */
+boolean mf_amiga_initscreen(void)
+{
+#ifdef DEBUG
+ printf("\ninitscreen()\n");
+#endif
+
+ /*
+ * Make sure the resources are correctly returned to the system
+ * when leaving the program.
+ */
+ if(atexit(&close_all)) { /* Can't happen. */
+ fprintf(stderr, "Exit trap failure! (close_all)\n");
+ uexit(1);
+ }
+
+ if (!(IntuitionBase = (struct IntuitionBase *)
+ OpenLibrary((unsigned char *)"intuition.library",(unsigned long)37L)))
+ {
+ fprintf(stderr,"\nCan't open intuition library. V37 required.\n");
+ close_all();
+ return(FALSE);
+ }
+
+ if (!(GfxBase = (struct GfxBase *)
+ OpenLibrary((unsigned char *)"graphics.library",(unsigned long)37L)))
+ {
+ fprintf(stderr,"\nCan't open intuition library. V37 required.\n");
+ close_all();
+ return(FALSE);
+ }
+
+ if (!(Scr = LockPubScreen(PUBSCREEN)))
+ {
+ fprintf(stderr,
+ "\nCan't get lock on public screen (%d).\n", PUBSCREEN);
+ close_all();
+ return(FALSE);
+ }
+
+ scaledwidth = screenwidth/scalefactor;
+ scaledheight = screendepth/scalefactor;
+
+ lacefactor = ((Scr->ViewPort.Modes & LACE) ? 1 : 2);
+
+ if (!(Win = (struct Window *)OpenWindowTags( NULL,
+ WA_InnerWidth, scaledwidth,
+ WA_InnerHeight, scaledheight/lacefactor,
+ WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET,
+ WA_AutoAdjust, FALSE,
+ WA_Title, (ULONG)" MetaFont V2.718 Online Display",
+ WA_PubScreen, (ULONG)Scr,
+ TAG_DONE)))
+ {
+
+ fprintf(stderr,
+ "\nCan't open online display window at size %d times %d.\n"
+#ifdef VARMEM
+ "Change your configuration file.\n",
+#else
+ "If you really absolutely need more capacity,\n"
+ "you can ask a wizard to enlarge me.\n",
+#endif
+ screenwidth,screendepth);
+
+ close_all();
+ return(FALSE);
+ }
+
+ InitBitMap(&tempbm, 1, scaledwidth, 1);
+
+ tempbm.Planes[0] = NULL;
+
+ if(!(tempbm.Planes[0] = (PLANEPTR)AllocRaster(scaledwidth, 1)))
+ return(FALSE);
+
+ InitRastPort(&temprp);
+
+ temprp.BitMap = &tempbm;
+
+ if(!(linearray = (UBYTE *)
+ calloc(ALIGN_SIXTEEN_BIT(scaledwidth),sizeof(UBYTE))))
+ return(FALSE);
+
+ UnlockPubScreen(NULL, Scr);
+
+#ifdef DEBUG
+ printf("initscreen() ok\n");
+#endif
+
+ return(TRUE);
+
+} /* mf_amiga_initscreen() */
+
+/*
+ * UPDATESCREEN: I really don't know what this function is supposed
+ * to do.
+ */
+void mf_amiga_updatescreen(void)
+{
+#ifdef DEBUG
+ printf("updatescreen()\n");
+#endif
+} /* mf_amiga_update_screen() */
+
+/*
+ * BLANKRECTANGLE: Reset the drawing rectangle bounded by
+ * ([left,right],[top,bottom]) to the background color.
+ */
+void mf_amiga_blankrectangle(screencol left, screencol right,
+ screenrow top, screenrow bottom)
+{
+#ifdef DEBUG
+ printf("blankrectangle() - left: %d right: %d top: %d bottom: %d\n",
+ left, right, top, bottom);
+#endif
+
+ SetAPen (Win->RPort, BACKGROUNDCOLOR);
+ RectFill(Win->RPort,
+ (SHORT)(Win->BorderLeft + left/scalefactor),
+ (SHORT)(Win->BorderTop + top/(scalefactor*lacefactor)),
+ (SHORT)(Win->BorderLeft + right/scalefactor - 1),
+ (SHORT)(Win->BorderTop + bottom/(scalefactor*lacefactor) - 1));
+} /* mf_amiga_blankrectangle() */
+
+/*
+ * PAINTROW: Paint a `row' starting with color `init_color', up to the
+ * next transition specified by `transition_vector', switch colors, and
+ * continue for `vector_size' transitions. It now only
+ * draws into the display window when a new raster line will be affected.
+ * A lot of pre-drawing and inter-drawing calculations and conditionals
+ * are evaluated to prepare a fast and clean drawing under the most
+ * circumstances to be expected on the Amiga. InterLace/Lace is taken
+ * care of and the sizes are set appropriately not to clobber the borders.
+ * (Don't ask me why this works; at least on my machine with my config.)
+ */
+void mf_amiga_paintrow(screenrow row, pixelcolor init_color,
+ transspec transition_vector, screencol vector_size)
+{
+ int start, scaledstart, scaledrow, scaledlaced;
+ register int i=0, j=0, col, color;
+
+#ifdef DEBUG
+ printf("paintrow() - vector size: %d\n", vector_size);
+#endif
+
+ color = ((0 == init_color) ? BACKGROUNDCOLOR : PENCOLOR);
+ scaledlaced = scalefactor * lacefactor;
+ start = *transition_vector++;
+ scaledstart = start / scalefactor;
+ scaledrow = row / scaledlaced;
+
+ ReadPixelLine8(Win->RPort, Win->BorderLeft + scaledstart,
+ Win->BorderTop + scaledrow, scaledwidth - scaledstart,
+ linearray, &temprp);
+
+ if(scalefactor>1) {
+
+ do {
+ for(col = *transition_vector++; i<col-start; i++) {
+ linearray[j] |= color;
+ if((i%scalefactor)==0) j++;
+ }
+
+ color = PENCOLOR - color;
+
+#ifdef DEBUG
+ printf("move col: %d row: %d ", col, row);
+ printf("draw col: %d row: %d\n", (*transition_vector)-1, row);
+#endif
+
+ } while (--vector_size);
+
+ if(i >= col-start) linearray[++j] |= color;
+
+ } else {
+
+ do {
+ for(col = *transition_vector++; j<col-start; j++) {
+ linearray[j] |= color;
+ }
+
+ color = PENCOLOR - color;
+
+#ifdef DEBUG
+ printf("move col: %d row: %d ", col, row);
+ printf("draw col: %d row: %d\n", (*transition_vector)-1, row);
+#endif
+
+ } while (--vector_size);
+ }
+
+ if( ( Win->BorderTop + scaledrow ) <
+ ( Win->Height - Win->BorderBottom ) )
+ WritePixelLine8(Win->RPort, Win->BorderLeft + scaledstart,
+ Win->BorderTop + scaledrow,
+ min(Win->Width - Win->BorderLeft - Win->BorderRight - scaledstart,j),
+ linearray, &temprp);
+
+} /* mf_amiga_paintrow() */
+
+#else
+int amiga_dummy;
+#endif /* AMIGAWIN */
diff --git a/Build/source/texk/web2c/window/depend.mak b/Build/source/texk/web2c/window/depend.mak
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Build/source/texk/web2c/window/depend.mak
diff --git a/Build/source/texk/web2c/window/depend.mk b/Build/source/texk/web2c/window/depend.mk
new file mode 100644
index 00000000000..c9a3225569d
--- /dev/null
+++ b/Build/source/texk/web2c/window/depend.mk
@@ -0,0 +1,182 @@
+amiga.o: amiga.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+epsf.o: epsf.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+hp2627.o: hp2627.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+mftalk.o: mftalk.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+next.o: next.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+regis.o: regis.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+suntools.o: suntools.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+tek.o: tek.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+trap.o: trap.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+uniterm.o: uniterm.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+win32.o: win32.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+x11.o: x11.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+x11-Xlib.o: x11-Xlib.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
+x11-Xt.o: x11-Xt.c ../mfd.h ../texmfmp.h ../cpascal.h ../config.h \
+ $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
+ $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
+ $(kpathsea_srcdir)/c-memstr.h \
+ $(kpathsea_srcdir)/c-errno.h \
+ $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
+ $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
+ $(kpathsea_srcdir)/types.h $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
+ ../../web2c/c-auto.h $(kpathsea_srcdir)/c-vararg.h $(kpathsea_srcdir)/c-fopen.h \
+ $(kpathsea_srcdir)/getopt.h \
+ $(kpathsea_srcdir)/proginit.h $(kpathsea_srcdir)/tex-file.h ../help.h \
+ $(kpathsea_srcdir)/c-pathch.h $(kpathsea_srcdir)/c-ctype.h \
+ $(kpathsea_srcdir)/tex-make.h ../texmfmem.h ../mfcoerce.h
diff --git a/Build/source/texk/web2c/window/epsf.c b/Build/source/texk/web2c/window/epsf.c
new file mode 100644
index 00000000000..05211a59970
--- /dev/null
+++ b/Build/source/texk/web2c/window/epsf.c
@@ -0,0 +1,176 @@
+/*
+ * epsf.c -- Encapsulated PostScript window server.
+ * Copyright (C) 1998 Mathias Herberts <herberts@infini.fr>
+ *
+ * These functions generate an Encapsulated PostScript File
+ * representing the graphics normally shown online. They are
+ * selected by setting MFTERM to epsf.
+ *
+ * The name of the file defaults to metafont.eps but can be
+ * changed by setting the MFEPSF environment variable.
+ *
+ * The file is closed when the program exits.
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+
+#define EXTERN extern
+
+#include "../mfd.h"
+
+#ifdef EPSFWIN
+
+#include <stdio.h>
+
+static FILE * psout = NULL;
+
+/*
+ * Arrays epsf_{left,right,top,bottom} hold the coordinates of
+ * open windows.
+ *
+ * When a new window is opened, i.e. when blankrectangle is
+ * called, we check the arrays to see if the blank rectangle
+ * clears an open window. If it is the case a showpage and an %%EOF is
+ * appended To the PostScript file and a new header is output thus
+ * making it easy to separate the pages.
+ *
+ * The last page of the file is not terminated by a showpage and
+ * an %%EOF, the user should add them himself.
+ *
+ */
+
+static screencol epsf_left[16];
+static screencol epsf_right[16];
+static screenrow epsf_top[16];
+static screenrow epsf_bottom[16];
+
+static short epsf_window = 0;
+static unsigned int epsf_page = 1;
+
+void
+mf_epsf_header ()
+{
+ fprintf (psout, "%%!PS-Adobe-3.0 EPSF-3.0\n");
+ fprintf (psout, "%%%%BoundingBox: -1 -1 %d %d\n", screenwidth, screendepth);
+ fprintf (psout, "%%%%Creator: METAFONT\n");
+ fprintf (psout, "%%%%Page: %d %d\n\n", epsf_page, epsf_page);
+ fprintf (psout, "1 dup scale\n");
+ fprintf (psout, "1 setlinewidth\n\n");
+
+ epsf_page++;
+}
+
+boolean
+mf_epsf_initscreen P1H(void)
+{
+ if (getenv ("MFEPSF") != (char *) NULL)
+ {
+ psout = fopen ((char *) getenv ("MFEPSF"), "w");
+ }
+ else
+ {
+ psout = fopen ("metafont.eps", "w");
+ }
+
+ if (psout == (FILE *) NULL)
+ {
+ return 0;
+ }
+ else
+ {
+ mf_epsf_header ();
+ epsf_window = 0;
+ return 1;
+ }
+}
+
+void
+mf_epsf_updatescreen P1H(void)
+{
+ fflush (psout);
+}
+
+void
+mf_epsf_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ int i;
+
+ for (i = 0; i < epsf_window; i++)
+ {
+ if (! ((right - 1 < epsf_left[i]) || (epsf_right[i] < left)) ) /* new window is neither left nor right of window i */
+ if ( ! ((top > epsf_bottom[i]) || (epsf_top[i] > bottom - 1))) /* new window is neither below nor above window i */
+ {
+ fprintf (psout, "\nshowpage\n%%%%EOF\n");
+ mf_epsf_header ();
+ epsf_window = 0;
+ break;
+ }
+ }
+
+ epsf_left[epsf_window] = left;
+ epsf_right[epsf_window] = right - 1;
+ epsf_top[epsf_window] = top;
+ epsf_bottom[epsf_window] = bottom - 1;
+
+ epsf_window++;
+
+ fprintf (psout, "1 setgray %d %d %d %d rectfill 0 setgray\n", left, screendepth - 1 - bottom, right - left, bottom - top);
+
+ fflush (psout);
+}
+
+
+void
+mf_epsf_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ int col;
+ int color;
+
+ color = (init_color == 0) ? 1 : 0;
+
+ do
+ {
+ col = *transition_vector++;
+
+ if (!color)
+ {
+ fprintf (psout, "newpath %d %d moveto %d %d lineto stroke\n",
+ col,
+ screendepth - 1 - row,
+ *transition_vector,
+ screendepth - 1 - row);
+ }
+
+ color = (color == 0) ? 1 : 0;
+ }
+ while (--vector_size > 0);
+}
+
+
+#else /* !EPSFWIN */
+
+int epsf_dummy;
+
+#endif /* !EPSFWIN */
diff --git a/Build/source/texk/web2c/window/hp2627.c b/Build/source/texk/web2c/window/hp2627.c
new file mode 100644
index 00000000000..2734bb36a02
--- /dev/null
+++ b/Build/source/texk/web2c/window/hp2627.c
@@ -0,0 +1,252 @@
+/*
+ * HP2627 Terminal Window interface to Unix Metafont.
+ */
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef HP2627WIN
+
+#include <stdio.h>
+
+/*
+ * HP2627a Color Graphics Terminal: Escape code definitions
+ *
+ * Drawing pen colors
+ */
+#define HP2627_BLACK '0'
+#define HP2627_RED '1'
+#define HP2627_GREEN '2'
+#define HP2627_YELLOW '3'
+#define HP2627_BLUE '4'
+#define HP2627_MAGENTA '5'
+#define HP2627_CYAN '6'
+#define HP2627_WHITE '7'
+
+/*
+ * Initialization: just do a hard graphics reset
+ * (then we can depend on the defaults
+ * being as we want them)
+ */
+#define HP2627_INITSTRING "\033*wR"
+#define HP2627_INITSTRINGLEN 4
+
+/*
+ * We want the text to be visible over both background and forground
+ * graphics data; the best color combination I found for this
+ * was to set the background RED and then paint with BLUE,
+ * although the eye doesn't focus on BLUE very well (black
+ * might be better? Or green? [to get in the holiday mood])
+ */
+#define HP2627_BACKGROUNDPEN HP2627_RED
+#define HP2627_FOREGROUNDPEN HP2627_BLUE
+
+static char mf_hp2627_pencolors[2] = {
+ HP2627_BACKGROUNDPEN, /* white */
+ HP2627_FOREGROUNDPEN /* black */
+};
+
+/*
+ * Screen dimensions: Note the origin is at the lower-left corner,
+ * not the upper left as MF expects - hence we need to translate.
+ */
+#define HP2627_MAXX 511
+#define HP2627_MAXY 389
+
+/*
+ * The actual Graphics routines. Note that these are highly tty
+ * dependent so I can minimize the number of characters that
+ * need to be sent to paint an image, since we only talk to
+ * the HP at 9.6Kb.
+ */
+
+/*
+ * function init_screen: boolean;
+ *
+ * Return true if window operations legal.
+ * We always return true (I suppose we could try to
+ * sense status or something masochistic like that)
+ */
+
+int mf_hp2627_initscreen()
+{
+ (void) fflush(stdout); /* make sure pascal-level output flushed */
+ (void) write(fileno(stdout), HP2627_INITSTRING, HP2627_INITSTRINGLEN);
+ return(1);
+}
+
+/*
+ * procedure updatescreen;
+ *
+ * Just make sure screen is ready to view
+ * (since we do Unix-level WRITE()s,
+ * we don't really need to flush stdio,
+ * but why not?)
+ */
+
+void mf_hp2627_updatescreen()
+{
+ (void) fflush(stdout);
+}
+
+/*
+ * procedure blankrectangle(left, right, top, bottom: integer);
+ *
+ * reset rectangle bounded by ([left,right],[top,bottom])
+ * to background color
+ */
+
+void mf_hp2627_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ char sprbuf[128];
+
+ (void) sprintf(sprbuf, "\033*m%cx%d,%d %d,%dE", HP2627_BACKGROUNDPEN,
+ left, HP2627_MAXY-bottom,
+ right, HP2627_MAXY-top);
+ (void) write(fileno(stdout), sprbuf, strlen(sprbuf));
+}
+
+/*
+ * procedure paintrow(
+ * row: screenrow;
+ * init_color: pixelcolor;
+ * var trans_vector: transspec;
+ * vector_size: screencol );
+ *
+ * Paint "row" starting with color "init_color", up to next
+ * transition specified by "transition_vector", switch colors,
+ * and continue for "vector_size" transitions.
+ */
+
+/*
+ * First some useful definitions:
+ */
+#define ASCIILABS 0 /* plot cmd format: ASCII long abs */
+#define BINLABS 1 /* plot cmd format: BINARY long abs */
+#define BINSINC 2 /* plot cmd format: BINARY short incr */
+
+#define ABS(x) ((x>=0)?x:-x) /* absolute value */
+
+/*
+ * An optimized "move to (x,y), with current pen lowered unless UP is
+ * true" function. Takes advantage of short commands for short
+ * movements to minimize character traffic to term.
+ *
+ * Note: the "x -= 1;" fudge is because we only want to DRAW
+ * to the next transition_vector entry - 1, but if we
+ * have the pen raised, we want to move to exactly the
+ * next point.
+ */
+#define MOVETO(x,y,up) \
+ if (up) *op++ = 'a'; \
+ else x -= 1; \
+ if (ABS(x-oldx) < 16 && ABS(y-oldy) < 16) { \
+ if (currentformat != BINSINC) { \
+ *op++ = 'j'; \
+ currentformat = BINSINC; \
+ } \
+ *op++ = (((x-oldx) & 0x1f) + ' '); \
+ *op++ = (((y-oldy) & 0x1f) + ' '); \
+ } else { \
+ if (currentformat != BINLABS) { \
+ *op++ = 'i'; \
+ currentformat = BINLABS; \
+ } \
+ *op++ = (((x&0x3e0)>>5)+' '); \
+ *op++ = ((x&0x01f) +' '); \
+ *op++ = (((y&0x3e0)>>5)+' '); \
+ *op++ = ((y&0x01f) +' '); \
+ } \
+ oldx = x; \
+ oldy = y;
+
+void mf_hp2627_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ register color;
+ char outbuf[512*6]; /* enough to hold an alternate color */
+ /* in each column */
+ register char *op;
+ register x, y, oldx, oldy;
+ int currentformat;
+
+ color = (init_color == 0)? 0 : 1;
+
+ /*
+ * We put all escape sequences in a buffer so the write
+ * has a chance of being atomic, and not interrupted by
+ * other independent output to our TTY. Also to avoid
+ * (literally millions) of stdio calls.
+ */
+ op = outbuf;
+ /*
+ * Select current pen to be the color of the first segment:
+ *
+ * our strategy here is to paint a long line from the first
+ * transition_vector value (left edge of row) to the last
+ * transition_vector entry (right edge of row). Then we switch
+ * colors to the contrasting color, and paint alternate
+ * segments with that color. Would that the HP2627 would provide
+ * a mode to paint the "background" color while the PEN is lifted.
+ * However, this is faster than using rectangular area fills.
+ */
+
+ *op++ = '\033'; *op++ = '*'; *op++ = 'm';
+ *op++ = mf_hp2627_pencolors[color];
+ *op++ = 'X';
+
+ /*
+ * Reset our "remembered" state for (X,Y) positioning and plot
+ * command format
+ */
+ oldx = oldy = -999;
+ currentformat = ASCIILABS;
+
+ /*
+ * Now, paint across the entire width of this row, make it the
+ * initial segment color.
+ */
+ x = *transition_vector;
+ y = HP2627_MAXY-row;
+ *op++ = '\033'; *op++ = '*'; *op++ = 'p';
+ MOVETO(x,y,1);
+ x = transition_vector[vector_size];
+ MOVETO(x,y,0);
+ *op++ = 'Z';
+
+ /*
+ * If there remain other segments (of contrasting color) to paint,
+ * switch pens colors and draw them
+ */
+ if (--vector_size > 0) {
+ *op++ = '\033'; *op++ = '*'; *op++ = 'm';
+ *op++ = mf_hp2627_pencolors[1-color]; *op++ = 'X';
+ color = 1-color;
+
+ oldx = oldy = -999;
+ currentformat = ASCIILABS;
+ *op++ = '\033'; *op++ = '*'; *op++ = 'p';
+ x = *++transition_vector;
+ MOVETO(x,y,1);
+ while (vector_size-- > 0) {
+ x = *++transition_vector;
+ MOVETO(x,y,(color==init_color));
+ color = 1 - color;
+ };
+ *op++ = 'Z';
+ };
+
+ /*
+ * Write the resulting plot commands, hopefully atomically
+ */
+ (void) write(fileno(stdout), outbuf, op-outbuf);
+}
+
+#else
+int hp2627_dummy;
+#endif /* HP2627WIN */
diff --git a/Build/source/texk/web2c/window/mftalk.c b/Build/source/texk/web2c/window/mftalk.c
new file mode 100644
index 00000000000..25554e05831
--- /dev/null
+++ b/Build/source/texk/web2c/window/mftalk.c
@@ -0,0 +1,273 @@
+/* mftalk.c -- generic Metafont window server.
+ Copyright (C) 1994 Ralph Schleicher
+ Slightly modified for Web2c 7.0 by kb@mail.tug.org.
+ Further modifications for Web2C 7.2 by Mathias.Herberts@irisa.fr */
+
+/* This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Please remember the following for porting to UNIX:
+
+ pid = fork ();
+ if (pid == 0)
+ execve (...); pid = spawnve (mode, ...);
+ else if (pid == -1) if (pid == -1)
+ error (); error ();
+ else else
+ success (); success ();
+
+ Spawnve(2) has many different modes and a `session' is indicated by
+ running on an extra terminal. */
+
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef MFTALKWIN
+
+#undef input
+#undef output
+#undef read
+#undef write
+#ifdef OS2
+#include <sys/param.h>
+#include <process.h>
+extern int close (int);
+extern int pipe (int *);
+extern int read (int, void *, size_t);
+extern int setmode (int, int);
+extern int write (int, const void *, size_t);
+#endif
+#include <fcntl.h>
+#include <signal.h>
+#include <kpathsea/variable.h>
+#include "mftalk.h"
+
+/* We use SIGCHLD, but fall back on SIGCLD if that's all we have. */
+#if !defined (SIGCHLD) && defined (SIGCLD)
+#define SIGCHLD SIGCLD
+#endif
+
+#define fatal(func, cond) do { if (cond) FATAL_PERROR ("perror"); } while (0)
+
+static RETSIGTYPE child_died P1H(int sig);
+static string app_type P2H(char *prog, int *app);
+
+static int pid = -1; /* Process ID of our child. */
+static int win = -1; /* Write handle to the `window'. */
+static int buf[8]; /* Temporary buffer. */
+static RETSIGTYPE (*old) (); /* Old signal handler. */
+
+
+boolean
+mf_mftalk_initscreen P1H(void)
+{
+ int app; /* Client application type. */
+ char *prog, *name; /* Client program name. */
+ /* Size of METAFONT window. */
+ char height[MAX_INT_LENGTH], width[MAX_INT_LENGTH];
+ /* Inherited pipe handles. */
+ char input[MAX_INT_LENGTH], output[MAX_INT_LENGTH];
+ char parent[MAX_INT_LENGTH]; /* My own process ID. */
+ int sc_pipe[2]; /* Server->Client pipe. */
+ int cs_pipe[2]; /* Client->Server pipe. */
+ int res, ack; /* Wait until child is ready. */
+
+ prog = kpse_var_value ("MFTALK");
+ if (prog == NULL)
+ prog = "mftalk.exe";
+
+ name = app_type (prog, &app);
+ if (!name)
+ return 0;
+
+ if (pipe (sc_pipe) == -1)
+ return 0;
+ if (pipe (cs_pipe) == -1)
+ {
+ close (sc_pipe[0]);
+ close (sc_pipe[1]);
+ return 0;
+ }
+#ifdef OS2
+ fatal (setmode, setmode (sc_pipe[0], O_BINARY) == -1);
+ fatal (setmode, setmode (sc_pipe[1], O_BINARY) == -1);
+ fatal (setmode, setmode (cs_pipe[0], O_BINARY) == -1);
+ fatal (setmode, setmode (cs_pipe[1], O_BINARY) == -1);
+#endif
+
+ old = signal (SIGCHLD, child_died);
+ fatal (old, old == SIG_ERR);
+
+ sprintf (height, "-h%d", screendepth);
+ sprintf (width, "-w%d", screenwidth);
+ sprintf (input, "-i%d", sc_pipe[0]);
+ sprintf (output, "-o%d", cs_pipe[1]);
+ sprintf (parent, "-p%d", getpid ());
+
+#ifdef OS2
+ pid = spawnl (app, name, prog, height, width, input, output, parent, NULL);
+#else
+ pid = fork ();
+ if (pid == 0)
+ {
+ fatal (close, close (0) == -1);
+ fatal (dup, dup (sc_pipe[0]) != 0);
+ fatal (close, close (sc_pipe[0]) == -1);
+ fatal (close, close (sc_pipe[1]) == -1);
+ fatal (close, close (1) == -1);
+ fatal (dup, dup (cs_pipe[1]) != 1);
+ fatal (close, close (cs_pipe[0]) == -1);
+ fatal (close, close (cs_pipe[1]) == -1);
+
+ /* We still pass the file handles as parameters for
+ * backward compatibility. instead of sc_pipe[0] and
+ * cs_pipe[1] we just pass 0 (stdin) and 1 (stdout).
+ */
+
+ sprintf (input, "-i0");
+ sprintf (output, "-o1");
+
+ execl (name, prog, height, width, input, output, parent, NULL);
+ }
+#endif /* not OS2 */
+ switch (pid)
+ {
+ case -1:
+ failure:
+ fatal (close, close (sc_pipe[0]) == -1);
+ fatal (close, close (sc_pipe[1]) == -1);
+ fatal (close, close (cs_pipe[0]) == -1);
+ fatal (close, close (cs_pipe[1]) == -1);
+ fatal (signal, signal (SIGCHLD, old) == SIG_ERR);
+ break;
+ default:
+ res = read (cs_pipe[0], &ack, sizeof (int));
+ if (res != sizeof (int) || ack != MF_ACK)
+ goto failure;
+ fatal (close, close (cs_pipe[0]) == -1);
+ win = sc_pipe[1];
+ break;
+ }
+
+ return (win == -1) ? 0 : 1;
+}
+
+
+void
+mf_mftalk_updatescreen P1H(void)
+{
+ buf[0] = MF_FLUSH;
+ write (win, buf, sizeof (int));
+}
+
+
+void
+mf_mftalk_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ buf[0] = MF_RECT;
+ buf[1] = MF_WHITE;
+ buf[2] = left;
+ buf[3] = bottom;
+ buf[4] = right;
+ buf[5] = top;
+
+ write (win, buf, 6 * sizeof (int));
+}
+
+
+void
+mf_mftalk_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ buf[0] = MF_LINE;
+ buf[1] = init_color == 0 ? MF_WHITE : MF_BLACK;
+ buf[2] = *transition_vector++;
+ buf[3] = row;
+ buf[4] = --vector_size;
+
+ write (win, buf, 5 * sizeof (int));
+ write (win, transition_vector, vector_size * sizeof (int));
+}
+
+
+static string
+app_type P2C(string, prog, int *, app)
+{
+#ifdef OS2
+ int res, app;
+
+ res = DosSearchPath (0x02 | 0x01, "PATH", prog, buf, len);
+ if (res != 0)
+ return -1;
+
+ res = DosQueryAppType (buf, &app);
+ if (res != 0)
+ return -1;
+
+ switch (app & 0x07) /* Quick guess. */
+ {
+ case 0x00: return (P_SESSION | P_DEFAULT);
+ case 0x01: return (P_SESSION | P_FULLSCREEN);
+ case 0x02: return (P_SESSION | P_WINDOWED);
+ case 0x03: return (P_PM);
+ }
+#endif /* OS2 */
+
+ *app = 0; /* Irrelevant. */
+ return prog;
+}
+
+
+static RETSIGTYPE
+child_died (int sig)
+{
+#ifdef OS2
+ fatal (signal, signal (sig, SIG_ACK) == SIG_ERR);
+#endif
+ fatal (signal, signal (sig, SIG_IGN) == SIG_ERR);
+
+ if (pid == -1 || kill (-pid, 0) == 0) /* This was not our child. */
+ {
+ if (old != SIG_IGN)
+ {
+ fatal (signal, signal (sig, old) == SIG_ERR);
+ fatal (raise, raise (sig) == -1);
+ }
+ fatal (signal, signal (sig, child_died) == SIG_ERR);
+ }
+ else
+ {
+ close (win); /* This may fail. */
+ win = -1;
+
+ pid = -1;
+
+ screenstarted = false; /* METAFONT variables. */
+ screenOK = false;
+
+ fatal (signal, signal (sig, old) == SIG_ERR);
+ }
+}
+
+#else /* !MFTALKWIN */
+
+int mftalk_dummy;
+
+#endif /* !MFTALKWIN */
diff --git a/Build/source/texk/web2c/window/next.c b/Build/source/texk/web2c/window/next.c
new file mode 100644
index 00000000000..c3f6d4203e6
--- /dev/null
+++ b/Build/source/texk/web2c/window/next.c
@@ -0,0 +1,177 @@
+/* next.c: display interface for the NeXT, joe@rilgp.tamri.com.
+
+This device code requires a second program ("DrawingServant") to
+act as the interface between sm and the WindowServer. The second program
+just serves to listen for commands on a pipe, but otherwise
+send everything else with a DPSPrintf to the WindowServer. The servant can
+also do things like implement it's own event loop and handle things
+like printing, saving .eps and the like. This seems (to me) to be the
+best way to put a multiplatform program into a NeXT application.
+
+You can get DrawingServant from sonata.cc.purdue.edu.
+*/
+
+/* with not too much work, the client side of things probably
+could be on another machine */
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef NEXTWIN /* the whole file */
+#define DRAWSERVER "DrawingServant"
+#define DEFWIDTH 400 /* default width and height */
+#define DEFHEIGHT 500
+
+/*these default values are taken from plain.mf
+and are used if we can't see anything better */
+static int nextheight=DEFHEIGHT;
+static int nextwidth=DEFWIDTH;
+static int outpipe[2],inpipe[2];
+static int pid;
+static int nextscreenlooksOK = 0;
+char outstring[1024]; /* the longest string pushed though a pipe */
+/* these are used a lot, so macro-ize these two lines */
+#define SENDPS write(outpipe[1],outstring,strlen(outstring)+1)
+#define GETACK do{\
+ read(inpipe[0],outstring,sizeof(outstring)-1);\
+ } while(strncmp(outstring,"Ok",2))
+#ifdef read
+#undef read
+#endif
+
+int mf_next_initscreen()
+{
+ int i;
+ void mf_next_closescreen();
+ /* strings for height, width, in and out pipes */
+ char hstr[20],wstr[20],instr[20],outstr[20];
+
+ /* I should figure out how to use screen_rows and screen_cols
+ to size the window. what I think I need is one of leftcol,rightcol
+ toprow and botrow. Let's find the first which is non-zero,
+ at least until someone tells me what the real answer is.*/
+
+ for(i=0;i<16;i++) {
+ if((leftcol[i]-rightcol[i]) && (toprow[i]-botrow[i])) {
+ nextwidth = rightcol[i]-leftcol[i];
+ nextheight = botrow[i]-toprow[i];
+ break;
+ }
+ }
+
+ /* fork a process and assign some pipes. return if unsuccessful */
+ if( pipe(outpipe)== -1)
+ return 0;
+ if( pipe(inpipe)== -1)
+ return 0;
+ if( (pid=fork())== -1)
+ return 0;
+
+ if(pid==0) {
+ /* things done by the child. we pass it height,width and
+ input and output pipes */
+ sprintf(hstr,"h %d ",nextheight);
+ sprintf(wstr,"w %d ",nextwidth);
+ sprintf(outstr,"i %d",outpipe[0]);
+ sprintf(instr,"o %d",inpipe[1]);
+ execl(DRAWSERVER,DRAWSERVER,hstr,wstr,instr,outstr,0);
+ exit(0);
+ }
+ sprintf(outstring,"initgraphics\n");
+ SENDPS;
+ GETACK;
+ nextscreenlooksOK = 1;
+
+ /* The prior version used a hacked version of uexit to kill the
+ server...at the urging of karl berry, here is a more legit way to
+ kill the server */
+ atexit(*mf_next_closescreen);
+
+ return 1;
+}
+/*
+ * void updatescreen;
+ * does nothing
+ *
+ */
+void mf_next_updatescreen()
+{
+}
+/*
+ * void blankrectangle(int left,int right,int top,int bottom);
+ *
+ * blank out a port of the screen.
+ */
+void mf_next_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+
+ if(left==0 && top==nextheight && right==nextwidth && bottom==0 ) {
+ /* clear and forgets PS strings */
+ sprintf(outstring,"DSclear");
+ } else {
+ sprintf(outstring,
+ " 1 setgray %d %d %d %d rectfill 0 setgray \n",
+ left+1,top+1,right,bottom+1);
+ }
+ SENDPS;
+ GETACK;
+}
+
+/*
+ * void paintrow(int row,int init_color,int transition_vector,
+ * int vector_size);
+ *
+ * Paint "row" starting with color "init_color", up to next
+ * transition specified by "transition_vector", switch colors,
+ * and continue for "vector_size" transitions.
+ */
+void mf_next_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ int i,whereami;
+ if(init_color) {
+ init_color = 1;
+ } else {
+ init_color = 0;
+ }
+ whereami = 0;
+
+ for(i=0;i<vector_size;i++) {
+ if(init_color) {
+ sprintf(outstring+whereami,
+ "newpath %d %d moveto %d %d lineto stroke ",
+ transition_vector[i],nextheight-row,
+ transition_vector[i+1],nextheight-row);
+ whereami = strlen(outstring);
+ /* buffering is good. perhaps. */
+ if(whereami > 500) {
+ SENDPS;
+ GETACK;
+ *outstring = 0;
+ whereami = 0;
+ }
+ }
+ init_color = 1-init_color;
+ }
+ if(whereami) {
+ SENDPS;
+ GETACK;
+ }
+}
+/* this isn't part of the online display routines. We need it to
+kill DrawingServant. This is called during exit */
+void mf_next_closescreen()
+{
+ if(nextscreenlooksOK) {
+ sprintf(outstring,"DSquit");
+ SENDPS;
+ }
+}
+
+#else
+int next_dummy;
+#endif /* NEXTWIN */
diff --git a/Build/source/texk/web2c/window/regis.c b/Build/source/texk/web2c/window/regis.c
new file mode 100644
index 00000000000..c23abce4ce4
--- /dev/null
+++ b/Build/source/texk/web2c/window/regis.c
@@ -0,0 +1,105 @@
+/* Regis terminal window interface for Metafont, joe@rilgp.tamri.com.
+ screen_rows is 480; screen_cols is 800. */
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef REGISWIN /* Whole file */
+
+#define ESCAPE 27
+
+/* set this up in one of two ways. if defined, display is white characters
+on a black background; undefined is the opposite */
+#undef WRITEWHITE
+
+/*
+ * int init_screen
+ * Put screen in graphics mode:<ESC>Pp
+ * Write no or both planes for the background black:S(I0)
+ * Write both or no planes for the forground white:W(I3)
+ * Erase screen:S(E)
+ * Return to alpha mode: <ESC>\
+ *
+ * Assuming that the speed limitation is a serial line to the
+ * terminal, we want to define macros for the most common
+ * character combinations.
+ * Define macros for ,+0]P[ (call this "p") and
+ * ,+0]V[ (this one is called "v").
+ * drawing a line is 4+(2 to 6) characters
+ * We always return true.
+ */
+
+int mf_regis_initscreen()
+{
+#ifdef WRITEWHITE
+ printf("%cPpS(I0)W(I3)S(E)%c",ESCAPE,ESCAPE);
+#else
+ printf("%cPpS(I3)W(I0)S(E)%c",ESCAPE,ESCAPE);
+#endif
+ printf("%cPp@:p,+0]P[@;@:v,+0]V[@;",ESCAPE);
+ return 1;
+}
+/*
+ * procedure updatescreen;
+ *
+ */
+void mf_regis_updatescreen()
+{
+}
+ /* void blankrectangle(int left,int right,int top,int bottom);
+ *
+ * Go to graphics mode: <ESC>Pp
+ * Move to lower left: P[%d,%d]
+ * Write no or both planes: W(I0)
+ * Turn on shading: W(S1)
+ * Vector to lower right, upper right, upper left, lower left: V's
+ * Turn off shading: W(S0)
+ * Write both or no planes: W(I3)
+ * Return to alpha mode: <ESC>\
+ */
+void mf_regis_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ printf(
+#ifdef WRITEWHITE
+ "%cPpP[%d,%d]W(I0)W(S1)V[%d,%d]V[%d,%d]V[%d,%d]V[%d,%d]W(S0)W(I3)%c\\",
+#else
+ "%cPpP[%d,%d]W(I3)W(S1)V[%d,%d]V[%d,%d]V[%d,%d]V[%d,%d]W(S0)W(I0)%c\\",
+#endif
+ ESCAPE,left,bottom,right,bottom,right,top,left,top,
+ left,bottom,ESCAPE);
+}
+
+/*
+ * void paintrow(int row, int init_color, int* transition_vector,
+ * int vector_size);
+ * Paint "row" starting with color "init_color", up to next
+ * transition specified by "transition_vector", switch colors,
+ * and continue for "vector_size" transitions.
+ */
+void mf_regis_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ int i;
+ if(init_color) {
+ init_color = 1;
+ } else {
+ init_color = 0;
+ }
+ printf("%cPpP[0,%d]P[",ESCAPE,row);
+ for(i=0;i<vector_size;i++) {
+ if(init_color)
+ printf("%d@v%d@p",transition_vector[i],
+ transition_vector[i+1]);
+ init_color = 1-init_color;
+ }
+ printf("+0,+0]%c\\",ESCAPE);
+}
+
+#else
+int regis_dummy;
+#endif /* REGISWIN */
diff --git a/Build/source/texk/web2c/window/suntools.c b/Build/source/texk/web2c/window/suntools.c
new file mode 100644
index 00000000000..b0cf48f0af1
--- /dev/null
+++ b/Build/source/texk/web2c/window/suntools.c
@@ -0,0 +1,214 @@
+/* Link this to sun.c if you are running on a SunView system */
+
+/*
+ * author = "Pierre MacKay (from the original by Paul Richards)"
+ * version = "0.5",
+ * date = "5 May 1991 - June 1992"
+ * filename = "sun_sunview.c",
+ * contact = "Pierre MacKay",
+ * email = "mackay@cs.washington.edu"
+ * Graphics window interface to Metafont for Suns running
+ * SunView (Sun Unix release 3.n)
+ * This code is essentially a translation from the old
+ * sun.c which used <suntool/gfxsw.h>. The model for the
+ * translation is the example in Appendix C (C.2.) of the
+ * Sunview 1 Programmer's guide as applied to bouncedemo.c
+ * There are nice additional benefits, such as a moveable
+ * and scalable graphics window, and the chance to see
+ * the controlling window while METAFONT is at work
+ *
+ * Destroy checking is bogus, and SunView does not clean up the mess
+ * if you "quit" from the pulldown menu. You will be left with
+ * an hysterical orphaned process screaming for a window that isn't
+ * there. You will have to go elsewhere and KILL that process.
+ * Otherwise it seems clean.
+ *
+ * For the moment this and the XView interface seem to be
+ * mutually exclusive, since they use library routines with
+ * the same names, which mightily confuses the loader.
+ * It doesn't help much to change the name of MFTERM since
+ * XView wants to name its own terminal "sun" just like
+ * the SunView terminal
+ */
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#undef _POSIX_SOURCE
+#ifdef SUNTOOLSWIN
+
+/* <sundev/cg9reg.h> wants to have a field named `reset'. Since we
+ don't need the WEB(2C) reset, no problem. */
+#undef reset
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <suntool/sunview.h>
+#include <suntool/canvas.h>
+
+static void repaint_proc();
+static void resize_proc();
+
+static Notify_value mf_notice_destroy();
+extern Notify_error notify_dispatch();
+
+static int destroy_ready; /* could be used for tighter control */
+
+/*
+ * global handle on the graphics subwindow
+ */
+
+struct MFsubwindow {
+ int mf_flags;
+#define MF_RESTART 0x01
+ struct pixwin *mf_pixwin;
+ struct rect mf_rect;
+ } sun_mf_subwin; /* Make sure that names storage is allocated. */
+
+static struct MFsubwindow *metafont_sw = &sun_mf_subwin; /* window handle */
+
+/*
+ * Gray background for graphics area
+ */
+
+static short mf_graybackground_image[] = {0x5555, 0xaaaa};
+ mpr_static(mf_sunview_gray_bkgr, 2, 2, 1, mf_graybackground_image);
+
+
+Rect *rect;
+Frame frame;
+Canvas canvas;
+Pixwin *pw;
+
+/*
+ * init_screen: boolean; return true if window operations legal
+ */
+
+int
+mf_sun_initscreen()
+{
+ frame = window_create(NULL,FRAME,
+ FRAME_LABEL, "METAFONT",
+ FRAME_SHOW_LABEL, TRUE,
+ WIN_ERROR_MSG, "! Window access requires METAFONT to run under suntools\n",
+ 0);
+ canvas = window_create(frame, CANVAS,
+ CANVAS_RESIZE_PROC, resize_proc,
+ CANVAS_FAST_MONO, TRUE,
+ WIN_ERROR_MSG, "Can't creat canvas",
+ 0);
+ pw = canvas_pixwin(canvas);
+
+ metafont_sw->mf_pixwin = canvas_pixwin(canvas);
+
+ /* interpose a destroy procedure so we can shut down cleanly */
+ (void) notify_interpose_destroy_func(frame, mf_notice_destroy);
+
+ /*
+ * Instead of using window_main_loop, just show the frame.
+ * Metafont's procedures will be in control, not the notifier.
+ */
+ window_set(frame,WIN_SHOW, TRUE, 0);
+
+ rect = (Rect *)window_get(canvas, WIN_RECT); /* Get current dimensions */
+ pw_replrop(pw,
+ 0, 0,
+ rect->r_width,
+ rect->r_height,
+ PIX_SRC,
+ &mf_sunview_gray_bkgr, 0, 0); /* clear subwindow */
+
+ return(1); /* Caller expects a TRUE value */
+}
+
+/*
+ * updatescreen; -- just make sure screen is ready to view
+ */
+
+void
+mf_sun_updatescreen()
+{
+ (void)notify_dispatch();
+/* if (destroy_ready != 0) return; */
+ rect = (Rect *)window_get(canvas, WIN_RECT); /* Get current dimensions */
+ if (metafont_sw->mf_flags & MF_RESTART) {
+ metafont_sw->mf_flags &= ~MF_RESTART;
+ pw_replrop(pw,
+ 0, 0,
+ rect->r_width,
+ rect->r_height,
+ PIX_SRC,
+ &mf_sunview_gray_bkgr, 0, 0); /* clear subwindow */
+ }
+}
+
+/*
+ * blankrectangle: reset rectangle bounded by ([left,right],[top,bottom])
+ * to background color
+ */
+
+void
+mf_sun_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ pw_writebackground(pw, left, top,
+ right-left+1, bottom-top+1, PIX_CLR);
+}
+
+/*
+ * paintrow -- paint "row" starting with color "init_color", up to next
+ * transition specified by "transition_vector", switch colors,
+ * and continue for "vector_size" transitions.
+ */
+
+void
+mf_sun_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ register col;
+ register color;
+
+ (void)notify_dispatch();
+ color = (init_color == 0)? 0 : 1;
+
+ do {
+ col = *transition_vector++;
+ pw_vector(pw,
+ col, row, (*transition_vector)-1, row,
+ PIX_SRC, color);
+ color = 1 - color;
+ } while (--vector_size);
+}
+
+static void
+repaint_proc( /* Ignore args */ )
+{
+ /* if repainting is required, just restart */
+ metafont_sw->mf_flags |= MF_RESTART;
+}
+
+static void
+resize_proc( /* Ignore args */ )
+{
+ metafont_sw->mf_flags |= MF_RESTART;
+}
+
+static Notify_value
+mf_notice_destroy(frame, status)
+ Frame frame;
+ Destroy_status status;
+{
+ if (status != DESTROY_CHECKING) {
+ destroy_ready = TRUE;
+ (void)notify_stop();
+ }
+ return(notify_next_destroy_func(frame,status));
+}
+
+#else
+int sunview_dummy;
+#endif /* SUNTOOLSWIN */
diff --git a/Build/source/texk/web2c/window/tek.c b/Build/source/texk/web2c/window/tek.c
new file mode 100644
index 00000000000..78dbae26bd6
--- /dev/null
+++ b/Build/source/texk/web2c/window/tek.c
@@ -0,0 +1,143 @@
+/* Tektronix terminal window interface for Metafont. */
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef TEKTRONIXWIN /* Whole file */
+
+#define FORMFEED 12
+#define ESCAPE 27
+#define GS 29
+#define US 31
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+#define WIDTH 1024 /* Screen width */
+#define HEIGHT 780 /* Screen height */
+#define WIDTHINBYTES (WIDTH/8) /* Only works if WIDTH % 8 == 0 */
+#define SETBIT(row,col) screen_pixel[row*WIDTHINBYTES+col/8] |= 1 << 7-col%8
+#define CLEARBIT(row,col) screen_pixel[row*WIDTHINBYTES+col/8] &= \
+ ~(1 << 7-col%8)
+#define ISSET(row,col) (screen_pixel[row*WIDTHINBYTES+col/8] & 1 << 7-col%8)
+
+char screen_pixel[WIDTHINBYTES*HEIGHT];
+char zero_array[WIDTHINBYTES];
+
+/*
+ * function init_screen: boolean;
+ *
+ * Return true if window operations legal.
+ * We always return true.
+ */
+
+int mf_tektronix_initscreen()
+{
+ bzero(zero_array, sizeof(zero_array));
+ return 1;
+}
+
+/*
+ * procedure updatescreen;
+ *
+ * Print out the screen bitmap.
+ */
+void mf_tektronix_updatescreen()
+{
+ int r, c, startc, makingline;
+
+ printf("%c%c", ESCAPE, FORMFEED);
+ for (r = 0; r < HEIGHT; r++) {
+ makingline = FALSE;
+ if (bcmp(&screen_pixel[r*WIDTHINBYTES],zero_array,WIDTHINBYTES) == 0)
+ continue;
+ for (c = 0; c < WIDTH; c++) {
+ if (ISSET(r, c)) {
+ if (!makingline) {
+ makingline = TRUE;
+ startc = c;
+ }
+ } else if (makingline) {
+ putchar(GS);
+ putchar(0x20|((HEIGHT-1)-r)>>5);
+ putchar(0x60|((HEIGHT-1)-r)&0x1F);
+ putchar(0x20|startc>>5);
+ putchar(0x40|startc&0x1F);
+ putchar(0x60|((HEIGHT-1)-r)&0x1F); /* Don't send high y */
+ putchar(0x20|c>>5);
+ putchar(0x40|c&0x1F);
+ makingline = FALSE;
+ }
+ }
+ if (makingline) {
+ putchar(GS);
+ putchar(0x20|((HEIGHT-1)-r)>>5);
+ putchar(0x60|((HEIGHT-1)-r)&0x1F);
+ putchar(0x20|startc>>5);
+ putchar(0x40|startc&0x1F);
+ putchar(0x60|((HEIGHT-1)-r)&0x1F); /* Don't send high y */
+ putchar(0x20|c>>5);
+ putchar(0x40|c&0x1F);
+ }
+ }
+ printf("%c%c%c%c%c", GS, 0x23, 0x66, 0x20, 0x40);
+ putchar(US);
+ fflush(stdout);
+}
+
+/*
+ * procedure blankrectangle(left, right, top, bottom: integer);
+ *
+ * Blanks out a port of the screen.
+ */
+void mf_tektronix_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ int r, c;
+
+ if (left == 0 && right == WIDTH && top == 0 && bottom == HEIGHT)
+ bzero(screen_pixel, sizeof(screen_pixel));
+ else
+ for (r = top; r < bottom; r++)
+ for (c = left; c < right; c++)
+ CLEARBIT(r, c);
+}
+
+/*
+ * procedure paintrow(
+ * row: screenrow;
+ * init_color: pixelcolor;
+ * var trans_vector: transspec;
+ * vector_size: screencol);
+ *
+ * Paint "row" starting with color "init_color", up to next
+ * transition specified by "transition_vector", switch colors,
+ * and continue for "vector_size" transitions.
+ */
+void mf_tektronix_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ int k = 0;
+ int c = transition_vector[0];
+
+ do {
+ k++;
+ do {
+ if (init_color)
+ SETBIT(row, c);
+ else
+ CLEARBIT(row, c);
+ } while (++c != transition_vector[k]);
+ init_color = !init_color;
+ } while (k != vector_size);
+}
+
+#else
+int tek_dummy;
+#endif /* TEKTRONIXWIN */
diff --git a/Build/source/texk/web2c/window/trap.c b/Build/source/texk/web2c/window/trap.c
new file mode 100644
index 00000000000..45d7f833fec
--- /dev/null
+++ b/Build/source/texk/web2c/window/trap.c
@@ -0,0 +1,50 @@
+/* trap.c -- generate output for the trap test. See comments in
+ lib/texmf.c for what each routine does. */
+
+#define EXTERN extern
+#include "../mfd.h"
+
+
+/* No #ifdef for the whole file, because we always want to support this. */
+
+
+/* This returns true if we can do window operations, else false. */
+
+boolean
+mf_trap_initscreen P1H(void)
+{
+ return 1;
+}
+
+void
+mf_trap_updatescreen P1H(void)
+{
+ fputs ("Calling UPDATESCREEN\n", logfile);
+}
+
+void
+mf_trap_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ fprintf (logfile, "\nCalling BLANKRECTANGLE(%ld,%ld,%ld,%ld)\n",
+ (long)left, (long)right, (long)top, (long)bottom);
+}
+
+void
+mf_trap_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, transition_vector,
+ screencol, vector_size)
+{
+ unsigned k;
+
+ fprintf (logfile, "Calling PAINTROW(%ld,%ld;", (long)row, (long)init_color);
+ for (k = 0; k <= vector_size; k++) {
+ fprintf (logfile, "%ld", (long)transition_vector[k]);
+ if (k != vector_size)
+ putc (',', logfile);
+ }
+ fputs (")\n", logfile);
+}
diff --git a/Build/source/texk/web2c/window/uniterm.c b/Build/source/texk/web2c/window/uniterm.c
new file mode 100644
index 00000000000..197bff77367
--- /dev/null
+++ b/Build/source/texk/web2c/window/uniterm.c
@@ -0,0 +1,184 @@
+/*
+ * title: uni.c
+ * abstract: Uniterm Terminal Window interface for Metafont.
+ * author: T.R.Hageman, Groningen, The Netherlands.
+ * created: May 1990
+ * modified:
+ * description:
+ * Uniterm (Simon Poole's terminal emulator for the Atari ST)
+ * emulates a `smart' Tektronix 4014 graphics terminal,
+ * and allows selective erasing of the graphics screen.
+ * (I do not know whether this is a standard feature of smart Teks
+ * or an invention of Mr. Poole)
+ *
+ * This file is offered as an alternative to the "standard"
+ * tektronix driver (which I find rather slow...)
+ *
+ * {{a possible way to improve the standard TEK driver would be to
+ * remember the (merged) transition lists instead converting to
+ * a bit map and back again.}}
+ *---*/
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef UNITERMWIN /* Whole file */
+
+#define WIDTH 1024
+#define HEIGHT 780
+/*
+ * Send a vector to the graphics terminal
+ * (in a slightly optimized way).
+ */
+static void
+sendvector(x, y)
+register unsigned x, y;
+{
+ static int Hi_Y, Lo_Y, Hi_X; /* remembered values */
+ register int Lo_Y_sent = 0;
+ register int t;
+#ifdef DEBUG
+ if (x >= WIDTH) /* clip... */
+ x = WIDTH - 1;
+ if (y >= HEIGHT)
+ y = HEIGHT - 1;
+#endif
+ /*
+ * Send Hi_Y only if it has changed.
+ */
+ if ((t = 0x20|(y >> 5)) != Hi_Y) {
+ Hi_Y = t, putchar(t);
+ }
+ /*
+ * Likewise, send Lo_Y only if it has changed.
+ * (and remember that it has been sent)
+ */
+ if ((t = 0x60|(y & 0x1f)) != Lo_Y) {
+ Lo_Y_sent = 1;
+ Lo_Y = t, putchar(t);
+ }
+ /*
+ * A slight complication here. If Hi_X has changed,
+ * we must send Lo_Y too, but only if we didn't already send it.
+ */
+ if ((t = 0x20|(x >> 5)) != Hi_X) {
+ if (!Lo_Y_sent)
+ putchar(Lo_Y);
+ Hi_X = t, putchar(t);
+ }
+ /*
+ * Lo_X is always sent, so don't bother to remember it.
+ */
+ t = 0x40|(x & 0x1f), putchar(t);
+}
+/*
+ * Tektronix has origin in lower-left corner, whereas MetaFont
+ * has its origin in the upper-left corner.
+ * The next macro hides this.
+ */
+#define VECTOR(col,row) sendvector((unsigned)(col),(unsigned)(HEIGHT-1-(row)))
+/*
+ * GS - `Dark' vectors are in fact invisible, i.e., a move.
+ * (Also switches from text- to graphics screen.)
+ */
+#define DARK() putchar('\35')
+/*
+ * CAN - Switch from graphics- to text screen.
+ */
+#define TEXT_SCREEN() putchar('\30')
+/*
+ * ESC STX(ETX) - Enable(disable) block-fill mode.
+ */
+#define BLOCK(on) (putchar('\33'),putchar(2+!(on)))
+/*
+ * ESC / 0(1) d - Set black(white) ink.
+ */
+#define INK(on) (putchar('\33'), putchar('\57'), \
+ putchar('\61'-(on)), putchar('\144'))
+/*
+ * US - Switch to `alpha mode'
+ */
+#define ALPHA_MODE() putchar('\37')
+/*
+ * ESC FF - clear graphics&alpha screen.
+ */
+#define ALPHA_CLS(); (putchar('\33'), putchar('\14'))
+int mf_uniterm_initscreen()
+{
+ ALPHA_CLS();
+ TEXT_SCREEN();
+ return 1;
+}
+void mf_uniterm_updatescreen()
+{
+ DARK();
+ VECTOR(0,HEIGHT-1);
+ fflush(stdout);
+ TEXT_SCREEN(); /* switch to text mode */
+}
+void mf_uniterm_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ if (top==0 && left==0 && bottom>=HEIGHT-1 && right>=WIDTH-1) {
+ ALPHA_CLS();
+ return;
+ }
+ DARK();
+ VECTOR(left, top);
+ BLOCK(1); /* setup block erase mode */
+ INK(0); /* use white ink */
+ VECTOR(right-1, bottom-1); /* this draws the block */
+ BLOCK(0); /* back to (black) linedraw mode */
+ INK(1); /* black ink */
+}
+void mf_uniterm_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ register transspec, transition_vector,
+ register screencol, vector_size)
+{
+ register int blank = !init_color;
+#if 0
+ /* This is the basic */
+ DARK();
+ VECTOR(*transition_vector++, row); /* move to first transition */
+ do {
+ INK(blank ^= 1);
+ VECTOR(*transition_vector++ - 1, row);
+ } while (--vector_size > 0);
+#endif
+ register screencol col;
+ /* However, we optimize the amount of output a bit by blanking
+ out the row first (since each INK command takes 4 bytes) */
+ DARK();
+ if (blank) {
+ VECTOR(transition_vector[((vector_size-1)&~1)+1] - 1, row);
+ INK(0);
+ VECTOR(*transition_vector++, row);
+ INK(1);
+ if (vector_size==1)
+ return;
+ }
+ else {
+ if (vector_size > 1) {
+ VECTOR(transition_vector[vector_size & ~1] - 1, row);
+ INK(0);
+ VECTOR(transition_vector[1], row);
+ INK(1);
+ DARK();
+ }
+ VECTOR(*transition_vector++, row);
+ }
+ do {
+ col = *transition_vector++;
+ if ((blank ^= 1) == 0)
+ DARK(); /* white -> black; move to first black pixel */
+ else
+ col--; /* black -> white; blacken to col-1 */
+ VECTOR(col, row);
+ } while (--vector_size > 0);
+}
+#else
+int uniterm_dummy;
+#endif /* UNITERMWIN */
diff --git a/Build/source/texk/web2c/window/win32.c b/Build/source/texk/web2c/window/win32.c
new file mode 100644
index 00000000000..1e85d8ba861
--- /dev/null
+++ b/Build/source/texk/web2c/window/win32.c
@@ -0,0 +1,415 @@
+/*
+
+ Win32 interface for Metafont.
+ Author: Fabrice Popineau <Fabrice.Popineau@supelec.fr>
+
+ */
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef WIN32WIN
+#include <windows.h>
+
+/*
+ The following constant enables some hack that should allow the
+ window to process its messages. Basically, the principle is to
+ create a thread which will do the message loop. Unfortunately,
+ it does not seem to work very well :-)
+ */
+#undef LOOPMSG
+#define LOOPMSG 1
+
+#undef DEBUG
+/* #define DEBUG 1 */
+
+static char szAppName[] = "MF";
+static char szTitle[] = " MetaFont V2.718 Online Display";
+static HWND my_window;
+static HDC my_dc;
+static HDC drawing_dc;
+static HBITMAP hbm;
+static RGBQUAD black = {0,0,0,0};
+static RGBQUAD white = {255,255,255,0};
+static MSG msg;
+static HANDLE hAccelTable;
+static HANDLE hMutex;
+/* Scrollbars' variables */
+static SCROLLINFO si;
+static int xMinScroll;
+static int xMaxScroll;
+static int xCurrentScroll;
+static int yMinScroll;
+static int yMaxScroll;
+static int yCurrentScroll;
+static BOOL fScroll;
+static BOOL fSize;
+
+#ifdef LOOPMSG
+void __cdecl InitGui(void*);
+#endif
+LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
+
+int
+mf_win32_initscreen()
+{
+ int ret;
+ if ((ret = _beginthread(InitGui, 0, NULL)) == -1) {
+ fprintf(stderr, "_beginthread returned with %d\n", ret);
+ return 0;
+ }
+ else
+ return 1;
+}
+
+ /* This window should be registered into a class. And maybe the
+ message loop could run into a separate thread. */
+
+void __cdecl InitGui(void *param)
+{
+ HWND hparentwnd;
+ HANDLE hinst;
+ WNDCLASSEX wndclass;
+ char szFile[80];
+
+ hinst = GetModuleHandle(NULL);
+ GetModuleFileName (hinst, szFile, sizeof(szFile));
+#ifdef DEBUG
+ printf ("hinst = %x\n", hinst);
+ printf ("File = %s\n", szFile);
+#endif
+ /* Fill in window class structure with parameters that describe
+ the main window. */
+ /* CS_OWNDC : un DC pour chaque fenêtre de la classe */
+ wndclass.cbSize = sizeof(wndclass);
+ wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
+ wndclass.lpfnWndProc = (WNDPROC)WndProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hinst;
+ wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
+ wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
+ wndclass.lpszClassName = szFile;
+ wndclass.lpszMenuName = NULL;
+
+ if (!RegisterClassEx(&wndclass))
+ Win32Error("Register class");
+
+ hparentwnd = GetFocus();
+ my_window = CreateWindow(szFile, szTitle,
+ WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
+ CW_USEDEFAULT, 0,
+ CW_USEDEFAULT, 0,
+ /* screenwidth, screendepth, */
+ hparentwnd, NULL, hinst, NULL);
+ if (!my_window) {
+ Win32Error("Create window");
+ }
+#ifdef DEBUG
+ fprintf(stderr, "my_window = %x\n", my_window);
+#endif
+
+#ifdef LOOPMSG
+ /* Acknowledge for UpdateWindow() (WM_PAINT message generated) */
+ hMutex = CreateMutex(NULL, FALSE, "DrawingMutex");
+ my_dc = GetDC(my_window);
+ /* Device context for drawing and the associated bitmap. */
+ drawing_dc = CreateCompatibleDC(my_dc);
+ hbm = CreateCompatibleBitmap(my_dc, screenwidth, screendepth);
+ SelectObject(drawing_dc, hbm);
+ /* Blank the bitmap */
+ SelectObject(drawing_dc, GetStockObject(WHITE_BRUSH));
+ PatBlt(drawing_dc, 0, 0, screenwidth, screendepth, PATCOPY);
+ hAccelTable = LoadAccelerators (hinst, szTitle);
+
+ ShowWindow(my_window, SW_SHOWNORMAL);
+ UpdateWindow(my_window);
+
+ /* Running the message loop */
+ while (GetMessage(&msg, my_window, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+#else
+ drawing_dc = my_dc = GetDC(my_window);
+#endif
+}
+
+/* Make sure the screen is up to date. (section 8.6 Handling the output
+buffer) */
+
+void
+mf_win32_updatescreen()
+{
+ RECT r;
+ r.left = 0;
+ r.top = 0;
+ r.right = screenwidth;
+ r.bottom = screendepth;
+
+ /* Send a WM_PAINT message to the window.
+ The rectangle should be invalidated for the message being sent. */
+ InvalidateRect(my_window, &r, FALSE);
+ UpdateWindow(my_window);
+}
+
+
+/* Blank the rectangular inside the given coordinates. We don't need to
+reset the foreground to black because we always set it at the beginning
+of paintrow (below). */
+
+void mf_win32_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ RECT r;
+ r.left = left;
+ r.top = top;
+ r.right = right+1; /* FIXME: must we fill the last row/column ? */
+ r.bottom = bottom+1;
+ /* Fixme : should synchronize with message processing. */
+ WaitForSingleObject(hMutex, INFINITE);
+ FillRect(drawing_dc, &r, GetStockObject(WHITE_BRUSH));
+ ReleaseMutex(hMutex);
+}
+
+
+/* Paint a row with the given ``transition specifications''. We might be
+able to do something here with drawing many lines. */
+
+void
+mf_win32_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, tvect,
+ register screencol, vector_size)
+{
+ register int col;
+ HGDIOBJ CurrentPen;
+ HGDIOBJ WhitePen = GetStockObject(WHITE_PEN);
+ HGDIOBJ BlackPen = GetStockObject(BLACK_PEN);
+ /* FIXME: should sync with msg processing */
+ WaitForSingleObject(hMutex, INFINITE);
+ CurrentPen = (init_color == 0) ? WhitePen : BlackPen;
+ do {
+ col = *tvect++;
+ MoveToEx(drawing_dc, col, (int) row, NULL);
+ SelectObject(drawing_dc, CurrentPen);
+
+ /* (section 6.3.2 Drawing single and multiple lines)
+ */
+ LineTo(drawing_dc, (int) *tvect, (int) row);
+ CurrentPen = (CurrentPen == WhitePen) ? BlackPen : WhitePen;
+ } while (--vector_size > 0);
+ SelectObject(drawing_dc, GetStockObject(NULL_PEN));
+ ReleaseMutex(hMutex);
+}
+
+#if 0
+void Win32Error(char *caller)
+{
+ LPVOID lpMsgBuf;
+
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+ /* Display the string. */
+ MessageBox( NULL, lpMsgBuf, caller, MB_OK|MB_ICONINFORMATION );
+ /* Free the buffer. */
+ LocalFree( lpMsgBuf );
+}
+#endif
+
+LRESULT APIENTRY WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
+{
+ PAINTSTRUCT ps;
+ int retval;
+
+#ifdef DEBUG
+ fprintf(stderr, "Message %x\n", iMsg);
+#endif
+#ifdef LOOPMSG
+ WaitForSingleObject(hMutex, INFINITE);
+ switch (iMsg) {
+ case WM_CREATE:
+ xMinScroll = 0;
+ xMaxScroll = screenwidth;
+ xCurrentScroll = 0;
+
+ yMinScroll = 0;
+ yMaxScroll = screendepth;
+ yCurrentScroll = 0;
+
+ fScroll = FALSE;
+ fSize = FALSE;
+
+ break;
+ case WM_SIZE:
+ {
+ int xNewSize, yNewSize;
+ xNewSize = LOWORD(lParam);
+ yNewSize = HIWORD(lParam);
+
+ fSize = TRUE;
+
+ xMaxScroll = max(screenwidth, xNewSize);
+ xCurrentScroll = min(xCurrentScroll, xMaxScroll);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = xMinScroll;
+ si.nMax = xMaxScroll;
+ si.nPage = xNewSize;
+ si.nPos = xCurrentScroll;
+ SetScrollInfo(my_window, SB_HORZ, &si, TRUE);
+
+ yMaxScroll = max(screendepth, yNewSize);
+ yCurrentScroll = min(yCurrentScroll, yMaxScroll);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
+ si.nMin = yMinScroll;
+ si.nMax = yMaxScroll;
+ si.nPage = yNewSize;
+ si.nPos = yCurrentScroll;
+ SetScrollInfo(my_window, SB_VERT, &si, TRUE);
+ }
+ case WM_PAINT:
+ {
+#ifdef DEBUG
+ fprintf(stderr, "WM_PAINT message hbm = %x\n", hbm);
+#endif
+ BeginPaint(my_window, &ps);
+ /* Shouldn't repaint all the screen, but so easy! */
+ if (!BitBlt(my_dc,
+ 0, 0,
+ screenwidth, screendepth,
+ drawing_dc,
+ xCurrentScroll,
+ yCurrentScroll, SRCCOPY))
+ Win32Error("Bitblt");
+ EndPaint(my_window, &ps);
+ retval = 0;
+ break;
+ }
+ case WM_HSCROLL:
+ {
+ int xDelta;
+ int xNewPos;
+ int yDelta = 0;
+ switch (LOWORD(wParam)) {
+ case SB_PAGEUP:
+ xNewPos = xCurrentScroll - 50;
+ break;
+ case SB_PAGEDOWN:
+ xNewPos = xCurrentScroll + 50;
+ break;
+ case SB_LINEUP:
+ xNewPos = xCurrentScroll - 5;
+ break;
+ case SB_LINEDOWN:
+ xNewPos = xCurrentScroll + 5;
+ break;
+ case SB_THUMBPOSITION:
+ xNewPos = HIWORD(wParam);
+ break;
+ default:
+ xNewPos = xCurrentScroll;
+ }
+ xNewPos = max(0, xNewPos);
+ xNewPos = min(xMaxScroll, xNewPos);
+
+ if (xNewPos == xCurrentScroll)
+ break;
+
+ fScroll = TRUE;
+
+ xDelta = xNewPos - xCurrentScroll;
+ xCurrentScroll = xNewPos;
+
+ ScrollWindowEx(my_window, -xDelta, -yDelta, (CONST RECT *)NULL,
+ (CONST RECT *)NULL, (HRGN)NULL, (LPRECT)NULL,
+ SW_INVALIDATE);
+ UpdateWindow(my_window);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = xCurrentScroll;
+ SetScrollInfo(my_window, SB_HORZ, &si, TRUE);
+ }
+ break;
+
+ case WM_VSCROLL:
+ {
+ int xDelta = 0;
+ int yNewPos;
+ int yDelta;
+ switch (LOWORD(wParam)) {
+ case SB_PAGEUP:
+ yNewPos = yCurrentScroll - 50;
+ break;
+ case SB_PAGEDOWN:
+ yNewPos = yCurrentScroll + 50;
+ break;
+ case SB_LINEUP:
+ yNewPos = yCurrentScroll - 5;
+ break;
+ case SB_LINEDOWN:
+ yNewPos = yCurrentScroll + 5;
+ break;
+ case SB_THUMBPOSITION:
+ yNewPos = HIWORD(wParam);
+ break;
+ default:
+ yNewPos = yCurrentScroll;
+ }
+ yNewPos = max(0, yNewPos);
+ yNewPos = min(yMaxScroll, yNewPos);
+
+ if (yNewPos == yCurrentScroll)
+ break;
+
+ fScroll = TRUE;
+
+ yDelta = yNewPos - yCurrentScroll;
+ yCurrentScroll = yNewPos;
+
+ ScrollWindowEx(my_window, -xDelta, -yDelta, (CONST RECT *)NULL,
+ (CONST RECT *)NULL, (HRGN)NULL, (LPRECT)NULL,
+ SW_INVALIDATE);
+ UpdateWindow(my_window);
+
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ si.nPos = yCurrentScroll;
+ SetScrollInfo(my_window, SB_VERT, &si, TRUE);
+ }
+ break;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ retval = 0;
+ break;
+ default:
+ retval = DefWindowProc(hwnd, iMsg, wParam, lParam);
+ break;
+ }
+ ReleaseMutex(hMutex);
+ return retval;
+#else
+ return DefWindowProc(hwnd, iMsg, wParam, lParam);
+#endif
+}
+
+#else
+int win32_dummy;
+#endif /* WIN32WIN */
diff --git a/Build/source/texk/web2c/window/win32.mak b/Build/source/texk/web2c/window/win32.mak
new file mode 100644
index 00000000000..8922108ffc8
--- /dev/null
+++ b/Build/source/texk/web2c/window/win32.mak
@@ -0,0 +1,48 @@
+################################################################################
+#
+# Makefile : Web2C / window metafont support
+# Author : Fabrice Popineau <Fabrice.Popineau@supelec.fr>
+# Platform : Win32, Microsoft VC++ 6.0, depends upon fpTeX 0.5 sources
+# Time-stamp: <01/12/14 19:41:51 popineau>
+#
+################################################################################
+root_srcdir = ..\..\..
+!ifdef DEVELOPMENT
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk.development
+!else
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk
+!endif
+
+USE_KPATHSEA = 1
+USE_GNUW32 = 1
+
+!include <msvc/common.mak>
+
+DEFS = -I.. $(DEFS) -DHAVE_CONFIG_H
+library = window
+
+#objects = $(objdir)\amiga.obj $(objdir)\hp2627.obj $(objdir)\mftalk.obj \
+# $(objdir)\next.obj $(objdir)\regis.obj $(objdir)\suntools.obj \
+# $(objdir)\tek.obj $(objdir)\trap.obj $(objdir)\uniterm.obj \
+# $(objdir)\x11.obj
+
+objects = $(objdir)\epsf.obj $(objdir)\win32.obj $(objdir)\trap.obj
+
+default: all
+
+all: $(objdir) $(objdir)\$(library).lib
+
+$(objdir)\$(library).lib: $(objects)
+ $(archive) $(objects)
+
+!include <msvc/config.mak>
+!include <msvc/install.mak>
+
+!include <msvc/clean.mak>
+
+!include <msvc/rdepend.mak>
+!include "./depend.mak"
+
+# Local Variables:
+# mode: Makefile
+# End:
diff --git a/Build/source/texk/web2c/window/x11-Xlib.c b/Build/source/texk/web2c/window/x11-Xlib.c
new file mode 100644
index 00000000000..52612cbf840
--- /dev/null
+++ b/Build/source/texk/web2c/window/x11-Xlib.c
@@ -0,0 +1,280 @@
+/*
+X Window System version 11 (release 3 et al.) interface for Metafont.
+
+Modified from Tim Morgan's X Version 11 routines by Richard Johnson.
+Modified from that by Karl Berry <karl@umb.edu>. 8/3/89
+
+MF can now understand geometry (sort of, at least on a Sun running 3.4
+and using uwm) in the resource database, as in the following in
+.Xdefaults to put a window of width 500 and height 600 at (200,50):
+
+Metafont*geometry: 500x600+200+200
+
+You cannot give the geometry on the command line (who would want to)?
+
+The width and height specified in the resource must not be larger than
+the screenwidth and screendepth defined in ../mf/cmf.ch.
+If they are, then I reset them to the maximum.
+
+We don't handle Expose events in general. This means that the window
+cannot be moved, resized, or obscured. The problem is that I don't know
+when we can look for such events. Adding a check to the main loop of
+Metafont was more than I wanted to do. Another problem is that Metafont
+does not keep track of the contents of the screen, and so I don't see
+how to know what to redraw. The right way to do this is probably to fork
+a process, and keep a Pixmap around of the contents of the window.
+
+I could never have done this without David Rosenthal's Hello World
+program for X. See $X/mit/doc/HelloWorld.
+
+All section numbers refer to Xlib -- C Language X Interface. */
+
+
+#define EXTERN extern
+#include "../mfd.h"
+
+
+#ifdef X11WIN
+
+#undef input /* the XWMHints structure has a field named `input' */
+#undef output
+
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+
+/* Variables for communicating between the routines we'll write. */
+
+static Display *my_display;
+static int my_screen;
+static Window my_window;
+static GC my_gc;
+static int white, black;
+
+
+/* Window manager hints. */
+
+static XWMHints wm_hints = {
+ (InputHint|StateHint), /* flags telling which values are set */
+ False, /* We don't expect input. */
+ NormalState, /* Initial state. */
+ 0, /* icon pixmap */
+ 0, /* icon window */
+ 0, 0, /* icon location (should get from resource?) */
+ 0, /* icon mask */
+ 0 /* window group */
+};
+
+
+/* Some constants for the resource database, etc. */
+#define PROGRAM_NAME "Metafont"
+#define ARG_GEOMETRY "geometry"
+#define BORDER_WIDTH 1 /* Should get this from resource. */
+#define DEFAULT_X_POSITION 0
+#define DEFAULT_Y_POSITION 0
+
+
+/* Return 1 (i.e., true) if display opened successfully, else 0. */
+
+int
+mf_x11_initscreen()
+{
+ char *geometry;
+ int geometry_found = 0;
+ char default_geometry[100];
+ XSizeHints sizehints;
+ XGCValues gcvalues;
+
+ /* We want the default display. (section 2.1 Opening the display) */
+ my_display = XOpenDisplay(NULL);
+ if (my_display == NULL) return 0;
+
+ /* Given a display, we can get the screen and the ``black'' and
+ ``white'' pixels. (section 2.2.1 Display macros) */
+ my_screen = DefaultScreen(my_display);
+ white = WhitePixel(my_display, my_screen);
+ black = BlackPixel(my_display, my_screen);
+
+
+ sizehints.x = DEFAULT_X_POSITION;
+ sizehints.y = DEFAULT_Y_POSITION;
+ sizehints.width = screenwidth;
+ sizehints.height = screendepth;
+ sizehints.flags = PPosition|PSize;
+
+ sprintf (default_geometry, "%ux%u+%u+%u", screenwidth, screendepth,
+ DEFAULT_X_POSITION, DEFAULT_Y_POSITION);
+
+ /* Look up the geometry for this window. (Section 10.2 Obtaining X
+ environment defaults) */
+ geometry = XGetDefault(my_display, PROGRAM_NAME, ARG_GEOMETRY);
+
+ if (geometry != NULL) {
+ /* (section 10.3 Parsing window geometry) */
+ int bitmask = XGeometry(my_display, my_screen,
+ geometry, default_geometry,
+ BORDER_WIDTH,
+ 1, 1, /* ``Font'' width and height. */
+ 0, 0, /* Interior padding. */
+ &(sizehints.x), &(sizehints.y),
+ &(sizehints.width), &(sizehints.height));
+
+ /* (section 9.1.6 Setting and getting window sizing hints) */
+ if (bitmask & (XValue|YValue)) {
+ sizehints.flags |= USPosition;
+ geometry_found = 1;
+ }
+
+ if (bitmask & (WidthValue|HeightValue)) {
+ sizehints.flags |= USSize;
+ if (sizehints.width > screenwidth) sizehints.width = screenwidth;
+ if (sizehints.height > screendepth) sizehints.height = screendepth;
+ geometry_found = 1;
+ }
+ }
+
+
+ /* Our window is pretty simple. (section 3.3 Creating windows) */
+ my_window = XCreateSimpleWindow(my_display,
+ DefaultRootWindow(my_display), /* parent */
+ sizehints.x, sizehints.y, /* upper left */
+ sizehints.width, sizehints.height,
+ BORDER_WIDTH,
+ black, /* border color */
+ white); /* background color */
+
+ /* (section 9.1.1 Setting standard properties) */
+ XSetStandardProperties(my_display, my_window,
+ PROGRAM_NAME, /* window name */
+ PROGRAM_NAME, /* icon name */
+ None, /* pixmap for icon */
+ 0, 0, /* argv and argc for restarting */
+ &sizehints);
+ XSetWMHints(my_display, my_window, &wm_hints);
+
+
+ /* We need a graphics context if we're going to draw anything.
+ (section 5.3 Manipulating graphics context/state) */
+ gcvalues.foreground = black;
+ gcvalues.background = white;
+ /* A ``thin'' line. This is much faster than a line of length 1,
+ although the manual cautions that the results might be less
+ consistent across screens. */
+ gcvalues.line_width = 0;
+
+ my_gc = XCreateGC(my_display, my_window,
+ GCForeground|GCBackground|GCLineWidth,
+ &gcvalues);
+
+ /* (section 3.5 Mapping windows) This is the confusing part of the
+ program, at least to me. If no geometry spec was found, then the
+ window manager puts up the blinking rectangle, and the user clicks,
+ all before the following call returns. But if a geometry spec was
+ found, then we want to do a whole mess of other things, because the
+ window manager is going to send us an expose event so that we can
+ bring our window up -- and this is one expose event we have to
+ handle. */
+ XMapWindow(my_display, my_window);
+
+ if (geometry_found) {
+ /* The window manager sends us an Expose event. Yuck.
+ */
+ XEvent my_event;
+ /* We certainly don't want to handle anything else.
+ (section 8.5 Selecting events)
+ */
+ XSelectInput(my_display, my_window, ExposureMask);
+
+ /* We also want to do this right now. This is the confusion. From
+ stepping through the program under the debugger, it appears
+ that it is this call to XSync (given the previous call to
+ XSelectInput) that actually brings the window up -- and yet
+ without the remaining code, the thing doesn't work right. Very
+ strange. (section 8.6 Handling the output buffer)
+ */
+ XSync(my_display, 0);
+
+ /* Now get the event. (section 8.8.1 Returning the next event)
+ */
+ XNextEvent(my_display, &my_event);
+
+ /* Ignore all but the last of the Expose events.
+ (section 8.4.5.1 Expose event processing)
+ */
+ if (my_event.type == Expose && my_event.xexpose.count == 0) {
+ /* Apparently the network might STILL have my_events coming in.
+ Let's throw away Expose my_events again. (section 8.8.3
+ Selecting my_events using a window or my_event mask)
+ */
+ while (XCheckTypedEvent(my_display, Expose, &my_event)) ;
+
+ /* Finally, let's draw the blank screen.
+ */
+ XClearWindow(my_display, my_window);
+ }
+ }
+
+ /* That's it. */
+ return 1;
+}
+
+
+/* Make sure the screen is up to date. (section 8.6 Handling the output
+buffer) */
+
+void
+mf_x11_updatescreen()
+{
+ XFlush(my_display);
+}
+
+
+/* Blank the rectangular inside the given coordinates. We don't need to
+reset the foreground to black because we always set it at the beginning
+of paintrow (below). */
+
+void
+mf_x11_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ XSetForeground(my_display, my_gc, white);
+ XFillRectangle(my_display, my_window, my_gc,
+ (int) left,
+ (int) top,
+ (unsigned) (right - left + 1),
+ (unsigned) (bottom - top + 1));
+}
+
+
+/* Paint a row with the given ``transition specifications''. We might be
+able to do something here with drawing many lines. */
+
+void
+mf_x11_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, tvect,
+ register screencol, vector_size)
+{
+ register int color, col;
+
+ color = (init_color == 0) ? white : black;
+
+ do {
+ col = *tvect++;
+ XSetForeground(my_display, my_gc, color);
+
+ /* (section 6.3.2 Drawing single and multiple lines)
+ */
+ XDrawLine(my_display, my_window, my_gc, col, (int) row,
+ (int) *tvect, (int) row);
+
+ color = (color == white) ? black : white;
+ } while (--vector_size > 0);
+}
+
+#else
+int x11_dummy;
+#endif /* X11WIN */
diff --git a/Build/source/texk/web2c/window/x11-Xt.c b/Build/source/texk/web2c/window/x11-Xt.c
new file mode 100644
index 00000000000..c22a586fb92
--- /dev/null
+++ b/Build/source/texk/web2c/window/x11-Xt.c
@@ -0,0 +1,370 @@
+/* x11.c: X11 window interface for Metafont, using Xt. Original by
+ rusty@garnet.berkeley.edu. */
+
+#define EXTERN extern
+#include "../mfd.h"
+
+#ifdef X11WIN /* almost whole file */
+
+/* For wchar_t et al., that the X files might want. */
+#include <kpathsea/systypes.h>
+
+/* See xdvik/xdvi.h for the purpose of the FOIL... */
+#ifdef FOIL_X_WCHAR_T
+#define wchar_t foil_x_defining_wchar_t
+#define X_WCHAR
+#endif
+#undef input /* the XWMHints structure has a field named `input' */
+#undef output
+#include <X11/Xlib.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#undef wchar_t
+
+#define PLANE 0
+
+static unsigned int mf_defwidth = 0;
+static unsigned int mf_defheight = 0;
+
+static Display *mf_display;
+static Window mf_window;
+
+static Pixmap mf_pixmap;
+
+static XtAppContext mf_app;
+
+static GC mf_dgc; /* draw gc */
+static GC mf_egc; /* erase gc */
+static GC mf_cgc; /* copy plane gc */
+
+typedef struct
+{
+ unsigned int mf_width, mf_height;
+ Pixel mf_fg, mf_bg;
+} mf_resources_struct;
+
+static mf_resources_struct mf_x11_resources;
+
+
+/* Don't paint anything until we're mapped. */
+static Boolean mf_mapped;
+
+#ifdef MF_XT_DEBUG
+static int mf_max_x, mf_max_y;
+static int mf_min_x, mf_min_y;
+
+static void mf_checkextent ();
+#endif
+
+static XtResource mf_resources[]
+ = { { "width", "Width", XtRInt, sizeof (int),
+ XtOffset (mf_resources_struct *, mf_width), XtRInt,
+ (XtPointer) & mf_defwidth },
+
+ { "height", "Height", XtRInt, sizeof (int),
+ XtOffset (mf_resources_struct *, mf_height), XtRInt,
+ (XtPointer) &mf_defheight },
+
+ { "foreground", "Foreground", XtRPixel, sizeof (Pixel),
+ XtOffset (mf_resources_struct *, mf_fg),
+ XtRString, (XtPointer) "Black" },
+
+ { "background", "Background", XtRPixel, sizeof (Pixel),
+ XtOffset (mf_resources_struct *, mf_bg), XtRString,
+ (XtPointer) "White" },
+};
+
+/* Maybe someday we'll read options, until then, this is just here for
+ the resources. */
+static XrmOptionDescRec mf_optiondesclist[]
+= { { "-width", "width", XrmoptionSepArg, (XPointer) NULL },
+ { "-height", "height", XrmoptionSepArg, (XPointer) NULL },
+ { "-fg", "foreground", XrmoptionSepArg, (XPointer) NULL },
+ { "-bg", "background", XrmoptionSepArg, (XPointer) NULL },
+};
+
+static void mf_events ();
+static void mf_mapstatus ();
+static void mf_newpixmap P2H(unsigned int, unsigned int);
+static void mf_redraw ();
+static void mf_repaint ();
+
+/* Return 1 if display opened successfully, else 0. */
+
+int
+mf_x11_initscreen ()
+{
+ XSetWindowAttributes xwa;
+ Widget mf_toplevel;
+ Widget mf_canvas;
+ XGCValues gcv;
+ Arg args[1];
+ int mf_argc;
+ char *mf_argv[2];
+
+ mf_argv[0] = "mf";
+ mf_argv[1] = NULL;
+ mf_argc = 1;
+
+ mf_toplevel = XtInitialize ("mf", "Metafont",
+ mf_optiondesclist,
+ XtNumber (mf_optiondesclist),
+ &mf_argc, mf_argv);
+
+ XtGetApplicationResources (mf_toplevel, (XtPointer) & mf_x11_resources,
+ mf_resources, XtNumber (mf_resources),
+ NULL, 0);
+
+ if (mf_argc != 1)
+ {
+ fprintf (stderr, "Usage: %s\n", mf_argv[0]);
+ return 0;
+ }
+
+ /* If nothing specified in their resources (e.g., .Xdefaults)
+ then use the values of Metafont's "screen". */
+ if (mf_x11_resources.mf_width == 0)
+ mf_x11_resources.mf_width = screenwidth;
+ if (mf_x11_resources.mf_height == 0)
+ mf_x11_resources.mf_height = screendepth;
+
+ mf_canvas = XtCreateManagedWidget ("canvas", widgetClass, mf_toplevel,
+ NULL, 0);
+
+ XtSetArg (args[0], XtNwidth, mf_x11_resources.mf_width);
+ XtSetValues (mf_canvas, args, 1);
+ XtSetArg (args[0], XtNheight, mf_x11_resources.mf_height);
+ XtSetValues (mf_canvas, args, 1);
+
+ /* for mf_x11_updatescreen() */
+ mf_app = XtWidgetToApplicationContext (mf_canvas);
+
+ XtAddEventHandler (mf_canvas, (Cardinal) ExposureMask, True,
+ mf_repaint, NULL);
+ XtAddEventHandler (mf_canvas, (Cardinal) StructureNotifyMask, True,
+ mf_mapstatus, NULL);
+
+ XtRealizeWidget (mf_toplevel);
+
+ mf_display = XtDisplay (mf_canvas);
+ mf_window = XtWindow (mf_canvas);
+
+ /* Since Metafont isn't your typical x window program that
+ sits in XTMainLoop, if the server supports backing store
+ and save unders this will help keep the output looking
+ nice. */
+ xwa.backing_store = Always;
+ xwa.save_under = True;
+ XChangeWindowAttributes (mf_display, mf_window,
+ CWBackingStore | CWSaveUnder, &xwa);
+
+ gcv.background = mf_x11_resources.mf_bg;
+ gcv.foreground = mf_x11_resources.mf_fg;
+ gcv.function = GXcopy;
+
+ /* copy plane gc */
+ mf_cgc = XCreateGC (mf_display, mf_window,
+ GCForeground | GCBackground | GCFunction, &gcv);
+
+ mf_newpixmap (screenwidth > mf_x11_resources.mf_width
+ ? screenwidth : mf_x11_resources.mf_width,
+ screendepth > mf_x11_resources.mf_height
+ ? screendepth : mf_x11_resources.mf_height);
+
+ return 1;
+}
+
+void
+mf_x11_updatescreen ()
+{
+ mf_events ();
+ mf_redraw ();
+
+#ifdef MF_XT_DEBUG
+ printf ("max_x=%d, min_x=%d, max_y=%d, min_y=%d\n",
+ mf_max_x, mf_min_x,
+ mf_max_y, mf_min_y);
+#endif
+}
+
+
+void
+mf_x11_blankrectangle P4C(screencol, left,
+ screencol, right,
+ screenrow, top,
+ screenrow, bottom)
+{
+ XFillRectangle (mf_display, mf_pixmap, mf_egc, (int) left, (int) top,
+ (int) (right - left + 1), (int) (bottom - top + 1));
+ mf_events ();
+}
+
+void
+mf_x11_paintrow P4C(screenrow, row,
+ pixelcolor, init_color,
+ transspec, tvect,
+ register screencol, vector_size)
+{
+ GC gc;
+ int col;
+
+ gc = (init_color == 0) ? mf_egc : mf_dgc;
+
+ do
+ {
+ col = *tvect++;
+
+#ifdef MF_XT_DEBUG
+ mf_checkextent (col, *tvect, row);
+#endif /* MF_XT_DEBUG */
+
+ XDrawLine (mf_display, mf_pixmap, gc, col, (int) row,
+ (int) *tvect, (int) row);
+
+ gc = (gc == mf_egc) ? mf_dgc : mf_egc;
+ }
+ while (--vector_size > 0);
+
+ mf_events ();
+}
+
+#ifdef MF_XT_DEBUG
+static void
+mf_checkextent P3C(int, x1, int, x2, int, y)
+{
+ if (x1 < mf_min_x)
+ mf_min_x = x1;
+ if (x1 > mf_max_x)
+ mf_max_x = x1;
+
+ if (x2 < mf_min_x)
+ mf_min_x = x2;
+ if (x2 > mf_max_x)
+ mf_max_x = x2;
+
+ if (y > mf_max_y)
+ mf_max_y = y;
+ if (y < mf_min_y)
+ mf_min_y = y;
+}
+#endif /* MF_XT_DEBUG */
+
+static void
+mf_events ()
+{
+ XEvent event;
+
+ if (XtAppPending (mf_app) != 0)
+ {
+ while (XtAppPending (mf_app) != 0)
+ {
+ XtAppNextEvent (mf_app, &event);
+ XtDispatchEvent (&event);
+ }
+ }
+}
+
+static void
+mf_newpixmap P2C(unsigned int, width, unsigned int, height)
+{
+ XGCValues gcv;
+ Pixmap newpixmap;
+
+ /* width == mf_width and height == mf_height
+ the first time mf_newpixmap() is called.
+ */
+ if (width < mf_x11_resources.mf_width && height < mf_x11_resources.mf_height)
+ return;
+
+ newpixmap = XCreatePixmap (mf_display, mf_window, width, height, 1);
+
+ gcv.background = 0;
+ gcv.foreground = 1;
+
+ if (mf_dgc != 0)
+ XFreeGC (mf_display, mf_dgc);
+
+ /* draw gc */
+ gcv.line_width = 1;
+ mf_dgc = XCreateGC (mf_display, newpixmap,
+ GCForeground | GCBackground | GCLineWidth, &gcv);
+
+ if (mf_egc != 0)
+ XFreeGC (mf_display, mf_egc);
+
+ /* erase gc */
+ gcv.foreground = 0;
+ mf_egc = XCreateGC (mf_display, newpixmap,
+ GCForeground | GCBackground | GCLineWidth, &gcv);
+
+ XFillRectangle (mf_display, newpixmap, mf_egc, 0, 0, width, height);
+
+ if (mf_pixmap != 0)
+ {
+ XCopyArea (mf_display, mf_pixmap, newpixmap, mf_dgc, 0, 0,
+ mf_x11_resources.mf_width,
+ mf_x11_resources.mf_height, 0, 0);
+
+ XFreePixmap (mf_display, mf_pixmap);
+ }
+
+ mf_pixmap = newpixmap;
+
+ mf_x11_resources.mf_width = width;
+ mf_x11_resources.mf_height = height;
+}
+
+static void
+mf_repaint P3C(Widget, w, XtPointer, data, XEvent*, ev)
+{
+ if (!mf_mapped || !ev || ev->type != Expose)
+ return;
+
+ /* We are a ``simple application''. */
+ if (ev->xexpose.count == 0)
+ {
+ XEvent event;
+
+ /* skip all excess redraws */
+ while (XCheckTypedEvent (mf_display, Expose, &event) != False)
+ continue;
+
+ mf_redraw ();
+ }
+}
+
+
+static void
+mf_mapstatus P3C(Widget, w, XtPointer, data, XEvent*, ev)
+{
+ switch (ev->type)
+ {
+ case MapNotify:
+ mf_mapped = True;
+ break;
+
+ case UnmapNotify:
+ mf_mapped = False;
+ break;
+
+ case ConfigureNotify:
+ mf_newpixmap (ev->xconfigure.width, ev->xconfigure.height);
+ mf_redraw ();
+ break;
+ }
+}
+
+
+static void
+mf_redraw ()
+{
+ XCopyPlane (mf_display, mf_pixmap, mf_window, mf_cgc, 0, 0,
+ mf_x11_resources.mf_width, mf_x11_resources.mf_height,
+ 0, 0, (unsigned long) 1);
+
+ XFlush (mf_display);
+}
+
+#else
+int x11_dummy;
+#endif /* X11WIN */