if (term->keyboard.type == keyboardIsVT220)
if (term->keyboard.type == keyboardIsVT220 && (keysym != XK_Delete || !xtermDeleteIsDEL()))
Input (	register TKeyboard *keyboard,	register TScreen *screen,	register XKeyEvent *event,	Bool eightbit){#define STRBUFSIZE 500	char strbuf[STRBUFSIZE];	register Char *string;	register int key = FALSE;	int	pty	= screen->respond;	int	nbytes;	KeySym  keysym = 0;	ANSI	reply;	int	dec_code;	short	modify_parm = 0;	int	keypad_mode = ((keyboard->flags & MODE_DECKPAM) != 0);#if OPT_WIDE_CHARS	long    ucs;#endif	/* Ignore characters typed at the keyboard */	if (keyboard->flags & MODE_KAM)		return;#if OPT_I18N_SUPPORT	if (screen->xic#if OPT_WIDE_CHARS	 && !screen->utf8_mode#endif	 ) {	    Status status_return;	    nbytes = XmbLookupString (screen->xic, event,				      strbuf, sizeof(strbuf),				      &keysym, &status_return);	}	else#endif	{	    static XComposeStatus compose_status = {NULL, 0};	    nbytes = XLookupString (event, strbuf, sizeof(strbuf),				    &keysym, &compose_status);	}#if OPT_WIDE_CHARS	/*	 * FIXME:  As long as Xlib does not provide proper UTF-8 conversion via	 * XLookupString(), we have to generate them here.  Once Xlib is fully	 * UTF-8 capable, this code here should be removed again.	 */	if (screen->utf8_mode) {		ucs = -1;		if (nbytes == 1) {		/* Take ISO 8859-1 character delivered by XLookupString() */			ucs = (unsigned char) strbuf[0];		} else if (!nbytes &&			   ((keysym >= 0x100 && keysym <= 0xf000) ||			    (keysym & 0xff000000U) == 0x01000000))			ucs = keysym2ucs(keysym);		else			ucs = -2;		if (ucs == -1)			nbytes = 0;		if (ucs >= 0)			nbytes = convertFromUTF8(ucs, (Char *)strbuf);	}#endif	string = (Char *)&strbuf[0];	reply.a_pintro = 0;	reply.a_final = 0;	reply.a_nparam = 0;	reply.a_inters = 0;	TRACE(("Input keysym %#04lx, %d:'%.*s'%s%s%s%s%s%s%s%s%s%s%s%s\n",		keysym,		nbytes,		nbytes > 0 ? nbytes : 1,		nbytes > 0 ? strbuf : "",		ModifierName(event->state & ShiftMask),		ModifierName(event->state & LockMask),		ModifierName(event->state & ControlMask),		ModifierName(event->state & Mod1Mask),		ModifierName(event->state & Mod2Mask),		ModifierName(event->state & Mod3Mask),		ModifierName(event->state & Mod4Mask),		ModifierName(event->state & Mod5Mask),		eightbit ? " 8bit" : " 7bit",		IsFunctionKey(keysym)     ? " FKey"     : "",		IsMiscFunctionKey(keysym) ? " MiscFKey" : "",		IsEditFunctionKey(keysym) ? " EditFkey" : ""));#if OPT_SUNPC_KBD	/*	 * DEC keyboards don't have keypad(+), but do have keypad(,) instead.	 * Other (Sun, PC) keyboards commonly have keypad(+), but no keypad(,)	 * - it's a pain for users to work around.	 */	if (term->keyboard.type != keyboardIsSun	 && (event->state & ShiftMask) == 0	 && term->keyboard.type == keyboardIsVT220	 && keysym == XK_KP_Add) {		keysym = XK_KP_Separator;		TRACE(("...Input keypad(+), change keysym to %#04lx\n", keysym));	}#endif	/*	 * The keyboard tables may give us different keypad codes according to	 * whether NumLock is pressed.  Use this check to simplify the process	 * of determining whether we generate an escape sequence for a keypad	 * key, or force it to the value kypd_num[].  There is no fixed	 * modifier for this feature, so we assume that it is the one assigned	 * to the NumLock key.	 *	 * This check used to try to return the contents of strbuf, but that	 * does not work properly when a control modifier is given (trash is	 * returned in the buffer in some cases -- perhaps an X bug).	 */#if OPT_NUM_LOCK	if (nbytes == 1	 && IsKeypadKey(keysym)	 && term->misc.real_NumLock	 && ((term->misc.num_lock == 0)	  || (term->misc.num_lock & event->state) != 0)) {		keypad_mode = 0;		TRACE(("...Input num_lock, force keypad_mode off\n"));	}#endif	/*	 * If we are in the normal (possibly Sun/PC) keyboard state, allow	 * modifiers to add a parameter to the function-key control sequences.	 */	if (event->state != 0	 && !(IsKeypadKey(keysym) && keypad_mode)#if OPT_SUNPC_KBD	 && term->keyboard.type != keyboardIsVT220#endif#if OPT_VT52_MODE	 && screen->ansi_level != 0#endif	) {#define ModifierParm(ctl,normal) \	    modify_parm = (event->state & ControlMask) ? ctl : normal#if OPT_NUM_LOCK	    if (term->misc.real_NumLock	     && ((event->state & term->misc.alt_left) != 0	      || (event->state & term->misc.alt_right)) != 0) {		if (event->state & ShiftMask) {		    ModifierParm(8, 4);		} else {		    ModifierParm(7, 3);		}	    } else#endif	    if (event->state & ShiftMask) {		ModifierParm(6, 2);	    } else {		ModifierParm(5, 1);	    }	    TRACE(("...ModifierParm %d\n", modify_parm));	}#if OPT_SHIFT_KEYS	if (term->misc.shift_keys	 && (event->state & ShiftMask) != 0) {		switch (keysym) {		case XK_KP_Add:		    HandleLargerFont((Widget)0, (XEvent *)0, (String *)0, (Cardinal *)0);		    return;		case XK_KP_Subtract:		    HandleSmallerFont((Widget)0, (XEvent *)0, (String *)0, (Cardinal *)0);		    return;		default:		    break;		}	}#endif	/* VT300 & up: backarrow toggle */	if ((nbytes == 1)	 && (((term->keyboard.flags & MODE_DECBKM) == 0)	   ^ ((event->state & ControlMask) != 0))	 && (keysym == XK_BackSpace)) {		strbuf[0] = '\177';		TRACE(("...Input backarrow changed to %d\n", *strbuf));	}#if OPT_SUNPC_KBD	/* make an DEC editing-keypad from a Sun or PC editing-keypad */	if (term->keyboard.type == keyboardIsVT220)		keysym = TranslateFromSUNPC(keysym);	else#endif	{#ifdef XK_KP_Home	if (keysym >= XK_KP_Home && keysym <= XK_KP_Begin) {		keysym += XK_Home - XK_KP_Home;		TRACE(("...Input keypad changed to %#04lx\n", keysym));	}#endif	}#if OPT_HP_FUNC_KEYS	if (term->keyboard.type == keyboardIsHP	 && (reply.a_final = hpfuncvalue (keysym)) != 0) {		reply.a_type = ESC;		MODIFIER_PARM;		unparseseq(&reply, pty);	} else#endif#if OPT_SCO_FUNC_KEYS	if (term->keyboard.type == keyboardIsSCO	 && (reply.a_final = scofuncvalue (keysym)) != 0) {		reply.a_type = CSI;		MODIFIER_PARM;		unparseseq(&reply, pty);	} else#endif	if (IsPFKey(keysym)) {		reply.a_type = SS3;		reply.a_final = keysym-XK_KP_F1+'P';		VT52_CURSOR_KEYS		MODIFIER_PARM;		unparseseq(&reply, pty);		key = TRUE;#if 0	/* OPT_SUNPC_KBD should suppress - but only for vt220 compatibility */	} else if (term->keyboard.type == keyboardIsVT220		&& screen->ansi_level <= 1		&& IsEditFunctionKey(keysym)) {		key = FALSE;	/* ignore editing-keypad in vt100 mode */#endif	} else if (IsCursorKey(keysym) &&		keysym != XK_Prior && keysym != XK_Next) {		if (keyboard->flags & MODE_DECCKM) {			reply.a_type = SS3;			reply.a_final = curfinal[keysym-XK_Home];			VT52_CURSOR_KEYS			MODIFIER_PARM;			unparseseq(&reply, pty);		} else {			reply.a_type = CSI;			if_OPT_VT52_MODE(screen,{ reply.a_type = ESC; })			reply.a_final = curfinal[keysym-XK_Home];			MODIFIER_PARM;			unparseseq(&reply, pty);		}		key = TRUE;	 } else if (IsFunctionKey(keysym)		|| IsMiscFunctionKey(keysym)		|| IsEditFunctionKey(keysym)		|| (keysym == XK_Delete		 && ((modify_parm > 1)#if OPT_SUNPC_KBD		  || ( !screen->delete_is_del		   && term->keyboard.type == keyboardIsDefault)		  || term->keyboard.type == keyboardIsVT220#endif		  ))) {#if OPT_SUNPC_KBD		if (term->keyboard.type == keyboardIsVT220) {			if ((event->state & ControlMask)			 && (keysym >= XK_F1 && keysym <= XK_F12))				keysym += 12;		}#endif		dec_code = decfuncvalue(keysym);		if ((event->state & ShiftMask)#if OPT_SUNPC_KBD		 && term->keyboard.type == keyboardIsVT220#endif		 && ((string = (Char *)udk_lookup(dec_code, &nbytes)) != 0)) {			while (nbytes-- > 0)				unparseputc(*string++, pty);		}#if OPT_VT52_MODE		/*		 * Interpret F1-F4 as PF1-PF4 for VT52, VT100		 */		else if (term->keyboard.type != keyboardIsSun		 && term->keyboard.type != keyboardIsLegacy		 && (dec_code >= 11 && dec_code <= 14))		{			reply.a_type = SS3;			VT52_CURSOR_KEYS			reply.a_final = A2E(dec_code - 11 + E2A('P')) ;			MODIFIER_PARM;			unparseseq(&reply, pty);		}#endif		else {			reply.a_type = CSI;			reply.a_nparam = 1;			reply.a_final = 0;			MODIFIER_PARM;			if (term->keyboard.type == keyboardIsSun ) {				reply.a_param[0] = sunfuncvalue (keysym);				reply.a_final = 'z';#ifdef XK_ISO_Left_Tab			} else if (keysym == XK_ISO_Left_Tab) {				reply.a_nparam = 0;				reply.a_final = 'Z';#endif			} else {				reply.a_param[0] = dec_code;				reply.a_final = '~';			}			if (reply.a_final != 0			 && (reply.a_nparam == 0 || reply.a_param[0] >= 0))				unparseseq(&reply, pty);		}		key = TRUE;	} else if (IsKeypadKey(keysym)) {		if (keypad_mode) {			reply.a_type  = SS3;			reply.a_final = kypd_apl[keysym-XK_KP_Space];			VT52_KEYPAD			MODIFIER_PARM;			unparseseq(&reply, pty);		} else {			unparseputc(kypd_num[keysym-XK_KP_Space], pty);		}		key = TRUE;	} else if (nbytes > 0) {#if OPT_TEK4014		if(screen->TekGIN) {			TekEnqMouse(*string++);			TekGINoff();			nbytes--;		}#endif		if (nbytes == 1) {#if OPT_NUM_LOCK			/*			 * Send ESC if we have a META modifier and			 * metaSendsEcape is true.  Like eightBitInput, except			 * that it is not associated with terminal settings.			 */			if (eightbit			 && screen->meta_sends_esc			 && ((event->state & term->misc.meta_left) != 0			  || (event->state & term->misc.meta_right)) != 0) {				TRACE(("...input-char is modified by META\n"));				eightbit = False;				unparseputc (ESC, pty);  /* escape */			}#endif			if (eightbit && screen->input_eight_bits) {				if (CharOf(*string) < 128) {					TRACE(("...input shift from %d to %d\n",						CharOf(*string),						CharOf(*string) | 0x80));					*string |= 0x80;				}				eightbit = False;			}			/* VT220 & up: National Replacement Characters */			if ((term->flags & NATIONAL) != 0) {				int cmp = xtermCharSetIn(CharOf(*string), screen->keyboard_dialect[0]);				TRACE(("...input NRC %d, %s %d\n",					CharOf(*string),					(CharOf(*string) == cmp)						? "unchanged"						: "changed to",					CharOf(cmp)));				*string = cmp;			} else if (eightbit) {				unparseputc (ESC, pty);  /* escape */			} else if (*string == '?'			    && (event->state & ControlMask) != 0) {				*string = 127;			}		}		while (nbytes-- > 0)			unparseputc(*string++, pty);		key = TRUE;	}	if(key && !TEK4014_ACTIVE(screen))		AdjustAfterInput(screen);#ifdef ENABLE_PRINT	if (keysym == XK_F2) TekPrint();#endif	return;}