keyboard.rc
author Claus Gittinger <cg@exept.de>
Tue, 16 Jul 2013 11:49:58 +0200
changeset 1318 e9fbcd98cb2b
parent 1313 c286f9b4fd53
child 1330 5a64cf920fd2
permissions -rw-r--r--
*** empty log message ***

"*
 * Encoding: iso8859-1
 *
 * $Header$
 *
 * MIMEType: application/x-smalltalk-source
 *
 * ST/X startup configuration file:
 *
 * sample keyboard.rc - file
 *
 * this file defines some mappings for common function keys.
 * These definitions used to be in 'private.rc',
 * but have been extracted into this separate file to allow easier
 * sharing of rc files (users having different private files, but want
 * to use the same keyboard mappings / keyboard macros)
 *
 * A copy of this file can reside in $home/.smalltalk/keyboard.rc or
 * in the current directory. After a change, file it in the running st/x,
 * using the fileBrowser's fileIn function.
 *
 * These are my personal preferrences which may not be
 * correct for your environment.
 *
 * WARNING:
 *   please keep the expressions below free from manipulating
 *   global state - all that should be done here is to set up the current
 *   screens keyboard map.
 *   Reason: in multihead applications, this will be consulted for each
 *   new display screen.
 *"
!
Smalltalk fileIn:'keyboardMacros.rc'.
!

"*
 * key bindings common to all display types
 * use event monitor, to see what the Xserver sends us;
 * put display-specific stuff into a d_hostName.rc file.
 *"
|map screen|

screen := Screen current.
map := screen keyboardMap.

#(
    #Cmd     #Alt
    #Cmd     #Menu
    #Menu    #Appl
    #Menu    #CtrlAppl
    #Menu    #CmdAppl

"/     #'Hardcopy'     #'Super_R'
    #'Alt'     #'Super_L'
    #'Alt'     #'Hyper_R'

    #UserInterrupt    #Break      "WIN"
    #UserAbort        #CtrlCancel "WIN: abort window process, but no debugger"
    #UserAbort        #CtrlPause
    #UserAbort        #CtrlBreak  "X11: abort window process, but no debugger"
    #FlushInput       #CtrlX     "flush typeahead input"
    #DestroyView      #CmdCtrlX  "to destroy dead views"
    #DestroyTopView   #CmdCtrlx  "to destroy dead views"

    #CloseWindowRequest      #CmdF4

    #DoIt          #Cmdd          "i e  Cmd-d / Alt-d (sometimes Meta-d)"
    #DoIt          #Ctrld
    #InspectIt     #Cmdi          "evaluate & inspect result"
    #InspectIt     #Ctrlq
    #PrintIt       #Cmdp          "evaluate and paste result"
    #PrintIt       #Ctrlp
    #ReplaceIt     #CmdP          "evaluate and replace selection by result"
    #BrowseIt      #CmdB
    #BrowseIt      #CtrlB
    #ImplementorsOfIt      #CtrlI
    #ImplementorsOfIt      #CmdI
"/     #SendersOfIt      #CtrlS
"/     #SendersOfIt      #CmdS

    #ToggleInsertMode                #CtrlInsert

    #Copy          #Cmdc          "copy selection to buffer"
    #Copy          #Ctrlc          "copy selection to buffer"

    #Cut           #Cmdx          "cut selection into buffer"
    #Cut           #Ctrlx
    #Paste         #Cmdv          "paste buffer or external selection"
    #Paste         #Ctrlv
    #PasteFromHistory         #CmdV          "show paste history"
    #PasteFromHistory         #CtrlV         "show paste history"
    #Replace       #Cmdr
    #Replace       #Ctrlr
    #Join          #Ctrlj         "join lines"
    #Join          #Cmdj          "join lines"
    #Find          #Cmds          "open searchbox"
    #Find          #Ctrlf
    #FindNext      #Cmdf          "search fwd for last searchpattern or selection"
    #FindPrev      #Cmdb          "search bwd for last searchpattern or selection"
    #FindPrev      #Ctrlb
    #SelectAll     #CmdA          "that is Alt-shift-a"
    #SelectAll     #Ctrla
    #GotoLine      #Ctrll
    #GotoLine      #Ctrlg
    #SelectWord    #Cmdw          "select word under cursor"
    #Undo          #Ctrlz
    #Redo          #Ctrly

    #Accept        #Cmda
    #Accept        #Ctrls

    #Explain       #Cmde
    #Explain       #Cmdh
    #Format        #CmdF              "that is Alt-shift-F"
"/     #Format        #CtrlF         "that is Ctrl-shift-F"

"/     #DeleteLine    #CtrlX

    #NextPage        #Next     "typically labelled PageDown on keyboard"
    #PreviousPage    #Prior    "typically labelled PageUp on keyboard"

"/     #PreviousPage    #Ctrlb    "vi behavior"
"/     #NextPage        #Ctrlf    "vi behavior"
"/     #HalfPageUp      #Ctrlu
"/     #HalfPageDown    #Ctrld

"/ old setting:
"/     #BeginOfText     #Home     "some prefer to bind #BeginOfLine to #Home"
"/     #EndOfText       #End      "some prefer to bind #EndOfLine to #End"
"/
"/ new setting:
    #BeginOfLine     #Home
    #EndOfLine       #End
    #BeginOfText     #CtrlHome
    #EndOfText       #CtrlEnd

    #EndOfLine       #Ctrle
    #NextWord        #Ctrlw
    #EndOfWord       #CtrlW

    #NextWord        #CtrlCursorRight
    #PreviousWord    #CtrlCursorLeft

    #ScrollUp        #CtrlCursorUp
    #ScrollDown      #CtrlCursorDown

    #SearchMatchingParent     #Ctrlm
    #SelectMatchingParents    #Cmdm

    #SelectToEnd              #CtrlE    "that is ctrl-shift-e"
    #SelectFromBeginning      #CtrlA    "that is ctrl-shift-a"
    #ExpandSelectionByLine    #Cmdl     "try multiple Cmd-l's ..."

    #ZoomIn    #'Ctrl+'
    #ZoomOut    #'Ctrl-'

    "Notice:
      Cmd-CursorLeft/Right and Alt-CursorLeft/Right
      are also used by some winmdowmanagers (fvwm)
      if this is the case on your system, either
      change the following to use different keys,
      or change the windowmanagers configuration file
      (usr/lib/X11/xxxwm/*rc)
      The above is the reason that the following defines Ctrl-xxx
      as an alternative (mwm in the INDY also uses the alt-sequences)
    "

    #FocusNext        #CmdCursorRight    "experimental"
    #FocusPrevious    #CmdCursorLeft     "experimental"
    #FocusNext        #CmdCursorDown     "experimental"
    #FocusPrevious    #CmdCursorUp       "experimental"

    #FocusNext        #AltCursorRight    "experimental"
    #FocusPrevious    #AltCursorLeft     "experimental"
    #FocusNext        #AltCursorDown     "experimental"
    #FocusPrevious    #AltCursorUp       "experimental"
"/     #FocusNext        #CtrlCursorRight   "experimental"
"/     #FocusPrevious    #CtrlCursorLeft    "experimental"


    #NonInsertingTab     #ShiftTab
"/     #BackTab             #ShiftTab
    #BackTab             #CtrlTab
    #NonInsertingTab     #'ISO_Left_Tab'
"/     #ToggleTabs          #CtrlTab

"/     #FocusNext        #CtrlTab           "experimental"
    #FocusNext        #CmdTab            "experimental"
"/     #FocusPrevious    #'ISO_Left_Tab'
    #FocusPrevious    #'CmdISO_Left_Tab'
"/ map bindValue:#Tab              #'ISO_Left_Tab'
    #Menu             #Cmdz
) pairWiseDo:[:symbolic :key |
	map bindValue:symbolic to:key.
].

OperatingSystem isMSWINDOWSlike ifTrue:[
    map bindValue:#UserAbort        to:#Pause.
] ifFalse:[
    map bindValue:#UserInterrupt    to:#Pause. "X11"
].

"*
 * ISO LATIN 1 symbolic characters - map to iso8859-1/unicode values
 * not all Xservers send those correctly.
 * As a fall back, dieresis mappings using Alt-key sequences are found at
 * the end.
 *"

#(
	"/ dieresis characters

	Udiaeresis      16rDC
	Adiaeresis      16rC4
	Odiaeresis      16rD6
	udiaeresis      16rFC
	adiaeresis      16rE4
	odiaeresis      16rF6
	ydiaeresis      16rFF

	"/ grave

	Agrave          16rC0
	Egrave          16rC8
	Igrave          16rCC
	Ograve          16rCC
	Ugrave          16rD9
	agrave          16rE0
	egrave          16rE8
	igrave          16rEC
	ograve          16rF2
	ugrave          16rF9

	"/ acute

	Aacute          16rC1
	Eacute          16rC9
	Iacute          16rCD
	Oacute          16rD3
	Uacute          16rDA
	Yacute          16rDD
	aacute          16rE1
	eacute          16rE9
	iacute          16rED
	oacute          16rF3
	uacute          16rFA
	yacute          16rFD

	"/ circumflex

	Acircumflex     16rC2
	Ecircumflex     16rCA
	Icircumflex     16rCE
	Ocircumflex     16rD4
	Ucircumflex     16rDB
	acircumflex     16rE2
	ecircumflex     16rEA
	icircumflex     16rEE
	ocircumflex     16rF4
	ucircumflex     16rFB

	"/ tilde

	Atilde          16rC3
	Ntilde          16rD1
	atilde          16rE3
	ntilde          16rF1

	"/ ring

	Aring           16rC4
	aring           16rE4

	"/ ligatures

	AE              16rC5
	ae              16rE5
	ssharp          16rDF

	"/ cedilla

	Ccedilla        16rC7
	ccedilla        16rE7

	"/ slashed

	Ooblique        16rD8
	oslash          16rF8

	"/ misc (if on your keyboard)

	Eth             16rD0   "/ some old servers still use this
	ETH             16rD0
	eth             16rF0
	multiply        16rD7
	Thorn           16rDE   "/ some old servers still use this
	THORN           16rDE   "/ some old servers still use this
	acute           16rEF
	division        16rF7
	thorn           16rFE

	section         16rA7
	rightdoublequotemark 16rAB
	leftdoublequotemark  16rBB
	notsign         16rAC
	degree          16rB0
	twosuperior     16rB2
	threesuperior   16rB3
	mu              16rB5
	cedilla         16rB8
	onesuperior     16rB9
	onequarter      16rBC
	onehalf         16rBD
	threequarter    16rBE
	EuroSign        16r20AC
) pairWiseDo:[:symbolic :numeric |
	map bindValue:(Character value:numeric) to:symbolic.
].

"*
 * need more here (katakana, arabic, cyrillic, greek etc.)
 *"

"*
 * numeric keypad - binding to normal numeric keys
 *"
"/ map bindValue:$0 to:#'KP_Insert'.
"/ map bindValue:$1 to:#'KP_End'.
"/ map bindValue:$2 to:#'KP_Down'.
"/ map bindValue:$3 to:#'KP_Next'.
"/ map bindValue:$4 to:#'KP_Left'.
"/ map bindValue:$5 to:#'KP_Begin'.
"/ map bindValue:$6 to:#'KP_Right'.
"/ map bindValue:$7 to:#'KP_Home'.
"/ map bindValue:$8 to:#'KP_Up'.
"/ map bindValue:$9 to:#'KP_Prior'.
map bindValue:#Return to:#'KP_Enter'.
map bindValue:#Delete to:#'KP_Delete'.


"/ remove these lines, if your keyboard has a COMPOSE-key.
"/ None of our Xdisplays here has one - so we simulate it using CTRL-R ...
"/ which on some (of our) servers comes pretranslated as Multi_key,
"/ CtrlMulti_key or even Mode_switch.

map bindValue:#Compose     to:#'Control_R'.       "/ the right compose key
"/ map bindValue:#Compose     to:#'Control_L'.       "/ the right compose key
map bindValue:#Compose     to:#'Multi_key'.       "/ the right compose key
map bindValue:#Compose     to:#'CtrlMulti_key'.   "/ the right compose key
"/ map bindValue:#Compose     to:#'Mode_switch'.


"/ a kludge: some Xservers send #Delete for both the backspace
"/ and the Delete key. In this case, we use the Backspace function
"/ for both keys. If your Xserver does not do this (it should not)
"/ remove or comment the following 'bindValue:#BackSpace'-line:
"/

"/ map bindValue:#BackSpace     to:#Delete.
map bindValue:#DeleteWordBeforeCursor    to:#CtrlBackSpace.
map bindValue:#Delete                    to:#CmdBackSpace.

"/
"/ my personal preferences - comment it, if you do not like them
"/ bind function and other keys as:
"/
"/ F1            - help
"/ F2            - rename (old: completion)
"/ F3            - comment-it
"/ F4            - uncomment-it
"/ F5            - paste shell output
"/ F8            - again
"/ F9            - undent by 4
"/ F10           - indent by 4
"/ Control-R     - Compose key
"/ Break         - UserInterrupt

"/
"/ convenient functions on the keyboard
"/
map bindValue:#Help             to:#F1.
map bindValue:#Again            to:#F8.
"/ map bindValue:#PrintIt       to:#Print.      "/ called PrintScreen on most keyboards
"/ map bindValue:#InspectIt     to:#Execute.    "/ called SysReq on most keyboards

map bindValue:#SaveAs        to:#CtrlS.
map bindValue:#SaveAs        to:#CmdS.

"/ xxxF5      -> macro ReplaceSelectionByUnixCommandsOutput (unix command output paste)
"/ CtrlTab -> macro ToggleTabs (toggle 4/8 tabs)
"/ F10     -> macro IndentBy4 (indent by 4)
"/ F9      -> macro UndentBy4 (undent by 4)
"/ F12     -> macro IndentBy1 (indent by 1)
"/ F11     -> macro UndentBy1 (undent by 1)
"/ F2      -> rename (old: completion)
"/ F3      -> commentSelection
"/ F4      -> uncommentSelection

"/ map bindValue:#ReplaceSelectionByUnixCommandsOutput  to:#F5.
"/ map bindValue:#CmdF97 to:#F7.
"/ map bindValue:#CmdF96 to:#F6.

map bindValue:#IndentBy4 to:#F10.
map bindValue:#UndentBy4 to:#F9.

map bindValue:#IndentBy1 to:#F12.
map bindValue:#UndentBy1 to:#F11.

map bindValue:#ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst to:#F6.
map bindValue:#ConvertSelectionToUppercase to:#CtrlF6.

map bindValue:#Rename           to:#F2.
map bindValue:#CommentSelection to:#F3.
map bindValue:#UncommentSelection to:#F4.

map bindValue:#ParenthizeSelection to:#'Cmd('.
map bindValue:#UnparenthizeSelection to:#'Cmd)'.

map bindValue:#LearnKeyboardMacro   to:#CtrlF2.
map bindValue:#ExecuteKeyboardMacro to:#CmdF2.

"/ map bindValue:#CodeCompletion     to:#F2.
map bindValue:#CodeCompletion     to:#'Ctrl '.          "that is Ctrl-Space"
map bindValue:#CodeCompletion     to:#'Ctrlspace'.      "mhmh - why is this sent on linux, and the above on windows (must check) ?"

map bindValue:#ExpandAbbreviation to:#'Cmd '.     "that is Alt-Space"

"/ map bindValue:#PasteBlockEvaluationsOutput to:#CmdV.

"/
"/ since some of my machines have german keyboards ;-)
"/ and I like to be able to edit my files on all machines,
"/ I need a translation in both ways.
"/ you'd normally not define things in both directions.
"/
"/ actually, these things belong into the servers modmap or
"/ into a display specific d_<displayName>.rc ...
"/
"/ german national characters on a US keyboard:
"/ comment this, if you have a german keyboard.
"/
"/map bindValue:(Character value:16rFC) to:#'Cmd['.   "/ u dieresis
"/map bindValue:(Character value:16rE4) to:#'Cmd'''.  "/ a dieresis
"/map bindValue:(Character value:16rF6) to:#'Cmd;'.   "/ o dieresis
"/map bindValue:(Character value:16rDC) to:#'Cmd{'.   "/ U dieresis
"/map bindValue:(Character value:16rC4) to:#'Cmd"'.   "/ A dieresis
"/map bindValue:(Character value:16rD6) to:#'Cmd:'.   "/ O dieresis
"/map bindValue:(Character value:16rDF) to:#'Cmd-'.   "/ s-sharp

"/
"/ US characters on national keyboards:
"/ (on many national keyboards, the x-server does NOT correctly
"/  xlate characters .... on others, it does and you may remove/comment
"/  the following.)
"/
map bindValue:$[ to:#'Alt['.
map bindValue:$] to:#'Alt]'.
map bindValue:$| to:#'Alt|'.
map bindValue:${ to:#'Alt{'.
map bindValue:$} to:#'Alt}'.
map bindValue:$\ to:#'Alt\'.
map bindValue:$~ to:#'Alt~'.
map bindValue:$@ to:#'Alt@'.

map bindValue:$[ to:#'Cmd['.
map bindValue:$] to:#'Cmd]'.
map bindValue:$| to:#'Cmd|'.
map bindValue:${ to:#'Cmd{'.
map bindValue:$} to:#'Cmd}'.
map bindValue:$\ to:#'Cmd\'.
map bindValue:$~ to:#'Cmd~'.
map bindValue:$@ to:#'Cmd@'.
map bindValue:$# to:#'Cmd#'.

map bindValue:#UserInterrupt to:#'Cmd.' .     "/ for squeak compatibility
"/ map bindValue:#UserInterrupt to:#'Ctrl.' .    "/ for vw compatibility

!