"*
* $Header$
*
* sample keyboard.rc - file
*
* this file defines some keyboard macros and adds 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.
*
* these are my personal preferrences which may not be
* correct for your environment
*"
|macros|
"/
"/ define some keyboard macros as virtual function-keys:
"/ Cmd-F99: paste the output of a selected unix command ..
"/ Cmd-F98: toggle between 4 and 8 col tab setting
"/ Cmd-F96: pipe text through spelling checker and collect its output
"/ Cmd-F97: get next entry from spell-list, search and highlight it
"/ Cmd-F95: indents selection by 4
"/ Cmd-F94: undents selection by 4
"/
macros := Smalltalk at:#FunctionKeySequences.
macros isNil ifTrue:[
macros := IdentityDictionary new.
Smalltalk at:#FunctionKeySequences put:macros.
].
"/
"/ macro to replace a text selection by unix commands output
"/
macros at:#F99 put:'
"replace selection by
corresponding
unix commands output"
|sel|
sel := self selection.
sel notNil ifTrue:[
self replace:
(PipeStream readingFrom:(sel asString))
contents asString
]'.
"/
"/ macro to toggle tabs
"/
macros at:#F98 put:'
"toggle between 4-col
and 8-col tabs"
(tabPositions == self class tab4Positions)
ifTrue:[self setTab8]
ifFalse:[self setTab4]'.
"/
"/ macro to get next spelling error, and select it
"/
macros at:#F97 put:'
|errs thisErr sl sc|
thisErr := Smalltalk at:#''_thisError''.
thisErr isNil ifTrue:[
errs := Smalltalk at:#''_spellOutput''.
(errs notNil and:[errs notEmpty]) ifTrue:[
thisErr := errs removeFirst.
errs isEmpty ifTrue:[Smalltalk removeKey:''_spellOut'']
].
Smalltalk at:#''_lastErrLine'' put:1.
Smalltalk at:#''_lastErrCol'' put:1.
].
thisErr notNil ifTrue:[
sl := Smalltalk at:#''_lastErrLine''.
sc := Smalltalk at:#''_lastErrCol''.
self searchForwardFor:thisErr
startingAtLine:sl col:sc
ifFound:[:fl :fc | self selectWordAtLine:fl col:fc.
Smalltalk at:#''_lastErrLine'' put:fl.
Smalltalk at:#''_lastErrCol'' put:fc+1]
ifAbsent:[self device beep]
]'.
"/
"/ macro to send contents to spell; remember spelling errors
"/ does not work on all systems (some do not have spell ...)
"/
macros at:#F96 put:'
|p f s|
f := Filename newTemporary. s := f writeStream.
s nextPutAll:self contents asString.
s close.
p := PipeStream readingFrom:''spell '' , f pathName.
Smalltalk at:#''_spellOutput'' put:p contents asString asCollectionOfLines.
p close.
self information:''F7 positions on the next spelling error''.
'.
"/
"/ macro to indent by 4
"/
macros at:#F95 put:'
"indent selected line-range
by 4 spaces (i.e. to the right)"
self selectionStartLine notNil ifTrue:[
self selectionStartLine to:self selectionEndLine-1 do:[:lineNr |
|line|
line := self listAt:lineNr.
line notNil ifTrue:[
line notEmpty ifTrue:[
line := '' '' , line.
self at:lineNr put:line
]
]
]
]
'.
"/
"/ macro to undent by 4
"/
macros at:#F94 put:'
"undent selected line-range
by 4 spaces (i.e. to the left)"
self selectionStartLine notNil ifTrue:[
self selectionStartLine to:self selectionEndLine-1 do:[:lineNr |
|line|
line := self listAt:lineNr.
line notNil ifTrue:[
line notEmpty ifTrue:[
(line startsWith:'' '') ifTrue:[
line := line copyFrom:5.
self at:lineNr put:line
]
]
]
]
]
'.
!
|map|
map := Display keyboardMap.
"/ 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,
"/ or even Mode_switch.
map bindValue:#Compose to:#'Control_R'.
map bindValue:#Compose to:#'Multi_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.
"/
"/ my personal preferences - comment it, if you do not like them
"/ bind function and other keys as:
"/
"/ F1 - again
"/ F3 - comment-it
"/ F4 - uncomment-it
"/ F5 - paste shell output
"/ F9 - undent by 4
"/ F10 - indent by 4
"/ Control-R - Compose key
"/ Break - UserInterrupt
"/ Print - PrintIt
"/ Execute - InspectIt
"/
"/ convenient functions on the keyboard
"/
map bindValue:#Again to:#F1.
map bindValue:#UserInterrupt to:#Break.
map bindValue:#PrintIt to:#Print. "/ called PrintScreen on most keyboards
map bindValue:#InspectIt to:#Execute. "/ called SysReq on most keyboards
map bindValue:#SaveAs to:#CmdS.
map bindValue:#CmdF99 to:#F5.
map bindValue:#CmdF98 to:#CtrlTab.
"/ map bindValue:#CmdF97 to:#F7.
"/ map bindValue:#CmdF96 to:#F6.
map bindValue:#CmdF95 to:#F10.
map bindValue:#CmdF94 to:#F9.
map bindValue:#CommentSelection to:#F3.
map bindValue:#UncommentSelection to:#F4.
"/
"/ 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:
"/
map bindValue:(Character value:16rFC) to:#'Cmd['.
map bindValue:(Character value:16rE4) to:#'Cmd'''.
map bindValue:(Character value:16rF6) to:#'Cmd;'.
map bindValue:(Character value:16rDC) to:#'Cmd{'.
map bindValue:(Character value:16rC4) to:#'Cmd"'.
map bindValue:(Character value:16rD6) to:#'Cmd:'.
map bindValue:(Character value:16rDF) to:#'Cmd-'.
"/
"/ US characters on german keyboard:
"/
map bindValue:$[ to:#'Alt['.
map bindValue:$] to:#'Alt]'.
map bindValue:$| to:#'Alt|'.
map bindValue:${ to:#'Alt{'.
map bindValue:$} to:#'Alt}'.
!