[comp.sources.x] v04i013: kterm -- Kanji

argv@island.uu.net (Dan Heller) (05/31/89)

Submitted-by: Hiroto Kagotani <kagotani@cs.titech.ac.jp>
Posting-number: Volume 4, Issue 13
Archive-name: kterm/part04

diff -rc ../xterm/data.c ./data.c
*** ../xterm/data.c	Wed Sep  7 06:08:02 1988
--- ./data.c	Tue May 30 14:53:39 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: data.c,v 1.4 88/09/06 17:08:01 jim Exp $
+  *	$Header: data.c,v 1.1 89/05/30 14:53:38 kagotani Rel $
   */
  
  #include <X11/copyright.h>
***************
*** 35,40 ****
--- 36,42 ----
  
  #ifndef lint
  static char rcs_id[] = "$XConsortium: data.c,v 1.4 88/09/06 17:08:01 jim Exp $";
+ static char kterm_id[] = "$Header: data.c,v 1.1 89/05/30 14:53:38 kagotani Rel $";
  #endif	/* lint */
  
  XPoint T_boxlarge[NBOX] = {
***************
*** 84,89 ****
--- 86,109 ----
  	{0, 0},
  	{0, 0},
  };
+ #ifdef	KANJI	/* sano */
+ XPoint VTwbox[NBOX] = {
+ 	{0, 0},
+ 	{0, 0},
+ 	{0, 0},
+ 	{0, 0},
+ 	{0, 0},
+ };
+ #endif	KANJI
+ #ifdef	STATUSLINE	/* michael */
+ XPoint status_box[NBOX] = {
+ 	{0, 0},
+ 	{0, 0},
+ 	{0, 0},
+ 	{0, 0},
+ 	{0, 0},
+ };
+ #endif	STATUSLINE
  T_fontsize Tfontsize[TEKNUMFONTS] = {
  	{9, 15},	/* large */
  	{8, 13},	/* #2 */
diff -rc ../xterm/data.h ./data.h
*** ../xterm/data.h	Wed Sep  7 06:08:03 1988
--- ./data.h	Tue May 30 14:53:40 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: data.h,v 1.3 88/09/06 17:08:02 jim Exp $
+  *	$Header: data.h,v 1.1 89/05/30 14:53:40 kagotani Rel $
   */
  
  
***************
*** 38,44 ****
--- 39,51 ----
  extern XPoint T_boxlarge[];
  extern XPoint T_boxsmall[];
  extern XPoint VTbox[];
+ #ifdef	KANJI	/* sano */
+ extern XPoint VTwbox[];
+ #endif	KANJI
  extern T_fontsize Tfontsize[];
+ #ifdef	STATUSLINE	/* michael */
+ extern XPoint status_box[];
+ #endif	STATUSLINE
  extern char *Tbptr;
  extern char *Tbuffer;
  extern char *Tpushb;
diff -rc ../xterm/main.c ./main.c
*** ../xterm/main.c	Fri May  5 00:43:59 1989
--- ./main.c	Tue May 30 14:53:47 1989
***************
*** 1,5 ****
--- 1,6 ----
  #ifndef lint
  static char rcs_id[] = "$XConsortium: main.c,v 1.99 89/01/04 14:33:47 jim Exp $";
+ static char kterm_id[] = "$Header: main.c,v 1.1 89/05/30 14:53:43 kagotani Rel $";
  #endif	/* lint */
  
  /*
***************
*** 121,126 ****
--- 122,131 ----
  #endif
  #endif
  
+ #ifdef KEEPALIVE
+ #include <sys/socket.h>
+ #endif
+ 
  #include "ptyx.h"
  #include "data.h"
  #include "error.h"
***************
*** 271,276 ****
--- 276,284 ----
      char *tty_modes;
      Boolean utmpInhibit;
      Boolean sunFunctionKeys;	/* %%% should be widget resource? */
+ #ifdef KEEPALIVE
+     Boolean keepalive;
+ #endif
  } resource;
  
  #ifndef GETTY_EXE
***************
*** 285,291 ****
--- 293,303 ----
  
  static XtResource application_resources[] = {
      {"name", "Name", XtRString, sizeof(char *),
+ #ifdef	KANJI	/* sano */
+ 	offset(xterm_name), XtRString, "kterm"},
+ #else	KANJI
  	offset(xterm_name), XtRString, "xterm"},
+ #endif	KANJI
      {"iconGeometry", "IconGeometry", XtRString, sizeof(char *),
  	offset(icon_geometry), XtRString, (caddr_t) NULL},
      {XtNtitle, XtCTitle, XtRString, sizeof(char *),
***************
*** 300,305 ****
--- 312,321 ----
  	offset(utmpInhibit), XtRString, "false"},
      {"sunFunctionKeys", "SunFunctionKeys", XtRBoolean, sizeof (Boolean),
  	offset(sunFunctionKeys), XtRString, "false"},
+ #ifdef KEEPALIVE
+     {"keepAlive", "KeepAlive", XtRBoolean, sizeof (Boolean),
+ 	offset(keepalive), XtRString, "false"},
+ #endif
  };
  #undef offset
  
***************
*** 323,330 ****
--- 339,357 ----
  {"+cu",		"*curses",	XrmoptionNoArg,		(caddr_t) "off"},
  {"-e",		NULL,		XrmoptionSkipLine,	(caddr_t) NULL},
  {"-fb",		"*boldFont",	XrmoptionSepArg,	(caddr_t) NULL},
+ #ifdef	KANJI	/* sano */
+ {"-fr",		"*kanaFont",	XrmoptionSepArg,	(caddr_t) NULL},
+ {"-frb",	"*kanaboldFont",XrmoptionSepArg,	(caddr_t) NULL},
+ {"-fk",		"*kanjiFont",	XrmoptionSepArg,	(caddr_t) NULL},
+ {"-fkb",	"*kanjiboldFont", XrmoptionSepArg,	(caddr_t) NULL},
+ {"-km",		"*kanjiMode",	XrmoptionSepArg,	(caddr_t) NULL},
+ #endif	KANJI
  {"-j",		"*jumpScroll",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+j",		"*jumpScroll",	XrmoptionNoArg,		(caddr_t) "off"},
+ #ifdef KEEPALIVE
+ {"-ka",		"*keepAlive",	XrmoptionNoArg,		(caddr_t) "on"},
+ {"+ka",		"*keepAlive",	XrmoptionNoArg,		(caddr_t) "off"},
+ #endif
  {"-l",		"*logging",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+l",		"*logging",	XrmoptionNoArg,		(caddr_t) "off"},
  {"-lf",		"*logFile",	XrmoptionSepArg,	(caddr_t) NULL},
***************
*** 347,352 ****
--- 374,385 ----
  {"+si",		"*scrollInput",	XrmoptionNoArg,		(caddr_t) "on"},
  {"-sk",		"*scrollKey",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+sk",		"*scrollKey",	XrmoptionNoArg,		(caddr_t) "off"},
+ #ifdef	STATUSLINE	/* michael */
+ {"-st",		"*statusLine",	XrmoptionNoArg,		(caddr_t) "on"},
+ {"+st",		"*statusLine",	XrmoptionNoArg,		(caddr_t) "off"},
+ {"-sn",		"*statusNormal",XrmoptionNoArg,		(caddr_t) "on"},
+ {"+sn",		"*statusNormal",XrmoptionNoArg,		(caddr_t) "off"},
+ #endif	STATUSLINE
  {"-sl",		"*saveLines",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-t",		"*tekStartup",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+t",		"*tekStartup",	XrmoptionNoArg,		(caddr_t) "off"},
***************
*** 395,401 ****
--- 428,444 ----
  { "-cr color",             "text cursor color" },
  { "-/+cu",                 "turn on/off curses emulation" },
  { "-fb fontname",          "bold text font" },
+ #ifdef	KANJI	/* sano */
+ { "-fr fontname",          "normal kana font" },
+ { "-frb fontname",         "bold kana font" },
+ { "-fk fontname",          "normal kanji font" },
+ { "-fkb fontname",         "bold kanji font" },
+ { "-km kanjimode",         "input kanji code (jis|euc|sjis)" },
+ #endif	KANJI
  { "-/+j",                  "turn on/off jump scroll" },
+ #ifdef KEEPALIVE
+ { "-/+ka",                  "turn on/off keeping connection alive" },
+ #endif
  { "-/+l",                  "turn on/off logging" },
  { "-lf filename",          "logging filename" },
  { "-/+ls",                 "turn on/off login shell" },
***************
*** 410,415 ****
--- 453,462 ----
  { "-/+si",                 "turn on/off scroll-on-input inhibit" },
  { "-/+sk",                 "turn on/off scroll-on-keypress" },
  { "-sl number",            "number of scrolled lines to save" },
+ #ifdef	STATUSLINE	/* michael */
+ { "-sn",                   "make status line normal video" },
+ { "-st",                   "turn on status line" },
+ #endif	STATUSLINE
  { "-/+t",                  "turn on/off Tek emulation window" },
  { "-tm string",            "terminal mode keywords and characters" },
  { "-tn name",              "TERM environment variable name" },
***************
*** 627,638 ****
--- 674,701 ----
  	    }
  	}
  	/* Init the Toolkit. */
+ #ifdef	KANJI	/* sano */
+ 	toplevel = XtInitialize("xterm", "KTerm",
+ #else	KANJI
  	toplevel = XtInitialize("xterm", "XTerm",
+ #endif	KANJI
  		optionDescList, XtNumber(optionDescList), &argc, argv);
  
  	XtGetApplicationResources( toplevel, &resource, application_resources,
  				   XtNumber(application_resources), NULL, 0 );
  
+ #ifdef KEEPALIVE
+ 	if (resource.keepalive) {
+ 		int     on = 1;
+ 		(void)setsockopt(ConnectionNumber(XtDisplay(toplevel)),
+ 				SOL_SOCKET, SO_KEEPALIVE,
+ 				(char *)&on, sizeof(on));
+ 	}
+ #endif
+ #ifdef KANJI
+ 	/* Atom Initialize */
+ 	SelAtomInitialize();
+ #endif
  	/*
  	 * fill in terminal modes
  	 */
***************
*** 649,655 ****
--- 712,722 ----
  
  	xterm_name = resource.xterm_name;
  	sunFunctionKeys = resource.sunFunctionKeys;
+ #ifdef	KANJI	/* sano */
+ 	if (strcmp(xterm_name, "-") == 0) xterm_name = "kterm";
+ #else	KANJI
  	if (strcmp(xterm_name, "-") == 0) xterm_name = "xterm";
+ #endif	KANJI
  	if (resource.icon_geometry != NULL) {
  	    int scr, junk;
  	    Arg args[2];
***************
*** 743,748 ****
--- 810,831 ----
  #endif /* DO_AUTOREPEAT */
  	if (!screen->jumpscroll)	term->flags |= SMOOTHSCROLL;
  	if (term->misc.reverseWrap)		term->flags |= REVERSEWRAP;
+ #ifdef	KANJI	/* sano */
+ 	/*
+ 	 * Reflect the kanji mode into the flags.
+ 	 * Note that SJIS_KANJI and EUC_KANJI are mutually exclusive.
+ 	 * Reset both bits if `jis' is specified.
+ 	 */
+ 	if (term->misc.k_m)
+ 		if (strcmp(term->misc.k_m, "euc") == 0) {
+ 			term->flags &= ~SJIS_KANJI;
+ 			term->flags |= EUC_KANJI;
+ 		} else if (strcmp(term->misc.k_m, "sjis") == 0) {
+ 			term->flags &= ~EUC_KANJI;
+ 			term->flags |= SJIS_KANJI;
+ 		} else if (strcmp(term->misc.k_m, "jis") == 0)
+ 			term->flags &= ~(EUC_KANJI | SJIS_KANJI);
+ #endif
  
  	inhibit = 0;
  	if (term->misc.logInhibit)			inhibit |= I_LOG;
***************
*** 749,754 ****
--- 832,841 ----
  	if (term->misc.signalInhibit)		inhibit |= I_SIGNAL;
  	if (term->misc.tekInhibit)			inhibit |= I_TEK;
  
+ #ifdef	STATUSLINE	/* michael */
+ 	screen->reversestatus = !term->misc.statusnormal;
+ #endif	STATUSLINE
+ 
  	term->initflags = term->flags;
  
  /*
***************
*** 1035,1040 ****
--- 1122,1130 ----
  };
  
  static char *vtterm[] = {
+ #ifdef	KANJI	/* sano */
+ 	"kterm",
+ #endif	KANJI
  #ifdef USE_X11TERM
  	"x11term",		/* for people who want special term name */
  #endif
***************
*** 1537,1543 ****
--- 1627,1642 ----
  		    }
  #endif	/* TIOCCONS */
  #else	/* USE_SYSV_TERMIO */
+ #ifdef	KANJI	/* michael */
+ 		    /*
+ 		     * EUC and SJIS require 8bit transparent pty module.
+ 		     * Even in such a case, parity should not be specified.
+ 		     */
+ 		    sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW
+ 					| EVENP | ODDP);
+ #else	KANJI
  		    sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW);
+ #endif	KANJI
  		    sg.sg_flags |= ECHO | CRMOD;
  		    /* make sure speed is set on pty so that editors work right*/
  		    sg.sg_ispeed = B9600;
diff -rc ../xterm/main.h ./main.h
*** ../xterm/main.h	Wed Sep  7 06:08:13 1988
--- ./main.h	Tue May 30 14:53:49 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: main.h,v 1.3 88/09/06 17:08:12 jim Exp $
+  *	$Header: main.h,v 1.1 89/05/30 14:53:48 kagotani Rel $
   */
  
  
***************
*** 30,36 ****
--- 31,48 ----
  
  /* @(#)main.h\tX10/6.6\t11/10/86 */
  
+ #ifdef	KANJI
+ #define	DEFBOLDFONT		" "
+ #define	DEFBORDER		2
+ #define	DEFBORDERWIDTH		1
+ #define	DEFFONT			"a14"
+ #define	DEFKANAFONT		"kana14"
+ #define	DEFKANABOLDFONT		" "
+ #define	DEFKANJIFONT		"k14"
+ #define	DEFKANJIBOLDFONT	" "
+ #else	KANJI
  #define	DEFBOLDFONT		"fixed"
  #define	DEFBORDER		2
  #define	DEFBORDERWIDTH		2
  #define	DEFFONT			"fixed"
+ #endif	KANJI
diff -rc ../xterm/ptyx.h ./ptyx.h
*** ../xterm/ptyx.h	Mon Nov 21 13:12:07 1988
--- ./ptyx.h	Tue May 30 14:53:52 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: ptyx.h,v 1.20 88/11/16 18:13:26 rws Exp $
+  *	$Header: ptyx.h,v 1.1 89/05/30 14:53:51 kagotani Rel $
   */
  
  #include <X11/copyright.h>
***************
*** 106,111 ****
--- 107,119 ----
  #endif	/* !hpux */
  #endif	/* !PTYCHAR2 */
  
+ #ifdef KANJI
+ #ifndef WCHAR_T
+ #define WCHAR_T
+ typedef unsigned short	wchar_t;
+ #endif
+ #endif
+ 
  /* Until the translation manager comes along, I have to do my own translation of
   * mouse events into the proper routines. */
  
***************
*** 164,170 ****
--- 172,182 ----
  	unsigned	flags;	/* Vt100 saves graphics rendition. Ugh! */
  	char		curgl;
  	char		curgr;
+ #ifdef	KANJI	/* sano */
+ 	short		gsets[4];
+ #else	KANJI
  	char		gsets[4];
+ #endif	KANJI
  } SavedCursor;
  
  #define	TEKNUMFONTS	4
***************
*** 205,212 ****
--- 217,240 ----
  	GC		reverseGC;	/* reverse painting		*/
  	GC		normalboldGC;	/* normal painting, bold font	*/
  	GC		reverseboldGC;	/* reverse painting, bold font	*/
+ #ifdef	KANJI	/* sano */
+ 	GC		r_normalGC;	/* normal GR painting		*/
+ 	GC		r_reverseGC;	/* reverse GR painting		*/
+ 	GC		r_normalboldGC;	/* normal GR painting, bold font*/
+ 	GC		r_reverseboldGC;/* reverse GR painting, bold font*/
+ 	GC		w_normalGC;	/* normal kanji painting	*/
+ 	GC		w_reverseGC;	/* reverse kanji painting	*/
+ 	GC		w_normalboldGC;	/* normal kanji, bold font	*/
+ 	GC		w_reverseboldGC;/* reverse kanji, bold font	*/
+ #endif	KANJI
  	GC		cursorGC;	/* normal cursor painting	*/
  	GC		reversecursorGC;/* reverse cursor painting	*/
+ #ifdef	KANJI	/* michael */
+ 	GC		r_cursorGC;	/* normal kana cursor painting	*/
+ 	GC		r_reversecursorGC;/* reverse kana cursor 	*/
+ 	GC		w_cursorGC;	/* normal kanji cursor painting	*/
+ 	GC		w_reversecursorGC;/* reverse kanji cursor 	*/
+ #endif	KANJI
  	GC		cursoroutlineGC;/* for painting lines around    */
  	Pixel		foreground;	/* foreground color		*/
  	Pixel		cursorcolor;	/* Cursor color			*/
***************
*** 242,248 ****
--- 270,287 ----
  	/* Terminal fonts must be of the same size and of fixed width */
  	XFontStruct	*fnt_norm;	/* normal font of terminal	*/
  	XFontStruct	*fnt_bold;	/* bold font of terminal	*/
+ #ifdef	KANJI	/* sano */
+ 	XFontStruct	*fnt_r_norm;	/* normal GR font of terminal	*/
+ 	XFontStruct	*fnt_r_bold;	/* bold GR font of terminal	*/
+ 	XFontStruct	*fnt_w_norm;	/* normal kanji font of terminal*/
+ 	XFontStruct	*fnt_w_bold;	/* bold kanji font of terminal	*/
+ #endif	KANJI
  	int		enbolden;	/* overstrike for bold font	*/
+ #ifdef	KANJI	/* sano */
+ 	int		r_enbolden;	/* overstrike for GR bold	*/
+ 	int		w_enbolden;	/* overstrike for kanji bold	*/
+ 	XPoint		*w_box;		/* draw unselected cursor	*/
+ #endif	KANJI
  	XPoint		*box;		/* draw unselected cursor	*/
  
  	int		cursor_state;	/* ON or OFF			*/
***************
*** 283,291 ****
--- 322,341 ----
  	int		scrolls;	/* outstanding scroll count	*/
  	SavedCursor	sc;		/* data for restore cursor	*/
  	int		save_modes[19];	/* save dec private modes	*/
+ #ifdef	STATUSLINE	/* michael */
+ 	Boolean		statusline;	/* status line showing		*/
+ 	int		statusheight;	/* status line height		*/
+ 	Boolean		instatus;	/* cursor in status line	*/
+ 	SavedCursor	statussc;	/* status line restore cursor	*/
+ 	Boolean		reversestatus;	/* status line reversed		*/
+ #endif	STATUSLINE
  
  	/* Improved VT100 emulation stuff.				*/
+ #ifdef	KANJI	/* sano */
+ 	short		gsets[4];	/* G0 through G3.		*/
+ #else	KANJI
  	char		gsets[4];	/* G0 through G3.		*/
+ #endif	KANJI
  	char		curgl;		/* Current GL setting.		*/
  	char		curgr;		/* Current GR setting.		*/
  	char		curss;		/* Current single shift.	*/
***************
*** 334,340 ****
--- 384,394 ----
  	char		*charClass;	/* for overriding word selection */
  	Boolean		cutNewline;	/* whether or not line cut has \n */
  	Boolean		cutToBeginningOfLine;  /* line cuts to BOL? */
+ #ifdef KANJI
+ 	wchar_t		*selection;	/* the current selection */
+ #else
  	char		*selection;	/* the current selection */
+ #endif
  	int		selection_size; /* size of allocated buffer */
  	int		selection_length; /* number of significant bytes */
  	int		selection_time;	/* latest event timestamp */
***************
*** 362,367 ****
--- 416,428 ----
      char *T_geometry;
      char *f_n;
      char *f_b;
+ #ifdef	KANJI	/* sano */
+     char *f_rn;
+     char *f_rb;
+     char *f_kn;
+     char *f_kb;
+     char *k_m;
+ #endif
      Boolean log_on;
      Boolean login_shell;
      Boolean re_verse;
***************
*** 371,376 ****
--- 432,440 ----
      Boolean tekInhibit;
      Boolean scrollbar;
      Boolean titeInhibit;
+ #ifdef	STATUSLINE	/* michael */
+     Boolean statusnormal;
+ #endif	STATUSLINE
  } Misc;
  
  typedef struct {int foo;} XtermClassPart, TekClassPart;
***************
*** 418,423 ****
--- 482,504 ----
  #define INVERSE		0x01	/* invert the characters to be output */
  #define UNDERLINE	0x02	/* true if underlining */
  #define BOLD		0x04
+ #ifdef	KANJI	/* sano */
+ #define	KCS		0x18	/* true if on KANJI char */
+ #define	KCS1		0x08	/* true if on the first byte of a Kanji char */
+ #define	KCS2		0x10	/* true if on the second byte of a Kanji char */
+ #define	KANACS		0x20	/* true if on KANA char */
+ #define WRAPAROUND	0x2000
+ #define REVERSE_VIDEO	0x4000	/* true if screen white on black */
+ #define ORIGIN		0x8000	/* true if in origin mode */
+ #define INSERT		0x10000	/* true if in insert mode */
+ #define SMOOTHSCROLL	0x20000	/* true if in smooth scroll mode */
+ #define AUTOREPEAT	0x40000	/* true if in autorepeat mode */
+ #define IN132COLUMNS	0x80000	/* true if in 132 column mode */
+ #define LINEFEED	0x100000
+ #define	REVERSEWRAP	0x200000/* true if reverse wraparound mode */
+ #define	EUC_KANJI	0x400000/* true if in EUC mode */
+ #define	SJIS_KANJI	0x800000/* true if in SJIS mode */
+ #else	KANJI
  #define WRAPAROUND	0x08
  #define REVERSE_VIDEO	0x10	/* true if screen white on black */
  #define ORIGIN		0x20	/* true if in origin mode */
***************
*** 429,438 ****
--- 510,528 ----
  #define IN132COLUMNS	0x200	/* true if in 132 column mode */
  #define LINEFEED	0x400
  #define	REVERSEWRAP	0x800	/* true if reverse wraparound mode */
+ #endif	KANJI
  
+ #ifdef	KANJI	/* sano */
+ #define	ATTRIBUTES	0x3f	/* attributes mask including KCS/KANACS */
+ #else	KANJI
  #define	ATTRIBUTES	0x07	/* attributes mask */
+ #endif	KANJI
  #define CHAR		0177
  
+ #ifdef	KANJI	/* sano */
+ #define	MBCS		0x80	/* MBCS stands for Multi Byte Character Set */
+ #endif	KANJI
+ 
  #define VWindow(screen)		(screen->fullVwin.window)
  #define VShellWindow		term->core.parent->core.window
  #define TextWindow(screen)      (screen->fullVwin.window)
***************
*** 452,459 ****
--- 542,556 ----
  
  #define CursorX(screen,col) ((col) * FontWidth(screen) + screen->border \
  			+ screen->scrollbar)
+ #ifdef	STATUSLINE	/* michael */
+ #define	CursorY(screen,row) ((screen->instatus?\
+ 			((row) * FontHeight(screen) + 1)\
+ 			: (((row) - screen->topline) * FontHeight(screen)))\
+ 			+ screen->border)
+ #else	STATUSLINE
  #define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \
  			+ screen->border)
+ #endif	STATUSLINE
  
  #define	TWINDOWEVENTS	(KeyPressMask | ExposureMask | ButtonPressMask |\
  			 ButtonReleaseMask | StructureNotifyMask |\
diff -rc ../xterm/screen.c ./screen.c
*** ../xterm/screen.c	Thu May  4 20:19:27 1989
--- ./screen.c	Tue May 30 14:53:54 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: screen.c,v 1.10 89/01/03 16:18:06 jim Exp $
+  *	$Header: screen.c,v 1.1 89/05/30 14:53:53 kagotani Rel $
   */
  
  #include <X11/copyright.h>
***************
*** 31,36 ****
--- 32,38 ----
  
  #ifndef lint
  static char rcs_id[] = "$XConsortium: screen.c,v 1.10 89/01/03 16:18:06 jim Exp $";
+ static char kterm_id[] = "$Header: screen.c,v 1.1 89/05/30 14:53:53 kagotani Rel $";
  #endif	/* lint */
  
  #include <X11/Xlib.h>
***************
*** 57,62 ****
--- 59,67 ----
  {
  	register ScrnBuf base;
  
+ #ifdef	STATUSLINE	/* kato */
+ 	nrow++;
+ #endif	STATUSLINE
  	if ((base = (ScrnBuf) calloc ((unsigned)(nrow *= 2), sizeof (char *))) == 0)
  		SysError (ERROR_SCALLOC);
  
***************
*** 90,95 ****
--- 95,109 ----
  	att = screen->buf[avail + 1] + screen->cur_col;
  	flags &= ATTRIBUTES;
  	Bcopy(str, col, length);
+ #ifdef	KANJI	/* sano */
+ 	if (flags & KCS) {
+ 		while (length > 0) {
+ 			*att++ = flags & ~KCS2;
+ 			*att++ = flags & ~KCS1;
+ 			length -= 2;
+ 		}
+ 	} else
+ #endif	KANJI
  	while(length-- > 0)
  		*att++ = flags;
  }
***************
*** 224,234 ****
--- 238,260 ----
  	int maxrow = toprow + nrows - 1;
  	int scrollamt = screen->scroll_amt;
  	int max = screen->max_row;
+ #ifdef	STATUSLINE	/* michael */
+ 	int dostatus = 0, left, width;
+ #endif	STATUSLINE
  
+ #ifdef	STATUSLINE	/* michael */
+ 	if (screen->statusline && maxrow == screen->max_row + 1) {
+ 		dostatus++;
+ 		maxrow--;
+ 	}
+ #endif	STATUSLINE
  	if(screen->cursor_col >= leftcol && screen->cursor_col <=
  	 (leftcol + ncols - 1) && screen->cursor_row >= toprow + topline &&
  	 screen->cursor_row <= maxrow + topline)
  		screen->cursor_state = OFF;
+ #ifdef	STATUSLINE	/* michael */
+ 	for ( ; ; ) {
+ #endif	STATUSLINE
  	for (row = toprow; row <= maxrow; y += FontHeight(screen), row++) {
  	   register char *chars;
  	   register char *att;
***************
*** 283,297 ****
  	       hilite = True;
  	   }
  
  	   if (col > maxcol) continue;
  
  	   flags = att[col];
  
  	   if ( (!hilite && (flags & INVERSE) != 0) ||
  	        (hilite && (flags & INVERSE) == 0) )
  	       if (flags & BOLD) gc = screen->reverseboldGC;
  	       else gc = screen->reverseGC;
! 	   else 
  	       if (flags & BOLD) gc = screen->normalboldGC;
  	       else gc = screen->normalGC;
  
--- 309,377 ----
  	       hilite = True;
  	   }
  
+ #ifdef	KANJI	/* sano */
+ 	   if ((att[col] & KCS2) && col != 0)
+ 	       col--;
+ 	   if (att[maxcol] & KCS1)
+ 	       maxcol++;
+ #endif
+ 
  	   if (col > maxcol) continue;
  
  	   flags = att[col];
  
+ #ifdef	KANJI	/* sano */
+ 	   if (flags & KCS)
+ #ifdef	STATUSLINE	/* michael */
+ 		if ((!hilite && (flags & INVERSE) != 0
+ 		    || hilite && (flags & INVERSE) == 0)
+ 		    ^ (dostatus < 0 && screen->reversestatus)) {
+ #else	STATUSLINE
+ 		if (!hilite && (flags & INVERSE) != 0
+ 		    || hilite && (flags & INVERSE) == 0) {
+ #endif	STATUSLINE
+ 			if (flags & BOLD)
+ 				gc = screen->w_reverseboldGC;
+ 			else
+ 				gc = screen->w_reverseGC;
+ 		} else {
+ 			if (flags & BOLD)
+ 				gc = screen->w_normalboldGC;
+ 			else
+ 				gc = screen->w_normalGC;
+ 		}
+ 	   else if (flags & KANACS)
+ #ifdef	STATUSLINE	/* michael */
+ 		if ((!hilite && (flags & INVERSE) != 0
+ 		    || hilite && (flags & INVERSE) == 0)
+ 		    ^ (dostatus < 0 && screen->reversestatus)) {
+ #else	STATUSLINE
+ 		if (!hilite && (flags & INVERSE) != 0
+ 		    || hilite && (flags & INVERSE) == 0) {
+ #endif	STATUSLINE
+ 			if (flags & BOLD)
+ 				gc = screen->r_reverseboldGC;
+ 			else
+ 				gc = screen->r_reverseGC;
+ 		} else {
+ 			if (flags & BOLD)
+ 				gc = screen->r_normalboldGC;
+ 			else
+ 				gc = screen->r_normalGC;
+ 		}
+ 	else
+ #endif	KANJI
+ #ifdef	STATUSLINE	/* michael */
+ 		if ((!hilite && (flags & INVERSE) != 0
+ 		    || hilite && (flags & INVERSE) == 0)
+ 		    ^ (dostatus < 0 && screen->reversestatus))
+ #else	STATUSLINE
  	   if ( (!hilite && (flags & INVERSE) != 0) ||
  	        (hilite && (flags & INVERSE) == 0) )
+ #endif	STATUSLINE
  	       if (flags & BOLD) gc = screen->reverseboldGC;
  	       else gc = screen->reverseGC;
! 	   else
  	       if (flags & BOLD) gc = screen->normalboldGC;
  	       else gc = screen->normalGC;
  
***************
*** 300,310 ****
--- 380,409 ----
  
  	   for (; col <= maxcol; col++) {
  		if (att[col] != flags) {
+ #ifdef	KANJI	/* sano */
+ 		   if (flags & KCS) {
+ 			XDrawImageString16(screen->display, TextWindow(screen),
+ 				gc, x, y, (XChar2b *)&chars[lastind],
+ 				(n = col - lastind) / 2);
+ 			if ((flags & BOLD) && screen->w_enbolden)
+ 			    XDrawString16(screen->display, TextWindow(screen),
+ 				gc, x + 1, y, (XChar2b *)&chars[lastind], n/2);
+ 		   } else if (flags & KANACS) {
+ 		   	XDrawImageString(screen->display, TextWindow(screen),
+ 				gc, x, y, &chars[lastind], n = col - lastind);
+ 		   	if ((flags & BOLD) && screen->r_enbolden)
+ 		 		XDrawString(screen->display, TextWindow(screen),
+ 					 gc, x + 1, y, &chars[lastind], n);
+ 		   } else {
+ #endif	KANJI
  		   XDrawImageString(screen->display, TextWindow(screen), 
  		        	gc, x, y, &chars[lastind], n = col - lastind);
  		   if((flags & BOLD) && screen->enbolden)
  		 	XDrawString(screen->display, TextWindow(screen), 
  			 gc, x + 1, y, &chars[lastind], n);
+ #ifdef	KANJI	/* sano */
+ 		   }
+ #endif	KANJI
  		   if(flags & UNDERLINE) 
  			XDrawLine(screen->display, TextWindow(screen), 
  			 gc, x, y+1, x+n*FontWidth(screen), y+1);
***************
*** 315,322 ****
  
  		   flags = att[col];
  
! 	   	   if ((!hilite && (flags & INVERSE) != 0) ||
! 		       (hilite && (flags & INVERSE) == 0) )
  	       		if (flags & BOLD) gc = screen->reverseboldGC;
  	       		else gc = screen->reverseGC;
  	  	    else 
--- 414,469 ----
  
  		   flags = att[col];
  
! #ifdef	KANJI	/* sano */
! 		   if (flags & KCS)
! #ifdef	STATUSLINE	/* michael */
! 			if ((!hilite && (flags & INVERSE) != 0
! 			    || hilite && (flags & INVERSE) == 0)
! 			    ^ (dostatus < 0 && screen->reversestatus)) {
! #else	STATUSLINE
! 			if (!hilite && (flags & INVERSE) != 0
! 			    || hilite && (flags & INVERSE) == 0) {
! #endif	STATUSLINE
! 			    if (flags & BOLD)
! 				gc = screen->w_reverseboldGC;
! 			    else
! 				gc = screen->w_reverseGC;
! 			} else {
! 			    if (flags & BOLD)
! 				gc = screen->w_normalboldGC;
! 			    else
! 				gc = screen->w_normalGC;
! 			}
! 		    else if (flags & KANACS)
! #ifdef	STATUSLINE	/* michael */
! 			if ((!hilite && (flags & INVERSE) != 0
! 			    || hilite && (flags & INVERSE) == 0)
! 			    ^ (dostatus < 0 && screen->reversestatus)) {
! #else	STATUSLINE
! 			if (!hilite && (flags & INVERSE) != 0
! 			    || hilite && (flags & INVERSE) == 0) {
! #endif	STATUSLINE
! 			    if (flags & BOLD)
! 				gc = screen->r_reverseboldGC;
! 			    else
! 				gc = screen->r_reverseGC;
! 			} else {
! 			    if (flags & BOLD)
! 				gc = screen->r_normalboldGC;
! 			    else
! 				gc = screen->r_normalGC;
! 			}
! 		    else
! #endif	KANJI
! 				
! #ifdef	STATUSLINE	/* michael */
! 		    if ((!hilite && (flags & INVERSE) != 0
! 			|| hilite && (flags & INVERSE) == 0)
! 			^ (dostatus < 0 && screen->reversestatus))
! #else	STATUSLINE
! 	   	    if (!hilite && (flags & INVERSE) != 0
! 		        || hilite && (flags & INVERSE) == 0)
! #endif	STATUSLINE
  	       		if (flags & BOLD) gc = screen->reverseboldGC;
  	       		else gc = screen->reverseGC;
  	  	    else 
***************
*** 326,350 ****
  
  		if(chars[col] == 0)
  			chars[col] = ' ';
  	   }
  
  
! 	   if ( (!hilite && (flags & INVERSE) != 0) ||
! 	        (hilite && (flags & INVERSE) == 0) )
  	       if (flags & BOLD) gc = screen->reverseboldGC;
  	       else gc = screen->reverseGC;
  	   else 
  	       if (flags & BOLD) gc = screen->normalboldGC;
  	       else gc = screen->normalGC;
  	   XDrawImageString(screen->display, TextWindow(screen), gc, 
  	         x, y, &chars[lastind], n = col - lastind);
  	   if((flags & BOLD) && screen->enbolden)
  		XDrawString(screen->display, TextWindow(screen), gc,
  		x + 1, y, &chars[lastind], n);
  	   if(flags & UNDERLINE) 
  		XDrawLine(screen->display, TextWindow(screen), gc, 
  		 x, y+1, x + n * FontWidth(screen), y+1);
  	}
  }
  
  ClearBufRows (screen, first, last)
--- 473,592 ----
  
  		if(chars[col] == 0)
  			chars[col] = ' ';
+ #ifdef	KANJI	/* sano */
+ 		if (att[col] & KCS1)
+ 			col++;
+ #endif	KANJI
  	   }
  
  
! #ifdef	KANJI	/* sano */
! 	   if (flags & KCS)
! #ifdef	STATUSLINE	/* michael */
! 		if ((!hilite && (flags & INVERSE) != 0
! 		     || hilite && (flags & INVERSE) == 0)
! 		    ^ (dostatus < 0 && screen->reversestatus)) {
! #else	STATUSLINE
! 		if (!hilite && (flags & INVERSE) != 0
! 		    || hilite && (flags & INVERSE) == 0) {
! #endif	STATUSLINE
! 		    if (flags & BOLD)
! 			gc = screen->w_reverseboldGC;
! 		    else
! 			gc = screen->w_reverseGC;
! 		} else {
! 		    if (flags & BOLD)
! 			gc = screen->w_normalboldGC;
! 		    else
! 			gc = screen->w_normalGC;
! 		}
! 	   else if (flags & KANACS)
! #ifdef	STATUSLINE	/* michael */
! 		if ((!hilite && (flags & INVERSE) != 0
! 		     || hilite && (flags & INVERSE) == 0)
! 		    ^ (dostatus < 0 && screen->reversestatus)) {
! #else	STATUSLINE
! 		if (!hilite && (flags & INVERSE) != 0
! 		    || hilite && (flags & INVERSE) == 0) {
! #endif	STATUSLINE
! 		    if (flags & BOLD)
! 			gc = screen->r_reverseboldGC;
! 		    else
! 			gc = screen->r_reverseGC;
! 		} else {
! 		    if (flags & BOLD)
! 			gc = screen->r_normalboldGC;
! 		    else
! 			gc = screen->r_normalGC;
! 		}
! 	   else
! #endif	KANJI
! 		
! #ifdef	STATUSLINE	/* michael */
! 	    if ((!hilite && (flags & INVERSE) != 0
! 		 || hilite && (flags & INVERSE) == 0)
! 		^ (dostatus < 0 && screen->reversestatus))
! #else	STATUSLINE
! 	   if (!hilite && (flags & INVERSE) != 0
! 	       || hilite && (flags & INVERSE) == 0)
! #endif	STATUSLINE
  	       if (flags & BOLD) gc = screen->reverseboldGC;
  	       else gc = screen->reverseGC;
  	   else 
  	       if (flags & BOLD) gc = screen->normalboldGC;
  	       else gc = screen->normalGC;
+ #ifdef	KANJI	/* sano */
+ 	   if (flags & KCS) {
+ 		XDrawImageString16(screen->display, TextWindow(screen), gc,
+ 			x, y, (XChar2b *)&chars[lastind],
+ 			(n = col - lastind) / 2);
+ 		if ((flags & BOLD) && screen->w_enbolden)
+ 		    XDrawString16(screen->display, TextWindow(screen), gc,
+ 			x + 1, y, (XChar2b *)&chars[lastind], n / 2);
+ 	   } else if (flags & KANACS) {
+ 	   	XDrawImageString(screen->display, TextWindow(screen), gc, 
+ 	         	x, y, &chars[lastind], n = col - lastind);
+ 	   	if((flags & BOLD) && screen->r_enbolden)
+ 			XDrawString(screen->display, TextWindow(screen), gc,
+ 			x + 1, y, &chars[lastind], n);
+ 	   } else {
+ #endif	KANJI
  	   XDrawImageString(screen->display, TextWindow(screen), gc, 
  	         x, y, &chars[lastind], n = col - lastind);
  	   if((flags & BOLD) && screen->enbolden)
  		XDrawString(screen->display, TextWindow(screen), gc,
  		x + 1, y, &chars[lastind], n);
+ #ifdef	KANJI	/* sano */
+ 	   }
+ #endif	KANJI
  	   if(flags & UNDERLINE) 
  		XDrawLine(screen->display, TextWindow(screen), gc, 
  		 x, y+1, x + n * FontWidth(screen), y+1);
  	}
+ #ifdef	STATUSLINE	/* michael */
+ 	if (dostatus <= 0)
+ 		break;
+ 	dostatus = -1;
+ 	topline = 0;
+ 	scrollamt = 0;
+ 	toprow = maxrow = max = screen->max_row + 1;
+ 	left = CursorX(screen, leftcol);
+ 	width = ncols * FontWidth(screen);
+ 	if (leftcol == 0) {
+ 		left--;
+ 		width++;
+ 	}
+ 	if (leftcol + ncols - 1 >= screen->max_col)
+ 		width++;
+ 	XFillRectangle(screen->display, TextWindow(screen),
+ 		screen->reversestatus ? screen->normalGC : screen->reverseGC,
+ 		left, y - screen->fnt_norm->max_bounds.ascent,
+ 		width, screen->statusheight);
+ 	if (!screen->reversestatus)
+ 		StatusBox(screen);
+ 	y++;
+ 	}	/* end of for(;;) { */
+ #endif	STATUSLINE
  }
  
  ClearBufRows (screen, first, last)
***************
*** 390,395 ****
--- 632,640 ----
  	register int x;
  	int border = 2 * screen->border;
  	int i, j, k;
+ #ifdef	STATUSLINE	/* michael */
+ 	register char *s10, *s11;	/* keep status line */
+ #endif	STATUSLINE
  #ifdef sun
  #ifdef TIOCSSIZE
  	struct ttysize ts;
***************
*** 414,420 ****
--- 659,669 ----
  
  	/* round so that it is unlikely the screen will change size on  */
  	/* small mouse movements.					*/
+ #ifdef	STATUSLINE	/* michael */
+ 	rows = (height + FontHeight(screen) / 2 - border - screen->statusheight) /
+ #else	STATUSLINE
  	rows = (height + FontHeight(screen) / 2 - border) /
+ #endif	STATUSLINE
  	 FontHeight(screen);
  	cols = (width + FontWidth(screen) / 2 - border - screen->scrollbar) /
  	 FontWidth(screen);
***************
*** 452,458 ****
--- 701,711 ----
  			}
  		}
  		/* resize current lines */
+ #ifdef	STATUSLINE	/* michael */
+                 k += savelines + 1;	/* includes status line */
+ #else	STATUSLINE
                  k += savelines;
+ #endif	STATUSLINE
  		for (index = x = 0; index <= k; x += 2, index++) {
  			if ((sb[x] = realloc(sb[x], (unsigned) cols)) == NULL)
  				SysError(ERROR_SREALLOC3);
***************
*** 463,470 ****
--- 716,731 ----
  				bzero (sb [x + 1] + j, i);
  			}
  		}
+ #ifdef	STATUSLINE	/* michael */
+ 		/* save status line */
+ 		s10 = sb[i = 2 * (savelines + screen->max_row + 1)];
+ 		s11 = sb[i + 1];
  		/* discard excess bottom rows */
+ 		for (index = rows, x = 2 * (k - 1); index <= screen->max_row;
+ #else	STATUSLINE
+ 		/* discard excess bottom rows */
  		for (index = rows, x = 2 * k; index <= screen->max_row;
+ #endif	STATUSLINE
  		 x += 2, index++) {
  		   free (sb [x]);
  		   free (sb [x + 1]);
***************
*** 475,481 ****
--- 736,746 ----
  			SysError (ERROR_RESIZE);
  		    screen->altbuf = ab;
  		}
+ #ifdef	STATUSLINE	/* michael */
+ 		k = 2 * (rows + savelines + 1);	/* includes status line */
+ #else	STATUSLINE
  		k = 2 * (rows + savelines);
+ #endif	STATUSLINE
  		/* resize sb */
  		if((sb = (ScrnBuf)realloc((char *) sb, (unsigned) k * sizeof(char *)))
  		  == NULL)
***************
*** 504,509 ****
--- 769,778 ----
  
  		screen->max_row = rows - 1;
  		screen->max_col = cols - 1;
+ #ifdef	STATUSLINE	/* michael */
+ 		sb[i = 2 * (savelines + screen->max_row + 1)] = s10;
+ 		sb[i + 1] = s11;
+ #endif	STATUSLINE
  	
  		/* adjust scrolling region */
  		screen->top_marg = 0;
***************
*** 510,521 ****
--- 779,799 ----
  		screen->bot_marg = screen->max_row;
  		*flags &= ~ORIGIN;
  	
+ #ifdef	STATUSLINE	/* michael */
+ 		if (screen->instatus)
+ 			screen->cur_row = screen->max_row + 1;
+ 		else
+ #endif	STATUSLINE
  		if (screen->cur_row > screen->max_row)
  			screen->cur_row = screen->max_row;
  		if (screen->cur_col > screen->max_col)
  			screen->cur_col = screen->max_col;
  	
+ #ifdef	STATUSLINE	/* michael */
+ 		screen->fullVwin.height = height - border - screen->statusheight;
+ #else	STATUSLINE
  		screen->fullVwin.height = height - border;
+ #endif	STATUSLINE
  		screen->fullVwin.width = width - border - screen->scrollbar;
  
  	} else if(FullHeight(screen) == height && FullWidth(screen) == width)
diff -rc ../xterm/scrollbar.c ./scrollbar.c
*** ../xterm/scrollbar.c	Thu May  4 20:19:28 1989
--- ./scrollbar.c	Tue May 30 14:53:56 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: scrollbar.c,v 1.17 88/11/23 13:56:05 rws Exp $
+  *	$Header: scrollbar.c,v 1.1 89/05/30 14:53:55 kagotani Rel $
   */
  
  #include <X11/copyright.h>
***************
*** 43,48 ****
--- 44,50 ----
  
  #ifndef lint
  static char rcs_id[] = "$XConsortium: scrollbar.c,v 1.17 88/11/23 13:56:05 rws Exp $";
+ static char kterm_id[] = "$Header: scrollbar.c,v 1.1 89/05/30 14:53:55 kagotani Rel $";
  #endif	/* lint */
  
  /* Event handlers */
***************
*** 63,69 ****
--- 65,75 ----
   * appropriate WM_SIZE_HINTS and taking advantage of bit gravity.
   */
  
+ #ifdef	STATUSLINE	/* michael */
+ void ResizeScreen(xw, min_width, min_height )
+ #else	STATUSLINE
  static void ResizeScreen(xw, min_width, min_height )
+ #endif	STATUSLINE
  	register XtermWidget xw;
  	int min_width, min_height;
  {
***************
*** 94,108 ****
  			     &sizehints))
  	    sizehints.flags = 0;
  	sizehints.min_width = min_width;
  	sizehints.min_height = min_height;
  	sizehints.width_inc = FontWidth(screen);
  	sizehints.height_inc = FontHeight(screen);
  	sizehints.width =  (screen->max_col + 1) * FontWidth(screen)
  				+ min_width;
  	sizehints.height = FontHeight(screen) * (screen->max_row + 1)
  				+ min_height;
  	sizehints.flags |= PMinSize|PResizeInc;
! #endif
  
  	argList[0].value = (XtArgVal)min_width;
  	argList[1].value = (XtArgVal)min_height;
--- 100,121 ----
  			     &sizehints))
  	    sizehints.flags = 0;
  	sizehints.min_width = min_width;
+ #ifdef	STATUSLINE	/* michael */
+ 	sizehints.min_height = min_height + screen->statusheight;
+ #else	STATUSLINE
  	sizehints.min_height = min_height;
+ #endif	STATUSLINE
  	sizehints.width_inc = FontWidth(screen);
  	sizehints.height_inc = FontHeight(screen);
  	sizehints.width =  (screen->max_col + 1) * FontWidth(screen)
  				+ min_width;
  	sizehints.height = FontHeight(screen) * (screen->max_row + 1)
+ #ifdef	STATUSLINE	/* michael */
+ 				+ screen->statusheight
+ #endif	STATUSLINE
  				+ min_height;
  	sizehints.flags |= PMinSize|PResizeInc;
! #endif	nothack
  
  	argList[0].value = (XtArgVal)min_width;
  	argList[1].value = (XtArgVal)min_height;
***************
*** 115,121 ****
--- 128,138 ----
  
  	newAttributes.event_mask =
  	    oldAttributes.your_event_mask | StructureNotifyMask;
+ #ifdef	STATUSLINE	/* michael */
+ 	newAttributes.bit_gravity = NorthEastGravity;
+ #else	STATUSLINE
  	newAttributes.bit_gravity = EastGravity;
+ #endif	STATUSLINE
  
          /* The following statement assumes scrollbar is on Left! 
             If we ever have scrollbars on the right, then the
***************
*** 126,132 ****
--- 143,154 ----
  	oldWidth = xw->core.width;
  	oldHeight = xw->core.height;
  	reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width;
+ #ifdef	STATUSLINE	/* michael */
+ 	reqHeight = FontHeight(screen) * (screen->max_row + 1)
+ 			+ screen->statusheight + min_height;
+ #else	STATUSLINE
  	reqHeight = FontHeight(screen) * (screen->max_row + 1) + min_height;
+ #endif	STATUSLINE
  	geomreqresult = XtMakeResizeRequest ((Widget)xw, reqWidth, reqHeight,
  					     &repWidth, &repHeight);
  
***************
*** 342,350 ****
--- 364,379 ----
  	}
  
  	ResizeScrollBar (screen->scrollWidget, -1, -1, 
+ #ifdef	STATUSLINE	/* michael */
+ 			 Height (screen) + border + screen->statusheight);
+ #else	STATUSLINE
  			 Height (screen) + border);
+ #endif	STATUSLINE
  	RealizeScrollBar (screen->scrollWidget, screen);
  	screen->scrollbar = screen->scrollWidget->core.width;
+ #ifdef	STATUSLINE	/* michael */
+ 	status_box[0].x += screen->scrollbar;
+ #endif	STATUSLINE
  
  	ScrollBarDrawThumb(screen->scrollWidget);
  	ResizeScreen (xw, border + screen->scrollWidget->core.width, border);
***************
*** 359,364 ****
--- 388,396 ----
  
  	if(!screen->scrollbar)
  		return;
+ #ifdef	STATUSLINE	/* michael */
+ 	status_box[0].x -= screen->scrollbar;
+ #endif	STATUSLINE
  	screen->scrollbar = 0;
  	XUnmapWindow(screen->display, XtWindow(screen->scrollWidget));
  	ResizeScreen( term, border, border );
diff -rc ../xterm/termcap ./termcap
*** ../xterm/termcap	Sat Oct  8 02:26:20 1988
--- ./termcap	Tue May 30 14:53:57 1989
***************
*** 8,13 ****
--- 8,15 ----
  #
  # 	:ic=\E[@:\
  #
+ vk|kterm|kterm| (X window system):\
+ 	:KJ:sc=\E7:rc=\E8:cs=\E[%i%d;%dr:TY=ascii:tc=xterms:
  vs|xterm|vs100|xterm terminal emulator (X window system):\
  	:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:MT:UP=\E[%dA:\
  	:al=\E[L:am:\
diff -rc ../xterm/util.c ./util.c
*** ../xterm/util.c	Fri Oct  7 21:20:55 1988
--- ./util.c	Tue May 30 14:53:59 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: util.c,v 1.10 88/10/07 08:20:08 swick Exp $
+  *	$Header: util.c,v 1.1 89/05/30 14:53:58 kagotani Rel $
   */
  
  #include <X11/copyright.h>
***************
*** 31,36 ****
--- 32,38 ----
  
  #ifndef lint
  static char rcs_id[] = "$XConsortium: util.c,v 1.10 88/10/07 08:20:08 swick Exp $";
+ static char kterm_id[] = "$Header: util.c,v 1.1 89/05/30 14:53:58 kagotani Rel $";
  #endif	/* lint */
  
  #include <stdio.h>
***************
*** 158,164 ****
--- 160,170 ----
  	register int amount = screen->refresh_amt;
  	register int row = screen->cur_row;
  
+ #ifdef	STATUSLINE	/* michael */
+ 	if(amount == 0 || screen->instatus)
+ #else	STATUSLINE
  	if(amount == 0)
+ #endif	STATUSLINE
  		return(0);
  	if(amount > 0) {
  		register int bottom;
***************
*** 572,578 ****
--- 578,589 ----
  	if(screen->cursor_state)
  		HideCursor();
  	screen->do_wrap = 0;
+ #ifdef	STATUSLINE	/* michael */
+ 	if(screen->cur_row - screen->topline <= screen->max_row ||
+ 	   screen->instatus) {
+ #else	STATUSLINE
  	if(screen->cur_row - screen->topline <= screen->max_row) {
+ #endif	STATUSLINE
  	    if(!AddToRefresh(screen)) {
  		if(screen->scroll_amt)
  			FlushScroll(screen);
***************
*** 595,600 ****
--- 606,614 ----
  		XFillRectangle(
  		    screen->display,
  		    TextWindow(screen), 
+ #ifdef	STATUSLINE	/* michael */
+ 		    screen->instatus ? screen->normalGC :
+ #endif	STATUSLINE
  		    screen->reverseGC,
  		    cx, cy,
  		    (unsigned) width, (unsigned) FontHeight(screen));
***************
*** 620,626 ****
--- 634,645 ----
  	if (n > (width = screen->max_col + 1 - screen->cur_col))
  	  	n = width;
  		
+ #ifdef	STATUSLINE	/* michael */
+ 	if(screen->cur_row - screen->topline <= screen->max_row ||
+ 	   screen->instatus) {
+ #else	STATUSLINE
  	if(screen->cur_row - screen->topline <= screen->max_row) {
+ #endif	STATUSLINE
  	    if(!AddToRefresh(screen)) {
  		if(screen->scroll_amt)
  			FlushScroll(screen);
***************
*** 641,646 ****
--- 660,668 ----
  		     FontHeight(screen), 
  		     cx, cy);
  		XFillRectangle (screen->display, TextWindow(screen),
+ #ifdef	STATUSLINE	/* michael */
+ 		     screen->instatus? screen->normalGC :
+ #endif	STATUSLINE
  		     screen->reverseGC,
  		     screen->border + screen->scrollbar + Width(screen) - width,
  		     cy, width, FontHeight(screen));
***************
*** 710,720 ****
--- 732,750 ----
  	if(screen->cursor_state)
  		HideCursor();
  	screen->do_wrap = 0;
+ #ifdef	STATUSLINE	/* michael */
+ 	if(screen->cur_row - screen->topline <= screen->max_row ||
+ 	   screen->instatus) {
+ #else	STATUSLINE
  	if(screen->cur_row - screen->topline <= screen->max_row) {
+ #endif	STATUSLINE
  	    if(!AddToRefresh(screen)) {
  	if(screen->scroll_amt)
  		FlushScroll(screen);
  		XFillRectangle(screen->display, TextWindow(screen),
+ #ifdef	STATUSLINE	/* michael */
+ 		screen->instatus ? screen->normalGC :
+ #endif	STATUSLINE
  		  screen->reverseGC,
  		 CursorX(screen, screen->cur_col),
  		 CursorY(screen, screen->cur_row),
***************
*** 737,747 ****
--- 767,785 ----
  	if(screen->cursor_state)
  		HideCursor();
  	screen->do_wrap = 0;
+ #ifdef	STATUSLINE	/* michael */
+ 	if(screen->cur_row - screen->topline <= screen->max_row ||
+ 	   screen->instatus) {
+ #else	STATUSLINE
  	if(screen->cur_row - screen->topline <= screen->max_row) {
+ #endif	STATUSLINE
  	    if(!AddToRefresh(screen)) {
  		if(screen->scroll_amt)
  			FlushScroll(screen);
  		XFillRectangle (screen->display, TextWindow(screen),
+ #ifdef	STATUSLINE	/* michael */
+ 		     screen->instatus ? screen->normalGC :
+ #endif	STATUSLINE
  		     screen->reverseGC,
  		     screen->border + screen->scrollbar,
  		      CursorY (screen, screen->cur_row),
***************
*** 762,772 ****
--- 800,819 ----
  	if(screen->cursor_state)
  		HideCursor();
  	screen->do_wrap = 0;
+ #ifdef	STATUSLINE	/* michael */
+ 	if(screen->cur_row - screen->topline <= screen->max_row ||
+ 	   screen->instatus) {
+ #else	STATUSLINE
  	if(screen->cur_row - screen->topline <= screen->max_row) {
+ #endif	STATUSLINE
  	    if(!AddToRefresh(screen)) {
  		if(screen->scroll_amt)
  			FlushScroll(screen);
  		XFillRectangle (screen->display, TextWindow(screen), 
+ #ifdef	STATUSLINE	/* michael & kato */
+ 		     screen->instatus && screen->reversestatus ?
+ 		     screen->normalGC :
+ #endif	STATUSLINE
  		     screen->reverseGC,
  		     screen->border + screen->scrollbar,
  		      CursorY (screen, screen->cur_row),
***************
*** 788,794 ****
--- 835,845 ----
  	if((top = -screen->topline) <= screen->max_row) {
  		if(screen->scroll_amt)
  			FlushScroll(screen);
+ #ifdef	STATUSLINE	/* michael */
+ 		if(top == 0 && !screen->statusline)
+ #else	STATUSLINE
  		if(top == 0)
+ #endif	STATUSLINE
  			XClearWindow(screen->display, TextWindow(screen));
  		else
  			XClearArea(screen->display, TextWindow(screen),
***************
*** 863,869 ****
--- 914,924 ----
  		toprow = 0;
  	}
  	if (toprow + nrows - 1 > screen->max_row)
+ #ifdef	STATUSLINE	/* michael */
+ 		nrows = screen->max_row - toprow + 1 + screen->statusline;
+ #else	STATUSLINE
  		nrows = screen->max_row - toprow + 1;
+ #endif	STATUSLINE
  	if (leftcol + ncols - 1 > screen->max_col)
  		ncols = screen->max_col - leftcol + 1;
  
***************
*** 901,907 ****
--- 956,983 ----
  	tmpGC = screen->normalboldGC;
  	screen->normalboldGC = screen->reverseboldGC;
  	screen->reverseboldGC = tmpGC;
+ /*
+  * Bug fix by michael
+  * 3 non null lines are inserted.
+  */
+ 	tmpGC = screen->cursorGC;
+ 	screen->cursorGC = screen->reversecursorGC;
+ 	screen->reversecursorGC = tmpGC;
  
+ #ifdef	KANJI	/* ariza & michael */
+ 	tmpGC = screen->w_normalGC;
+ 	screen->w_normalGC = screen->w_reverseGC;
+ 	screen->w_reverseGC = tmpGC;
+ 
+ 	tmpGC = screen->w_normalboldGC;
+ 	screen->w_normalboldGC = screen->w_reverseboldGC;
+ 	screen->w_reverseboldGC = tmpGC;
+ 
+ 	tmpGC = screen->w_cursorGC;
+ 	screen->w_cursorGC = screen->w_reversecursorGC;
+ 	screen->w_reversecursorGC = tmpGC;
+ #endif	KANJI
+ 
  	{
  	    unsigned long fg, bg;
  	    bg = term->core.background_pixel;
***************
*** 945,951 ****
--- 1021,1031 ----
  	    TekReverseVideo(screen);
  	}
  	XClearWindow(screen->display, TextWindow(screen));
+ #ifdef	STATUSLINE	/* michael */
+ 	ScrnRefresh (screen, 0, 0, screen->max_row + 1 + screen->statusline,
+ #else	STATUSLINE
  	ScrnRefresh (screen, 0, 0, screen->max_row + 1,
+ #endif	STATUSLINE
  	 screen->max_col + 1, False);
  	if(screen->Tshow) {
  	    XClearWindow(screen->display, tek);