# The following bindings should work with most keyboards when used
# with the 'xterm' terminal emulator.  There are two sets of bindings of
# function keys within 'xterm' that are commonly used on Suns, one emulating
# the customary Sun bindings and the other being more vt220-like.  The
# following binding will work with either of them.  Note: in the preceding,
# "binding" means the characters sent by xterm to the program in response
# to keystrokes.

# Xterm Mouse Bindings
#
# If its program enables the mode, xterm will send the client character
# sequences signifying certain mouse events.  JOVE will enable this mode
# while it is running if the xt-mouse variable is on.

set xt-mouse on

# JOVE decodes the resulting character sequences using its normal
# key binding techiques.  These bindings invoke certain commands designed
# to process mouse events.  Here we have two set of bindings: one
# makes mouse actions behave analogously to those in xterm; the other
# is more like OpenLook.  One should be suppressed via commenting.
#
# Bindings to give other "looks and feels" are possible, except for
# operations marked 'button 1 ONLY' below.  Those operations involving
# use of CTRL require the special translation table contained in the
# file 'XTermresource'.

# Xterm "Look and Feel" Bindings:
#
# button 1:
#	down with no modifiers:
#		xt-mouse-point [set point to mouse location]
#	down with CTRL held:
#		xt-mouse-mark [set point and mark to mouse location]
# button 2:
#	down with no modifiers:
#		xt-mouse-point-yank [yank at mouse location]
#		[weaker but more xterm-like binding: xt-mouse-yank for yank at point]
#	down with CTRL held:
#		xt-mouse-cut-point-yank [delete region and yank at mouse location]
# button 3:
#	down with no modifiers:
#		xt-mouse-extend [extend copied region and re-copy]
#	down with CTRL held:
#		xt-mouse-null
# button up:
#	up after drag: [button 1 ONLY]
#		xt-mouse-mark-drag-point-copy [set region and copy]
#	other button up:
#		xt-mouse-null

# button 1 down [note that the next line has a SPace at the end]
bind-to-key xt-mouse-point ^[[M 
bind-to-key xt-mouse-mark ^[[M0

# button 2 down
# less powerful but more xterm-like: bind-to-key xt-mouse-yank ^[[M!
bind-to-key xt-mouse-point-yank ^[[M!
bind-to-key xt-mouse-cut-point-yank ^[[M1

# button 3 down
bind-to-key xt-mouse-extend ^[[M"
bind-to-key xt-mouse-null ^[[M2

# button 1 up after drag and/or multiclick
bind-to-key xt-mouse-mark-drag-point-copy ^[[T
bind-to-key xt-mouse-mark-drag-point-copy ^[[t

# other button releases
bind-to-key xt-mouse-null ^[[M#
bind-to-key xt-mouse-null ^[[M3

# End of xterm "look and feel" bindings.


## OpenLook "Look and Feel" Bindings:
##
## The differences are in buttons 2 and 3.
##
## button 1:
##	down with no modifiers:
##		xt-mouse-point [set point to mouse location]
##	down with CTRL held:
##		xt-mouse-mark [set point and mark to mouse location]
## button 2:
##	down with no modifiers:
##		xt-mouse-extend [extend copied region and re-copy]
##	down with CTRL held:
##		xt-mouse-point-yank [yank at mouse location]
## button 3:
##	down with no modifiers:
##		xt-mouse-null
##	down with CTRL held:
##		xt-mouse-cut-point-yank [delete region and yank at mouse location]
## button up:
##	up after drag: [button 1 ONLY]
##		xt-mouse-mark-drag-point-copy [set region and copy]
##	other button up:
##		xt-mouse-null
#
## button 1 down [note that the next line has a SPace at the end]
#bind-to-key xt-mouse-point ^[[M 
#bind-to-key xt-mouse-mark ^[[M0
#
## button 2 down
#bind-to-key xt-mouse-extend ^[[M!
#bind-to-key xt-mouse-point-yank ^[[M1
#
## button 3 down
#bind-to-key xt-mouse-null ^[[M"
#bind-to-key xt-mouse-cut-point-yank ^[[M2
#
## button 1 up after drag and/or multiclick
#bind-to-key xt-mouse-mark-drag-point-copy ^[[T
#bind-to-key xt-mouse-mark-drag-point-copy ^[[t
#
## other button releases
#bind-to-key xt-mouse-null ^[[M#
#bind-to-key xt-mouse-null ^[[M3
#
## End of OpenLook "look and feel" bindings.


# define macro to display TERMinal-specific keychart file
define-macro keychart ^[xpushlibd^M^U^[xshell-command-with-typeout cat keychart.$TERM^M^[xpopd^M

# See the file jove.rc.sun(-cmd) for further details of this binding, and
# for reasons why it is as it is.

# Arrow keys
bind-to-key backward-character ^[[D
bind-to-key previous-line ^[[A
bind-to-key next-line ^[[B
bind-to-key forward-character ^[[C
bind-to-key backward-character ^[OD
bind-to-key previous-line ^[OA
bind-to-key next-line ^[OB
bind-to-key forward-character ^[OC

# L keys
bind-to-key over-write-mode ^[[192z
bind-to-key auto-fill-mode ^[[193z
bind-to-key set-mark ^[[194z
bind-to-key set-mark ^[[25~
bind-to-key exchange-point-and-mark ^[[195z
bind-to-key exchange-point-and-mark ^[[26~
bind-to-key copy-region ^[[197z
bind-to-key copy-region ^[[29~
bind-to-key yank ^[[199z
bind-to-key yank ^[[32~
bind-to-key search-forward ^[[200z
bind-to-key search-forward ^[[33~
bind-to-key search-forward ^[[1~
bind-to-key search-reverse ^[^[[200z
bind-to-key search-reverse ^[^[[33~
bind-to-key search-reverse ^[^[[1~
bind-to-key kill-region ^[[201z
bind-to-key kill-region ^[[34~

# Help key
bind-macro-to-key keychart ^[[202z

# F keys
bind-to-key execute-named-command ^[[224z
bind-to-key execute-named-command ^[[11~
bind-to-key split-current-window ^[[225z
bind-to-key split-current-window ^[[12~
bind-to-key next-window ^[[226z
bind-to-key next-window ^[[13~
bind-to-key delete-other-window ^[[227z
bind-to-key delete-other-window ^[[14~
bind-to-key delete-current-window ^[[228z
bind-to-key delete-current-window ^[[15~
bind-to-key grow-window ^[[229z
bind-to-key grow-window ^[[17~
bind-to-key spell-buffer ^[[230z
bind-to-key spell-buffer ^[[18~
bind-to-key fill-comment ^[[231z
bind-to-key fill-comment ^[[19~
bind-to-key fill-paragraph ^[[232z
bind-to-key fill-paragraph ^[[20~
bind-to-key list-buffers ^[[233z
bind-to-key list-buffers ^[[21~
bind-to-key select-buffer ^[[234z
bind-to-key select-buffer ^[[23~
bind-to-key find-file ^[[235z
bind-to-key find-file ^[[24~

# On many keyboards the Backspace key is near Delete and, in the
# default Jove bindings these both do delete-previous-character. They would
# make a fine pair with one to delete forward and one to delete backward.
# For historical reasons, we leave them both as delete backward, but
# recommend that the adventurous (or IBM PC acculturated) enable these.
# bind-to-key delete-next-character ^?
# bind-to-key kill-next-word ^[^?

# R keys (these are all associated with cursor movement or scrolling)
bind-to-key unbound ^[[208z
bind-to-key beginning-of-line ^[[209z
bind-to-key end-of-line ^[[210z
bind-to-key unbound ^[[211z
bind-to-key backward-word ^[[212z
bind-to-key forward-word ^[[213z
bind-to-key beginning-of-file ^[[214z
bind-to-key beginning-of-file ^[[41~
bind-to-key previous-page ^[[216z
bind-to-key previous-page ^[[5~
# This moves the cursor to the start of the next line.
define-macro newline-and-beginning ^A^N
bind-macro-to-key newline-and-beginning ^[[218z
bind-to-key end-of-file ^[[220z
bind-to-key next-page ^[[222z
bind-to-key next-page ^[[6~

# KP_0 (engraved "Ins")
bind-to-key newline-and-backup ^[[2~
# KP_Point (engraved "Del")
bind-macro-to-key kill-line ^[[249z
# KP_Enter
bind-to-key shell ^[[250z
# KP_Add
bind-to-key scroll-up ^[[253z
# KP_Subtract
bind-to-key scroll-down ^[[254z

set scroll-bar on
