author | Claus Gittinger <cg@exept.de> |
Fri, 04 Dec 2009 14:22:22 +0100 | |
changeset 1086 | 18aa0a0cd8b1 |
parent 1077 | 6ac6f64936f8 |
child 1243 | 1fc6b3f01e48 |
permissions | -rw-r--r-- |
718 | 1 |
"* |
2 |
* Encoding: iso8859-1 |
|
3 |
* |
|
4 |
* $Header$ |
|
5 |
* |
|
6 |
* MIMEType: application/x-smalltalk-source |
|
7 |
* |
|
8 |
* sample keyboardMacros.rc - file |
|
9 |
* |
|
10 |
* this file defines some keyboard macros |
|
11 |
* Feel free to add your own. |
|
12 |
* Here, only the macro-codes are defined; |
|
13 |
* the actual binding of macro to a particular key is done in keyboard.rc. |
|
14 |
* |
|
15 |
* these are my personal preferrences which may not be |
|
16 |
* correct for your environment. |
|
17 |
* |
|
18 |
* WARNING: |
|
19 |
* please keep the expressions below free from manipulating |
|
20 |
* global state. |
|
21 |
* Reason: in multihead applications, this will be consulted for each |
|
22 |
* new display screen. |
|
23 |
*" |
|
24 |
||
25 |
|macros| |
|
26 |
||
27 |
macros := UserPreferences current functionKeySequences. |
|
28 |
||
29 |
"/ |
|
30 |
"/ macro to replace a text selection by unix commands output |
|
31 |
"/ |
|
32 |
macros at:#ReplaceSelectionByUnixCommandsOutput put:' |
|
33 |
"replace selection by corresponding |
|
34 |
unix commands output" |
|
35 |
||
36 |
|sel| |
|
37 |
||
38 |
sel := self selection. |
|
39 |
sel notNil ifTrue:[ |
|
40 |
self replace: |
|
41 |
(PipeStream readingFrom:(sel asString)) |
|
42 |
contents asString |
|
43 |
] |
|
44 |
'. |
|
45 |
||
46 |
"/ |
|
47 |
"/ macro to paste the text generated by a block |
|
48 |
"/ |
|
49 |
"/macros at:#PasteBlockEvaluationsOutput put:' |
|
50 |
"/ "replace selection by blocks output" |
|
51 |
"/ |
|
52 |
"/ |sel s block| |
|
53 |
"/ |
|
54 |
"/ sel := self selectionAsString. |
|
55 |
"/ sel notNil ifTrue:[ |
|
56 |
"/ block := Compiler evaluate:sel asString string. |
|
57 |
"/ s := '''' writeStream. |
|
58 |
"/ block value:s. |
|
59 |
"/ self paste:s contents asString |
|
60 |
"/ ] |
|
61 |
"/'. |
|
62 |
||
63 |
"/ |
|
64 |
"/ macro to toggle tabs |
|
65 |
"/ |
|
66 |
macros at:#ToggleTabs put:' |
|
67 |
"toggle between 4-col |
|
68 |
and 8-col tabs" |
|
69 |
||
70 |
(tabPositions == self class tab4Positions) |
|
71 |
ifTrue:[self setTab8] |
|
72 |
ifFalse:[self setTab4] |
|
73 |
'. |
|
74 |
||
75 |
"/ |
|
76 |
"/ macro to indent by 4 |
|
77 |
"/ |
|
78 |
macros at:#IndentBy4 put:' |
|
79 |
"indent selected line-range |
|
80 |
by 4 spaces (i.e. to the right)" |
|
81 |
||
82 |
|line1 line2| |
|
83 |
||
84 |
line1 := self selectionStartLine. |
|
85 |
line2 := self selectionEndLine. |
|
86 |
line1 isNil ifTrue:[ |
|
87 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
88 |
line1 notNil ifTrue:[ |
|
89 |
line2 := line1+1 |
|
90 |
] |
|
91 |
]. |
|
92 |
line1 notNil ifTrue:[ |
|
93 |
self withExecuteCursorDo:[ |
|
94 |
line1 to:line2-1 do:[:lineNr | |
|
95 |
|line| |
|
96 |
||
97 |
line := self listAt:lineNr. |
|
98 |
line notNil ifTrue:[ |
|
99 |
line notEmpty ifTrue:[ |
|
100 |
line := '' '' , line. |
|
101 |
self withoutRedrawAt:lineNr put:line. |
|
1086
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
102 |
line1 = (line2-1) ifTrue:[ |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
103 |
self cursorRight:4 |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
104 |
]. |
718 | 105 |
] |
106 |
] |
|
107 |
]. |
|
108 |
self textChanged. |
|
109 |
line1 to:line2-1 do:[:lineNr | |
|
110 |
self invalidateLine:lineNr. |
|
111 |
]. |
|
112 |
]. |
|
113 |
] |
|
114 |
'. |
|
115 |
||
116 |
"/ |
|
117 |
"/ macro to undent by 4 |
|
118 |
"/ |
|
119 |
macros at:#UndentBy4 put:' |
|
120 |
"undent selected line-range |
|
121 |
by 4 spaces (i.e. to the left)" |
|
122 |
||
123 |
|line1 line2| |
|
124 |
||
125 |
line1 := self selectionStartLine. |
|
126 |
line2 := self selectionEndLine. |
|
127 |
line1 isNil ifTrue:[ |
|
128 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
129 |
line1 notNil ifTrue:[ |
|
130 |
line2 := line1+1 |
|
131 |
] |
|
132 |
]. |
|
133 |
line1 notNil ifTrue:[ |
|
134 |
self withExecuteCursorDo:[ |
|
135 |
line1 to:line2-1 do:[:lineNr | |
|
136 |
|line| |
|
137 |
||
138 |
line := self listAt:lineNr. |
|
139 |
line notNil ifTrue:[ |
|
140 |
line notEmpty ifTrue:[ |
|
141 |
(line startsWith:'' '') ifTrue:[ |
|
142 |
line := line copyFrom:5. |
|
143 |
self withoutRedrawAt:lineNr put:line. |
|
1086
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
144 |
line1 = (line2-1) ifTrue:[ |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
145 |
cursorCol > 4 ifTrue:[ self cursorLeft:4 ] |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
146 |
]. |
718 | 147 |
] |
148 |
] |
|
149 |
] |
|
150 |
]. |
|
151 |
self textChanged. |
|
152 |
line1 to:line2-1 do:[:lineNr | |
|
153 |
self invalidateLine:lineNr. |
|
154 |
]. |
|
155 |
]. |
|
156 |
] |
|
157 |
'. |
|
158 |
||
159 |
"/ |
|
160 |
"/ macro to indent by 1 |
|
161 |
"/ |
|
162 |
macros at:#IndentBy1 put:' |
|
163 |
"indent selected line-range |
|
164 |
by 1 space (i.e. to the right)" |
|
165 |
||
166 |
|line1 line2| |
|
167 |
||
168 |
line1 := self selectionStartLine. |
|
169 |
line2 := self selectionEndLine. |
|
170 |
line1 isNil ifTrue:[ |
|
171 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
172 |
line1 notNil ifTrue:[ |
|
173 |
line2 := line1+1 |
|
174 |
] |
|
175 |
]. |
|
176 |
line1 notNil ifTrue:[ |
|
177 |
self withExecuteCursorDo:[ |
|
178 |
line1 to:line2-1 do:[:lineNr | |
|
179 |
|line| |
|
180 |
||
181 |
line := self listAt:lineNr. |
|
182 |
line notNil ifTrue:[ |
|
183 |
line notEmpty ifTrue:[ |
|
184 |
line := '' '' , line. |
|
185 |
self withoutRedrawAt:lineNr put:line. |
|
1086
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
186 |
line1 = (line2-1) ifTrue:[ |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
187 |
self cursorRight:1 |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
188 |
]. |
718 | 189 |
] |
190 |
] |
|
191 |
]. |
|
192 |
self textChanged. |
|
193 |
line1 to:line2-1 do:[:lineNr | |
|
194 |
self invalidateLine:lineNr. |
|
195 |
]. |
|
196 |
] |
|
197 |
] |
|
198 |
'. |
|
199 |
||
200 |
"/ |
|
201 |
"/ macro to undent by 1 |
|
202 |
"/ |
|
203 |
macros at:#UndentBy1 put:' |
|
204 |
"undent selected line-range |
|
205 |
by 1 space (i.e. to the left)" |
|
206 |
||
207 |
|line1 line2| |
|
208 |
||
209 |
line1 := self selectionStartLine. |
|
210 |
line2 := self selectionEndLine. |
|
211 |
line1 isNil ifTrue:[ |
|
212 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
213 |
line1 notNil ifTrue:[ |
|
214 |
line2 := line1+1 |
|
215 |
] |
|
216 |
]. |
|
217 |
line1 notNil ifTrue:[ |
|
218 |
self withExecuteCursorDo:[ |
|
219 |
line1 to:line2-1 do:[:lineNr | |
|
220 |
|line| |
|
221 |
||
222 |
line := self listAt:lineNr. |
|
223 |
line notNil ifTrue:[ |
|
224 |
line notEmpty ifTrue:[ |
|
225 |
(line startsWith:'' '') ifTrue:[ |
|
226 |
line := line copyFrom:2. |
|
227 |
self withoutRedrawAt:lineNr put:line. |
|
1086
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
228 |
line1 = (line2-1) ifTrue:[ |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
229 |
cursorCol > 1 ifTrue:[ self cursorLeft:1 ] |
18aa0a0cd8b1
when indenting/undenting, move the cursor with it
Claus Gittinger <cg@exept.de>
parents:
1077
diff
changeset
|
230 |
]. |
718 | 231 |
] |
232 |
] |
|
233 |
] |
|
234 |
]. |
|
235 |
self textChanged. |
|
236 |
line1 to:line2-1 do:[:lineNr | |
|
237 |
self invalidateLine:lineNr. |
|
238 |
]. |
|
239 |
]. |
|
240 |
] |
|
241 |
'. |
|
242 |
||
243 |
"/ |
|
244 |
"/ macro to convert selection to lowercase |
|
245 |
"/ |
|
246 |
macros at:#ConvertSelectionToLowercase put:' |
|
247 |
"to-lower selected text" |
|
248 |
||
249 |
|line1 line2| |
|
250 |
||
251 |
line1 := self selectionStartLine. |
|
252 |
line2 := self selectionEndLine. |
|
253 |
line1 isNil ifTrue:[ |
|
254 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
255 |
line1 notNil ifTrue:[ |
|
256 |
line2 := line1 |
|
257 |
] |
|
258 |
]. |
|
259 |
line1 notNil ifTrue:[ |
|
260 |
line1 to:line2 do:[:lineNr | |
|
261 |
|line col1 col2| |
|
262 |
||
263 |
line := (self listAt:lineNr) copy. |
|
264 |
line size > 0 ifTrue:[ |
|
265 |
lineNr == line1 ifTrue:[ |
|
266 |
col1 := selectionStartCol. |
|
267 |
] ifFalse:[ |
|
268 |
col1 := 1. |
|
269 |
]. |
|
270 |
lineNr == line2 ifTrue:[ |
|
271 |
col2 := selectionEndCol. |
|
272 |
] ifFalse:[ |
|
273 |
col2 := (self listAt:lineNr) size. |
|
274 |
]. |
|
275 |
||
276 |
col1 to:col2 do:[:col | |
|
277 |
|ch| |
|
278 |
||
279 |
ch := line at:col. |
|
280 |
line at:col put:ch asLowercase. |
|
281 |
]. |
|
282 |
self withoutRedrawAt:lineNr put:line. |
|
283 |
self invalidateLine:lineNr. |
|
284 |
]. |
|
285 |
]. |
|
286 |
] |
|
287 |
'. |
|
288 |
||
289 |
"/ |
|
290 |
"/ macro to convert selection to uppercaseFirst words |
|
291 |
"/ |
|
292 |
macros at:#ConvertSelectionToUppercaseFirst put:' |
|
1077 | 293 |
"to-upperFirst selected text" |
718 | 294 |
|
295 |
|line1 line2| |
|
296 |
||
297 |
line1 := self selectionStartLine. |
|
298 |
line2 := self selectionEndLine. |
|
299 |
line1 isNil ifTrue:[ |
|
300 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
301 |
line1 notNil ifTrue:[ |
|
302 |
line2 := line1 |
|
303 |
] |
|
304 |
]. |
|
305 |
line1 notNil ifTrue:[ |
|
306 |
line1 to:line2 do:[:lineNr | |
|
307 |
|line col1 col2 state| |
|
308 |
||
309 |
line := (self listAt:lineNr) copy. |
|
310 |
line size > 0 ifTrue:[ |
|
311 |
lineNr == line1 ifTrue:[ |
|
312 |
col1 := selectionStartCol. |
|
313 |
] ifFalse:[ |
|
314 |
col1 := 1. |
|
315 |
]. |
|
316 |
lineNr == line2 ifTrue:[ |
|
317 |
col2 := selectionEndCol. |
|
318 |
] ifFalse:[ |
|
319 |
col2 := (self listAt:lineNr) size. |
|
320 |
]. |
|
321 |
||
322 |
state := #first. |
|
323 |
col1 to:col2 do:[:col | |
|
324 |
|ch| |
|
325 |
||
326 |
ch := line at:col. |
|
327 |
ch isSeparator ifFalse:[ |
|
328 |
state == #first ifTrue:[ |
|
329 |
line at:col put:ch asUppercase. |
|
330 |
state := #skipRest |
|
331 |
] |
|
332 |
] ifTrue:[ |
|
333 |
state := #first |
|
334 |
] |
|
335 |
]. |
|
336 |
self withoutRedrawAt:lineNr put:line. |
|
337 |
self invalidateLine:lineNr. |
|
338 |
]. |
|
339 |
]. |
|
340 |
] |
|
341 |
'. |
|
342 |
||
343 |
macros at:#ConvertSelectionToUppercase put:' |
|
1077 | 344 |
"to-upper selected text" |
718 | 345 |
|
346 |
|line1 line2| |
|
347 |
||
348 |
line1 := self selectionStartLine. |
|
349 |
line2 := self selectionEndLine. |
|
350 |
line1 isNil ifTrue:[ |
|
351 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
352 |
line1 notNil ifTrue:[ |
|
353 |
line2 := line1 |
|
354 |
] |
|
355 |
]. |
|
356 |
line1 notNil ifTrue:[ |
|
357 |
line1 to:line2 do:[:lineNr | |
|
358 |
|line col1 col2| |
|
359 |
||
360 |
line := (self listAt:lineNr) copy. |
|
361 |
line size > 0 ifTrue:[ |
|
362 |
lineNr == line1 ifTrue:[ |
|
363 |
col1 := selectionStartCol. |
|
364 |
] ifFalse:[ |
|
365 |
col1 := 1. |
|
366 |
]. |
|
367 |
lineNr == line2 ifTrue:[ |
|
368 |
col2 := selectionEndCol. |
|
369 |
] ifFalse:[ |
|
370 |
col2 := (self listAt:lineNr) size. |
|
371 |
]. |
|
372 |
||
373 |
col1 to:col2 do:[:col | |
|
374 |
|ch| |
|
375 |
||
376 |
ch := line at:col. |
|
377 |
line at:col put:ch asUppercase. |
|
378 |
]. |
|
379 |
self withoutRedrawAt:lineNr put:line. |
|
380 |
self invalidateLine:lineNr. |
|
381 |
]. |
|
382 |
]. |
|
383 |
] |
|
384 |
'. |
|
385 |
||
726 | 386 |
macros at:#ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst put:' |
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
387 |
"toLower/toUppercaseFirst/toUpper selected text" |
726 | 388 |
|
389 |
|line1 line2| |
|
390 |
||
391 |
line1 := self selectionStartLine. |
|
392 |
line2 := self selectionEndLine. |
|
393 |
line1 isNil ifTrue:[ |
|
394 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
|
395 |
line1 notNil ifTrue:[ |
|
396 |
line2 := line1 |
|
397 |
] |
|
398 |
]. |
|
399 |
line1 notNil ifTrue:[ |
|
400 |
line1 to:line2 do:[:lineNr | |
|
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
401 |
|line col1 col2 isAllLower isLowerFirst isAllUpper isUpperFirst |
1077 | 402 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
726 | 403 |
|
404 |
line := (self listAt:lineNr) copy. |
|
405 |
line size > 0 ifTrue:[ |
|
406 |
lineNr == line1 ifTrue:[ |
|
407 |
col1 := selectionStartCol. |
|
408 |
] ifFalse:[ |
|
409 |
col1 := 1. |
|
410 |
]. |
|
411 |
lineNr == line2 ifTrue:[ |
|
412 |
col2 := selectionEndCol. |
|
413 |
] ifFalse:[ |
|
414 |
col2 := (self listAt:lineNr) size. |
|
415 |
]. |
|
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
416 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
1070 | 417 |
col1 to:col2 do:[:col | |
418 |
|ch| |
|
726 | 419 |
|
1070 | 420 |
ch := line at:col. |
421 |
ch isUppercase ifTrue:[ |
|
422 |
isAllLower := false. |
|
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
423 |
col == col1 ifTrue:[ |
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
424 |
isLowerFirst := false. |
1070 | 425 |
]. |
426 |
] ifFalse:[ |
|
427 |
ch isLowercase ifTrue:[ |
|
428 |
isAllUpper := false. |
|
429 |
col == col1 ifTrue:[ |
|
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
430 |
isUpperFirst := false. |
726 | 431 |
]. |
1070 | 432 |
] |
726 | 433 |
]. |
434 |
]. |
|
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
435 |
|
1077 | 436 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
437 |
isLowerFirst ifTrue:[ |
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
438 |
makeUppercaseFirst := true. |
726 | 439 |
] ifFalse:[ |
1077 | 440 |
"/ must remember where we come from - otherwise, we end up |
441 |
"/ in upperFirst - lowerFirst cycle. |
|
442 |
"/ think about a good place to store this state |
|
443 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
444 |
makeLowercaseFirst := true. |
|
445 |
] ifFalse:[ |
|
446 |
isAllUpper ifTrue:[ |
|
447 |
makeLowercase := true. |
|
448 |
] ifFalse:[ |
|
449 |
makeUppercase := true. |
|
450 |
] |
|
726 | 451 |
] |
452 |
]. |
|
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
453 |
makeUppercaseFirst ifTrue:[ |
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
454 |
line at:col1 put:(line at:col1) asUppercase. |
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
455 |
] ifFalse:[ |
1077 | 456 |
makeLowercaseFirst ifTrue:[ |
457 |
line at:col1 put:(line at:col1) asLowercase. |
|
458 |
] ifFalse:[ |
|
459 |
col1 to:col2 do:[:col | |
|
460 |
|ch| |
|
726 | 461 |
|
1077 | 462 |
ch := line at:col. |
463 |
ch := makeLowercase |
|
464 |
ifTrue:[ ch asLowercase ] |
|
465 |
ifFalse:[ |
|
466 |
makeUppercase |
|
467 |
ifTrue:[ ch asUppercase ] |
|
468 |
ifFalse:[ |
|
469 |
col == col1 |
|
470 |
ifTrue:[ ch asUppercase ] |
|
471 |
ifFalse:[ ch asLowercase ] |
|
472 |
] |
|
473 |
]. |
|
474 |
line at:col put:ch. |
|
475 |
]. |
|
1076
2d6b2399e42c
better F& behavior; start by makeing UpperFirst
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
476 |
]. |
726 | 477 |
]. |
478 |
self withoutRedrawAt:lineNr put:line. |
|
479 |
self invalidateLine:lineNr. |
|
480 |
]. |
|
481 |
]. |
|
482 |
] |
|
483 |
'. |
|
484 |
||
718 | 485 |
macros at:#ParenthizeSelection put:' |
486 |
"place parenthesis around the selected text" |
|
487 |
||
488 |
|line1 col1 line2 col2| |
|
489 |
||
490 |
line1 := self selectionStartLine. |
|
491 |
col1 := self selectionStartCol. |
|
492 |
line2 := self selectionEndLine. |
|
493 |
col2 := self selectionEndCol. |
|
494 |
(line1 notNil |
|
495 |
and:[ col1 notNil |
|
496 |
and:[ line2 notNil |
|
497 |
and:[ col2 notNil ]]]) |
|
498 |
ifTrue:[ |
|
499 |
self insertString:'')'' atLine:line2 col:col2+1. |
|
500 |
self insertString:''('' atLine:line1 col:col1. |
|
501 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
502 |
] ifFalse:[ |
|
503 |
self beep. |
|
504 |
] |
|
505 |
'. |
|
506 |
||
507 |
macros at:#UnparenthizeSelection put:' |
|
508 |
"remove parenthesis in the selected text" |
|
509 |
||
510 |
|line1 col1 line2 col2| |
|
511 |
||
512 |
line1 := self selectionStartLine. |
|
513 |
col1 := self selectionStartCol. |
|
514 |
line2 := self selectionEndLine. |
|
515 |
col2 := self selectionEndCol. |
|
516 |
(line1 notNil |
|
517 |
and:[ col1 notNil |
|
518 |
and:[ line2 notNil |
|
519 |
and:[ col2 notNil |
|
520 |
and:[ (''({[<'' includes:(self characterAtLine:line1 col:col1)) |
|
521 |
and:[ (''>]})'' includes:(self characterAtLine:line2 col:col2)) ]]]]]) |
|
522 |
ifTrue:[ |
|
523 |
self deleteCharAtLine:line2 col:col2. |
|
524 |
self deleteCharAtLine:line1 col:col1. |
|
525 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2-2. |
|
526 |
] ifFalse:[ |
|
527 |
self beep. |
|
528 |
] |
|
529 |
'. |
|
530 |
||
936 | 531 |
macros at:#SingleQuoteSelection put:' |
532 |
"place single quotes around the selected text" |
|
533 |
||
534 |
|line1 col1 line2 col2| |
|
535 |
||
536 |
line1 := self selectionStartLine. |
|
537 |
col1 := self selectionStartCol. |
|
538 |
line2 := self selectionEndLine. |
|
539 |
col2 := self selectionEndCol. |
|
540 |
(line1 notNil |
|
541 |
and:[ col1 notNil |
|
542 |
and:[ line2 notNil |
|
543 |
and:[ col2 notNil ]]]) |
|
544 |
ifTrue:[ |
|
545 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
|
546 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
547 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
548 |
] ifFalse:[ |
|
549 |
self beep. |
|
550 |
] |
|
551 |
'. |
|
552 |
||
720 | 553 |
"/macros keys do:[:k | |
554 |
"/ Transcript showCR:k. |
|
555 |
"/]. |
|
718 | 556 |
! |