! This file contains keybindings for xterm to ensure that every key on the
! keyboard (including all function keys, keypad keys, and freestanding arrow
! keys etc.) produces some key sequence that may be recognised by Jove.  The
! file jove.rc.xterm then provides suggested translations from those key
! sequences to Jove commands.  Note: these resources are to be installed
! on the X server and affect its keyboard and mouse.
!
! On Suns, xterm provides a choice of keybindings for the funcion keys, to
! match the usual Sun bindings if XTerm*sunFunctionKeys is true and to match
! VT220-like bindings otherwise.  This file supports both modes.
!
! For keys which are not customarily bound at all in xterm, we have chosen
! bindings in the Sun style, to minimise the possibility of accidentally
! producing sequences that might be meaningful to some program.  Thus it is
! expected that existing applications using xterm will not be affected by
! these bindings.
!
! This file may be incorporated in your .Xdefaults file, or kept as a separate
! file to be invoked by xrdb (probably from within your .xinitrc).  In either
! case, the call of xrdb must be in the form
!	xrdb -merge -DSUN -DSUNKEYS -DJOVE -DXTERM=xjoveterm $HOME/.Xdefaults
! where you should include
! -DSUN on any Sun machine (to cope with the strange Sun bindings of
!                           F11 and F12).
! -DSUNKEYS to define the sunFunctionKeys resource and adjust other
!           bindings so that Sun keyboard sequences are generated
!           instead of the "standard" sequences.  See xterm(1).
! -DJOVE if you want full Jove mouse operations
!        (tells xterm to pass Ctrl-modified mouse events through)
! -DXTERM=xjoveterm if the effects are only required when xterm is called by
!        the name 'xjoveterm' (or whatever), where 'xjoveterm' might be a
!        soft link to xterm.  The combination of this facility with -DJOVE
!        is recommended.
!
! Alternatively, this file may be included in your XFILESEARCHPATH
! or XUSERFILESEARCHPATH, or in the XENVIRONMENT variable, in which case it
! must first be passed through cpp with -DSUN etc. as appropriate.
!
! If SUN is #defined, the CLIPBOARD is used for xterm-style cutting and
! pasting, thus permitting cutting and pasting from cmdtool and textedit
! windows.  This may be overridden by #defining BUFFER (e.g. to CUT_BUFFER0).

#ifndef XTERM
#define XTERM	XTerm
#endif

#ifndef BUFFER
#ifdef SUN
#define BUFFER CLIPBOARD
#else
#define BUFFER CUT_BUFFER0
#endif
#endif

#ifdef JOVE
#define MOUSE_SPECIFIC	\
	!Ctrl <BtnDown>: ignore()\n \
	!Ctrl <BtnUp>: ignore()\n \
	~Ctrl ~Meta <Btn2Up>: insert-selection(PRIMARY,BUFFER)\n \
	<BtnUp>: select-end(PRIMARY,BUFFER)\n 
#else
#define MOUSE_SPECIFIC	\
	~Ctrl ~Meta <Btn2Up>: insert-selection(PRIMARY,BUFFER)\n \
	<BtnUp>: select-end(PRIMARY,BUFFER)\n 
#endif

#ifdef SUN
#define SUNSPECIFIC	\
	<Key>L1:		string(0x1B)string("[192z")\n \
	<Key>L2:		string(0x1B)string("[193z")\n \
	<Key>Pause:		string(0x1B)string("[208z")\n \
	<Key>Print:		string(0x1B)string("[209z")\n \
	<Key>Scroll_Lock:	string(0x1B)string("[210z")\n
#else
#define SUNSPECIFIC	
#endif

#ifndef SUNKEYS
XTERM*sunFunctionKeys:			false
#define SUNKEYS_SPECIFIC	\
	~@Num_Lock<Key>KP_Equal:	string(0x1B)string("[211z")\n \
	~@Num_Lock<Key>KP_Divide:	string(0x1B)string("[212z")\n \
	~@Num_Lock<Key>KP_Multiply:	string(0x1B)string("[213z")\n \
	~@Num_Lock<Key>KP_5:		string(0x1B)string("[218z")\n
#define SUNKEYS_KP_SPECIFIC	\
	<Key>Prior:	string(0x1B)string("[5~")\n \
	<Key>Next:	string(0x1B)string("[6~")\n \
	<Key>Insert:	string(0x1B)string("[2~")\n \
	<Key>Find:	string(0x1B)string("[1~")\n
#else
XTERM*sunFunctionKeys:			true
#define SUNKEYS_SPECIFIC	
#define SUNKEYS_KP_SPECIFIC	\
	<Key>Prior:	string(0x1B)string("[216z")\n \
	<Key>Next:	string(0x1B)string("[222z")\n \
	<Key>Insert:	string(0x1B)string("[2~")\n
#endif

XTERM.VT100.Translations: #override \
	<Key>SunF36:	string(0x1B)string("[234z")\n \
	<Key>SunF37:	string(0x1B)string("[235z")\n \
SUNSPECIFIC \
SUNKEYS_SPECIFIC \
	~@Num_Lock<Key>KP_Decimal:	string(0x1B)string("[249z")\n \
	~@Num_Lock<Key>KP_Enter:	string(0x1B)string("[250z")\n \
	~@Num_Lock<Key>KP_Add:		string(0x1B)string("[253z")\n \
	~@Num_Lock<Key>KP_Subtract:	string(0x1B)string("[254z")\n \
	~@Num_Lock<Key>KP_Insert:	string(0x1B)string("[2~")\n \
	@Num_Lock<Key>KP_0:		string(0)\n \
	@Num_Lock<Key>KP_1:		string(1)\n \
	@Num_Lock<Key>KP_2:		string(2)\n \
	@Num_Lock<Key>KP_3:		string(3)\n \
	@Num_Lock<Key>KP_4:		string(4)\n \
	@Num_Lock<Key>KP_5:		string(5)\n \
	@Num_Lock<Key>KP_6:		string(6)\n \
	@Num_Lock<Key>KP_7:		string(7)\n \
	@Num_Lock<Key>KP_8:		string(8)\n \
	@Num_Lock<Key>KP_9:		string(9)\n \
	@Num_Lock<Key>KP_Decimal:	string(.)\n \
	@Num_Lock<Key>KP_Enter:		string(0x0D)\n \
	@Num_Lock<Key>KP_Add:		string(+)\n \
	@Num_Lock<Key>KP_Subtract:	string(-)\n \
	@Num_Lock<Key>KP_Multiply:	string(*)\n \
	@Num_Lock<Key>KP_Divide:	string(/)\n \
	@Num_Lock<Key>KP_Equal:		string(=)\n \
	<Key>Help:	string(0x1B)string("[202z")\n \
	<Key>Left:	string(0x1B)string("[D")\n \
	<Key>Right:	string(0x1B)string("[C")\n \
	<Key>Up:	string(0x1B)string("[A")\n \
	<Key>Down:	string(0x1B)string("[B")\n \
	<Key>Home:	string(0x1B)string("[214z")\n \
	<Key>End:	string(0x1B)string("[220z")\n \
SUNKEYS_KP_SPECIFIC \
MOUSE_SPECIFIC
