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 Feb 12 05:10:00 2001
@@ -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 Feb 12 05:10:00 2001
@@ -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.180 kit/draw.c:1.181
--- kit/draw.c:1.180	Sun Feb  4 03:46:50 2001
+++ kit/draw.c	Thu Feb  8 17:54:13 2001
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: draw.c,v 1.180 2001/02/03 18:46:50 nishida Exp $
+ * $Id: draw.c,v 1.181 2001/02/08 08:54:13 nishida Exp $
  */
 
 #include "mgp.h"
@@ -132,6 +132,7 @@
 static void obj_draw_anim __P((struct render_state *, 
 	u_int, u_int, struct render_object *));
 #endif
+static int valign = VL_BOTTOM;
 
 #define CHECK_CACHE {if (caching){caching = -1; return;}}
 
@@ -788,6 +789,10 @@
 		break;
 #endif
 
+	case CTL_VALIGN:
+		valign = cp->cti_value;
+		break;
+
 	default:
 		fprintf(stderr,
 			"undefined directive %d at page %d line %d:\n\t",
@@ -2806,8 +2811,18 @@
 		goto end;
 	}
 
-	/* because vertloc of image is VL_TOP */
-	draw_line_itemsize(state, height * yzoomrate / 100, 0);
+	switch(valign){
+	case VL_TOP:
+		draw_line_itemsize(state, 0, height * yzoomrate / 100);
+		break;
+	case VL_BOTTOM:
+		draw_line_itemsize(state, height * yzoomrate / 100, 0);
+		break;
+	case VL_CENTER:
+		draw_line_itemsize(state, height * yzoomrate / 200, 
+			height * yzoomrate / 200);
+		break;
+	}
 
 	if (centerflag)
 		image_posx = char_size[caching] / 2 - (width * xzoomrate / 100) / 2;
@@ -3919,6 +3934,8 @@
 	if (cached_page == page || page > maxpage || page <= 0)
 		return;
 
+	if (!page_attribute[page].pg_linenum) return;
+
 	XFlush(display);
 	memset(state, 0, sizeof(struct render_state));
 	state->target = cachewin;  /*XXX*/
@@ -4066,7 +4083,8 @@
 	struct render_state *state;
 {
 	if (!caching && cached_page != state->page 
-			&& page_attribute[state->page].pg_text){
+			&& page_attribute[state->page].pg_text
+			&& page_attribute[state->page].pg_linenum){
 		cache_page(&cache_state, state->page);
 		set_from_cache(state);
 		pcache_process(state->page);
@@ -4103,7 +4121,10 @@
 			back_gradation(state, &ctl->ct_val.ctrl_grad);
 			break;
 		case CTL_BACK:
+			break;
 		default:
+			fprintf(stderr, "fatal error in get_background_image()\n");
+			cleanup(-1);
 			break;
 		}
 	}
@@ -4170,7 +4191,8 @@
 		XSetWindowBackground(display, window, ctl->ctl_value);
 		break;
 	default:
-		fprintf(stderr, "fatal error in set_background_image()\n");
+		fprintf(stderr, "fatal error in set_background_image() %d\n", 
+			ctl->ct_op);
 		cleanup(-1);
 		break;
 	}
@@ -4296,8 +4318,17 @@
 	obj_new_anim(state, state->linewidth, - height, 
 		width, height, cp->ctc_value, cp);
 
-	/* XXX specify VL_CENTER. This suites my taste. :P  */
-	draw_line_itemsize(state, height /2 , height /2);
+	switch(valign){
+	case VL_TOP:
+		draw_line_itemsize(state, 0, height);
+		break;
+	case VL_BOTTOM:
+		draw_line_itemsize(state, height, 0);
+		break;
+	case VL_CENTER:
+		draw_line_itemsize(state, height /2 , height /2);
+		break;
+	}
 
 	state->linewidth += width;
 	state->brankline = 0;
Index: kit/globals.c
diff -u kit/globals.c:1.43 kit/globals.c:1.44
--- kit/globals.c:1.43	Sun Feb  4 03:46:50 2001
+++ kit/globals.c	Thu Feb  8 17:54:13 2001
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: globals.c,v 1.43 2001/02/03 18:46:50 nishida Exp $
+ * $Id: globals.c,v 1.44 2001/02/08 08:54:13 nishida Exp $
  */
 
 #include "mgp.h"
@@ -146,5 +146,6 @@
 /*CTL*/	{ CTL_TMFONT0,		T_STR,	"tmfont0", 7 },
 /*CTL*/	{ CTL_PCACHE,		T_SP,	"pcache", 6 },
 /*CTL*/	{ CTL_ANIM,		T_STR,	"anim", 4 },
+/*CTL*/	{ CTL_VALIGN,		T_STR,	"valign", 6 },
 	{ 0, 0, NULL, 0 },
 };
Index: kit/grammar.y
diff -u kit/grammar.y:1.36 kit/grammar.y:1.37
--- kit/grammar.y:1.36	Sun Feb  4 03:46:50 2001
+++ kit/grammar.y	Thu Feb  8 17:54:13 2001
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: grammar.y,v 1.36 2001/02/03 18:46:50 nishida Exp $
+ * $Id: grammar.y,v 1.37 2001/02/08 08:54:13 nishida Exp $
  */
 /*
  * partly derived from lbl libpcap source code, which has the following
@@ -518,6 +518,34 @@
 	return ct;
 }
 
+static struct ctrl *
+gen_valign(align)
+	char *align;
+{
+	struct ctrl *ct;
+
+	if (!(ct = ctlalloc1(CTL_VALIGN))) {
+		yyerror("cannot allocate node (op=VALIGN)");
+		return ct;
+	}
+	if (!strcmp(align, "center")) 
+		ct->cti_value = VL_CENTER;
+	else { 
+		if (!strcmp(align, "top")) 
+			ct->cti_value = VL_TOP;
+		else {
+			if (!strcmp(align, "bottom")) 
+				ct->cti_value = VL_BOTTOM;
+			else {
+				yyerror("%valign center|top|bottom");
+				ctlfree(ct);
+				return NULL;
+			}
+		}
+	}
+	return ct;
+}
+
 #if 0
 
 static struct ctrl *
@@ -669,7 +697,7 @@
 %token KW_LINESTART KW_LINEEND KW_MARK KW_SYSTEM KW_FILTER KW_ENDFILTER
 %token KW_QUALITY KW_ICON KW_LEFTFILL KW_XSYSTEM KW_VFCAP KW_TFONT KW_TFDIR
 %token KW_DEFFONT KW_FONT KW_TFONT0 KW_EMBED KW_ENDEMBED KW_NEWIMAGE
-%token KW_CHARSET KW_TMFONT KW_PCACHE KW_TMFONT0 KW_ANIM
+%token KW_CHARSET KW_TMFONT KW_PCACHE KW_TMFONT0 KW_ANIM KW_VALIGN
 
 %type <ct> toplevel
 %type <ct> line defaultline tabline shellline deffontline
@@ -924,6 +952,9 @@
 			yywarn("directive \"anim\" not supported "
 					"in this configuration");
 #endif
+	}
+	| KW_VALIGN STRorID	{
+			$$ = gen_valign($2);
 	}
 	;
 tabcmd:	  KW_TAB NUM	{ $$ = gen_int(CTL_TAB, $2); }
Index: kit/print.c
diff -u kit/print.c:1.92 kit/print.c:1.93
--- kit/print.c:1.92	Tue Jan 23 00:52:41 2001
+++ kit/print.c	Thu Feb  8 17:54:13 2001
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: print.c,v 1.92 2001/01/22 15:52:41 nishida Exp $
+ * $Id: print.c,v 1.93 2001/02/08 08:54:13 nishida Exp $
  */
 /*
  * Paper size selection code is based on psutil.c by Angus J. C. Duggan
@@ -53,6 +53,7 @@
 static int painticon = 0;
 static u_int curlinenum;
 static u_int curpagenum;
+static u_int valign = VL_BOTTOM;
 
 #ifdef FREETYPE
 static u_int usetfont = 0;
@@ -764,6 +765,10 @@
 		fprintf(fp,"markx marky moveto /xpos markx def /ypos marky def\n");
 		break;
 
+	case CTL_VALIGN:
+		valign = cp->cti_value;
+		break;
+
 	default:
 		break;
 	}
@@ -883,7 +888,18 @@
 		}
 	}
 	fprintf(fp, "/yypos ypos charsize imgsize gt \n");
-	fprintf(fp, " { 0 } { imgsize charsize sub } ifelse sub def\n");
+
+	switch(valign){
+	case VL_TOP:
+		fprintf(fp, " { 0 } { 0 } ifelse sub def\n");
+		break;
+	case VL_BOTTOM:
+		fprintf(fp, " { 0 } { imgsize charsize sub } ifelse sub def\n");
+		break;
+	case VL_CENTER:
+		fprintf(fp, " { 0 } { imgsize charsize sub 2 div } ifelse sub def\n");
+		break;
+	}
 	fprintf(fp, "xpos yypos ymax sub moveto\n");
 
 	for (i = 0; i < ntextpool; i++) {
Index: kit/scanner.l
diff -u kit/scanner.l:1.20 kit/scanner.l:1.21
--- kit/scanner.l:1.20	Sun Feb  4 03:46:50 2001
+++ kit/scanner.l	Thu Feb  8 17:54:14 2001
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 /*
- * $Id: scanner.l,v 1.20 2001/02/03 18:46:50 nishida Exp $
+ * $Id: scanner.l,v 1.21 2001/02/08 08:54:14 nishida Exp $
  */
 /*
  * partly derived from lbl libpcap source code, which has the following
@@ -163,6 +163,7 @@
 (CHARSET|charset)	return KW_CHARSET;
 (PCACHE|pcache)	return KW_PCACHE;
 (ANIM|anim)	return KW_ANIM;
+(VALIGN|valign)	return KW_VALIGN;
 
 [ \n\t]		;
 ","		return COMMA;
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 Feb 12 05:10:01 2001
@@ -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/sample/cloud.gif
Index: kit/sample/dad.gif
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
