/* $Header: /usr4/Src/emu.new/tdesc/RCS/xterm-ops,v 1.4 92/05/16 06:40:08 jkh Exp $ */

/*
 * Copyright 1990 by PCS Computer Systeme, GmbH. Munich, West Germany.
 *
 *                        All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its 
 * documentation for any purpose and without fee is hereby granted, 
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in 
 * supporting documentation, and that the names of PCS or the authors not
 * be used in advertising or publicity pertaining to distribution of the
 * software without specific, written prior permission.  
 * 
 * PCS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * PCS, THE AUTHORS, OR THEIR HOUSEPETS BE LIABLE FOR ANY SPECIAL, INDIRECT
 * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE. SO DON'T SUE US. THANK YOU.
 *
 */

/*
 * Input operations for the emu "xterm" terminal.
 *
 * Author: Michael Elbel, Jordan Hubbard.
 * Date: June 28th, 1990
 * Description: This file describes, in essence, what the "xterm" terminal
 *		looks like. It is a 'hacked down' vt220 description.
 *		So if you find any inconsistencies, let us know.
 *
 * Revision History:
 *
 * $Log:	xterm-ops,v $
# Revision 1.4  92/05/16  06:40:08  jkh
# Synchronization.
# 
 * Revision 1.3  92/02/26  13:18:16  me
 * Checkpoint
 *
 * Revision 1.2  91/09/30  18:30:01  me
 * added the 'alternate screen' switch as dummy
 *
 * Revision 1.1  91/09/30  18:15:36  me
 * Initial revision
 * 
 *
 */

*term.xterm-ops:							\
/* Absolute Cursor Positioning */					\
OP_MOVE_ABS		<\\E[%d;%d%{1,-,px,1,-,py}H>			\
OP_MOVE_ABS		<\\E[%d;%d%{1,-,px,1,-,py}f>			\
OP_MOVE_ABS		<\\E[%{0,py,0,px}H>				\
OP_MOVE_ABS		<\\E[%{0,py,0,px}f>				\
OP_MOVE_ABS_COLUMN	<%0%px\\r>					\
/* Relative Cursor Positioning */					\
OP_MOVE_REL_ROW		<\\E[%-1%pyA>					\
OP_MOVE_REL_ROW		<\\E[%{d,-1,*,py}A>				\
OP_MOVE_REL_ROW		<\\E[%1%pyB>					\
OP_MOVE_REL_ROW		<\\E[%d%pyB>					\
OP_MOVE_REL_COLUMN	<\\E[%{d,D,0,=,?,X,1,;,px}C>			\
OP_MOVE_REL_COLUMN	<\\E[%1%pxC>					\
OP_MOVE_REL_COLUMN	<\\E[%{d,D,0,=,?,X,1,;,-1,*,px}D>		\
OP_MOVE_REL_COLUMN	<\\E[%-1%pxD>					\
OP_MOVE_REL_COLUMN	<%-1%px\\b>					\
/* Scrolled Positioning */						\
OP_MOVE_REL_ROW_SCROLLED<%1%py\\n>					\
OP_MOVE_REL_ROW_SCROLLED<%1%py^K>					\
OP_MOVE_REL_ROW_SCROLLED<%1%py^L>					\
OP_MOVE_REL_ROW_SCROLLED<\\E%-1%pyM>					\
OP_MOVE_REL_ROW_SCROLLED<\\E%1%pyD>					\
OP_MOVE_REL_ROW_SCROLLED,OP_MOVE_ABS_COLUMN<\\E%1%py%0%pxE>		\
/* Deleting */								\
OP_DELETE_CHARS		<\\E[%1%paP>					\
OP_DELETE_CHARS		<\\E[%d%paP>					\
OP_ERASE_CHARS		<\\E[%d%paX>					\
OP_DELETE_TO_EOL	<\\E[K>						\
OP_DELETE_TO_EOL	<\\E[0K>					\
OP_ERASE_LINE_LEFT	<\\E[1K>					\
OP_ERASE_LINES		<\\E[2%1%paK>					\
OP_DELETE_TO_EOSCR	<\\E[J>						\
OP_DELETE_TO_EOSCR	<\\E[0J>					\
OP_ERASE_FROM_TOSCR	<\\E[1J>					\
OP_CLEAR_SCREEN		<\\E[2J>					\
/* Inserting */								\
OP_INSERT_LINES		<\\E[%1%paL>					\
OP_INSERT_LINES		<\\E[%d%paL>					\
OP_DELETE_LINES		<\\E[%1%paM>					\
OP_DELETE_LINES		<\\E[%d%paM>					\
/* Bell */								\
OP_RING_BELL		<^G>						\
/* Attributes */							\
OP_CLEAR_ATTRIBUTE	<\\E[%15%pbm>					\
OP_NOP			<\\E[%{						\
	s D								\
	/* clear everything and out */					\
	/* now loop over the string to find the arguments */		\
	La /* Loop head */						\
		';' $ 		/* find the next delimiter (if any) */	\
		CB_INT_TYPE @						\
		D 0 = ?		/* all off */				\
			15 pb OP_CLEAR_ATTRIBUTE C jb ;			\
		D 7 = ?		/* reverse video */			\
			ATT_REVERSE pa OP_SET_ATTRIBUTE  C jb ;		\
		D 1 = ?		/* bold */				\
			ATT_BOLD pa OP_SET_ATTRIBUTE  C jb ;		\
		D 4 = ?		/* underlined */			\
			ATT_UNDERL pa OP_SET_ATTRIBUTE  C jb ;		\
		D 5 = ?		/* blinking */				\
			ATT_BLINK pa OP_SET_ATTRIBUTE  C jb ;		\
		D 22 = ?	/* bold off */				\
			ATT_BOLD pb OP_CLEAR_ATTRIBUTE  C jb ;		\
		D 24 = ?	/* underline off */			\
			ATT_UNDERL pb OP_CLEAR_ATTRIBUTE  C jb ;	\
		D 25 = ?	/* blinking off */			\
			ATT_BLINK pb OP_CLEAR_ATTRIBUTE  C jb ;		\
		D 27 = ?	/* reverse video off */			\
			ATT_REVERSE pb OP_CLEAR_ATTRIBUTE  C;		\
		D 30 = ?	/* black fg */				\
			1 pa OP_CHANGE_FG_COLOR  C jb ; 		\
		D 31 = ?	/* red fg */				\
			2 pa OP_CHANGE_FG_COLOR  C jb ;	        	\
		D 32 = ?	/* green fg */				\
			3 pa OP_CHANGE_FG_COLOR  C jb ; 		\
		D 33 = ?	/* yellow fg */				\
			4 pa OP_CHANGE_FG_COLOR  C jb ; 		\
		D 34 = ?	/* blue fg */				\
			5 pa OP_CHANGE_FG_COLOR  C jb ; 		\
		D 35 = ?	/* magenta fg */			\
			6 pa OP_CHANGE_FG_COLOR  C jb ;	        	\
		D 36 = ?	/* cyan fg */				\
			7 pa OP_CHANGE_FG_COLOR  C jb ; 		\
		D 37 = ?	/* white fg */				\
			8 pa OP_CHANGE_FG_COLOR  C jb ; 		\
		D 40 = ?	/* black bg */				\
			1 pb OP_CHANGE_BG_COLOR  C jb ; 		\
		D 41 = ?	/* red bg */				\
			2 pb OP_CHANGE_BG_COLOR  C jb ;	        	\
		D 42 = ?	/* green bg */				\
			3 pb OP_CHANGE_BG_COLOR  C jb ; 		\
		D 43 = ?	/* yellow bg */				\
			4 pb OP_CHANGE_BG_COLOR  C jb ; 		\
		D 44 = ?	/* blue bg */				\
			5 pb OP_CHANGE_BG_COLOR  C jb ; 		\
		D 45 = ?	/* magenta bg */			\
			6 pb OP_CHANGE_BG_COLOR  C jb ;	        	\
		D 46 = ?	/* cyan bg */				\
			7 pb OP_CHANGE_BG_COLOR  C jb ; 		\
		D 47 = ?	/* white bg */				\
			8 pb OP_CHANGE_BG_COLOR  C jb ; 		\
		Lb							\
		X 		/* drop the processed item */		\
		D l ? ja ;	/* jump back if there's anything left */\
	Lc								\
	X f}m>								\
									\
/* Terminal Modes */							\
/* ANSI Modes */							\
OP_NOP			<\\E[%{						\
	/* get the string and rip off the l at the end */		\
	s D								\
	/* now loop over the string to find the arguments */		\
	La /* Loop head */						\
		';' $ 		/* find the next delimiter (if any) */	\
		CB_INT_TYPE @						\
		D 4 = ?		/* insert mode off */			\
			OP_OVERWRITE_MODE C ;				\
		X 		/* drop the processed item */		\
		D l ? ja ;	/* jump back if there's anything left */\
	X f}l>								\
									\
OP_NOP			<\\E[%{						\
	/* get the string and rip off the h at the end */		\
	s D								\
	/* now loop over the string to find the arguments */		\
	La /* Loop head */						\
		';' $ 		/* find the next delimiter (if any) */	\
		CB_INT_TYPE @						\
		D 4 = ?		/* insert mode  on */			\
			OP_INSERT_MODE C ;				\
		X 		/* drop the processed item */		\
		D l ? ja ;	/* jump back if there's anything left */\
	X f}h>								\
									\
/* DEC private Modes */							\
OP_NOP			<\\E[?%{					\
	s D								\
	/* now loop over the string to find the arguments */		\
	La /* Loop head */						\
		';' $ 		/* find the next delimiter (if any) */	\
		CB_INT_TYPE @						\
		D 47 = ?	/* alternate screen */			\
			/* we don't support this (yet) */ jb ;		\
		D 25 = ?	/* cursor invisible */			\
			OP_CURSOR_OFF C jb ;				\
		D 1 = ?	/* ANSI control cursor keys */			\
			"normCKeys" pa OP_OVERRIDE_TRANSLATIONS C jb ;	\
		D 3 = ?	/* 80 columns */				\
			OP_CANVAS_SIZE C /* get the current size */	\
			80 px 		 /* set 80 columns */		\
			OP_SET_SCREEN_SIZE C jb ;			\
		D 5 = ?	/* normal video	*/				\
			OP_NORMAL_VIDEO C jb ;				\
		D 6 = ?	/* cursor positioning absolute */		\
			OP_CURSOR_POS_ABSOLUTE C			\
			0 px 0 py OP_MOVE_ABS C jb ; /* go to 0/0 */	\
		D 7 = ?	/* don't wrap around at end of line */		\
			OP_DONT_WRAP C ;				\
		Lb							\
		X 		/* drop the processed item */		\
		D l ? ja ;	/* jump back if there's anything left */\
	X f}l>								\
									\
OP_NOP			<\\E[?%{					\
	s D								\
	/* now loop over the string to find the arguments */		\
	La /* Loop head */						\
		';' $ 		/* find the next delimiter (if any) */	\
		CB_INT_TYPE @						\
		D 47 = ?	/* alternate screen */			\
			/* we don't support this (yet) */ jb ;		\
		D 25 = ?	/* cursor visible */			\
			OP_CURSOR_ON C jb ;				\
		D 1 = ?	/* application control cursor keys */		\
			"appCKeys" pa OP_OVERRIDE_TRANSLATIONS C jb ;	\
		D 3 = ?	/* 132 columns */				\
			OP_CANVAS_SIZE C /* get the current size */	\
			132 px		 /* set 80 columns */		\
			OP_SET_SCREEN_SIZE C jb ;			\
		D 5 = ?	/* reverse video */				\
			OP_REVERSE_VIDEO C jb ;				\
		D 6 = ?	/* cursor positioning relative */		\
			OP_CURSOR_POS_REL_TO_SCR_REG C			\
			0 px 0 py OP_MOVE_ABS C jb ; /* go to 0/0 */	\
		D 7 = ?	/* wrap around at end of line */		\
			OP_WRAP_AROUND C ;				\
		Lb							\
		X 		/* drop the processed item */		\
		D l ? ja ;	/* jump back if there's anything left */\
	X f}h>								\
									\
/* Tabs */								\
OP_SET_TAB_CUR_COL	<\\EH>						\
OP_CLEAR_TAB_CUR_COL	<\\E[g>						\
OP_CLEAR_TAB_CUR_COL	<\\E[0g>					\
OP_NOP			<\\E[1g>  /* what is this supposed to do ??? */	\
OP_NOP			<\\E[2g>  /* what is this supposed to do ??? */	\
OP_CLEAR_ALL_TABS	<\\E[3g>					\
OP_HOR_TAB		<\\t>						\
/* Modes */								\
/* Translation Management */						\
OP_OVERRIDE_TRANSLATIONS<\\E%"appKeypad"%pa=>				\
OP_OVERRIDE_TRANSLATIONS<\\E%"numKeypad"%pa\\>>				\
									\
/* FLUT settings : G0 to G3 are stored in registers 0 to 3 */		\
OP_NOP			<\\EB>						\
OP_NOP			<\\E(%{						\
		/* check if G0 was already invoked into GL */		\
		0 g5 = ?						\
			"ascii" pa 32 pb OP_CHANGE_FLUT C ;		\
		"ascii" p0						\
		}B>							\
OP_NOP			<\\E)%"ascii"%p1B>				\
OP_NOP			<\\E*%"ascii"%p2B>				\
OP_NOP			<\\E+%"ascii"%p3B>				\
OP_NOP			<\\E<>						\
OP_NOP			<\\E(%{						\
		/* check if G0 was already invoked into GL */		\
		0 g5 = ?						\
			"dec" pa 32 pb OP_CHANGE_FLUT C ;		\
		"dec" p0						\
		}<>							\
OP_NOP			<\\E)%"dec"%p1<>				\
OP_NOP			<\\E*%"dec"%p2<>				\
OP_NOP			<\\E+%"dec"%p3<>				\
OP_NOP			<\\EA>						\
OP_NOP			<\\E(%"uk"%p0A>					\
OP_NOP			<\\E)%"uk"%p1A>					\
OP_NOP			<\\E0>						\
OP_NOP			<\\E(%{						\
		/* check if G0 was already invoked into GL */		\
		0 g5 = ?						\
			"graphics" pa 32 pb OP_CHANGE_FLUT C ;		\
		"graphics" p0						\
		}0>							\
OP_NOP			<\\E)%"graphics"%p10>				\
OP_NOP			<\\E*%"graphics"%p20>				\
OP_NOP			<\\E+%"graphics"%p30>				\
									\
/* Actual FLUT changing, the arguments come from registers 1 to 4, */	\
/* the character sets GL and GR are stored in registers 5 and 6 */	\
OP_CHANGE_FLUT		<%{g0,1,p5,pa,32,pb}\017>			\
OP_CHANGE_FLUT		<%{g1,1,p5,pa,32,pb}\016>			\
OP_CHANGE_FLUT		<\\E%{g2,2,p5,pa,32,pb}n>			\
OP_CHANGE_FLUT		<\\E%{g3,3,p5,pa,32,pb}o>			\
OP_CHANGE_FLUT		<\\E%{g1,1,p6,pa,160,pb}~>			\
OP_CHANGE_FLUT		<\\E%{g2,2,p6,pa,160,pb}\}>			\
OP_CHANGE_FLUT		<\\E%{g3,3,p6,pa,160,pb}|>			\
									\
/* Invoking G2 or G3 into GL for a single shift */			\
OP_NOP			<\\EN%c%{					\
		g2 pa 32 pb OP_CHANGE_FLUT C	     /* invoke g2 */	\
 		CB_STR_TYPE @ bs OP_INSERT C	     /* print char */	\
		g5 '0' + G pa 32 pb OP_CHANGE_FLUT C /* restore flut */	\
			}>						\
OP_NOP			<\\EO%c%{					\
		g3 pa 32 pb OP_CHANGE_FLUT C	     /* invoke g2 */	\
 		CB_STR_TYPE @ bs OP_INSERT C	     /* print char */	\
		g5 '0' + G pa 32 pb OP_CHANGE_FLUT C /* restore flut */	\
			}>						\
									\
/* Scroll region setting */						\
OP_SET_SCROLL_REGION	<\\E[%d;%d%{1,-,pb,1,-,pa}r>			\
OP_SET_SCROLL_REGION	<\\E[%{OP_CANVAS_SIZE,C,gy,1,-,pb,0,pa}r>	\
									\
/* Saving and restoring state. Regs o - w are used for storage */	\
OP_NOP			<\\E%{						\
		g0 g1 g2 g3 po pp pq pr 		/* save fluts */\
		OP_CANVAS_CURSOR_POS C gx gy ps pt	/* cursor pos */\
		OP_CANVAS_ATTRIBS C ga pu		/* attributes */\
		OP_CANVAS_WRAP_MODE C ga pv		/* wrap flag  */\
		OP_SAVE_FLUT C				/* save flut  */\
			}7>						\
OP_NOP			<\\E%{						\
		go gp gq gr p0 p1 p2 p3			/* fluts */	\
		gs gt px py OP_MOVE_ABS C		/* cursor pos */\
		15 pb OP_CLEAR_ATTRIBUTE C				\
		gu pa OP_SET_ATTRIBUTE C		/* attributes */\
		gv ? OP_WRAP_AROUND : OP_DONT_WRAP ; C	/* wrapping   */\
		OP_RESTORE_FLUT C			/* restore it */\
			}8>						\
									\
/* Print full screen of 'E's for test pattern */			\
OP_NOP			<\\E#%{						\
	OP_CANVAS_CURSOR_POS C gx gy					\
	0 px 0 py OP_MOVE_ABS C						\
	OP_CLEAR_SCREEN C						\
	OP_CANVAS_SIZE C						\
	gx								\
	"" bs								\
		Lb							\
		"E" ba							\
		1 - D ? jb ;						\
	gy								\
		La							\
		OP_INSERT C						\
		1 - D ? ja ;						\
	 py px OP_MOVE_ABS C						\
			}8>						\
/* Reports from the Emulation */					\
OP_NOP		<\\E[7%{OP_CANVAS_SIZE C ROP_SCREEN_SIZE R}n>		\
OP_NOP		<\\E[6%{OP_CANVAS_CURSOR_POS C ROP_CURSOR_POS R}n>	\
/* Now the unsupported Features, we just ignore them */			\
OP_NOP		<\\E F>							\
OP_NOP		<\\E G>							\
OP_NOP		<\\E[%cq>						\
OP_NOP		<\\E[?K>						\
OP_NOP		<\\E[?%dK>						\
OP_NOP		<\\E[?J>						\
OP_NOP		<\\E[?%dJ>						\
OP_NOP		<\\E#3>							\
OP_NOP		<\\E#4>							\
OP_NOP		<\\E#5>							\
OP_NOP		<\\E#6>							\
OP_NOP		<\\E[%d\"p>						\
OP_NOP		<\\E[%d;%d\"p>						\
OP_NOP		<\\E[i>							\
OP_NOP		<\\E[%di>						\
OP_NOP		<\\E[?%di>						\
/* Special xterm Sequences */						\
OP_NOP		<\\E%dr>						\
OP_NOP		<\\E%ds>						\
/* Setting the title */							\
OP_NOP		<\\E]2;%{s,D,t,f}\\007>					\
/* Setting the icon */							\
OP_NOP		<\\E]1;%{s,D,i,f}\\007>					\
/* Setting title and icon */						\
OP_NOP		<\\E]0;%{s,D,D,t,i,f}\\007>				\
/* Unsupported xterm Features. We have to explicitly ignore these */	\
/* Mouse tracking */							\
OP_NOP		<\\E%d;%d;%d;%d;%dT>					\
/* Device Attributes */							\
OP_NOP		<\\E%dc>						\
/* Device Status Report */						\
OP_NOP		<\\E%dn>						\
/* Save and restore DEC Private Mode Values */				\
OP_NOP		<\\E[?%s%fr>						\
OP_NOP		<\\E[?%s%fs>
