41
|
1 |
"*
|
|
2 |
* $Header$
|
|
3 |
*
|
|
4 |
* sample keyboard.rc - file
|
|
5 |
*
|
|
6 |
* this file defines some keyboard macros and adds mappings for
|
54
|
7 |
* common function keys. These definitions used to be in 'private.rc',
|
41
|
8 |
* but have been extracted into this separate file to allow easier
|
|
9 |
* sharing of rc files (users having different private files, but want
|
54
|
10 |
* to use the same keyboard mappings / keyboard macros)
|
41
|
11 |
*
|
54
|
12 |
* a copy of this file can reside in $home/.smalltalk/keyboard.rc or
|
|
13 |
* in the current directory.
|
|
14 |
*
|
|
15 |
* these are my personal preferrences which may not be
|
|
16 |
* correct for your environment
|
41
|
17 |
*"
|
|
18 |
|
86
|
19 |
|macros|
|
41
|
20 |
|
|
21 |
"/
|
|
22 |
"/ define some keyboard macros as virtual function-keys:
|
|
23 |
"/ Cmd-F99: paste the output of a selected unix command ..
|
|
24 |
"/ Cmd-F98: toggle between 4 and 8 col tab setting
|
|
25 |
"/ Cmd-F96: pipe text through spelling checker and collect its output
|
|
26 |
"/ Cmd-F97: get next entry from spell-list, search and highlight it
|
|
27 |
"/ Cmd-F95: indents selection by 4
|
|
28 |
"/ Cmd-F94: undents selection by 4
|
|
29 |
"/
|
86
|
30 |
|
41
|
31 |
macros := Smalltalk at:#FunctionKeySequences.
|
|
32 |
macros isNil ifTrue:[
|
|
33 |
macros := IdentityDictionary new.
|
|
34 |
Smalltalk at:#FunctionKeySequences put:macros.
|
|
35 |
].
|
|
36 |
|
86
|
37 |
"/
|
|
38 |
"/ macro to replace a text selection by unix commands output
|
|
39 |
"/
|
|
40 |
|
41
|
41 |
macros at:#F99 put:'
|
|
42 |
"replace selection by
|
|
43 |
corresponding
|
|
44 |
unix commands output"
|
|
45 |
|
|
46 |
|sel|
|
|
47 |
|
|
48 |
sel := self selection.
|
|
49 |
sel notNil ifTrue:[
|
|
50 |
self replace:
|
|
51 |
(PipeStream readingFrom:(sel asString))
|
|
52 |
contents asString
|
|
53 |
]'.
|
|
54 |
|
86
|
55 |
"/
|
41
|
56 |
"/ macro to toggle tabs
|
86
|
57 |
"/
|
41
|
58 |
macros at:#F98 put:'
|
|
59 |
"toggle between 4-col
|
|
60 |
and 8-col tabs"
|
|
61 |
|
|
62 |
(tabPositions == self class tab4Positions)
|
|
63 |
ifTrue:[self setTab8]
|
|
64 |
ifFalse:[self setTab4]'.
|
|
65 |
|
86
|
66 |
"/
|
41
|
67 |
"/ macro to get next spelling error, and select it
|
86
|
68 |
"/
|
41
|
69 |
macros at:#F97 put:'
|
|
70 |
|errs thisErr sl sc|
|
|
71 |
|
|
72 |
thisErr := Smalltalk at:#''_thisError''.
|
|
73 |
thisErr isNil ifTrue:[
|
|
74 |
errs := Smalltalk at:#''_spellOutput''.
|
|
75 |
(errs notNil and:[errs notEmpty]) ifTrue:[
|
|
76 |
thisErr := errs removeFirst.
|
|
77 |
errs isEmpty ifTrue:[Smalltalk removeKey:''_spellOut'']
|
|
78 |
].
|
|
79 |
Smalltalk at:#''_lastErrLine'' put:1.
|
|
80 |
Smalltalk at:#''_lastErrCol'' put:1.
|
|
81 |
].
|
|
82 |
thisErr notNil ifTrue:[
|
|
83 |
sl := Smalltalk at:#''_lastErrLine''.
|
|
84 |
sc := Smalltalk at:#''_lastErrCol''.
|
|
85 |
self searchForwardFor:thisErr
|
|
86 |
startingAtLine:sl col:sc
|
|
87 |
ifFound:[:fl :fc | self selectWordAtLine:fl col:fc.
|
|
88 |
Smalltalk at:#''_lastErrLine'' put:fl.
|
|
89 |
Smalltalk at:#''_lastErrCol'' put:fc+1]
|
|
90 |
ifAbsent:[self device beep]
|
|
91 |
]'.
|
|
92 |
|
86
|
93 |
"/
|
41
|
94 |
"/ macro to send contents to spell; remember spelling errors
|
|
95 |
"/ does not work on all systems (some do not have spell ...)
|
86
|
96 |
"/
|
41
|
97 |
macros at:#F96 put:'
|
|
98 |
|p f s|
|
|
99 |
|
|
100 |
f := Filename newTemporary. s := f writeStream.
|
|
101 |
s nextPutAll:self contents asString.
|
|
102 |
s close.
|
|
103 |
p := PipeStream readingFrom:''spell '' , f pathName.
|
|
104 |
Smalltalk at:#''_spellOutput'' put:p contents asString asCollectionOfLines.
|
|
105 |
p close.
|
|
106 |
self information:''F7 positions on the next spelling error''.
|
|
107 |
'.
|
|
108 |
|
86
|
109 |
"/
|
41
|
110 |
"/ macro to indent by 4
|
86
|
111 |
"/
|
41
|
112 |
macros at:#F95 put:'
|
|
113 |
"indent selected line-range
|
|
114 |
by 4 spaces (i.e. to the right)"
|
|
115 |
|
76
|
116 |
self selectionStartLine notNil ifTrue:[
|
|
117 |
self selectionStartLine to:self selectionEndLine-1 do:[:lineNr |
|
|
118 |
|line|
|
41
|
119 |
|
76
|
120 |
line := self listAt:lineNr.
|
|
121 |
line notNil ifTrue:[
|
|
122 |
line notEmpty ifTrue:[
|
|
123 |
line := '' '' , line.
|
|
124 |
self at:lineNr put:line
|
|
125 |
]
|
41
|
126 |
]
|
|
127 |
]
|
|
128 |
]
|
|
129 |
'.
|
86
|
130 |
|
|
131 |
"/
|
41
|
132 |
"/ macro to undent by 4
|
86
|
133 |
"/
|
41
|
134 |
macros at:#F94 put:'
|
|
135 |
"undent selected line-range
|
|
136 |
by 4 spaces (i.e. to the left)"
|
|
137 |
|
76
|
138 |
self selectionStartLine notNil ifTrue:[
|
|
139 |
self selectionStartLine to:self selectionEndLine-1 do:[:lineNr |
|
|
140 |
|line|
|
41
|
141 |
|
76
|
142 |
line := self listAt:lineNr.
|
|
143 |
line notNil ifTrue:[
|
|
144 |
line notEmpty ifTrue:[
|
|
145 |
(line startsWith:'' '') ifTrue:[
|
|
146 |
line := line copyFrom:5.
|
|
147 |
self at:lineNr put:line
|
|
148 |
]
|
41
|
149 |
]
|
|
150 |
]
|
|
151 |
]
|
|
152 |
]
|
|
153 |
'.
|
86
|
154 |
!
|
|
155 |
|
|
156 |
|map|
|
|
157 |
|
|
158 |
map := Display keyboardMap.
|
|
159 |
|
|
160 |
"/ remove these lines, if your keyboard has a COMPOSE-key.
|
|
161 |
"/ None of our Xdisplays here has one - so we simulate it using CTRL-R ...
|
|
162 |
"/ which on some (of our) servers comes pretranslated as Multi_key,
|
|
163 |
"/ or even Mode_switch.
|
|
164 |
|
|
165 |
map bindValue:#Compose to:#'Control_R'.
|
|
166 |
map bindValue:#Compose to:#'Multi_key'.
|
|
167 |
map bindValue:#Compose to:#'Mode_switch'.
|
|
168 |
|
|
169 |
|
|
170 |
"/ a kludge: some Xservers send #Delete for both the backspace
|
|
171 |
"/ and the Delete key. In this case, we use the Backspace function
|
|
172 |
"/ for both keys. If your Xserver does not do this (it should not)
|
|
173 |
"/ remove or comment the following 'bindValue:#BackSpace'-line:
|
|
174 |
"/
|
|
175 |
|
|
176 |
map bindValue:#BackSpace to:#Delete.
|
|
177 |
|
41
|
178 |
"/
|
|
179 |
"/ my personal preferences - comment it, if you do not like them
|
|
180 |
"/ bind function and other keys as:
|
|
181 |
"/
|
|
182 |
"/ F1 - again
|
|
183 |
"/ F3 - comment-it
|
|
184 |
"/ F4 - uncomment-it
|
|
185 |
"/ F5 - paste shell output
|
|
186 |
"/ F9 - undent by 4
|
|
187 |
"/ F10 - indent by 4
|
|
188 |
"/ Control-R - Compose key
|
|
189 |
"/ Break - UserInterrupt
|
|
190 |
"/ Print - PrintIt
|
|
191 |
"/ Execute - InspectIt
|
|
192 |
|
|
193 |
"/
|
|
194 |
"/ convenient functions on the keyboard
|
|
195 |
"/
|
|
196 |
map bindValue:#Again to:#F1.
|
|
197 |
map bindValue:#UserInterrupt to:#Break.
|
|
198 |
map bindValue:#PrintIt to:#Print. "/ called PrintScreen on most keyboards
|
|
199 |
map bindValue:#InspectIt to:#Execute. "/ called SysReq on most keyboards
|
|
200 |
|
88
|
201 |
map bindValue:#SaveAs to:#CmdS.
|
|
202 |
|
41
|
203 |
|
|
204 |
map bindValue:#CmdF99 to:#F5.
|
|
205 |
map bindValue:#CmdF98 to:#CtrlTab.
|
|
206 |
"/ map bindValue:#CmdF97 to:#F7.
|
|
207 |
"/ map bindValue:#CmdF96 to:#F6.
|
|
208 |
map bindValue:#CmdF95 to:#F10.
|
|
209 |
map bindValue:#CmdF94 to:#F9.
|
|
210 |
|
|
211 |
map bindValue:#CommentSelection to:#F3.
|
|
212 |
map bindValue:#UncommentSelection to:#F4.
|
|
213 |
|
|
214 |
"/
|
|
215 |
"/ since some of my machines have german keyboards ;-)
|
|
216 |
"/ and I like to be able to edit my files on all machines,
|
|
217 |
"/ I need a translation in both ways.
|
|
218 |
"/ you'd normally not define things in both directions.
|
|
219 |
"/
|
57
|
220 |
"/ actually, these things belong into the servers modmap or
|
|
221 |
"/ into a display specific d_<displayName>.rc ...
|
41
|
222 |
"/
|
|
223 |
"/ german national characters on a US keyboard:
|
|
224 |
"/
|
|
225 |
map bindValue:(Character value:16rFC) to:#'Cmd['.
|
|
226 |
map bindValue:(Character value:16rE4) to:#'Cmd'''.
|
|
227 |
map bindValue:(Character value:16rF6) to:#'Cmd;'.
|
|
228 |
map bindValue:(Character value:16rDC) to:#'Cmd{'.
|
|
229 |
map bindValue:(Character value:16rC4) to:#'Cmd"'.
|
|
230 |
map bindValue:(Character value:16rD6) to:#'Cmd:'.
|
|
231 |
map bindValue:(Character value:16rDF) to:#'Cmd-'.
|
|
232 |
|
|
233 |
"/
|
|
234 |
"/ US characters on german keyboard:
|
|
235 |
"/
|
|
236 |
map bindValue:$[ to:#'Alt['.
|
|
237 |
map bindValue:$] to:#'Alt]'.
|
|
238 |
map bindValue:$| to:#'Alt|'.
|
|
239 |
map bindValue:${ to:#'Alt{'.
|
57
|
240 |
map bindValue:$} to:#'Alt}'.
|
41
|
241 |
!
|