v04i011: kterm -- Kanji (japanese) xterm, Part02/04

Dan Heller argv at island.uu.net
Wed May 31 16:00:55 AEST 1989


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

diff -rc ../xterm/Imakefile ./Imakefile
*** ../xterm/Imakefile	Thu May  4 20:19:15 1989
--- ./Imakefile	Tue May 30 14:53:21 1989
***************
*** 25,46 ****
  #define GettyProgram /* as nothing */
  #endif
  /* add -DWTMP and -DLASTLOG if you want them */
!         DEFINES = -DMODEMENU -DUTMP -DBcopy=bcopy GettyProgram
            SRCS1 = button.c charproc.c cursor.c data.c input.c \
  		  main.c menu.c misc.c screen.c scrollbar.c tabs.c \
! 		  TekPrsTbl.c Tekproc.c util.c VTPrsTbl.c
            OBJS1 = main.o input.o charproc.o cursor.o util.o tabs.o \
  		  screen.o scrollbar.o button.o Tekproc.o misc.o \
! 		  VTPrsTbl.o TekPrsTbl.o data.o menu.o
!           SRCS2 = resize.c
!           OBJS2 = resize.o
!        PROGRAMS = resize xterm
     INSTALLFLAGS = $(INSTUIDFLAGS)
         INCLUDES = -I$(TOOLKITSRC) -I$(TOP)
  
  
! ComplexProgramTarget_1(xterm,$(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB),-ltermcap)
! 
! SingleProgramTarget(resize,$(OBJS2),,-lc -ltermcap)
! InstallProgramWithFlags(resize, $(BINDIR), )
! InstallManPage(resize,$(MANDIR))
--- 25,43 ----
  #define GettyProgram /* as nothing */
  #endif
  /* add -DWTMP and -DLASTLOG if you want them */
!         DEFINES = -DMODEMENU -DUTMP -DKANJI -DSTATUSLINE \
! 		  -DKEEPALIVE -DBcopy=bcopy GettyProgram
            SRCS1 = button.c charproc.c cursor.c data.c input.c \
  		  main.c menu.c misc.c screen.c scrollbar.c tabs.c \
! 		  TekPrsTbl.c Tekproc.c util.c VTPrsTbl.c \
! 		  convert.c patchlevel.c
            OBJS1 = main.o input.o charproc.o cursor.o util.o tabs.o \
  		  screen.o scrollbar.o button.o Tekproc.o misc.o \
! 		  VTPrsTbl.o TekPrsTbl.o data.o menu.o \
! 		  convert.o patchlevel.o
!        PROGRAMS = kterm
     INSTALLFLAGS = $(INSTUIDFLAGS)
         INCLUDES = -I$(TOOLKITSRC) -I$(TOP)
  
  
! ComplexProgramTarget_1(kterm,$(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB),-ltermcap)
diff -rc ../xterm/VTPrsTbl.c ./VTPrsTbl.c
*** ../xterm/VTPrsTbl.c	Thu May  4 20:19:17 1989
--- ./VTPrsTbl.c	Tue May 30 14:53:26 1989
***************
*** 35,40 ****
--- 35,41 ----
  #include "VTparse.h"
  #ifndef lint
  static char rcs_id[] = "$XConsortium: VTPrsTbl.c,v 1.3 89/01/04 13:37:41 jim Exp $";
+ static char kterm_id[] = "$Header: VTPrsTbl.c,v 1.1 89/05/30 14:53:25 kagotani Rel $";
  #endif	/* lint */
  
  /*
***************
*** 455,465 ****
--- 456,475 ----
  CASE_GROUND_STATE,
  /*	D		E		F		G	*/
  CASE_GROUND_STATE,
+ #ifdef	STATUSLINE	/* michael */
+ CASE_ERASE_STATUS,
+ CASE_FROM_STATUS,
+ #else	STATUSLINE
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
+ #endif	STATUSLINE
  CASE_GROUND_STATE,
  /*	H		I		J		K	*/
+ #ifdef	STATUSLINE	/* michael */
+ CASE_HIDE_STATUS,
+ #else	STATUSLINE
  CASE_GROUND_STATE,
+ #endif	STATUSLINE
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
***************
*** 472,480 ****
--- 482,498 ----
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
+ #ifdef	STATUSLINE	/* michael */
+ CASE_SHOW_STATUS,
+ #else	STATUSLINE
  CASE_GROUND_STATE,
+ #endif	STATUSLINE
  /*	T		U		V		W	*/
+ #ifdef	STATUSLINE	/* michael */
+ CASE_TO_STATUS,
+ #else	STATUSLINE
  CASE_GROUND_STATE,
+ #endif	STATUSLINE
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
***************
*** 741,747 ****
--- 759,769 ----
  CASE_ESC_IGNORE,
  CASE_SCR_STATE,
  /*	$		%		&		'	*/
+ #ifdef	KANJI	/* sano & kagotani */
+ CASE_MBCS,
+ #else	KANJI
  CASE_ESC_IGNORE,
+ #endif	KANJI
  CASE_ESC_IGNORE,
  CASE_ESC_IGNORE,
  CASE_ESC_IGNORE,
***************
*** 1438,1446 ****
--- 1460,1474 ----
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
  /*	H		I		J		K	*/
+ #ifdef	KANJI	/* sano */
+ CASE_GSETS,
+ CASE_GSETS,
+ CASE_GSETS,
+ #else	KANJI
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
+ #endif	KANJI
  CASE_GROUND_STATE,
  /*	L		M		N		O	*/
  CASE_GROUND_STATE,
***************
*** 1508,1510 ****
--- 1536,1703 ----
  CASE_GROUND_STATE,
  CASE_GROUND_STATE,
  };
+ 
+ #ifdef	KANJI	/* kagotani */
+ int mbcstable[] = {
+ /*	NUL		SOH		STX		ETX	*/
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ /*	EOT		ENQ		ACK		BEL	*/
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_BELL,
+ /*	BS		HT		NL		VT	*/
+ CASE_BS,
+ CASE_TAB,
+ CASE_VMOT,
+ CASE_VMOT,
+ /*	NP		CR		SO		SI	*/
+ CASE_VMOT,
+ CASE_CR,
+ CASE_SO,
+ CASE_SI,
+ /*	DLE		DC1		DC2		DC3	*/
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ /*	DC4		NAK		SYN		ETB	*/
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ /*	CAN		EM		SUB		ESC	*/
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_ESC,
+ /*	FS		GS		RS		US	*/
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ CASE_IGNORE,
+ /*	SP		!		"		#	*/
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ /*	$		%		&		'	*/
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ /*	(		)		*		+	*/
+ CASE_SCS0_STATE,
+ CASE_SCS1_STATE,
+ CASE_SCS2_STATE,
+ CASE_SCS3_STATE,
+ /*	,		-		.		/	*/
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ CASE_ESC_IGNORE,
+ /*	0		1		2		3	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	4		5		6		7	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	8		9		:		;	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	<		=		>		?	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	@		A		B		C	*/
+ CASE_GSETS,		/* ESC-$-@ Japanise (JIS-78) */
+ CASE_GROUND_STATE,
+ CASE_GSETS,		/* ESC-$-B Japanese (JIS-83) */
+ CASE_GROUND_STATE,
+ /*	D		E		F		G	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	H		I		J		K	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	L		M		N		O	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	P		Q		R		S	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	T		U		V		W	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	X		Y		Z		[	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	\		]		^		_	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	`		a		b		c	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	d		e		f		g	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	h		i		j		k	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	l		m		n		o	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	p		q		r		s	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	t		u		v		w	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	x		y		z		{	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ /*	|		}		~		DEL	*/
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ CASE_GROUND_STATE,
+ };
+ #endif KANJI
diff -rc ../xterm/VTparse.def ./VTparse.def
*** ../xterm/VTparse.def	Thu May  4 20:19:18 1989
--- ./VTparse.def	Tue May 30 14:53:27 1989
***************
*** 1,5 ****
  #
! # $XConsortium: VTparse.def,v 1.3 89/01/04 13:37:48 jim Exp $
  #
  # List of symbols that need to be defined for VTparse.h.  If you need to 
  # change any of the CASE_ macros, make the change here and rerun the command
--- 1,5 ----
  #
! # $Header: VTparse.def,v 1.1 89/05/30 14:53:27 kagotani Rel $
  #
  # List of symbols that need to be defined for VTparse.h.  If you need to 
  # change any of the CASE_ macros, make the change here and rerun the command
***************
*** 74,76 ****
--- 74,77 ----
  CASE_XTERM_RESTORE
  CASE_XTERM_TITLE
  CASE_DECID
+ CASE_MBCS
diff -rc ../xterm/VTparse.h ./VTparse.h
*** ../xterm/VTparse.h	Thu May  4 20:19:18 1989
--- ./VTparse.h	Tue May 30 14:53:28 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: VTparse.h,v 1.4 89/01/04 13:37:49 jim Exp $
+  *	$Header: VTparse.h,v 1.1 89/05/30 14:53:28 kagotani Rel $
   */
  
  
***************
*** 110,112 ****
--- 111,119 ----
  #define CASE_XTERM_RESTORE 65
  #define CASE_XTERM_TITLE 66
  #define CASE_DECID 67
+ #define CASE_MBCS 68
+ #define	CASE_TO_STATUS		69
+ #define	CASE_FROM_STATUS	70
+ #define	CASE_SHOW_STATUS	71
+ #define	CASE_HIDE_STATUS	72
+ #define	CASE_ERASE_STATUS	73
diff -rc ../xterm/button.c ./button.c
*** ../xterm/button.c	Thu May  4 20:19:20 1989
--- ./button.c	Tue May 30 14:53:31 1989
***************
*** 1,5 ****
--- 1,6 ----
  /*
   *	$XConsortium: button.c,v 1.32 89/01/05 12:47:45 swick Exp $
+  *	$Header: button.c,v 1.1 89/05/30 14:53:29 kagotani Rel $
   */
  
  
***************
*** 36,41 ****
--- 37,43 ----
  */
  #ifndef lint
  static char rcs_id[] = "$XConsortium: button.c,v 1.32 89/01/05 12:47:45 swick Exp $";
+ static char kterm_id[] = "$Header: button.c,v 1.1 89/05/30 14:53:29 kagotani Rel $";
  #endif	/* lint */
  #include <X11/Xos.h>
  #include <X11/Xlib.h>
***************
*** 53,58 ****
--- 55,72 ----
  #include "menu.h"
  #endif	/* MODEMENU */
  
+ #ifndef LOCAL_ALLOC
+ #ifdef __GNUC__
+ #define LOCAL_ALLOC(x)	__builtin_alloca(x)
+ #else
+ #define LOCAL_ALLOC(x)	alloca(x)
+ extern char *alloca();
+ #endif
+ #endif
+ #ifndef LOCAL_FREE
+ #define LOCAL_FREE(x)
+ #endif
+ 
  extern char *malloc();
  
  #define KeyState(x) (((x) & (ShiftMask|ControlMask)) + (((x) & Mod1Mask) ? 2 : 0))
***************
*** 69,75 ****
--- 83,98 ----
  #define SHIFTS 8		/* three keys, so eight combinations */
  #define	Coordinate(r,c)		((r) * (term->screen.max_col+1) + (c))
  
+ #ifdef KANJI
+ static AtomPtr	_XA_COMPOUND_TEXT;
+ #define XA_COMPOUND_TEXT(d)	XmuInternAtom(d, _XA_COMPOUND_TEXT)
+ #endif
+ 
+ #ifdef KANJI
+ wchar_t *SaveText();
+ #else
  char *SaveText();
+ #endif
  extern EditorButton();
  
  extern ModeMenu();
***************
*** 251,256 ****
--- 274,285 ----
      Time time;
  };
  
+ #ifdef KANJI
+ SelAtomInitialize()
+ {
+     _XA_COMPOUND_TEXT = XmuMakeAtom("COMPOUND_TEXT");
+ }
+ #endif
  
  static void _GetSelection(w, time, params, num_params)
  Widget w;
***************
*** 293,300 ****
--- 322,334 ----
  	    list->count = num_params;
  	    list->time = time;
  	} else list = NULL;
+ #ifdef KANJI
+ 	XtGetSelectionValue(w, selection, XA_TEXT(XtDisplay(w)), SelectionReceived,
+ 			    (caddr_t)list, time);
+ #else
  	XtGetSelectionValue(w, selection, XA_STRING, SelectionReceived,
  			    (caddr_t)list, time);
+ #endif
      }
  }
  
***************
*** 322,327 ****
--- 356,432 ----
  	return;
      }
  
+ #ifdef KANJI
+     if (*type == XA_STRING) {
+ 	char *p, *q;
+ 	int n = *length;
+ 
+ 	line = LOCAL_ALLOC(n + 1);
+ 	bcopy((char *)value, line, n);
+ 	line[n] = '\0';
+ 	p = (char *)value;
+ 	q = line;
+ 	while (n-- > 0) {
+ 	    if (!(*p & 0x80)) {
+ 		*q++ = *p;
+ 	    }
+ 	    p++;
+ 	}
+ 	end = q;
+     } else if (*type == XA_COMPOUND_TEXT(XtDisplay(w))) {
+ 	unsigned char *ct = (unsigned char *)value;
+ 	wchar_t *ws;
+ 	int (*func)();
+ 	int n;
+ 	int convWStoEUC(), convWStoSJIS(), convWStoJIS();
+ 
+ 	n = convCTtoJWS(ct, *length, NULL);
+ 	if (n < 0) {	/* data broken */
+ 	    XtFree(client_data);
+ 	    XtFree(value);
+ 	    return;
+ 	}
+ 	ws = (wchar_t *)LOCAL_ALLOC((n + 1) * sizeof(wchar_t));
+ 	(void)convCTtoJWS(ct, *length, ws);
+ 
+ 	switch (((XtermWidget)w)->flags & (EUC_KANJI|SJIS_KANJI)) {
+ 	case EUC_KANJI:
+ 	    func = convWStoEUC;
+ 	    break;
+ 	case SJIS_KANJI:
+ 	    func = convWStoSJIS;
+ 	    break;
+ 	default:
+ 	    func = convWStoJIS;
+ 	    break;
+ 	}
+ 
+ 	n = (*func)(ws, NULL);
+ 	line = LOCAL_ALLOC(n + 1);
+ 	(void)(*func)(ws, line);
+ 	end = line + n;
+ 	LOCAL_FREE(ws);
+     } else {
+ 	/* I don't know */
+ 	XtFree(client_data);
+ 	XtFree(value);
+ 	return;
+     }
+     lag = line;
+     for (cp = line; cp != end; cp++)
+ 	{
+ 	    if (*cp != '\n') continue;
+ 	    *cp = '\r';
+ 	    v_write(pty, lag, cp - lag + 1);
+ 	    lag = cp + 1;
+ 	}
+     if (lag != end)
+ 	v_write(pty, lag, end - lag);
+ 
+     LOCAL_FREE(line);
+     XtFree(client_data);
+     XtFree(value);
+ #else
      end = &line[*length];
      lag = line;
      for (cp = line; cp != end; cp++)
***************
*** 336,341 ****
--- 441,447 ----
  
      XtFree(client_data);
      XtFree(value);
+ #endif
  }
  
  
***************
*** 919,925 ****
--- 1025,1035 ----
  {
  	register TScreen *screen = &term->screen;
  	register int i, j = 0;
+ #ifdef KANJI	/* ishisone */
+ 	wchar_t *line, *lp;
+ #else
  	char *line, *lp;
+ #endif
  
  	--col;
  	/* first we need to know how long the string is before we can save it*/
***************
*** 936,942 ****
--- 1046,1059 ----
  	/* now get some memory to save it in */
  
  	if (screen->selection_size <= j) {
+ #ifdef	KANJI	/* ishisone */
+ 	    /*
+ 	     * Selection data are stored in EUC process code
+ 	     */
+ 	    if((line = (wchar_t *)malloc((unsigned)((j + 1) * 2))) == (wchar_t *)NULL)
+ #else	/* KANJI */
  	    if((line = malloc((unsigned) j + 1)) == (char *)NULL)
+ #endif	/* KANJI */
  		SysError(ERROR_BMALLOC2);
  	    XtFree(screen->selection);
  	    screen->selection = line;
***************
*** 957,963 ****
--- 1074,1088 ----
  	}
  	*lp = '\0';		/* make sure we have end marked */
  	
+ #ifdef	KANJI	/* kato */
+ 	/*
+ 	 * (lp - line) should be used to express the length of the converted
+ 	 * Kanji string. j is only its original length.
+ 	 */
+ 	screen->selection_length = lp - line;
+ #else	/* KANJI */
  	screen->selection_length = j;
+ #endif	/* KANJI */
  	_OwnSelection(term, params, num_params);
  }
  
***************
*** 983,988 ****
--- 1108,1116 ----
  		    target, type, (caddr_t*)&std_targets, &std_length, format
  		   );
  	*length = std_length + 4;
+ #ifdef KANJI	/* ishisone */
+ 	*length++;
+ #endif
  	*value = (caddr_t)XtMalloc(sizeof(Atom)*(*length));
  	targetP = *(Atom**)value;
  	*targetP++ = XA_STRING;
***************
*** 989,994 ****
--- 1117,1125 ----
  	*targetP++ = XA_TEXT(d);
  	*targetP++ = XA_LENGTH(d);
  	*targetP++ = XA_LIST_LENGTH(d);
+ #ifdef KANJI	/* ishisone */
+ 	*targetP++ = XA_COMPOUND_TEXT(d);
+ #endif
  	bcopy((char*)std_targets, (char*)targetP, sizeof(Atom)*std_length);
  	XtFree((char*)std_targets);
  	*type = XA_ATOM;
***************
*** 996,1001 ****
--- 1127,1150 ----
  	return True;
      }
  
+ #ifdef KANJI	/* ishisone */
+     if (*target == XA_STRING) {
+ 	*type = XA_STRING;
+ 	*length = convJWStoLatin1(xterm->screen.selection, NULL);
+ 	*value = (caddr_t)XtMalloc(*length + 1);
+ 	(void)convJWStoLatin1(xterm->screen.selection, (wchar_t *)*value);
+ 	*format = 8;
+ 	return True;
+     }
+     if (*target == XA_TEXT(d) || *target == XA_COMPOUND_TEXT(d)) {
+ 	*type = XA_COMPOUND_TEXT(d);
+ 	*length = convJWStoCT(xterm->screen.selection, NULL, 0);
+ 	*value = (caddr_t)XtMalloc(*length + 1);
+ 	(void)convJWStoCT(xterm->screen.selection, (unsigned char *)*value, 0);
+ 	*format = 8;
+ 	return True;
+     }
+ #else
      if (*target == XA_STRING || *target == XA_TEXT(d)) {
  	*type = XA_STRING;
  	*value = xterm->screen.selection;
***************
*** 1003,1008 ****
--- 1152,1158 ----
  	*format = 8;
  	return True;
      }
+ #endif
      if (*target == XA_LIST_LENGTH(d)) {
  	*value = XtMalloc(4);
  	if (sizeof(long) == 4)
***************
*** 1018,1029 ****
--- 1168,1188 ----
      }
      if (*target == XA_LENGTH(d)) {
  	*value = XtMalloc(4);
+ #ifdef KANJI	/* ishisone */
  	if (sizeof(long) == 4)
+ 	    *(long*)*value = convJWStoCT(xterm->screen.selection, NULL, 0);
+ 	else {
+ 	    long temp = convJWStoCT(xterm->screen.selection, NULL, 0);
+ 	    bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4);
+ 	}
+ #else
+ 	if (sizeof(long) == 4)
  	    *(long*)*value = xterm->screen.selection_length;
  	else {
  	    long temp = xterm->screen.selection_length;
  	    bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4);
  	}
+ #endif
  	*type = XA_INTEGER;
  	*length = 1;
  	*format = 32;
***************
*** 1081,1086 ****
--- 1240,1246 ----
  }
  
  
+ #ifndef KANJI
  /* ARGSUSED */
  static void SelectionDone(w, selection, target)
  Widget w;
***************
*** 1088,1095 ****
  {
      /* empty proc so Intrinsics know we want to keep storage */
  }
  
- 
  static /* void */ _OwnSelection(term, selections, count)
  register XtermWidget term;
  String *selections;
--- 1248,1255 ----
  {
      /* empty proc so Intrinsics know we want to keep storage */
  }
+ #endif
  
  static /* void */ _OwnSelection(term, selections, count)
  register XtermWidget term;
  String *selections;
***************
*** 1120,1132 ****
--- 1280,1321 ----
  	  default:	       buffer = -1;
  	}
  	if (buffer >= 0)
+ #ifdef KANJI	/* ishisone */
+ 	{
+ 	    /* Since type of a CUT_BUFFER is STRING, KANJI and KANA
+ 	     * characters can't store in a CUT_BUFFER
+ 	     */
+ 	    int nw;
+ 	    int	nc = 0;
+ 	    wchar_t *p;
+ 	    char *s, *q;
+ 	    p = term->screen.selection;
+ 	    for (nw = term->screen.selection_length; nw > 0; nw--) {
+ 		if ((*p++ & 0x8080) == 0)
+ 		    nc++;
+ 	    }
+ 	    p = term->screen.selection;
+ 	    s = q = (char *)LOCAL_ALLOC(nc);
+ 	    for (nw = term->screen.selection_length; nw > 0; nw--, p++) {
+ 		if ((*p & 0x8080) == 0)
+ 		    *q++ = *p & 0x7f;
+ 	    }
+ 	    XStoreBytes( XtDisplay((Widget)term), s, nc, buffer);
+ 	    LOCAL_FREE(s);
+ 	}
+ #else
  	    XStoreBytes( XtDisplay((Widget)term), term->screen.selection,
  			 term->screen.selection_length, buffer );
+ #endif
  	else if (!replyToEmacs) {
  	    have_selection |=
  		XtOwnSelection( (Widget)term, atoms[i],
  			    term->screen.selection_time,
+ #ifdef KANJI
+ 			    ConvertSelection, LoseSelection, NULL);
+ #else
  			    ConvertSelection, LoseSelection, SelectionDone );
+ #endif
  	}
      }
      if (!replyToEmacs)
***************
*** 1179,1197 ****
--- 1368,1427 ----
  }
  
  /* copies text into line, preallocated */
+ #ifdef KANJI
+ wchar_t *SaveText(screen, row, scol, ecol, lp)
+ int row;
+ int scol, ecol;
+ TScreen *screen;
+ register wchar_t *lp;		/* pointer to where to put the text */
+ #else
  char *SaveText(screen, row, scol, ecol, lp)
  int row;
  int scol, ecol;
  TScreen *screen;
  register char *lp;		/* pointer to where to put the text */
+ #endif
  {
  	register int i = 0;
  	register char *ch = screen->buf[2 * (row + screen->topline)];
  	register int c;
+ #ifdef	KANJI	/* kato */
+ 	char *att = screen->buf[2 * (row + screen->topline) + 1];
+ #endif	/* KANJI */
  
  	if ((i = Length(screen, row, scol, ecol)) == 0) return(lp);
+ #ifdef	KANJI	/* kato */
+ 	/*
+ 	 * If the first byte is pointed to the 2nd byte of a Kanji char,
+ 	 * adjust to its 1st byte.
+ 	 */
+ 	if (att[scol] & KCS2) {
+ 		i++; scol--;
+ 	}
+ #endif	/* KANJI */
  	ecol = scol + i;
  	for (i = scol; i < ecol; i++) {
+ #ifdef KANJI
+ 		c = ch[i];
+ 		if (att[i] & KCS) {
+ 			/* KANJI */
+ 			c = (c << 8) | ch[i + 1] | 0x8080;
+ 			i++;
+ 		} else if (att[i] & KANACS) {
+ 			/* KANA */
+ 			c = c | 0x80;
+ 		} else if (c == 0) {
+ 			c = ' ';
+ 		} else if (c < ' ') {
+ 			if (c == '\036')
+ 				c = '#';
+ 			else
+ 				c += 0x5f;
+ 		} else if (c == 0x7f) {
+ 			c = 0x5f;
+ 		}
+ 		*lp++ = c;
+ #else
  		if ((c = ch[i]) == 0)
  			c = ' ';
  		else if(c < ' ') {
***************
*** 1202,1207 ****
--- 1432,1438 ----
  		} else if(c == 0x7f)
  			c = 0x5f;
  		*lp++ = c;
+ #endif
  	}
  	return(lp);
  }
***************
*** 1393,1399 ****
--- 1624,1635 ----
  	register int i;
  
  	if (*menu == NULL) {
+ #ifdef	KANJI	/* sano */
+ 		extern char menuname[]; /* defined in patchlevel.c */
+ 		if ((*menu = NewMenu(menuname)) == NULL)
+ #else	/* KANJI */
  		if ((*menu = NewMenu("xterm X11")) == NULL)
+ #endif	/* KANJI */
  			return(NULL);
  		for(cp = xtext ; *cp ; cp++)
  			AddMenuItem(*menu, *cp);



More information about the Comp.sources.x mailing list