Index: kit/CHANGELOG
diff -u kit/CHANGELOG:1.9 kit/CHANGELOG:removed
--- kit/CHANGELOG:1.9	Sat Sep  5 00:11:21 1998
+++ kit/CHANGELOG	Mon Sep  6 05:10:01 2004
@@ -1,51 +0,0 @@
-CHANGELOG for magicpoint
-$Id: CHANGELOG,v 1.9 1998/09/04 15:11:21 onoe Exp $
-
-Fri Sep  5 1998  onoe@sm.sony.co.jp
-	* handle key inputs from invoked terminal as pressed on Xserver,
-	  even if the Xserver is running on a remote host.
-
-Mon Aug 26 1998  itojun@iijlab.net
-	* new copyright. (BSDish copyright without clause 3)
-
-Mon Aug 25 1998  itojun@iijlab.net
-	* print.c: better x11/freetype/vflib -> postscript font mapping.
-
-Mon Aug 23 1998  kato@wide.ad.jp
-	* embedded image support (added mgpembed.pl and embed.c)
-
-Mon Aug 22 1998  itojun@iijlab.net
-	* added contrib/xmindpath, MindPath PocketPoint user-level driver.
-
-Fri Jul 10 11:57:59 JST 1998  itojun@iijlab.net
-	* cache gs-generated image file.
-	  Suggested by: luigi@FreeBSD.org
-
-Mon Jul  6 11:38:32 JST 1998  itojun@iijlab.net
-	* capable of handling GB2312 and KSC5601 encoding.
-	  they must be encoded by using iso-2022 like escape sequences.
-	  EUC-cn or EUC-kr does not work.
-	* -x option is added.
-
-Thu Jul  2 18:04:16 JST 1998  itojun@iijlab.net
-	* eliminate gsview.
-	* revamp "xfont" directive. (see SYNTAX for detail)
-
-Thu Jun 25 13:10:28 JST 1998  itojun@iijlab.net
-	* print.c: color postscript support by "mgp2ps -c".
-
-changes between 1.02a and 1.03a:
-	* To allow color name that has space inbetween ("dark blue"), 
-	  color name after directives SHOULD come with doublequote.
-	  Therefore,
-		%fore blue
-	  should be
-		%fore "blue"
-	  At this moment, doublequote can be ommitted for backward
-	  compatibility.  We may require to have doublequote in the future.
-	  Font names and other string parameter obeys the same rule.
-	* %image is now capable of rendering encapsulated postscript files
-	  (*.eps).
-		%image foo.eps
-	  should work fine.
-	  By using -X option, you can specify device name for ghostscript.
Index: kit/ctlwords.pl
diff -u kit/ctlwords.pl:1.2 kit/ctlwords.pl:removed
--- kit/ctlwords.pl:1.2	Sat Sep  5 06:05:08 1998
+++ kit/ctlwords.pl	Mon Sep  6 05:10:01 2004
@@ -1,12 +0,0 @@
-#! /usr/bin/perl
-$counter = 0;	# 0 origin
-print "/* generated by ctlwords.awk. do not edit by hand. */\n";
-
-while (<>) {
-	next if (!/^\/\*CTL\*\//);
-	next if ($_ !~ /(CTL_[A-Z0-9]+)/);
-
-	$word = $1;
-	print "#define $word\t$counter\n";
-	$counter++;
-}
Index: kit/draw.c
diff -u kit/draw.c:1.221 kit/draw.c:1.223
--- kit/draw.c:1.221	Fri Aug 20 01:28:57 2004
+++ kit/draw.c	Sat Sep  4 02:58:30 2004
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: draw.c,v 1.221 2004/08/19 16:28:57 nishida Exp $
+ * $Id: draw.c,v 1.223 2004/09/03 17:58:30 nishida Exp $
  */
 
 #include "mgp.h"
@@ -1040,6 +1040,7 @@
 	state->ypos += 2;
 }
 
+#define min(x, y) (x < y ? x: y)  
 static void
 cutin(state, lx, ly, dir)
 	struct render_state *state;
@@ -1048,15 +1049,11 @@
 	int dir;
 {
 	u_int step, x, xoff, yoff;
-	int i;
-	int sx;
-	int round;
-	Window cutinWin;
-
-#ifdef USE_M17N
-	// we cannot use cutin with m17n-lib so far.
-	return;
-#endif
+	int i, sx, round;
+	int root_x, root_y, use_copy;
+	Window cutinWin, junkwin;
+	XImage *copywin; 
+	static XWindowAttributes xa;
 
 	if (state->repaint)
 		return;
@@ -1064,6 +1061,14 @@
 	if (!state->linewidth)
 		return;
 
+	if (!xa.width) 
+		XGetWindowAttributes(display, DefaultRootWindow(display), &xa);
+	XTranslateCoordinates(display, window, DefaultRootWindow(display), 
+		0, 0, &root_x ,&root_y, &junkwin);
+	use_copy = 1;
+	if ((root_x + window_width > xa.width) || (root_y + window_height > xa.height) ||
+			(root_x < 0 || root_y < 0)) use_copy = 1;
+
 	sx = (0 < dir) ? 0 : state->width - state->linewidth;
 	round = 20;	/*XXX*/
 #ifndef abs
@@ -1076,29 +1081,42 @@
 
 	step = (lx - sx) / round;
 
-	cutinWin = XCreateSimpleWindow(display, state->target,
-		sx, ly, state->linewidth, state->maxascent + state->maxdescent,
-		0, fore_color[caching], back_color[caching]);
-	XSetWindowBackgroundPixmap(display, cutinWin, None);
-	XMapSubwindows(display, state->target);
+	if (!use_copy){
+		cutinWin = XCreateSimpleWindow(display, state->target,
+			sx, ly, state->linewidth, state->maxascent + state->maxdescent,
+			0, fore_color[caching], back_color[caching]);
+		XSetWindowBackgroundPixmap(display, cutinWin, None);
+		XMapSubwindows(display, state->target);
+	} else {
+		copywin = XGetImage(display, window, state->xoff + min(sx, lx), ly + state->yoff, state->linewidth + abs(lx - sx),	
+					state->maxascent + state->maxdescent, AllPlanes, ZPixmap);
+	}
 
 	xoff = state->xoff;	
 	yoff = state->yoff;	
 	state->xoff = state->yoff = 0;
-	if (state->obj) {
+	if (state->obj && !use_copy) {
 		obj_draw(state, cutinWin, 0, 0);
 	}
 	XFlush(display);
 
 	x = sx;
 	for (i = 0; i < round; i++) {
-		XMoveWindow(display, cutinWin, x + xoff, ly + yoff);
+		if (use_copy && state->obj) 
+				obj_draw(state, state->target, x + xoff, ly + yoff);
+		else 
+				XMoveWindow(display, cutinWin, x + xoff, ly + yoff);
 		XFlush(display);
 		usleep(CUTIN_DELAY);
+		if (use_copy && state->obj) {
+			XPutImage(display, state->target, gc_cache, copywin, 
+				x - min(sx, lx) , 0, x + xoff, ly + yoff, 
+				state->linewidth, state->maxascent + state->maxdescent);
+		}
 		x += step;
 	}
 
-	XDestroyWindow(display, cutinWin);
+	if (!use_copy) XDestroyWindow(display, cutinWin);
 	state->xoff = xoff;	
 	state->yoff = yoff;	
 }
@@ -4633,8 +4651,7 @@
 	static char etab[3][20] = { "iso-2022-jp", "gb2312", "ksc5601"};
 	static char rtab[3][20] = { "jisx208", "gb2312", "ksc5601"};
 	static char prefix[3][20] = { "\033$B", "\033$A", "\033$(C"};
-	char buf16[1024];
-	const char *p16;
+	char buf16[1024], *p16;
 	char out16[1024], *o16;
 	int ileft, oleft;
 #ifdef HAVE_ICONV
Index: kit/mng.c
diff -u kit/mng.c:1.1 kit/mng.c:1.2
--- kit/mng.c:1.1	Sun Feb  4 03:46:50 2001
+++ kit/mng.c	Wed Sep  1 12:50:32 2004
@@ -4,7 +4,7 @@
 /*
 	mngplay
 
-	$Date: 2001/02/03 18:46:50 $
+	$Date: 2004/09/01 03:50:32 $
 
 	Ralph Giles <giles@ashlu.bc.ca>
 
@@ -19,7 +19,7 @@
 	patches welcome.
 */
 /*
- * $Id: mng.c,v 1.1 2001/02/03 18:46:50 nishida Exp $
+ * $Id: mng.c,v 1.2 2004/09/01 03:50:32 nishida Exp $
  */
 
 #ifdef MNG
@@ -43,6 +43,8 @@
 	mng_uint32	delay;     /* ticks to wait before resuming decode */
 } mngstuff;
 
+void mng_window_setup __P((mngstuff *mymng, int x, int y, int width, int height));
+
 /* callbacks for the mng decoder */
 
 /* memory allocation; data must be zeroed */
@@ -228,7 +230,7 @@
 	return (0);
 }
 
-int mymngquit()
+void mymngquit()
 {
 	mngstuff	*mymng;
 
Index: kit/image/gif.h
diff -u kit/image/gif.h:1.2 kit/image/gif.h:removed
--- kit/image/gif.h:1.2	Mon Dec 28 17:23:03 1998
+++ kit/image/gif.h	Mon Sep  6 05:10:01 2004
@@ -1,72 +0,0 @@
-/* gif.h:
- *
- * gifin.h
- * kirk johnson
- * november 1989
- * external interface to gifin.c
- *
- * Copyright 1989 Kirk L. Johnson (see the included file
- * "kljcpyrght.h" for complete copyright information)
- */
-
-/*
- * gifin return codes
- */
-#define GIFIN_SUCCESS       0   /* success */
-#define GIFIN_DONE          1   /* no more images */
-
-#define GIFIN_ERR_BAD_SD   -1   /* bad screen descriptor */
-#define GIFIN_ERR_BAD_SEP  -2   /* bad image separator */
-#define GIFIN_ERR_BAD_SIG  -3   /* bad signature */
-#define GIFIN_ERR_EOD      -4   /* unexpected end of raster data */
-#define GIFIN_ERR_EOF      -5   /* unexpected end of input stream */
-#define GIFIN_ERR_FAO      -6   /* file already open */
-#define GIFIN_ERR_IAO      -7   /* image already open */
-#define GIFIN_ERR_NFO      -8   /* no file open */
-#define GIFIN_ERR_NIO      -9   /* no image open */
-
-/*
- * colormap indices 
- */
-
-#define GIF_RED  0
-#define GIF_GRN  1
-#define GIF_BLU  2
-
-/*
- * typedef BYTE for convenience
- */
-
-typedef unsigned char BYTE;
-
-static int gifin_open_file();
-static int gifin_open_image();
-static int gifin_get_pixel();
-#if 0
-static int gifin_close_image();
-#endif
-static int gifin_close_file();
-static int gifin_load_cmap();
-static int gifin_skip_extension();
-static int gifin_read_data_block();
-static int gifin_push_string();
-static void gifin_add_string();
-static void gifin_fatal();
-
-/* #defines, typedefs, and such
- */
-
-#define GIF_SIG      "GIF87a"
-#define GIF_SIG_89   "GIF89a"
-#define GIF_SIG_LEN  6          /* GIF signature length */
-#define GIF_SD_SIZE  7          /* GIF screen descriptor size */
-#define GIF_ID_SIZE  9          /* GIF image descriptor size */
-
-#define GIF_SEPARATOR   ','     /* GIF image separator */
-#define GIF_EXTENSION   '!'     /* GIF extension block marker */
-#define GIF_TERMINATOR  ';'     /* GIF terminator */
-
-#define STAB_SIZE  4096         /* string table size */
-#define PSTK_SIZE  4096         /* pixel stack size */
-
-#define NULL_CODE  -1           /* string table null code */
Index: kit/image/imagetypes.h
diff -u kit/image/imagetypes.h:1.5 kit/image/imagetypes.h:1.6
--- kit/image/imagetypes.h:1.5	Thu Jan 18 18:07:14 2001
+++ kit/image/imagetypes.h	Wed Sep  1 12:50:32 2004
@@ -44,5 +44,5 @@
 int imIdent();
 #ifdef USE_PNG
 int pngIdent();
-int pngLoad();
+Image *pngLoad();
 #endif
Index: kit/image/new.c
diff -u kit/image/new.c:1.4 kit/image/new.c:1.5
--- kit/image/new.c:1.4	Thu Jul 29 00:47:31 2004
+++ kit/image/new.c	Wed Sep  1 12:50:32 2004
@@ -25,39 +25,39 @@
  */
 
 unsigned long DepthToColorsTable[] = {
-  /*  0 */ 1,
-  /*  1 */ 2,
-  /*  2 */ 4,
-  /*  3 */ 8,
-  /*  4 */ 16,
-  /*  5 */ 32,
-  /*  6 */ 64,
-  /*  7 */ 128,
-  /*  8 */ 256,
-  /*  9 */ 512,
-  /* 10 */ 1024,
-  /* 11 */ 2048,
-  /* 12 */ 4096,
-  /* 13 */ 8192,
-  /* 14 */ 16384,
-  /* 15 */ 32768,
-  /* 16 */ 65536,
-  /* 17 */ 131072,
-  /* 18 */ 262144,
-  /* 19 */ 524288,
-  /* 20 */ 1048576,
-  /* 21 */ 2097152,
-  /* 22 */ 4194304,
-  /* 23 */ 8388608,
-  /* 24 */ 16777216,
-  /* 25 */ 33554432,
-  /* 26 */ 67108864,
-  /* 27 */ 134217728,
-  /* 28 */ 268435456,
-  /* 29 */ 536870912,
-  /* 30 */ 1073741824,
-  /* 31 */ 2147483648,
-  /* 32 */ 2147483648 /* bigger than unsigned int; this is good enough */
+  /*  0 */ 1UL,
+  /*  1 */ 2UL,
+  /*  2 */ 4UL,
+  /*  3 */ 8UL,
+  /*  4 */ 16UL,
+  /*  5 */ 32UL,
+  /*  6 */ 64UL,
+  /*  7 */ 128UL,
+  /*  8 */ 256UL,
+  /*  9 */ 512UL,
+  /* 10 */ 1024UL,
+  /* 11 */ 2048UL,
+  /* 12 */ 4096UL,
+  /* 13 */ 8192UL,
+  /* 14 */ 16384UL,
+  /* 15 */ 32768UL,
+  /* 16 */ 65536UL,
+  /* 17 */ 131072UL,
+  /* 18 */ 262144UL,
+  /* 19 */ 524288UL,
+  /* 20 */ 1048576UL,
+  /* 21 */ 2097152UL,
+  /* 22 */ 4194304UL,
+  /* 23 */ 8388608UL,
+  /* 24 */ 16777216UL,
+  /* 25 */ 33554432UL,
+  /* 26 */ 67108864UL,
+  /* 27 */ 134217728UL,
+  /* 28 */ 268435456UL,
+  /* 29 */ 536870912UL,
+  /* 30 */ 1073741824UL,
+  /* 31 */ 2147483648UL,
+  /* 32 */ 2147483648UL /* bigger than unsigned int; this is good enough */
 };
 
 unsigned long colorsToDepth(ncolors)
Index: kit/sample/cloud.gif
Index: kit/sample/dad.gif
Index: kit/sample/dns-jp.mgp
diff -u kit/sample/dns-jp.mgp:1.5 kit/sample/dns-jp.mgp:removed
--- kit/sample/dns-jp.mgp:1.5	Fri Sep  4 21:33:18 1998
+++ kit/sample/dns-jp.mgp	Mon Sep  6 05:10:01 2004
@@ -1,130 +0,0 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
-%%	This file is automatically created from the file
-%%	main.pre modified at Fri Jan 23 14:31:24 1998
-%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
-%include "default.mgp"
-%% "noop" cancels definitions in default.mgp
-%default 1 left, size 7, fore "light yellow", back "blue4", font "standard", ccolor "white", vgap 35
-%default 2 noop
-%default 3 fore "white", bar "gray70", vgap 10
-%default 4 noop
-%tab 1 noop
-%tab 2 noop
-%tab 3 noop
-%%%
-%page
-%nodefault
-%fore "red", back "blue4", size 9, vgap 15
-%center, fore "yellow", font "thick"
-%ccolor "white"
-
-
-
-Root DNS `M' $B$K$D$$$F(B
-
-%size 6, fore "red", font "thick"
-$B2CF#(B   $BO/(B
-
-%size 5, fore "white", font "standard"
-$BEl5~Bg3XBg7?7W;;5!%;%s%?!<(B
-
-
-%font "typewriter"
-kato@wide.ad.jp
-%font "standard"
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B7P0^(B (1)
-%fore "red", size 6, font "thick"
-   $B!y(B Root DNS
-%fore "white", size 5, font "standard"
-       $B!&(B $B#9Bf$G1?MQ(B
-%fore "white", size 5, font "standard"
-          $B!](B $B#8Bf$,(B US
-          $B!](B Stockholm $B$K#1Bf(B
-%fore "white", size 5, font "standard"
-       $B!&(B $B:GBg$G#1#3Bf(B
-%fore "white", size 5, font "standard"
-          $B!](B $B%Q%1%C%HD9$N@)Ls(B
-%fore "red", size 6, font "thick"
-   $B!y(B Root DNS $B$N1?MQ4p=`(B
-%fore "white", size 5, font "standard"
-       $B!&(B RFC 2010
-       $B!&(B gTLD $B$H$N4X78(B
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B7P0^(B (2)
-%fore "red", size 6, font "thick"
-   $B!y(B IEPG $B$G3HD%$r8!F$(B
-   $B!y(B $B%h!<%m%C%QCO0h(B
-%fore "white", size 5, font "standard"
-       $B!&(B LINX $B$K?7@_(B : 1997 $BG/(B 4 $B7n(B
-%fore "white", size 5, font "standard"
-          $B!](B RIPE/NCC $B$,4IM}(B
-          $B!](B `K'
-%fore "red", size 6, font "thick"
-   $B!y(B $B%"%8%"B@J?MNCO0h(B
-%fore "white", size 5, font "standard"
-       $B!&(B NSPIXP-2 $B!'(B 1997 $BG/(B 8 $B7n(B
-%fore "white", size 5, font "standard"
-          $B!](B WIDE $B$,4IM}(B
-          $B!](B `M'
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  `M'
-%fore "red", size 6, font "thick"
-   $B!y(B $B9=@.(B
-%fore "white", size 5, font "standard"
-       $B!&(B $B#2Bf$N(B PentiumPro 200MHz
-       $B!&(B Primary/Backup$B!"(B $B<+F0@Z$jBX$((B
-%fore "red", size 6, font "thick"
-   $B!y(B Root-only $B%5!<%P(B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-202.12.27.33
-%font "standard"
-       $B!&(B 400 $B!A(B 500 query/sec
-%fore "red", size 6, font "thick"
-   $B!y(B $B1?MQ4IM}(B
-%fore "white", size 5, font "standard"
-       $B!&(B WIDE $B$*$h$S(B ISP $BM-;V(B
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%page
-
-%back "blue4"
-  $B$*4j$$(B
-%fore "red", size 6, font "thick"
-   $B!y(B $B:G?7$N(B root.cache $B$NF~$l49$((B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-1997082200
-%fore "red", size 6, font "thick"
-   $B!y(B Named $B$N99?7(B
-%fore "white", size 5, font "standard"
-       $B!&(B 4.9.6/8.8.1
-%fore "red", size 6, font "thick"
-   $B!y(B $BM7$P$J$$$G!'(B
-%fore "white", size 5, font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-ping/traceroute
-%font "standard"
-       $B!&(B 
-%cont, font "typewriter"
-telnet/spray/...
-%fore "red", size 6, font "thick"
-   $B!y(B Thanks to
-%fore "white", size 5, font "standard"
-       $B!&(B $BF|K\(B Cisco/$BB?$/$N(B ISP
-       $B!&(B `M' $B4IM}%0%k!<%W(B
Index: kit/sample/mgp-old1.gif
Index: kit/sample/mgp-old2.gif
Index: kit/sample/mgp-old3.gif
Index: kit/sample/mgp1.gif
Index: kit/sample/mgp2.gif
Index: kit/sample/mgp3.gif
Index: kit/sample/v6header.gif
