author | Claus Gittinger <cg@exept.de> |
Tue, 01 Jul 2014 12:57:27 +0200 | |
changeset 5081 | 64ecf2a36648 |
parent 5068 | 3ad3eb432172 |
child 5082 | 57b4941c5788 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4823 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
0 | 14 |
TextView subclass:#EditTextView |
4826 | 15 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
16 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
17 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
18 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
19 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
20 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
21 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
22 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
23 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
24 |
undoSupport lastStringFromReplaceForNextSearch |
|
25 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
26 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
27 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
28 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
29 |
poolDictionaries:'' |
|
30 |
category:'Views-Text' |
|
0 | 31 |
! |
32 |
||
2952 | 33 |
Object subclass:#EditAction |
4826 | 34 |
instanceVariableNames:'userFriendlyInfo' |
35 |
classVariableNames:'' |
|
36 |
poolDictionaries:'' |
|
37 |
privateIn:EditTextView |
|
2952 | 38 |
! |
39 |
||
40 |
EditTextView::EditAction subclass:#DeleteRange |
|
4826 | 41 |
instanceVariableNames:'line1 col1 line2 col2' |
42 |
classVariableNames:'' |
|
43 |
poolDictionaries:'' |
|
44 |
privateIn:EditTextView |
|
2952 | 45 |
! |
46 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
47 |
EditTextView::EditAction subclass:#DeleteCharacters |
4826 | 48 |
instanceVariableNames:'line col1 col2' |
49 |
classVariableNames:'' |
|
50 |
poolDictionaries:'' |
|
51 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
52 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
53 |
|
3235 | 54 |
Object subclass:#EditMode |
4826 | 55 |
instanceVariableNames:'' |
56 |
classVariableNames:'' |
|
57 |
poolDictionaries:'' |
|
58 |
privateIn:EditTextView |
|
3235 | 59 |
! |
60 |
||
61 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
4826 | 62 |
instanceVariableNames:'' |
63 |
classVariableNames:'' |
|
64 |
poolDictionaries:'' |
|
65 |
privateIn:EditTextView::EditMode |
|
3235 | 66 |
! |
67 |
||
68 |
EditTextView::EditMode subclass:#InsertMode |
|
4826 | 69 |
instanceVariableNames:'' |
70 |
classVariableNames:'' |
|
71 |
poolDictionaries:'' |
|
72 |
privateIn:EditTextView::EditMode |
|
3235 | 73 |
! |
74 |
||
75 |
EditTextView::EditMode subclass:#OverwriteMode |
|
4826 | 76 |
instanceVariableNames:'' |
77 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
78 |
poolDictionaries:'' |
|
79 |
privateIn:EditTextView::EditMode |
|
3235 | 80 |
! |
81 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
82 |
Query subclass:#ExecutingMacroQuery |
4826 | 83 |
instanceVariableNames:'' |
84 |
classVariableNames:'' |
|
85 |
poolDictionaries:'' |
|
86 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
87 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
88 |
|
4048 | 89 |
Object subclass:#LastReplacementInfo |
4826 | 90 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
91 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
92 |
classVariableNames:'' |
|
93 |
poolDictionaries:'' |
|
94 |
privateIn:EditTextView |
|
4048 | 95 |
! |
96 |
||
2952 | 97 |
EditTextView::EditAction subclass:#PasteString |
4826 | 98 |
instanceVariableNames:'line col string selected' |
99 |
classVariableNames:'' |
|
100 |
poolDictionaries:'' |
|
101 |
privateIn:EditTextView |
|
2952 | 102 |
! |
103 |
||
104 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
4826 | 105 |
instanceVariableNames:'line col character' |
106 |
classVariableNames:'' |
|
107 |
poolDictionaries:'' |
|
108 |
privateIn:EditTextView |
|
2952 | 109 |
! |
110 |
||
3235 | 111 |
EditTextView::EditAction subclass:#ReplaceCharacters |
4826 | 112 |
instanceVariableNames:'line col1 col2 characters' |
113 |
classVariableNames:'' |
|
114 |
poolDictionaries:'' |
|
115 |
privateIn:EditTextView |
|
3235 | 116 |
! |
117 |
||
3131 | 118 |
EditTextView::EditAction subclass:#ReplaceContents |
4826 | 119 |
instanceVariableNames:'text' |
120 |
classVariableNames:'' |
|
121 |
poolDictionaries:'' |
|
122 |
privateIn:EditTextView |
|
3131 | 123 |
! |
124 |
||
3130 | 125 |
EditTextView::EditAction subclass:#ReplaceLine |
4826 | 126 |
instanceVariableNames:'line text' |
127 |
classVariableNames:'' |
|
128 |
poolDictionaries:'' |
|
129 |
privateIn:EditTextView |
|
3130 | 130 |
! |
131 |
||
3402 | 132 |
EditTextView::EditAction subclass:#ReplaceLines |
4826 | 133 |
instanceVariableNames:'line text' |
134 |
classVariableNames:'' |
|
135 |
poolDictionaries:'' |
|
136 |
privateIn:EditTextView |
|
3402 | 137 |
! |
138 |
||
865 | 139 |
!EditTextView class methodsFor:'documentation'! |
0 | 140 |
|
33 | 141 |
copyright |
142 |
" |
|
143 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 144 |
All Rights Reserved |
33 | 145 |
|
146 |
This software is furnished under a license and may be used |
|
147 |
only in accordance with the terms of that license and with the |
|
148 |
inclusion of the above copyright notice. This software may not |
|
149 |
be provided or otherwise made available to, or used by, any |
|
150 |
other person. No title to or ownership of the software is |
|
151 |
hereby transferred. |
|
152 |
" |
|
153 |
! |
|
154 |
||
0 | 155 |
documentation |
156 |
" |
|
157 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 158 |
Also, it adds accept functionality, and defines a new actionBlock: |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
159 |
acceptAction to be performed for accept |
125 | 160 |
|
161 |
If used with a model, this is informed by sending it a changeMsg with |
|
162 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
163 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 164 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
165 |
Please read the historic notice in the ListView class. |
0 | 166 |
|
586 | 167 |
[Instance variables:] |
0 | 168 |
|
4010 | 169 |
cursorLine <Number> line where cursor sits (1..) |
170 |
||
171 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
172 |
||
173 |
cursorCol <Number> col where cursor sits (1..) |
|
174 |
||
175 |
cursorShown <Boolean> true, if cursor is currently shown |
|
176 |
||
177 |
readOnly <Boolean> true, if text may not be edited |
|
178 |
||
179 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
180 |
cleared on accept. |
|
181 |
||
182 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
183 |
||
184 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
185 |
||
186 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
187 |
if it returns true, the modification will be done anyway. |
|
188 |
if it returns anything else, the modification is not done. |
|
189 |
||
190 |
cursorFgColor <Color> color used for cursor drawing |
|
191 |
cursorBgColor <Color> color used for cursor drawing |
|
192 |
||
193 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 194 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 195 |
(vertical bar at insertion point) |
4721 | 196 |
and #caret (caret below insertion-point). |
197 |
see cursorType: for an up-to-date list. |
|
4010 | 198 |
|
199 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
200 |
nil means: hide the cursor. |
|
201 |
||
202 |
undoAction <Block> block which undoes last cut, paste or replace |
|
203 |
(not yet fully implemented) |
|
204 |
||
205 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
206 |
this affects the next keyPress: if #paste it does not |
|
207 |
replace; otherwise it replaces the selection. |
|
208 |
||
209 |
lastCut <String> last cut or replaced string |
|
210 |
||
4053 | 211 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
212 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
213 |
lastReplacement is the string to replace lastStringToReplace |
|
214 |
||
215 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
216 |
(cleared after a new selection) |
|
4010 | 217 |
|
218 |
replacing <Boolean> true if entered characters replace last selection |
|
219 |
||
220 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
221 |
when entering one; this is the default. |
|
222 |
||
223 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
224 |
||
225 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
226 |
argument |
|
227 |
||
228 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
229 |
focus to the next field. For editTextViews, this is false |
|
230 |
by default (i.e. tabs can be entered into the text). |
|
231 |
For some subclasses (inputFields), this may be true. |
|
232 |
||
233 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
234 |
removed when editing. |
|
235 |
Default is true. |
|
236 |
||
237 |
wordWrap <Boolean> Currently not used. |
|
238 |
||
239 |
lockUpdates <Boolean> internal, private |
|
240 |
||
241 |
prevCursorState <Boolean> temporary, private |
|
242 |
||
243 |
cursorMovementWhenUpdating |
|
244 |
<Symbol> defines where the cursor is to be positioned if the |
|
245 |
model changes its value by some outside activity |
|
246 |
(i.e. not by user input into the field). |
|
247 |
Can be one of: |
|
248 |
#keep / nil -> stay where it was |
|
249 |
#endOfText -> cursor to the end |
|
250 |
#endOfLine -> stay in the line, but move to end |
|
251 |
#beginOfText -> cursor to the beginning |
|
252 |
#beginOfLine -> stay in the line, but move to begin |
|
253 |
The default is #beginOfText |
|
254 |
||
255 |
||
256 |
||
257 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 258 |
|
259 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
260 |
userPreference values: |
4010 | 261 |
userPreferences.st80EditMode |
262 |
<Boolean> if true, cursor positioning is |
|
263 |
done as in vi or ST80; i.e. |
|
264 |
wysiwyg mode is somewhat relaxed, |
|
265 |
in that the cursor cannot be |
|
266 |
positioned behind a lines end. |
|
267 |
This is not yet completely implemented. |
|
33 | 268 |
used globals: |
269 |
||
4010 | 270 |
DeleteHistory <Text> last 1000 lines of deleted text |
271 |
(but only if this variable exists already) |
|
586 | 272 |
|
273 |
[styleSheet parameters:] |
|
121 | 274 |
|
4010 | 275 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
276 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
277 |
textCursorNoFocusForegroundColor |
|
278 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
279 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 280 |
|
281 |
[author:] |
|
4010 | 282 |
Claus Gittinger |
586 | 283 |
|
284 |
[see also:] |
|
4010 | 285 |
CodeView Workspace TextView ListView |
286 |
EditField |
|
0 | 287 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
288 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
289 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
290 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
291 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
292 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
293 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
294 |
basic setup: |
4823 | 295 |
[exBegin] |
296 |
|top textView| |
|
297 |
||
298 |
top := StandardSystemView new. |
|
299 |
top extent:300@200. |
|
300 |
||
301 |
textView := EditTextView new. |
|
302 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
303 |
top addSubView:textView. |
|
304 |
||
305 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
306 |
||
307 |
top open. |
|
308 |
[exEnd] |
|
594 | 309 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
310 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
311 |
with vertical scrollbar: |
4823 | 312 |
[exBegin] |
313 |
|top scrollView textView| |
|
314 |
||
315 |
top := StandardSystemView new. |
|
316 |
top extent:300@200. |
|
317 |
||
318 |
scrollView := ScrollableView for:EditTextView. |
|
319 |
textView := scrollView scrolledView. |
|
320 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
321 |
top addSubView:scrollView. |
|
322 |
||
323 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
324 |
||
325 |
top open. |
|
326 |
[exEnd] |
|
594 | 327 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
328 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
329 |
with horizontal & vertical scrollbars: |
4823 | 330 |
[exBegin] |
331 |
|top scrollView textView| |
|
332 |
||
333 |
top := StandardSystemView new. |
|
334 |
top extent:300@200. |
|
335 |
||
336 |
scrollView := HVScrollableView for:EditTextView. |
|
337 |
textView := scrollView scrolledView. |
|
338 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
339 |
top addSubView:scrollView. |
|
340 |
||
341 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
342 |
||
343 |
top open. |
|
344 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
345 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
346 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
347 |
set the action for accept: |
4823 | 348 |
[exBegin] |
349 |
|top textView| |
|
350 |
||
351 |
top := StandardSystemView new. |
|
352 |
top extent:300@200. |
|
353 |
||
354 |
textView := EditTextView new. |
|
355 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
356 |
top addSubView:textView. |
|
357 |
||
358 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
359 |
textView acceptAction:[:contents | |
|
360 |
Transcript showCR:'will not overwrite the file with:'. |
|
361 |
Transcript showCR:contents asString |
|
362 |
]. |
|
363 |
top open. |
|
364 |
[exEnd] |
|
594 | 365 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
366 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
367 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
368 |
non-string (text) items: |
4823 | 369 |
[exBegin] |
370 |
|top textView list| |
|
371 |
||
372 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
373 |
1 to:list size by:2 do:[:nr | |
|
374 |
list at:nr put:(Text string:(list at:nr) |
|
375 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
376 |
]. |
|
377 |
||
378 |
top := StandardSystemView new. |
|
379 |
top extent:300@200. |
|
380 |
||
381 |
textView := EditTextView new. |
|
382 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
383 |
top addSubView:textView. |
|
384 |
||
385 |
textView contents:list. |
|
386 |
top open. |
|
387 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
388 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
389 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
390 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
391 |
MVC operation: |
594 | 392 |
(the examples model here is a plug simulating a real model; |
393 |
real world applications would not use a plug ..) |
|
4823 | 394 |
[exBegin] |
395 |
|top textView model| |
|
396 |
||
397 |
model := Plug new. |
|
398 |
model respondTo:#accepted: |
|
399 |
with:[:newContents | |
|
400 |
Transcript showCR:'will not overwrite the file with:'. |
|
401 |
Transcript showCR:newContents asString |
|
402 |
]. |
|
403 |
model respondTo:#getList |
|
404 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
405 |
||
406 |
||
407 |
top := StandardSystemView new. |
|
408 |
top extent:300@200. |
|
409 |
||
410 |
textView := EditTextView new. |
|
411 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
412 |
top addSubView:textView. |
|
413 |
||
414 |
textView listMessage:#getList; |
|
415 |
model:model; |
|
416 |
changeMessage:#accepted:; |
|
417 |
aspect:#list. |
|
418 |
top open. |
|
419 |
[exEnd] |
|
594 | 420 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
421 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
422 |
two textViews on the same model: |
4823 | 423 |
[exBegin] |
424 |
|top1 textView1 top2 textView2 model currentContents| |
|
425 |
||
426 |
model := Plug new. |
|
427 |
model respondTo:#accepted: |
|
428 |
with:[:newContents | |
|
429 |
Transcript showCR:'accepted:'. |
|
430 |
Transcript showCR:newContents asString. |
|
431 |
currentContents := newContents. |
|
432 |
model changed:#contents |
|
433 |
]. |
|
434 |
model respondTo:#getList |
|
435 |
with:[Transcript showCR:'query'. |
|
436 |
currentContents]. |
|
437 |
||
438 |
||
439 |
top1 := StandardSystemView new. |
|
440 |
top1 extent:300@200. |
|
441 |
||
442 |
textView1 := EditTextView new. |
|
443 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
444 |
top1 addSubView:textView1. |
|
445 |
||
446 |
textView1 listMessage:#getList; |
|
447 |
model:model; |
|
448 |
aspect:#contents; |
|
449 |
changeMessage:#accepted:. |
|
450 |
top1 open. |
|
451 |
||
452 |
top2 := StandardSystemView new. |
|
453 |
top2 extent:300@200. |
|
454 |
||
455 |
textView2 := EditTextView new. |
|
456 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
457 |
top2 addSubView:textView2. |
|
458 |
||
459 |
textView2 listMessage:#getList; |
|
460 |
model:model; |
|
461 |
aspect:#contents; |
|
462 |
changeMessage:#accepted:. |
|
463 |
top2 open. |
|
464 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
465 |
" |
0 | 466 |
! ! |
467 |
||
865 | 468 |
!EditTextView class methodsFor:'defaults'! |
59 | 469 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
470 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
471 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
472 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
473 |
"Created: / 26-09-2013 / 17:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
474 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
475 |
|
1419 | 476 |
st80Mode |
477 |
"return true, if the st80 editing mode is turned on. |
|
478 |
This setting affects the behavior of the cursor, when positioned |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
479 |
beyond the end of a line or the end of the text." |
1419 | 480 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
481 |
^ UserPreferences current st80EditMode |
1419 | 482 |
|
483 |
" |
|
484 |
EditTextView st80Mode:true |
|
485 |
EditTextView st80Mode:false |
|
486 |
" |
|
487 |
||
488 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
489 |
! |
|
490 |
||
491 |
st80Mode:aBoolean |
|
492 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 493 |
beyond the end of a line or the last line" |
1419 | 494 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
495 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 496 |
|
497 |
" |
|
498 |
EditTextView st80Mode:true |
|
499 |
EditTextView st80Mode:false |
|
500 |
" |
|
501 |
||
502 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
503 |
! |
|
504 |
||
59 | 505 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
506 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
507 |
|
1390 | 508 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 509 |
#'textCursor.noFocusForegroundColor' |
510 |
#'textCursor.type' |
|
511 |
#'textCursor.typeNoFocus' |
|
512 |
#'editText.st80Mode')> |
|
1355 | 513 |
|
514 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
515 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
516 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
517 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
518 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
519 |
|
1419 | 520 |
" |
521 |
self updateStyleCache |
|
522 |
" |
|
523 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
524 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 525 |
! ! |
526 |
||
3431 | 527 |
!EditTextView class methodsFor:'specs'! |
528 |
||
529 |
searchReplaceDialogSpec |
|
530 |
"This resource specification was automatically generated |
|
531 |
by the UIPainter of ST/X." |
|
532 |
||
533 |
"Do not manually edit this!! If it is corrupted, |
|
534 |
the UIPainter may not be able to read the specification." |
|
535 |
||
536 |
" |
|
537 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
538 |
" |
|
539 |
||
540 |
<resource: #canvas> |
|
541 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
542 |
^ |
3431 | 543 |
#(FullSpec |
4823 | 544 |
name: searchReplaceDialogSpec |
545 |
window: |
|
3431 | 546 |
(WindowSpec |
4823 | 547 |
label: 'String Search and Replace' |
548 |
name: 'String Search and Replace' |
|
549 |
min: (Point 283 196) |
|
550 |
max: (Point 283 196) |
|
551 |
bounds: (Rectangle 0 0 279 192) |
|
552 |
) |
|
553 |
component: |
|
3431 | 554 |
(SpecCollection |
4823 | 555 |
collection: ( |
556 |
(LabelSpec |
|
557 |
label: 'Search Pattern:' |
|
558 |
name: 'label' |
|
559 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
560 |
level: 0 |
|
561 |
translateLabel: true |
|
562 |
adjust: left |
|
563 |
) |
|
564 |
(ComboBoxSpec |
|
565 |
name: 'patternComboBox' |
|
566 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
567 |
tabable: true |
|
568 |
model: searchPattern |
|
569 |
immediateAccept: false |
|
570 |
acceptOnLeave: true |
|
571 |
acceptOnReturn: true |
|
572 |
acceptOnTab: true |
|
573 |
acceptOnLostFocus: true |
|
574 |
acceptOnPointerLeave: false |
|
575 |
autoSelectInitialText: true |
|
576 |
comboList: patternList |
|
577 |
) |
|
578 |
(ComboBoxSpec |
|
579 |
name: 'replaceComboBox' |
|
580 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
581 |
tabable: true |
|
582 |
model: replacePattern |
|
583 |
immediateAccept: false |
|
584 |
acceptOnLeave: true |
|
585 |
acceptOnReturn: true |
|
586 |
acceptOnTab: true |
|
587 |
acceptOnLostFocus: true |
|
588 |
acceptOnPointerLeave: false |
|
589 |
autoSelectInitialText: true |
|
590 |
comboList: patternList |
|
591 |
) |
|
592 |
(CheckBoxSpec |
|
593 |
label: 'Ignore Case' |
|
594 |
name: 'ignoreCaseCheckBox' |
|
595 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
596 |
level: 0 |
|
597 |
tabable: true |
|
598 |
model: ignoreCase |
|
599 |
translateLabel: true |
|
600 |
) |
|
601 |
(VariableVerticalPanelSpec |
|
602 |
name: 'VariableVerticalPanel1' |
|
603 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
604 |
component: |
|
605 |
(SpecCollection |
|
606 |
collection: ( |
|
607 |
(HorizontalPanelViewSpec |
|
608 |
name: 'HorizontalPanel1' |
|
609 |
level: 0 |
|
610 |
horizontalLayout: fitSpace |
|
611 |
verticalLayout: center |
|
612 |
horizontalSpace: 3 |
|
613 |
verticalSpace: 3 |
|
614 |
ignoreInvisibleComponents: true |
|
615 |
reverseOrderIfOKAtLeft: true |
|
616 |
component: |
|
617 |
(SpecCollection |
|
618 |
collection: ( |
|
619 |
(ActionButtonSpec |
|
620 |
label: 'Replace' |
|
621 |
name: 'replaceButton' |
|
622 |
level: 2 |
|
623 |
translateLabel: true |
|
624 |
tabable: true |
|
625 |
model: replaceAction |
|
626 |
extent: (Point 134 21) |
|
627 |
) |
|
628 |
(ActionButtonSpec |
|
629 |
label: 'Replace All' |
|
630 |
name: 'replaceAllButton' |
|
631 |
level: 2 |
|
632 |
borderWidth: 1 |
|
633 |
translateLabel: true |
|
634 |
tabable: true |
|
635 |
model: replaceAllAction |
|
636 |
extent: (Point 134 21) |
|
637 |
) |
|
638 |
) |
|
639 |
||
640 |
) |
|
641 |
) |
|
642 |
(HorizontalPanelViewSpec |
|
643 |
name: 'horizontalPanelView' |
|
644 |
level: 0 |
|
645 |
horizontalLayout: fitSpace |
|
646 |
verticalLayout: center |
|
647 |
horizontalSpace: 3 |
|
648 |
verticalSpace: 3 |
|
649 |
ignoreInvisibleComponents: true |
|
650 |
reverseOrderIfOKAtLeft: true |
|
651 |
component: |
|
652 |
(SpecCollection |
|
653 |
collection: ( |
|
654 |
(ActionButtonSpec |
|
655 |
label: 'Cancel' |
|
656 |
name: 'cancelButton' |
|
657 |
level: 2 |
|
658 |
translateLabel: true |
|
659 |
tabable: true |
|
660 |
model: cancel |
|
661 |
extent: (Point 88 21) |
|
662 |
) |
|
663 |
(ActionButtonSpec |
|
664 |
label: 'Prev' |
|
665 |
name: 'prevButton' |
|
666 |
level: 2 |
|
667 |
translateLabel: true |
|
668 |
tabable: true |
|
669 |
model: prevAction |
|
670 |
extent: (Point 89 21) |
|
671 |
) |
|
672 |
(ActionButtonSpec |
|
673 |
label: 'Next' |
|
674 |
name: 'nextButton' |
|
675 |
level: 2 |
|
676 |
borderWidth: 1 |
|
677 |
translateLabel: true |
|
678 |
tabable: true |
|
679 |
model: nextAction |
|
680 |
isDefault: true |
|
681 |
extent: (Point 88 21) |
|
682 |
) |
|
683 |
) |
|
684 |
||
685 |
) |
|
686 |
) |
|
687 |
) |
|
688 |
||
689 |
) |
|
690 |
handles: (Any 0.5 1.0) |
|
691 |
) |
|
692 |
(LabelSpec |
|
693 |
label: 'Replace By:' |
|
694 |
name: 'ReplaceLabel' |
|
695 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
696 |
level: 0 |
|
697 |
translateLabel: true |
|
698 |
adjust: left |
|
699 |
) |
|
700 |
) |
|
701 |
||
702 |
) |
|
3431 | 703 |
) |
704 |
||
705 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
706 |
! ! |
|
707 |
||
2744 | 708 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
709 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
710 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
711 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
712 |
|
2019 | 713 |
"Created: / 5.6.1998 / 15:30:32 / cg " |
1585
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
714 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
715 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
716 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
717 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
718 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
719 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
720 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
721 |
|
1390 | 722 |
cutSelection |
723 |
self cut |
|
724 |
||
725 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
726 |
! |
|
727 |
||
1590 | 728 |
deselect |
729 |
"remove the selection" |
|
730 |
||
731 |
^ self unselect |
|
732 |
||
733 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
734 |
! |
|
735 |
||
2101 | 736 |
enabled:aBoolean |
737 |
||
738 |
self readOnly:aBoolean not |
|
739 |
||
740 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
741 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
742 |
! |
|
743 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
744 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
745 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
746 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
747 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
748 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
749 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
750 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
751 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
752 |
"insert a string at aCharacterPosition." |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
753 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
754 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
755 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
756 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
757 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
758 |
col < 1 ifTrue:[ |
4823 | 759 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
760 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
761 |
self insertString:aString atLine:line col:col. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
762 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
763 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
764 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
765 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
766 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
767 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
768 |
v := EditTextView origin:0.0@0.0 corner:1.0@1.0 in:top. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
769 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
770 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
771 |
v insert:'<- hello there' at:5. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
772 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
773 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
774 |
"Modified: / 5.4.1998 / 17:20:08 / cg" |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
775 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
776 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
777 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
778 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
779 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
780 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
781 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
782 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 783 |
col := (aCharacterPosition - (self characterPositionOfLine:line col:1) + 1) max:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
784 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
785 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 786 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
787 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
788 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
789 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
790 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
791 |
v insertAndSelect:'<- hello there' at:5. |
125 | 792 |
" |
1390 | 793 |
! |
794 |
||
795 |
pasteSelection |
|
796 |
self paste |
|
797 |
||
798 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 799 |
! |
800 |
||
801 |
replaceSelectionWith:aString |
|
802 |
^ self replaceSelectionBy:aString |
|
803 |
||
804 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
805 |
! |
|
806 |
||
807 |
selectAt:pos |
|
808 |
"move the cursor before cursorPosition." |
|
809 |
||
810 |
self cursorToCharacterPosition:pos |
|
811 |
||
812 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
813 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
814 |
! |
|
815 |
||
2101 | 816 |
textHasChanged |
817 |
^ self modified |
|
818 |
||
819 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
820 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
821 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
822 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
823 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
824 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
825 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
826 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
827 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
828 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
829 |
|
4585 | 830 |
!EditTextView methodsFor:'accessing'! |
831 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
832 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
833 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
834 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
835 |
codeAspect := codeAspectHolder value. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
836 |
codeAspect notNil ifTrue:[^codeAspect]. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
837 |
self editedMethod notNil ifTrue:[^SyntaxHighlighter codeAspectMethod]. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
838 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
839 |
"/ Applications should set it explictly, however, to make it behavinh like |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
840 |
"/ CodeView2, I kept fetching code here for now. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
841 |
^((app := self topView application) notNil and:[app respondsTo: #codeAspect]) |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
842 |
ifTrue:[app codeAspect] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
843 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
844 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
845 |
"Created: / 27-09-2013 / 09:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
846 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
847 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
848 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
849 |
codeAspectHolder value: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
850 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
851 |
"Created: / 27-09-2013 / 09:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
852 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
853 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
854 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
855 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
856 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
857 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
858 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
859 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
860 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
861 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
862 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
863 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
864 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
865 |
"Created: / 26-09-2013 / 17:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
866 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
867 |
|
4609 | 868 |
editedClass |
869 |
|cm| |
|
870 |
||
871 |
cm := self editedMethodOrClass. |
|
872 |
cm isBehavior ifTrue:[^ cm]. |
|
873 |
cm isMethod ifTrue:[^ cm mclass]. |
|
874 |
^ nil |
|
875 |
! |
|
876 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
877 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
878 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
879 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
880 |
"Created: / 18-09-2013 / 14:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
881 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
882 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
883 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
884 |
"Sets the edited language. Only defined here to make it polymorph with Workspace" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
885 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
886 |
"Created: / 27-09-2013 / 10:15:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
887 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
888 |
|
4609 | 889 |
editedMethod |
890 |
|cm| |
|
891 |
||
892 |
cm := self editedMethodOrClass. |
|
893 |
cm isMethod ifTrue:[^ cm]. |
|
894 |
cm isBehavior ifTrue:[^ nil]. |
|
895 |
^ nil |
|
896 |
! |
|
897 |
||
898 |
editedMethodOrClass |
|
899 |
^ nil |
|
900 |
! |
|
901 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
902 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
903 |
"Sets the edited method or class. Only defined here to make it polymorph with Workspace" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
904 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
905 |
"Created: / 27-09-2013 / 10:10:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
906 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
907 |
|
4585 | 908 |
hasSelectionOrTextInCursorLine |
909 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
910 |
! |
|
911 |
||
4589 | 912 |
selectionOrTextOfCursorLine |
913 |
^ self selectionOrTextOfCursorLine:true |
|
914 |
! |
|
915 |
||
4585 | 916 |
selectionOrTextOfCursorLine:doSelect |
917 |
|sel lNr line| |
|
918 |
||
919 |
sel := self selectionAsString. |
|
920 |
sel notNil ifTrue:[^ sel]. |
|
921 |
||
922 |
lNr := self cursorLine. |
|
923 |
line := self listAt:lNr. |
|
924 |
line notEmptyOrNil ifTrue:[ |
|
925 |
doSelect ifTrue:[ |
|
926 |
self selectLine:lNr. |
|
927 |
]. |
|
928 |
^ line |
|
929 |
]. |
|
930 |
||
931 |
^ nil |
|
932 |
! ! |
|
933 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
934 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
935 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
936 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
937 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
938 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
939 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
940 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
941 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
942 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
943 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
944 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
945 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
946 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
947 |
|
2792 | 948 |
acceptChannel |
949 |
"return the valueHolder holding true if text was accepted. |
|
950 |
By placing a true into this channel, an accept can also be forced." |
|
951 |
||
952 |
^ acceptChannel |
|
953 |
||
954 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
955 |
! |
|
956 |
||
957 |
acceptChannel:aValueHolder |
|
958 |
"set the valueHolder holding true if text was accepted. |
|
959 |
By placing a true into this channel, an accept can also be forced." |
|
960 |
||
961 |
|prev| |
|
962 |
||
963 |
prev := acceptChannel. |
|
964 |
acceptChannel := aValueHolder. |
|
965 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
966 |
||
967 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
968 |
! |
|
969 |
||
1108 | 970 |
acceptEnabled:aBoolean |
971 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
972 |
||
973 |
acceptEnabled := aBoolean |
|
974 |
||
975 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
976 |
! |
|
977 |
||
2792 | 978 |
accepted |
979 |
"return true if text was accepted" |
|
980 |
||
981 |
^ acceptChannel value |
|
982 |
||
983 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
984 |
! |
|
985 |
||
986 |
accepted:aBoolean |
|
987 |
"set/clear the accepted flag. |
|
988 |
This may force my current contents to be placed into my model." |
|
989 |
||
990 |
acceptChannel value:aBoolean. |
|
991 |
||
992 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
993 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
994 |
! |
|
995 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
996 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
997 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
998 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
999 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1000 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1001 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1002 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1003 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1004 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1005 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1006 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1007 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1008 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1009 |
|
2774 | 1010 |
cursorMovementWhenUpdating |
3160 | 1011 |
"return what is be done with the cursor, |
2774 | 1012 |
when I get a new text (via the model or the #contents/#list) |
1013 |
Allowed arguments are: |
|
4823 | 1014 |
#keep / nil -> stay where it was |
1015 |
#endOfText -> position cursor to the end |
|
1016 |
#beginOfText -> position cursor to the beginning |
|
1017 |
#endOfLine -> position cursor to the current lines end |
|
1018 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1019 |
The default is #beginOfText. |
1020 |
This may be useful for fields which get new values assigned from |
|
1021 |
the program (i.e. not from the user)" |
|
1022 |
||
1023 |
^ cursorMovementWhenUpdating |
|
1024 |
||
1025 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1026 |
! |
|
1027 |
||
2133 | 1028 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1029 |
"define what should be done with the cursor, |
2133 | 1030 |
when I get a new text (via the model or the #contents/#list) |
1031 |
Allowed arguments are: |
|
4823 | 1032 |
#keep / nil -> stay where it was |
1033 |
#endOfText -> position cursor to the end |
|
1034 |
#beginOfText -> position cursor to the beginning |
|
1035 |
#endOfLine -> position cursor to the current lines end |
|
1036 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1037 |
The default is #beginOfText. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1038 |
This may be useful for fields which get new values assigned from |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1039 |
the program (i.e. not from the user)" |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1040 |
|
2133 | 1041 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1042 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1043 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1044 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1045 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1046 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1047 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1048 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1049 |
|
2438 | 1050 |
dontReplaceSelectionOnInput |
4742 | 1051 |
"remember that the current selection was created by a paste operation |
1052 |
(as opposed to an explicit selection by the user). |
|
1053 |
This selection will not be replaced by followup user input, |
|
1054 |
so multiple pastes will be possible." |
|
1055 |
||
2438 | 1056 |
typeOfSelection := #paste |
1057 |
! |
|
1058 |
||
3235 | 1059 |
editModeHolder |
1060 |
^ editMode. |
|
1061 |
! |
|
1062 |
||
1063 |
editModeInsert |
|
1064 |
editMode value:EditMode insertMode |
|
1065 |
! |
|
1066 |
||
1067 |
editModeInsertAndSelect |
|
1068 |
editMode value:EditMode insertAndSelectMode |
|
1069 |
! |
|
1070 |
||
1071 |
editModeOverwrite |
|
1072 |
editMode value:EditMode overwriteMode |
|
1073 |
! |
|
1074 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1075 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1076 |
"define the action to be triggered when user tries to modify |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1077 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1078 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1079 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1080 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1081 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1082 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1083 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1084 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1085 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1086 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1087 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1088 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1089 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1090 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1091 |
readOnly == true ifFalse:[ |
4823 | 1092 |
readOnly := true. |
1093 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1094 |
menu disableAll:#(cut paste replace indent) |
|
1095 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1096 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1097 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1098 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1099 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1100 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1101 |
insertMode:aBoolean |
3235 | 1102 |
editMode value:(aBoolean ifTrue:[EditMode insertMode] ifFalse:[EditMode overwriteMode]) |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1103 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1104 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1105 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1106 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1107 |
insertModeHolder |
3235 | 1108 |
^ BlockValue |
4823 | 1109 |
with:[:m | m isInsertMode] |
1110 |
argument:(editMode). |
|
3465 | 1111 |
|
1112 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1113 |
! |
1114 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1115 |
isInInsertMode |
3235 | 1116 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1117 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1118 |
|
2792 | 1119 |
isReadOnly |
1120 |
"return true, if the text is readonly." |
|
1121 |
||
1122 |
^ readOnly value |
|
1123 |
||
1124 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1125 |
! |
|
1126 |
||
2796 | 1127 |
modeLabelHolder |
1128 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1129 |
||
3160 | 1130 |
^ BlockValue |
4041 | 1131 |
with:[:e :l | |
1132 |
self isReadOnly ifTrue:[ |
|
1133 |
'' |
|
1134 |
] ifFalse:[ |
|
1135 |
l ifTrue:[ 'L' allBold colorizeAllWith:Color red] |
|
1136 |
ifFalse:[ e infoPrintString]]] |
|
1137 |
argument:(self editModeHolder) |
|
1138 |
argument:(self learnModeHolder). |
|
3465 | 1139 |
|
1140 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1141 |
! |
1142 |
||
2792 | 1143 |
modified |
1144 |
"return true if text was modified" |
|
1145 |
||
1146 |
^ modifiedChannel value |
|
1147 |
! |
|
1148 |
||
1149 |
modified:aBoolean |
|
1150 |
"set/clear the modified flag" |
|
1151 |
||
1152 |
modifiedChannel value:aBoolean |
|
1153 |
||
1154 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1155 |
! |
|
1156 |
||
1157 |
modifiedChannel |
|
1158 |
"return the valueHolder holding true if text was modified" |
|
1159 |
||
1160 |
^ modifiedChannel |
|
1161 |
! |
|
1162 |
||
1163 |
modifiedChannel:aValueHolder |
|
1164 |
"set the valueHolder holding true if text was modified" |
|
1165 |
||
1166 |
|prev| |
|
1167 |
||
1168 |
prev := modifiedChannel. |
|
1169 |
modifiedChannel := aValueHolder. |
|
1170 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1171 |
||
1172 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1173 |
! |
|
1174 |
||
1175 |
readOnly |
|
1176 |
"make the text readonly. |
|
4664 | 1177 |
Obsolete because it is obfuscating (looks like a getter) |
1178 |
- use #readOnly:" |
|
2792 | 1179 |
|
1180 |
<resource:#obsolete> |
|
1181 |
||
1182 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1183 |
self readOnly:true. |
2792 | 1184 |
|
4664 | 1185 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1186 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1187 |
! |
1188 |
||
1189 |
readOnly:aBoolean |
|
1190 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1191 |
The argument may also be a valueHolder." |
|
1192 |
||
1193 |
readOnly := aBoolean |
|
1194 |
||
1195 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1196 |
! |
|
1197 |
||
4782 | 1198 |
reallyModifiedChannel |
1199 |
"return the valueHolder holding true if text was really modified. |
|
1200 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1201 |
||
1202 |
^ self modifiedChannel |
|
1203 |
! |
|
1204 |
||
4192 | 1205 |
st80Mode:aBoolean |
1206 |
"set/clear the st80Mode flag. |
|
1207 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
1208 |
if off, we have the Rand-editor behavior (random access)" |
|
1209 |
||
1210 |
st80Mode := aBoolean |
|
1211 |
||
1212 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1213 |
! |
|
1214 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1215 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1216 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1217 |
If true, Tab is ignored and shifts the keyboard focus. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1218 |
If false, tabs can be entered into the text. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1219 |
The default is true for editTextView, false for single-line |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1220 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1221 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1222 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1223 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1224 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1225 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1226 |
"returns true, if a focus tabbing requires a control-key to be pressed. |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1227 |
The default is true for editTextView, false for other widgets, |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1228 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1229 |
|
3160 | 1230 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1231 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1232 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1233 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1234 |
"controls if a focus tabbing requires a control-key to be pressed. |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1235 |
The default is true for editTextView, false for other widgets, |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1236 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1237 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1238 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1239 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1240 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1241 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1242 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1243 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1244 |
"change a line without change notification" |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1245 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1246 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1247 |
super at:lineNr put:aLine. |
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1248 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1249 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1250 |
|
522 | 1251 |
at:lineNr put:aLine |
1252 |
(self at:lineNr) = aLine ifFalse:[ |
|
4823 | 1253 |
super at:lineNr put:aLine. |
1254 |
self textChanged |
|
522 | 1255 |
]. |
1256 |
! |
|
1257 |
||
4700 | 1258 |
characterAfterCursor |
1259 |
"return the character one after the cursor - space if beyond line." |
|
1260 |
||
1261 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1262 |
! |
|
1263 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1264 |
characterBeforeCursor |
4700 | 1265 |
"return the character to the left of cursor - space if beyond line, nil if at the beginning." |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1266 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1267 |
cursorCol == 1 ifTrue:[^ nil]. |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1268 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1269 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1270 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1271 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1272 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1273 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1274 |
characterUnderCursor |
2707 | 1275 |
"return the character under the cursor - space if beyond line. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1276 |
For non-block cursors, this is the character immediately to the right |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1277 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1278 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1279 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1280 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1281 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1282 |
contents |
2213 | 1283 |
"return the contents as a String or Text (i.e. with emphasis)" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1284 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1285 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1286 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1287 |
^ super contents. |
3313 | 1288 |
|
1289 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1290 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1291 |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1292 |
contents:something |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1293 |
self contents:something keepUndoHistory:false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1294 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1295 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1296 |
contents:something keepUndoHistory:keepUndoHistory |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1297 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1298 |
keepUndoHistory ifFalse:[ |
4823 | 1299 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1300 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1301 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1302 |
|
2213 | 1303 |
contentsAsString |
1304 |
"return the contents as a String (i.e. without emphasis)" |
|
1305 |
||
1306 |
list isNil ifTrue:[^ '']. |
|
1307 |
self removeTrailingBlankLines. |
|
1308 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1309 |
ifFalse:[each string] |
1310 |
]) asStringWithCRs |
|
2213 | 1311 |
! |
1312 |
||
5067 | 1313 |
contentsAsStringWithTabs |
1314 |
"return the contents as a String (i.e. without emphasis) |
|
1315 |
and with leading spaces replaced by tab characters |
|
1316 |
(i.e. as would be written to a file)" |
|
1317 |
||
1318 |
list isNil ifTrue:[^ '']. |
|
1319 |
self removeTrailingBlankLines. |
|
1320 |
^ (list collect:[:each | |
|
1321 |
each isNil |
|
1322 |
ifTrue:[''] |
|
1323 |
ifFalse:[each string withTabs] |
|
1324 |
]) asStringWithCRs |
|
1325 |
! |
|
1326 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1327 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1328 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1329 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1330 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1331 |
^ cursorCol |
125 | 1332 |
! |
1333 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1334 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1335 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1336 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1337 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1338 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1339 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1340 |
cursorLine |
3160 | 1341 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1342 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1343 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1344 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1345 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1346 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1347 |
cursorLineHolder |
3160 | 1348 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1349 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1350 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1351 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1352 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1353 |
|
4713 | 1354 |
lineStringBeforeCursor |
1355 |
"return the line's string before the cursor. |
|
1356 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1357 |
||
1358 |
|line| |
|
1359 |
||
1360 |
line := ((self at:cursorLine) ? '') string. |
|
1361 |
line size < (cursorCol-1) ifTrue:[ |
|
1362 |
^ line paddedTo:(cursorCol-1) |
|
1363 |
]. |
|
1364 |
^ line copyTo:(cursorCol-1) |
|
1365 |
! |
|
1366 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1367 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1368 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1369 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1370 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1371 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1372 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1373 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1374 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1375 |
super list:something. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1376 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1377 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1378 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1379 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1380 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1381 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1382 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1383 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1384 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1385 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1386 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1387 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1388 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1389 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1390 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1391 |
^ self cursorLine:prevCursorLine col:1. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1392 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1393 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1394 |
"/ default: stay where it was |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1395 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1396 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1397 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1398 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1399 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1400 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1401 |
undoSupport resetHistories. |
2955 | 1402 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1403 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1404 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1405 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1406 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1407 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1408 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1409 |
|
4609 | 1410 |
!EditTextView methodsFor:'accessing-dimensions'! |
1411 |
||
1412 |
xOfCursor |
|
4728 | 1413 |
|point| |
1414 |
||
1415 |
cursorVisibleLine isNil ifTrue:[ |
|
1416 |
"/ take the end of the selection, if any |
|
1417 |
(selectionStartLine notNil |
|
1418 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1419 |
ifTrue:[ |
|
1420 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1421 |
]. |
|
1422 |
||
1423 |
"/ point := device |
|
1424 |
"/ translatePoint:(device pointerPosition) |
|
1425 |
"/ fromView:nil |
|
1426 |
"/ toView:self. |
|
1427 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1428 |
"/ ^ point x |
|
1429 |
"/ ]. |
|
1430 |
"/ ^ 0 |
|
1431 |
^ nil |
|
1432 |
]. |
|
4609 | 1433 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1434 |
||
1435 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1436 |
! ! |
|
4590 | 1437 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1438 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1439 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1440 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1441 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1442 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1443 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1444 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1445 |
wasOn := self hideCursor. |
4940 | 1446 |
cursorFgColor := color1 onDevice:self graphicsDevice. |
1447 |
cursorBgColor := color2 onDevice:self graphicsDevice. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1448 |
wasOn ifTrue:[self showCursor] |
1333 | 1449 |
! |
1450 |
||
1899 | 1451 |
cursorType |
1452 |
"return the style of the text cursor. |
|
4721 | 1453 |
Currently, supported are: #none |
1454 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1455 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1456 |
|
1457 |
^ cursorType |
|
1458 |
||
1459 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1460 |
! |
|
1461 |
||
1333 | 1462 |
cursorType:aCursorTypeSymbol |
1463 |
"set the style of the text cursor. |
|
4721 | 1464 |
Currently, supported are: #none |
1465 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1466 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1467 |
|
1334 | 1468 |
cursorType := aCursorTypeSymbol. |
1333 | 1469 |
|
1470 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1471 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1472 |
! |
1473 |
||
1899 | 1474 |
cursorTypeNoFocus |
1475 |
"return the style of the text cursor when the view has no focus. |
|
1476 |
If left unspecified, this is the same as the regular cursorType." |
|
1477 |
||
1478 |
^ cursorTypeNoFocus |
|
1479 |
||
1480 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1481 |
! |
|
1482 |
||
1334 | 1483 |
cursorTypeNoFocus:aCursorTypeSymbol |
1484 |
"set the style of the text cursor when the view has no focus. |
|
1485 |
If left unspecified, this is the same as the regular cursorType." |
|
1486 |
||
1487 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1488 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1489 |
|
4048 | 1490 |
!EditTextView methodsFor:'accessing-replace'! |
1491 |
||
4746 | 1492 |
lastReplacementInfo |
1493 |
^ lastReplacementInfo |
|
1494 |
! |
|
1495 |
||
4048 | 1496 |
lastStringToReplace: aString |
4818 | 1497 |
! |
1498 |
||
1499 |
previousReplacements |
|
1500 |
"accessor for the code completion" |
|
1501 |
||
1502 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1503 |
! ! |
1504 |
||
2119 | 1505 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1506 |
|
125 | 1507 |
accept |
1508 |
"accept the current contents by executing the accept-action and/or |
|
1509 |
changeMessage." |
|
1510 |
||
1108 | 1511 |
acceptEnabled == false ifTrue:[ |
3945 | 1512 |
self beep. |
1513 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1514 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1515 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1516 |
^ self |
1108 | 1517 |
]. |
1518 |
||
125 | 1519 |
lockUpdates := true. |
1013 | 1520 |
|
1521 |
"/ |
|
1522 |
"/ ST-80 way of doing it |
|
1523 |
"/ |
|
1524 |
model notNil ifTrue:[ |
|
4142 | 1525 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
3945 | 1526 |
acceptChannel value:true withoutNotifying:self. |
2999 | 1527 |
]. |
1528 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1529 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1530 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1531 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1532 |
"/ the block is called with a stringCollection |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1533 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1534 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1535 |
acceptAction notNil ifTrue:[ |
3945 | 1536 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1537 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1538 |
|
125 | 1539 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1540 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1541 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1542 |
! |
1543 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1544 |
argForChangeMessage |
597 | 1545 |
"return the argument to be passed with the change notification. |
1546 |
Defined as separate method for easier subclassability." |
|
1547 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1548 |
^ self contents |
597 | 1549 |
|
1550 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1551 |
! |
1552 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1553 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1554 |
"get my contents from the model. |
597 | 1555 |
Redefined to ignore updates resulting from my own changes |
1556 |
(i.e. if lockUpdates is true)." |
|
121 | 1557 |
|
1558 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1559 |
ignore updates from my own change |
121 | 1560 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1561 |
lockUpdates ifTrue:[ |
4823 | 1562 |
lockUpdates := false. |
1563 |
^ self |
|
121 | 1564 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1565 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1566 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1567 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1568 |
"/ validate the cursorLine |
3160 | 1569 |
(cursorLine notNil |
2310 | 1570 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1571 |
self cursorLine:list size + 1 col:1 |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1572 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1573 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1574 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1575 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1576 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1577 |
acceptChannel value == true ifTrue:[ |
1578 |
self accept. |
|
1579 |
]. |
|
1580 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1581 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1582 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1583 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1584 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1585 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1586 |
! ! |
1587 |
||
1588 |
!EditTextView methodsFor:'cursor handling'! |
|
1589 |
||
4820 | 1590 |
basicCursorReturn |
1591 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1592 |
||
1593 |
|wasOn| |
|
1594 |
||
1595 |
self checkForExistingLine:(cursorLine + 1). |
|
1596 |
cursorVisibleLine notNil ifTrue:[ |
|
1597 |
nFullLinesShown notNil ifTrue:[ |
|
1598 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1599 |
] |
|
1600 |
]. |
|
1601 |
||
1602 |
wasOn := self hideCursor. |
|
1603 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1604 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1605 |
||
1606 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1607 |
! |
|
1608 |
||
2406 | 1609 |
characterPositionOfCursor |
1610 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1611 |
! |
|
1612 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1613 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1614 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1615 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1616 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1617 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1618 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1619 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1620 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1621 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1622 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1623 |
|
2822 | 1624 |
(cursorCol == newCol) ifTrue:[^ self]. |
1625 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1626 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1627 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1628 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1629 |
|
1630 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1631 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1632 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1633 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1634 |
"move cursor down; scroll if at end of visible text; |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1635 |
beep if at end of physical text." |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1636 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1637 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1638 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1639 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1640 |
|
2707 | 1641 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1642 |
cursorLine > list size ifTrue:[ |
4595 | 1643 |
wasOn := self hideCursor. |
1644 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1645 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1646 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1647 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1648 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1649 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1650 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1651 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1652 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1653 |
"move cursor down by n lines; scroll if at end of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1654 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1655 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1656 |
|
4595 | 1657 |
(nL := cursorLine) isNil ifTrue:[ |
1658 |
nL := firstLineShown |
|
1659 |
]. |
|
1660 |
||
1661 |
self st80EditMode ifTrue:[ |
|
1662 |
nL == list size ifTrue:[ |
|
1663 |
wasOn := self hideCursor. |
|
1664 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1665 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1666 |
self beep. |
|
1667 |
^ self. |
|
1668 |
] |
|
1669 |
]. |
|
1670 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1671 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1672 |
wasOn := self hideCursor. |
1673 |
nv := cursorVisibleLine + n - 1. |
|
1674 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1675 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1676 |
]. |
|
1677 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1678 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1679 |
] ifFalse:[ |
4595 | 1680 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1681 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1682 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1683 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1684 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1685 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1686 |
|
121 | 1687 |
cursorHome |
597 | 1688 |
"scroll to top AND move cursor to first line of text." |
121 | 1689 |
|
674 | 1690 |
self cursorLine:1 col:1 |
1691 |
||
1692 |
"/ |wasOn| |
|
1693 |
"/ |
|
1694 |
"/ wasOn := self hideCursor. |
|
1695 |
"/ self scrollToTop. |
|
1696 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1697 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1698 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1699 |
||
1700 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1701 |
! |
1702 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1703 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1704 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1705 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1706 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1707 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1708 |
] ifFalse:[ |
4823 | 1709 |
cursorLine ~~ 1 ifTrue:[ |
1710 |
self st80EditMode ifTrue:[ |
|
1711 |
self cursorUp. |
|
1712 |
self cursorToEndOfLine. |
|
1713 |
] |
|
1714 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1715 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1716 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1717 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1718 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1719 |
|
4126 | 1720 |
cursorLeft:n |
1721 |
"move cursor to left" |
|
1722 |
||
1723 |
n timesRepeat:[ |
|
1724 |
self cursorLeft |
|
1725 |
]. |
|
1726 |
! |
|
1727 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1728 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1729 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1730 |
|
5056 | 1731 |
self cursorLine:line col:col makeVisible:true |
1732 |
! |
|
1733 |
||
1734 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
1735 |
"this positions onto physical - not visible - line" |
|
1736 |
||
676 | 1737 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1738 |
|
2822 | 1739 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1740 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1741 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1742 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1743 |
|
672 | 1744 |
(col < 1) ifTrue:[ |
4823 | 1745 |
newCol := 1 |
672 | 1746 |
] ifFalse:[ |
4823 | 1747 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1748 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1749 |
self st80EditMode ifTrue:[ |
4823 | 1750 |
(cursorLine == list size |
1751 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1752 |
newCol := (self listAt:(list size)) size + 1. |
|
1753 |
] |
|
1419 | 1754 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1755 |
self setValidatedCursorCol:newCol. |
5056 | 1756 |
makeVisibleBoolean ifTrue:[ |
1757 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1758 |
] ifFalse:[ |
|
1759 |
wasOn ifTrue:[self showCursor] |
|
1760 |
]. |
|
672 | 1761 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1762 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1763 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1764 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1765 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1766 |
"return true, if the user may move the cursor around |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1767 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1768 |
By default, true is returned, but this may be redefined |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1769 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1770 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1771 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1772 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1773 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1774 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1775 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1776 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1777 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1778 |
"move cursor to start of next line; scroll if at end of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1779 |
|
4820 | 1780 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1781 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1782 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1783 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1784 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1785 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1786 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1787 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1788 |
self st80EditMode ifTrue:[ |
4823 | 1789 |
l := (self listAt:cursorLine). |
1790 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1791 |
cursorLine < list size ifTrue:[ |
|
1792 |
self cursorReturn. |
|
1793 |
]. |
|
1794 |
^ self |
|
1795 |
] |
|
3160 | 1796 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1797 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1798 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1799 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1800 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1801 |
|
4126 | 1802 |
cursorRight:n |
1803 |
"move cursor to right" |
|
1804 |
||
1805 |
n timesRepeat:[ |
|
1806 |
self cursorRight |
|
1807 |
]. |
|
1808 |
! |
|
1809 |
||
1833 | 1810 |
cursorShown:aBoolean |
1811 |
"change cursor visibility |
|
1812 |
return true if cursor was visible before." |
|
1813 |
||
1814 |
|oldState| |
|
1815 |
||
4494 | 1816 |
aBoolean == cursorShown ifTrue:[ |
1817 |
^ cursorShown |
|
1818 |
]. |
|
1819 |
||
1833 | 1820 |
oldState := cursorShown. |
1821 |
||
1822 |
aBoolean ifTrue:[ |
|
4494 | 1823 |
self drawCursor. |
1833 | 1824 |
] ifFalse:[ |
4494 | 1825 |
(cursorShown and:[shown]) ifTrue: [ |
1826 |
self undrawCursor. |
|
1827 |
]. |
|
1833 | 1828 |
]. |
1829 |
cursorShown := aBoolean. |
|
1830 |
||
1831 |
^ oldState |
|
1832 |
||
1833 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1834 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1835 |
! |
|
1836 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1837 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1838 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1839 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1840 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1841 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1842 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1843 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1844 |
"move cursor to the start of the current line" |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1845 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1846 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1847 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1848 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1849 |
textStart := l isNil ifTrue:[1] ifFalse:[l indexOfNonSeparator]. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1850 |
cursorCol > textStart ifTrue:[ |
4823 | 1851 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1852 |
] ifFalse:[ |
4823 | 1853 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1854 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1855 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1856 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1857 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1858 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1859 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1860 |
"move cursor to the last line of text (col 1)" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1861 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1862 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1863 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1864 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1865 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1866 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1867 |
(newTop < 1) ifTrue:[ |
4823 | 1868 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1869 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1870 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1871 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1872 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1873 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1874 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1875 |
|
674 | 1876 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1877 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1878 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1879 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1880 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1881 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1882 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1883 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1884 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1885 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1886 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1887 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1888 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1889 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1890 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1891 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1892 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1893 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1894 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1895 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1896 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1897 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1898 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1899 |
cursorLine >= lineNr ifTrue:[ |
4823 | 1900 |
line := self listAt:cursorLine. |
1901 |
(line isEmptyOrNil) ifTrue:[ |
|
1902 |
^ self |
|
1903 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1904 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1905 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1906 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1907 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1908 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1909 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1910 |
(newTop < 1) ifTrue:[ |
4823 | 1911 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1912 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1913 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1914 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1915 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1916 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1917 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1918 |
|
674 | 1919 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1920 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1921 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1922 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1923 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1924 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1925 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1926 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1927 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1928 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1929 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1930 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1931 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1932 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1933 |
cursorToEndOfText |
4288 | 1934 |
"move cursor to the end of the text (behind the last character in last line)" |
1935 |
||
1936 |
|wasOn newTop lastLineLength pos| |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1937 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1938 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1939 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1940 |
newTop := list size - nFullLinesShown. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1941 |
(newTop < 1) ifTrue:[ |
4288 | 1942 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1943 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1944 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1945 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1946 |
self setValidatedCursorLine:list size. |
4288 | 1947 |
lastLineLength := (self listAt:cursorLine) size. |
1948 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
1949 |
self setCursorCol:(self validateCursorCol:pos inLine:cursorLine). |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1950 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1951 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 1952 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
1953 |
"Modified: / 15-07-2011 / 20:14:43 / cg" |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1954 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1955 |
|
3310 | 1956 |
cursorToEndOfWord |
1957 |
"move the cursor to the end of the word" |
|
1958 |
||
1959 |
(cursorLine > list size) ifTrue:[^ self]. |
|
1960 |
||
1961 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 1962 |
:beginLine :beginCol :endLine :endCol :style | |
1963 |
||
1964 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 1965 |
] |
1966 |
||
1967 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
1968 |
! |
|
1969 |
||
131 | 1970 |
cursorToFirstVisibleLine |
1971 |
"place cursor into the first visible line; do not scroll." |
|
1972 |
||
1973 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
1974 |
! |
|
1975 |
||
1976 |
cursorToLastVisibleLine |
|
1977 |
"place cursor into the first visible line; do not scroll." |
|
1978 |
||
1979 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
1980 |
! |
|
1981 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1982 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1984 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1985 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1986 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1987 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1988 |
|
3890 | 1989 |
self |
4707 | 1990 |
wordAtLine:cursorLine col:cursorCol |
1991 |
do:[ |
|
3890 | 1992 |
:beginLine :beginCol :endLine :endCol :style | |
1993 |
||
1994 |
line := endLine. |
|
1995 |
col := endCol + 1. |
|
1996 |
searching := true. |
|
4707 | 1997 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 1998 |
self wordAtLine:line col:col do:[ |
1999 |
:beginLine :beginCol :endLine :endCol :style | |
|
2000 |
||
2001 |
(line > list size) ifTrue:[ |
|
2002 |
"break out" |
|
2003 |
searching := false |
|
2004 |
] ifFalse:[ |
|
2005 |
line := endLine. |
|
2006 |
col := endCol + 1. |
|
2007 |
] |
|
2008 |
] |
|
2009 |
]. |
|
2010 |
self cursorLine:line col:col |
|
4707 | 2011 |
] |
121 | 2012 |
! |
2013 |
||
499 | 2014 |
cursorToPreviousWord |
2015 |
"move the cursor to the beginning of this or the previous word" |
|
2016 |
||
2017 |
|col line searching l| |
|
2018 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2019 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2020 |
|
2021 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2022 |
:beginLine :beginCol :endLine :endCol :style | |
2023 |
||
2024 |
line := beginLine. |
|
2025 |
col := beginCol. |
|
2026 |
style == #wordLeft ifTrue:[ |
|
2027 |
col := col + 1 |
|
2028 |
]. |
|
2029 |
||
2030 |
(cursorLine == line |
|
2031 |
and:[cursorCol == col]) ifTrue:[ |
|
2032 |
searching := true. |
|
2033 |
||
2034 |
col > 1 ifTrue:[ |
|
2035 |
col := col - 1. |
|
2036 |
]. |
|
2037 |
||
2038 |
[searching] whileTrue:[ |
|
2039 |
(col == 1) ifTrue:[ |
|
2040 |
line == 1 ifTrue:[ |
|
2041 |
searching := false |
|
2042 |
] ifFalse:[ |
|
2043 |
line := line - 1. |
|
2044 |
l := list at:line. |
|
2045 |
col := l size + 1. |
|
2046 |
] |
|
2047 |
] ifFalse:[ |
|
2048 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2049 |
self wordAtLine:line col:col do:[ |
|
2050 |
:beginLine :beginCol :endLine :endCol :style | |
|
2051 |
||
2052 |
line := beginLine. |
|
2053 |
col := beginCol. |
|
2054 |
style == #wordLeft ifTrue:[ |
|
2055 |
col := col + 1 |
|
2056 |
]. |
|
2057 |
searching := false. |
|
2058 |
] |
|
2059 |
] ifTrue:[ |
|
2060 |
col := col - 1 |
|
2061 |
] |
|
2062 |
] |
|
2063 |
] |
|
2064 |
]. |
|
2065 |
self cursorLine:line col:col |
|
499 | 2066 |
] |
2067 |
||
2068 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2069 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2070 |
! |
|
2071 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2072 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2073 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2074 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2075 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2076 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2077 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2078 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2079 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2080 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2081 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2082 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2083 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2084 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2085 |
"move cursor up n lines; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2086 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2087 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2088 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2089 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2090 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2091 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2092 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2093 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2094 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2095 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2096 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2097 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2098 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2099 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2100 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2101 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2102 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2103 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2104 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2105 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2106 |
] |
672 | 2107 |
|
674 | 2108 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2109 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2110 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2111 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2112 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2113 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2114 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2115 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2116 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2117 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2118 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2119 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2120 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2121 |
|
676 | 2122 |
newCol := colNr. |
2123 |
(newCol < 1) ifTrue:[ |
|
4823 | 2124 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2125 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2126 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2127 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2128 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2129 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2130 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2131 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2132 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2133 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2134 |
"put cursor to position next to x/y coordinate in view" |
121 | 2135 |
|
2136 |
|line col| |
|
2137 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2139 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2140 |
self cursorVisibleLine:line col:col. |
121 | 2141 |
! |
2142 |
||
2143 |
drawCursor |
|
2144 |
"draw the cursor if shown and cursor is visible. |
|
2145 |
(but not, if there is a selection - to avoid confusion)" |
|
2146 |
||
2147 |
shown ifTrue:[ |
|
4823 | 2148 |
cursorVisibleLine notNil ifTrue:[ |
2149 |
self hasSelection ifFalse:[ |
|
2150 |
self drawCursorCharacter |
|
2151 |
] |
|
2152 |
] |
|
121 | 2153 |
] |
2154 |
! |
|
2155 |
||
2156 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2157 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2158 |
of cursor should be drawn. |
4721 | 2159 |
Currently, supported are: #none, |
2160 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2161 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2162 |
|
2570 | 2163 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2164 |
|
2165 |
self hasSelection ifTrue:[ |
|
4580 | 2166 |
" |
2167 |
hide cursor, if there is a selection |
|
2168 |
" |
|
2169 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2170 |
]. |
2171 |
||
1334 | 2172 |
cursorType == #none ifTrue:[ |
4580 | 2173 |
^ self |
1334 | 2174 |
]. |
2175 |
||
121 | 2176 |
cursorType == #block ifTrue:[ |
4829 | 2177 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2178 |
^ self |
121 | 2179 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2180 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2181 |
y := self yOfVisibleLine:cursorVisibleLine. |
2182 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2183 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2184 |
cursorType == #frame ifTrue:[ |
4580 | 2185 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2186 |
||
2187 |
char := self characterUnderCursor asString. |
|
4829 | 2188 |
self paint:bgColor. |
4889 | 2189 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2190 |
] ifFalse:[ |
4580 | 2191 |
self paint:bgColor. |
2192 |
cursorType == #ibeam ifTrue:[ |
|
2193 |
x1 := x - 1. |
|
2194 |
y2 := y + fontHeight - lineSpacing. |
|
2195 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2196 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2197 |
^ self |
|
2198 |
]. |
|
2199 |
||
2200 |
cursorType == #Ibeam ifTrue:[ |
|
2201 |
x1 := x - 1. |
|
2202 |
y := y + 1. |
|
2203 |
y2 := y + fontHeight - lineSpacing. |
|
2204 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2205 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2206 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2207 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2208 |
^ self |
|
2209 |
]. |
|
2210 |
||
2211 |
y := y + fontHeight - 3. |
|
2212 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2213 |
w := (fontWidth * 2 // 3) max:4. |
|
2214 |
y2 := y + w + (w//2). |
|
2215 |
] ifFalse:[ |
|
2216 |
w := (fontWidth // 2) max:4. |
|
2217 |
y2 := y + w. |
|
2218 |
]. |
|
2219 |
x1 := x - w. |
|
2220 |
x2 := x + w. |
|
2221 |
||
2222 |
oldClip := self clippingRectangleOrNil. |
|
2223 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2224 |
||
2225 |
cursorType == #caret ifTrue:[ |
|
2226 |
self lineWidth:2. |
|
2227 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2228 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2229 |
] ifFalse:[ |
|
2230 |
"anything else: solidCaret" |
|
2231 |
||
2232 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2233 |
with:(x @ y) |
|
2234 |
with:(x2 @ y2)) |
|
2235 |
]. |
|
2236 |
||
2237 |
self clippingRectangle:oldClip |
|
121 | 2238 |
]. |
133 | 2239 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2240 |
|
2088 | 2241 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2242 |
! |
2243 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2244 |
drawCursorCharacter |
3160 | 2245 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2246 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2247 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2248 |
|
3160 | 2249 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2250 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2251 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2252 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2253 |
] ifFalse:[ |
4823 | 2254 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2255 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2256 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2257 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2258 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2259 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2260 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2261 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2262 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2263 |
self hasSelection ifTrue:[ |
4823 | 2264 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
1334 | 2265 |
]. |
2266 |
cursorType == #none ifTrue:[ |
|
4823 | 2267 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2268 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2269 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2270 |
|
2271 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2272 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2273 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2274 |
drawNoFocusCursor |
3160 | 2275 |
"draw the cursor for the case when the view has no keyboard focus" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2276 |
|
1334 | 2277 |
|cType| |
2278 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2279 |
self hasSelection ifTrue:[ |
4823 | 2280 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2281 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2282 |
|
1334 | 2283 |
cType := cursorTypeNoFocus ? cursorType. |
2284 |
cType == #none ifTrue:[ |
|
4823 | 2285 |
^ self undrawCursor |
1334 | 2286 |
]. |
2287 |
||
2288 |
cType == #block ifTrue:[ |
|
4823 | 2289 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2290 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2291 |
|
1334 | 2292 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2293 |
||
2294 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2295 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2296 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2297 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2298 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2299 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2300 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2301 |
self makeLineVisible:aLineNumber. |
2951 | 2302 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2303 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2304 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2305 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2306 |
hideCursor |
1833 | 2307 |
"make cursor invisible if currently invisible" |
2308 |
||
2309 |
^ self cursorShown:false |
|
2310 |
||
2311 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2312 |
! |
2313 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2314 |
makeCursorVisible |
3160 | 2315 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2316 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2317 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2318 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2319 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2320 |
cursorLine notNil ifTrue:[ |
4823 | 2321 |
line := cursorLine. |
2322 |
col := cursorCol. |
|
2323 |
" |
|
2324 |
if there is a selection, its better to |
|
2325 |
have its start being visible, instead of the end |
|
2326 |
" |
|
2327 |
(selectionStartLine notNil |
|
2328 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2329 |
expandingTop ~~ false ifTrue:[ |
|
2330 |
line := selectionStartLine. |
|
2331 |
col := selectionStartCol. |
|
2332 |
] ifFalse:[ |
|
2333 |
line := selectionEndLine. |
|
2334 |
col := selectionEndCol |
|
2335 |
] |
|
2336 |
]. |
|
2337 |
self makeLineVisible:line. |
|
2338 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2339 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2340 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2341 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2342 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2343 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2344 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2345 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2346 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2347 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2348 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2349 |
flag ifTrue:[self showCursor] |
121 | 2350 |
! |
2351 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2352 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2353 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2354 |
|
2815 | 2355 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2356 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2357 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2358 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2359 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2360 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2361 |
|
3303 | 2362 |
"/ self assert:(lineNr notNil). |
2363 |
||
2364 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2365 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2366 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2367 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2368 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2369 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2370 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2371 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2372 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2373 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2374 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2375 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2376 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2377 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2378 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2379 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2380 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2381 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2382 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2383 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2384 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2385 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2386 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2387 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2388 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2389 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2390 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2391 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2392 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2393 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2394 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2395 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2396 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2397 |
|
1833 | 2398 |
^ self cursorShown:true |
2399 |
||
2400 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2401 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2402 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2403 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2404 |
"undraw the cursor (i.e. redraw the character(s) under the cursor)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2405 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2406 |
|prevCol line oldClip x y e1 e2 e3| |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2407 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2408 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2409 |
prevCol := cursorCol - 1. |
2410 |
||
2411 |
"/ if there is any italic stuff in the cursor line, |
|
2412 |
"/ redraw it completely (because characters overlap). |
|
2413 |
cursorCol > 1 ifTrue:[ |
|
2414 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2415 |
line hasChangeOfEmphasis ifTrue:[ |
|
2416 |
line size >= (cursorCol-1) ifTrue:[ |
|
2417 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2418 |
line size >= (cursorCol) ifTrue:[ |
|
2419 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2420 |
line size >= (cursorCol+1) ifTrue:[ |
|
2421 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2422 |
]. |
|
2423 |
]. |
|
2424 |
]. |
|
2425 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2426 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2427 |
] |
|
2428 |
] |
|
2429 |
] |
|
2430 |
]. |
|
2431 |
||
2432 |
((cursorType == #caret) |
|
2433 |
or:[cursorType == #solidCaret |
|
2434 |
or:[cursorType == #bigSolidCaret |
|
2435 |
or:[cursorType == #bigCaret |
|
2436 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2437 |
"caret-cursor touches 4 characters" |
|
2438 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2439 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2440 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2441 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2442 |
] ifFalse:[ |
|
2443 |
"care for left margin" |
|
2444 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2445 |
]. |
|
2446 |
^ self |
|
2447 |
]. |
|
2448 |
||
2449 |
cursorType == #ibeam ifTrue:[ |
|
2450 |
"ibeam-cursor touches 2 characters" |
|
2451 |
cursorCol > 1 ifTrue:[ |
|
2452 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2453 |
] ifFalse:[ |
|
2454 |
"care for left margin" |
|
2455 |
super redrawVisibleLine:cursorVisibleLine. |
|
2456 |
]. |
|
2457 |
^ self |
|
2458 |
]. |
|
2459 |
||
2460 |
"block cursor is simple - just one character under cursor" |
|
2461 |
||
2462 |
"/ however, if italic characters are involved, we must care |
|
2463 |
"/ for the chars before/after the cursor. |
|
2464 |
"/ We redraw the part of the previous character which got |
|
2465 |
"/ detroyed by the block cursor. |
|
2466 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2467 |
||
2468 |
line := self visibleAt:cursorVisibleLine. |
|
2469 |
(line notNil and:[line isText]) ifTrue:[ |
|
2470 |
cursorCol > 1 ifTrue:[ |
|
2471 |
oldClip := self clippingRectangleOrNil. |
|
2472 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2473 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2474 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2475 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2476 |
self clippingRectangle:oldClip. |
|
2477 |
^ self. |
|
2478 |
]. |
|
2479 |
]. |
|
2480 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2481 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2482 |
|
2088 | 2483 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2484 |
! |
2485 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2486 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2487 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2488 |
notice: visibleLine will be set to nil if the cursor is not visible" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2489 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2490 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2491 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2492 |
|
672 | 2493 |
validateCursorCol:col inLine:line |
674 | 2494 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2495 |
Here, no limits are enforced (and col is returned), |
2496 |
but it may be redefined in EditFields or views which dont like the |
|
674 | 2497 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2498 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2499 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2500 |
|
1419 | 2501 |
"/ in ST80 mode, |
2707 | 2502 |
"/ the cursor may not be positioned beyond the |
2503 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2504 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2505 |
self st80EditMode ifTrue:[ |
4823 | 2506 |
l := (self listAt:line). |
2507 |
max := l size + 1. |
|
2508 |
col > max ifTrue:[ |
|
2509 |
^ max |
|
2510 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2511 |
]. |
672 | 2512 |
^ col |
2513 |
||
1419 | 2514 |
"Created: / 22.5.1996 / 14:25:30 / cg" |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2515 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2516 |
! |
2517 |
||
2518 |
validateCursorLine:line |
|
2519 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2520 |
Here, no limits are enforced (and line is returned), but it may be |
674 | 2521 |
redefined in views which dont like the cursor to be positioned |
2522 |
behind the end of the text (vi/st-80 behavior), or want to |
|
2523 |
skip reserved regions" |
|
2524 |
||
1419 | 2525 |
"/ |
2526 |
"/ in st80Mode, the cursor may not be positioned |
|
2707 | 2527 |
"/ beyond the last line |
1419 | 2528 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2529 |
self st80EditMode ifTrue:[ |
4823 | 2530 |
^ (line min:(list size)) max:1 |
1419 | 2531 |
]. |
674 | 2532 |
^ line |
2533 |
||
1419 | 2534 |
"Created: / 22.5.1996 / 18:22:23 / cg" |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2535 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2536 |
! |
2537 |
||
121 | 2538 |
withCursorOffDo:aBlock |
2539 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2540 |
||
2541 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2542 |
^ aBlock value |
121 | 2543 |
]. |
2544 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2545 |
aBlock ensure:[ |
4823 | 2546 |
self showCursor |
121 | 2547 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2548 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2549 |
|
2589 | 2550 |
!EditTextView methodsFor:'drag & drop'! |
2551 |
||
2552 |
allowDrop:aBoolean |
|
3236 | 2553 |
"enable/disable drop support" |
2554 |
||
2589 | 2555 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2556 |
dropTarget := nil. |
2589 | 2557 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2558 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2559 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2560 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2561 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2562 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2563 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2564 |
] |
3236 | 2565 |
]. |
2566 |
! |
|
2567 |
||
3412 | 2568 |
canDrop:aDropContext |
2569 |
"public from d&d. |
|
2570 |
I accept textObjects and fileObjects only." |
|
2571 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2572 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2573 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2574 |
^ self canDropObjects:aDropContext dropObjects |
|
2575 |
||
2576 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2577 |
! |
|
2578 |
||
2579 |
canDropObjects:aCollectionOfDropObjects |
|
2580 |
"public from d&d. |
|
2581 |
I accept textObjects and fileObjects only." |
|
2589 | 2582 |
|
2583 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2584 |
||
3412 | 2585 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2586 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2587 |
||
2588 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2589 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2590 |
! |
|
2591 |
||
2592 |
drop:aDropContext |
|
2593 |
"public from d&d. |
|
2594 |
drop objects (new API)" |
|
2595 |
||
2596 |
self dropObjects:(aDropContext dropObjects) |
|
2597 |
||
2598 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2599 |
! |
|
2600 |
||
2601 |
dropFileObject:aDropObject |
|
2589 | 2602 |
"drop objects |
3236 | 2603 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2604 |
||
4136 | 2605 |
|answer text fn pasteWhat sensor dontAskAgainHolder enforcedDropMode app| |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2606 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2607 |
pasteWhat := #name. |
3412 | 2608 |
|
2609 |
fn := aDropObject asFilename. |
|
2610 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2611 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2612 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2613 |
and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2614 |
pasteWhat := enforcedDropMode. |
3886 | 2615 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2616 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2617 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2618 |
pasteWhat := #name. |
3886 | 2619 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2620 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2621 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2622 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2623 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2624 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2625 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2626 |
stringWithCRs:'Drop the Filename (%1)\or its Contents ?\\Hint: bypass this dialog by pressing SHIFT/CTRL or ALT during the next drop.\SHIFT/CTRL to drop the name, ALT for the contents.' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2627 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2628 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2629 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2630 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2631 |
check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2632 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2633 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2634 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2635 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2636 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2637 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2638 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2639 |
] |
3886 | 2640 |
] |
2641 |
]. |
|
2642 |
]. |
|
2643 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2644 |
pasteWhat == #name ifTrue:[ |
3886 | 2645 |
text := fn pathName |
2646 |
] ifFalse:[ |
|
2647 |
self withWaitCursorDo:[ |
|
5063 | 2648 |
text := fn contentsAsString |
4136 | 2649 |
]. |
2650 |
(app := self application) notNil ifTrue:[ |
|
2651 |
app droppedFile:fn in:self |
|
2652 |
]. |
|
3886 | 2653 |
]. |
2654 |
||
3799 | 2655 |
self |
2656 |
undoablePaste:text |
|
2657 |
info:'Drop File'. |
|
3412 | 2658 |
|
2659 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2660 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2661 |
! |
2662 |
||
2663 |
dropObject:aDropObject |
|
2664 |
"drop objects |
|
2665 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2666 |
||
3415 | 2667 |
|text| |
2668 |
||
3412 | 2669 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2670 |
self dropFileObject:aDropObject |
3412 | 2671 |
] ifFalse:[ |
3799 | 2672 |
aDropObject isTextObject ifTrue:[ |
2673 |
text := aDropObject theObject. |
|
2674 |
text isStringCollection ifTrue:[ |
|
2675 |
text := text asStringWithoutFinalCR |
|
2676 |
]. |
|
2677 |
] ifFalse:[ |
|
2678 |
text := aDropObject theObject asString |
|
2679 |
]. |
|
2680 |
self |
|
2681 |
undoablePaste:text |
|
2682 |
info:'Drop'. |
|
3412 | 2683 |
]. |
2684 |
||
2685 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2686 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2687 |
! |
2688 |
||
2689 |
dropObjects:aCollectionOfDropObjects |
|
2690 |
"public from d&d. |
|
2691 |
drop objects (old API)" |
|
2692 |
||
3868 | 2693 |
aCollectionOfDropObjects do:[:el | |
2694 |
self dropObject:el |
|
3412 | 2695 |
]. |
2696 |
||
2697 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2698 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2699 |
! ! |
2700 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2701 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2702 |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2703 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2704 |
"toLower/toUppercaseFirst/toUpper selected text" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2705 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2706 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2707 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2708 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2709 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2710 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2711 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2712 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2713 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2714 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2715 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2716 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2717 |
line1 to:line2 do:[:lineNr | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2718 |
|line col1 col2 isAllLower isLowerFirst isAllUpper isUpperFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2719 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2720 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2721 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2722 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2723 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2724 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2725 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2726 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2727 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2728 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2729 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2730 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2731 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2732 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2733 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2734 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2735 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2736 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2737 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2738 |
ch isUppercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2739 |
isAllLower := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2740 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2741 |
isLowerFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2742 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2743 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2744 |
ch isLowercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2745 |
isAllUpper := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2746 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2747 |
isUpperFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2748 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2749 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2750 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2751 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2752 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2753 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2754 |
isLowerFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2755 |
makeUppercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2756 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2757 |
"/ must remember where we come from - otherwise, we end up |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2758 |
"/ in upperFirst - lowerFirst cycle. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2759 |
"/ think about a good place to store this state |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2760 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2761 |
makeLowercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2762 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2763 |
isAllUpper ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2764 |
makeLowercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2765 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2766 |
makeUppercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2767 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2768 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2769 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2770 |
makeUppercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2771 |
line at:col1 put:(line at:col1) asUppercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2772 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2773 |
makeLowercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2774 |
line at:col1 put:(line at:col1) asLowercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2775 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2776 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2777 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2778 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2779 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2780 |
ch := makeLowercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2781 |
ifTrue:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2782 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2783 |
makeUppercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2784 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2785 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2786 |
col == col1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2787 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2788 |
ifFalse:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2789 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2790 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2791 |
line at:col put:ch. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2792 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2793 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2794 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2795 |
self withoutRedrawAt:lineNr put:line. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2796 |
self invalidateLine:lineNr. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2797 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2798 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2799 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2800 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2801 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2802 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2803 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2804 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2805 |
"copy the selection into the pastBuffer and delete it" |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2806 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2807 |
selectionStartLine notNil ifTrue:[ |
4823 | 2808 |
self setClipboardText:(self selection). |
2809 |
self deleteSelection. |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2810 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2811 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2812 |
"Created: 27.1.1996 / 16:23:28 / cg" |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2813 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2814 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2815 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2816 |
"delete single character under cursor; does not merge lines" |
121 | 2817 |
|
2818 |
|wasOn| |
|
2819 |
||
2820 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2821 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2822 |
wasOn ifTrue:[self showCursor] |
2823 |
! |
|
2824 |
||
827 | 2825 |
deleteCharAtLine:lineNr col:colNr |
2826 |
"delete a single character at colNr in line lineNr" |
|
2827 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2828 |
self st80EditMode ifTrue:[ |
4823 | 2829 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2830 |
| wasOn | |
|
2831 |
wasOn := self hideCursor. |
|
2832 |
self |
|
2833 |
cursorReturn; |
|
2834 |
cursorCol:1; |
|
2835 |
deleteCharBeforeCursor. |
|
2836 |
wasOn ifTrue:[ self showCursor]. |
|
2837 |
^ self. |
|
2838 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2839 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2840 |
|
827 | 2841 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2842 |
! |
|
2843 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2844 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2845 |
"delete single character to the left of cursor and move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2846 |
|
4592 | 2847 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 2848 |
|
2849 |
wasOn := self hideCursor. |
|
4814 | 2850 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 2851 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
4966 | 2852 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
4592 | 2853 |
ln size < prevTab ifTrue:[ |
2854 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2855 |
]. |
|
2856 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2857 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2858 |
cursorCol > prevTab ifTrue:[ |
|
2859 |
self st80EditMode ifTrue:[ |
|
2860 |
"/ ensure that there is no conflict here: st80EditMode will |
|
2861 |
"/ not allow a cursor position beyond the end of line, |
|
2862 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
|
2863 |
originalLine size < prevTab ifTrue:[ |
|
4771 | 2864 |
self basicListAt:cursorLine put:ln |
4592 | 2865 |
] |
2866 |
]. |
|
2867 |
self cursorLine:cursorLine col:prevTab. |
|
2868 |
wasOn ifTrue:[ self showCursor ]. |
|
2869 |
^ self |
|
2870 |
]. |
|
2871 |
] ifFalse:[ |
|
2872 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2873 |
self cursorLine:cursorLine col:prevTab. |
|
2874 |
wasOn ifTrue:[ self showCursor ]. |
|
2875 |
^ self. |
|
2876 |
] |
|
2877 |
]. |
|
827 | 2878 |
]. |
2879 |
||
2491 | 2880 |
"/ (autoIndent |
2881 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2882 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2883 |
"/ ifTrue:[ |
2884 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2885 |
"/ |
|
2886 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2887 |
"/ ln := list at:cursorLine. |
|
2888 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2889 |
"/ soCol := 1 |
|
2890 |
"/ ] |
|
2891 |
"/ ] |
|
2892 |
"/ ] ifFalse:[ |
|
4592 | 2893 |
soCol := 1. |
2491 | 2894 |
"/ ]. |
2895 |
||
1419 | 2896 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 2897 |
" |
2898 |
somewhere in the middle of a line |
|
2899 |
" |
|
2900 |
self cursorLeft. |
|
2901 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2902 |
] ifFalse:[ |
4592 | 2903 |
" |
2904 |
at begin of line - merge with previous line; |
|
2905 |
except for the very first line. |
|
2906 |
" |
|
2907 |
(cursorLine == 1) ifFalse:[ |
|
2908 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2909 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2910 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2911 |
"/ we are beyond the end of the text. |
|
2912 |
"/ move the cursor to the previous line. |
|
2913 |
self cursorLine:lineNrAboveCursor col:1. |
|
2914 |
] ifFalse:[ |
|
2915 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2916 |
] |
|
2917 |
] |
|
2918 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2919 |
]. |
827 | 2920 |
wasOn ifTrue:[ self showCursor ] |
2921 |
||
1419 | 2922 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2923 |
! |
2924 |
||
2925 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2926 |
"delete characters from colNr up to the end in line lineNr" |
|
2927 |
||
2928 |
|line| |
|
2929 |
||
2930 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 2931 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2932 |
] |
2933 |
||
2934 |
! |
|
2935 |
||
4458 | 2936 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
2937 |
"delete characters from startCol to endCol in line lineNr" |
|
2938 |
||
2939 |
|deleted| |
|
2940 |
||
2941 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
2942 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
2943 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
2944 |
! |
|
2945 |
||
827 | 2946 |
deleteCharsAtLine:lineNr toCol:colNr |
2947 |
"delete characters from start up to colNr in line lineNr" |
|
2948 |
||
2949 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
2950 |
||
2951 |
||
121 | 2952 |
! |
2953 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2954 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2955 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2956 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2957 |
self deleteLine:cursorLine |
121 | 2958 |
! |
2959 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2960 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2961 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2962 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2963 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2964 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2965 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2966 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2967 |
col1 == 0 ifTrue:[ |
4823 | 2968 |
line1 := line1 - 1. |
2969 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
2970 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2971 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2972 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2973 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2974 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2975 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2976 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
2977 |
|
2954 | 2978 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
2979 |
"delete all text from startLine/startCol to endLine/endCol - |
|
2980 |
joining lines if nescessary" |
|
2981 |
||
2982 |
|line newLine lineSize nMore| |
|
2983 |
||
2984 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
2985 |
list isNil ifTrue:[^ self]. |
|
2986 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
2987 |
||
2988 |
(startLine == endLine) ifTrue:[ |
|
4225 | 2989 |
"/ delete chars within a line |
2990 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
2991 |
^ self |
|
2954 | 2992 |
]. |
2993 |
||
2994 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 2995 |
"/ delete full lines only |
2996 |
endLine > startLine ifTrue:[ |
|
2997 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
2998 |
]. |
|
2999 |
^ self |
|
2954 | 3000 |
]. |
3001 |
||
3002 |
"/ delete right rest of 1st line |
|
4786 | 3003 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3004 |
|
3005 |
"/ delete the inner lines ... |
|
3006 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3007 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3008 |
]. |
3009 |
||
3010 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3011 |
"/ delete the left rest of the last line |
3012 |
||
3013 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3014 |
||
3015 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3016 |
startLine <= list size ifTrue:[ |
|
3017 |
line := list at:startLine. |
|
3018 |
lineSize := line size. |
|
3019 |
(startCol > lineSize) ifTrue:[ |
|
3020 |
newLine := line. |
|
3021 |
line isNil ifTrue:[ |
|
3022 |
newLine := String new:(startCol - 1) |
|
3023 |
] ifFalse:[ |
|
3024 |
nMore := startCol - 1 - lineSize. |
|
3025 |
nMore > 0 ifTrue:[ |
|
3026 |
newLine := line , (line species new:nMore) |
|
3027 |
] |
|
3028 |
]. |
|
3029 |
newLine ~~ line ifTrue:[ |
|
4771 | 3030 |
self basicListAt:startLine put:newLine. |
4225 | 3031 |
]. |
3032 |
"/ TODO: remember old maxwidth of linerange, |
|
3033 |
"/ only clear widthOfWidestLine, if this max |
|
3034 |
"/ length was (one of) the longest. |
|
3035 |
"/ avoids slow delete with huge texts. |
|
3036 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3037 |
self textChanged. |
|
3038 |
] |
|
3039 |
] |
|
2954 | 3040 |
]. |
3041 |
||
3042 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3043 |
self mergeLine:startLine removeBlanks:false |
|
3044 |
||
4225 | 3045 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3046 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3047 |
! |
3048 |
||
4458 | 3049 |
deleteFromLine:startLineNr toLine:endLineNr |
3050 |
"delete some lines" |
|
3051 |
||
3052 |
|deleted| |
|
3053 |
||
3054 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3055 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3056 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3057 |
! |
|
3058 |
||
827 | 3059 |
deleteLine:lineNr |
3060 |
"delete line" |
|
3061 |
||
3062 |
self deleteFromLine:lineNr toLine:lineNr |
|
3063 |
||
3064 |
||
3065 |
! |
|
3066 |
||
4458 | 3067 |
deleteLineWithoutRedraw:lineNr |
3068 |
"delete line - no redraw; |
|
3069 |
return true, if something was really deleted" |
|
3070 |
||
3071 |
|deleted ret| |
|
3072 |
||
3073 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3074 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3075 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3076 |
^ ret. |
|
3077 |
! |
|
3078 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3079 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3080 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3081 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3082 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3083 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3084 |
|
4771 | 3085 |
self checkModificationsAllowed ifFalse:[^ false]. |
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3086 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3087 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3088 |
(endLine > list size) ifTrue:[ |
4771 | 3089 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3090 |
] ifFalse:[ |
4771 | 3091 |
lastLine := endLine |
3092 |
]. |
|
3093 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3094 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3095 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3096 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3097 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3098 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3099 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3100 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3101 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3102 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3103 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3104 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3105 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3106 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3107 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3108 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3109 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3110 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3111 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3112 |
selectionStartLine notNil ifTrue:[ |
4823 | 3113 |
wasOn := self hideCursor. |
3114 |
||
3115 |
startLine := selectionStartLine. |
|
3116 |
startCol := selectionStartCol. |
|
3117 |
endLine := selectionEndLine. |
|
3118 |
endCol := selectionEndCol. |
|
3119 |
self unselectWithoutRedraw. |
|
3120 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3121 |
self setCursorLine:startLine col:startCol. |
|
3122 |
||
3123 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3124 |
] |
121 | 3125 |
! |
3126 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3127 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3128 |
"delete the word to the left of cursor and move cursor to left" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3129 |
|
2952 | 3130 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3131 |
|
3799 | 3132 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3133 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3134 |
wasOn := self hideCursor. |
3799 | 3135 |
self |
3136 |
undoableDo:[ |
|
3137 |
endCol := cursorCol-1. |
|
3138 |
endLine := cursorLine. |
|
3139 |
self cursorToPreviousWord. |
|
3140 |
beginCol := cursorCol. |
|
3141 |
beginLine := cursorLine. |
|
3142 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3143 |
] |
|
3144 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3145 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3146 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3147 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3148 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3149 |
|
4458 | 3150 |
insert:aCharacter atLine:lineNr col:colNr |
3151 |
"insert a single character at lineNr/colNr; |
|
3152 |
set emphasis to character at current position" |
|
3153 |
||
3154 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3155 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3156 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3157 |
] |
3158 |
! |
|
3159 |
||
121 | 3160 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3161 |
"insert a single character at cursor-position - advance cursor." |
121 | 3162 |
|
3163 |
|wasOn| |
|
3164 |
||
3165 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3166 |
aCharacter == Character tab ifTrue:[ |
4820 | 3167 |
"/ needs special care to advance cursor correctly |
3168 |
self insertTabAtCursor |
|
121 | 3169 |
] ifFalse:[ |
4820 | 3170 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3171 |
aCharacter == (Character cr) ifTrue:[ |
|
3172 |
self basicCursorReturn |
|
3173 |
] ifFalse:[ |
|
3174 |
self cursorRight. |
|
3175 |
]. |
|
121 | 3176 |
]. |
3177 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3178 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3179 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3180 |
! |
3181 |
||
641 | 3182 |
insertLine:aString before:lineNr |
3183 |
"insert the line aString before line lineNr" |
|
3184 |
||
3185 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3186 |
||
3187 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3188 |
! |
|
3189 |
||
155 | 3190 |
insertLines:aStringCollection before:lineNr |
3191 |
"insert a bunch before line lineNr" |
|
3192 |
||
3193 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3194 |
||
3195 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3196 |
! |
|
3197 |
||
4771 | 3198 |
insertLines:someText from:start to:end before:lineNr |
3199 |
"insert a bunch of lines before line lineNr. |
|
3200 |
The cursor position is left unchanged." |
|
3201 |
||
3202 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3203 |
srcY "{ Class: SmallInteger }" |
|
3204 |
dstY "{ Class: SmallInteger }" | |
|
3205 |
||
3206 |
autoIndent ifTrue:[ |
|
3207 |
indent := self leftIndentForLine:lineNr. |
|
3208 |
||
4812 | 3209 |
text := someText |
3210 |
collect:[:ln||line| |
|
3211 |
ln notNil ifTrue:[ |
|
3212 |
line := ln withoutLeadingSeparators. |
|
3213 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3214 |
line := (String new:indent), line |
|
3215 |
]. |
|
3216 |
line |
|
3217 |
] ifFalse:[ |
|
3218 |
nil |
|
3219 |
] |
|
3220 |
]. |
|
4771 | 3221 |
] ifFalse:[ |
3222 |
text := someText |
|
3223 |
]. |
|
3224 |
||
3225 |
visLine := self listLineToVisibleLine:lineNr. |
|
3226 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3227 |
self withoutRedrawInsertLines:text |
|
3228 |
from:start to:end |
|
3229 |
before:lineNr. |
|
3230 |
] ifFalse:[ |
|
3231 |
nLines := end - start + 1. |
|
3232 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3233 |
self withoutRedrawInsertLines:text |
|
3234 |
from:start to:end |
|
3235 |
before:lineNr. |
|
3236 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3237 |
] ifFalse:[ |
|
3238 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3239 |
and:(firstLineShown + nLines + nLinesShown). |
|
3240 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3241 |
dstY := srcY + (nLines * fontHeight). |
|
3242 |
||
3243 |
"/ |
|
3244 |
"/ scroll ... |
|
3245 |
"/ |
|
3246 |
" |
|
3247 |
stupid: must catchExpose before inserting new |
|
3248 |
stuff - since catchExpose may perform redraws |
|
3249 |
" |
|
3250 |
self catchExpose. |
|
3251 |
self withoutRedrawInsertLines:text |
|
3252 |
from:start to:end |
|
3253 |
before:lineNr. |
|
3254 |
self |
|
3255 |
copyFrom:self |
|
3256 |
x:textStartLeft y:srcY |
|
3257 |
toX:textStartLeft y:dstY |
|
3258 |
width:w |
|
3259 |
height:(height - dstY) |
|
3260 |
async:true. |
|
3261 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3262 |
self waitForExpose |
|
3263 |
]. |
|
3264 |
]. |
|
3265 |
widthOfWidestLine notNil ifTrue:[ |
|
3266 |
text do:[:line | |
|
3267 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3268 |
] |
|
3269 |
]. |
|
3270 |
self textChanged. |
|
3271 |
||
3272 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3273 |
! |
|
3274 |
||
654 | 3275 |
insertLines:lines withCR:withCr |
3160 | 3276 |
"insert a bunch of lines at cursor position. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3277 |
Cursor is moved behind insertion. |
641 | 3278 |
If withCr is true, append cr after last line" |
3279 |
||
3280 |
|start end nLines wasOn| |
|
3281 |
||
3282 |
lines notNil ifTrue:[ |
|
4649 | 3283 |
nLines := lines size. |
3284 |
(nLines == 1) ifTrue:[ |
|
3285 |
self insertStringAtCursor:(lines at:1). |
|
3286 |
withCr ifTrue:[ |
|
3287 |
self insertCharAtCursor:(Character cr) |
|
3288 |
] |
|
3289 |
] ifFalse:[ |
|
3290 |
(cursorCol ~~ 1) ifTrue:[ |
|
3291 |
self insertStringAtCursor:(lines at:1). |
|
3292 |
self insertCharAtCursor:(Character cr). |
|
3293 |
start := 2 |
|
3294 |
] ifFalse:[ |
|
3295 |
start := 1 |
|
3296 |
]. |
|
3297 |
withCr ifTrue:[ |
|
3298 |
end := nLines |
|
3299 |
] ifFalse:[ |
|
3300 |
end := nLines - 1 |
|
3301 |
]. |
|
3302 |
(start <= nLines) ifTrue:[ |
|
3303 |
(end >= start) ifTrue:[ |
|
3304 |
wasOn := self hideCursor. |
|
3305 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3306 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3307 |
wasOn ifTrue:[self showCursor]. |
|
3308 |
] |
|
3309 |
]. |
|
3310 |
withCr ifFalse:[ |
|
3311 |
"last line without cr" |
|
3312 |
self insertStringAtCursor:(lines at:nLines) |
|
3313 |
] |
|
3314 |
] |
|
641 | 3315 |
] |
654 | 3316 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3317 |
"Created: / 18.5.1996 / 15:32:06 / cg" |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3318 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3319 |
! |
3320 |
||
3321 |
insertLines:lines withCr:withCr |
|
3322 |
"insert a bunch of lines at cursor position. Cursor |
|
3323 |
is moved behind insertion. |
|
3324 |
If withCr is true, append cr after last line" |
|
3325 |
||
2363 | 3326 |
<resource:#obsolete> |
3327 |
||
1292 | 3328 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3329 |
self insertLines:lines withCR:withCr. |
|
3330 |
||
3331 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3332 |
! |
3333 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3334 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3335 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3336 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3337 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3338 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3339 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3340 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3341 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3342 |
self selectFromLine:startLine col:startCol |
4823 | 3343 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3344 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3345 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3346 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3347 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3348 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3349 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3350 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3351 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3352 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3353 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3354 |
col == 0 ifTrue:[ |
3355 |
line > 1 ifTrue:[ |
|
3356 |
line := line - 1. |
|
3357 |
col := (self listAt:line) size. |
|
3358 |
] ifFalse:[ |
|
3359 |
col := 1. |
|
3360 |
] |
|
3361 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3362 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3363 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3364 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3365 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3366 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3367 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3368 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3369 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3370 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3371 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3372 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3373 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3374 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3375 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3376 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3377 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3378 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3379 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3380 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3381 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3382 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3383 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3384 |
[start <= end] whileTrue:[ |
4823 | 3385 |
stop := aString indexOf:(Character cr) startingAt:start. |
3386 |
stop == 0 ifTrue:[ |
|
3387 |
stop := end + 1 |
|
3388 |
]. |
|
3389 |
subString := aString copyFrom:start to:(stop - 1). |
|
3390 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3391 |
(stop <= end) ifTrue:[ |
|
3392 |
c := c + subString size. |
|
3393 |
self insert:(Character cr) atLine:l col:c. |
|
3394 |
l := l + 1. |
|
3395 |
c := 1 |
|
3396 |
]. |
|
3397 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3398 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3399 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3400 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3401 |
! |
3402 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3403 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3404 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3405 |
handle cr's correctly. A nil argument is interpreted as an empty line." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3406 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3407 |
aString isNil ifTrue:[ |
4823 | 3408 |
"new:" |
3409 |
self insertCharAtCursor:(Character cr). |
|
3410 |
^ self |
|
105 | 3411 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3412 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3413 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3414 |
]. |
3415 |
||
654 | 3416 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3417 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3418 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3419 |
! |
3420 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3421 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3422 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3423 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3424 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3425 |
shown ifTrue:[ |
4889 | 3426 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3427 |
self invalidateLine:lineNr. |
3428 |
] ifFalse:[ |
|
3429 |
self redrawLine:lineNr from:colNr |
|
3430 |
] |
|
3431 |
] |
|
3432 |
||
4191 | 3433 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3434 |
! |
3435 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3436 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3437 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3438 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3439 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3440 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3441 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3442 |
aString size > 0 ifTrue:[ |
4823 | 3443 |
wasOn := self hideCursor. |
3444 |
(aString includes:Character tab) ifTrue:[ |
|
3445 |
self checkForExistingLine:cursorLine. |
|
3446 |
oldLen := (list at:cursorLine) size. |
|
3447 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3448 |
newLen := (list at:cursorLine) size. |
|
3449 |
deltaLen := newLen - oldLen. |
|
3450 |
] ifFalse:[ |
|
3451 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3452 |
deltaLen := aString size. |
|
3453 |
]. |
|
3454 |
self setCursorCol:(cursorCol + deltaLen). |
|
3455 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3456 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3457 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3458 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3459 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3460 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3461 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3462 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3463 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3464 |
|wasOn nextTab| |
105 | 3465 |
|
121 | 3466 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3467 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3468 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3469 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3470 |
! |
3471 |
||
3542 | 3472 |
joinLines |
3890 | 3473 |
"join lines (remove line-break)" |
3474 |
||
3583 | 3475 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3476 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3477 |
self |
3890 | 3478 |
undoableDo:[ |
3479 |
|line col lineLen| |
|
3480 |
||
3481 |
line := cursorLine. |
|
3482 |
col := cursorCol. |
|
3483 |
lineLen := (list at:line) size. |
|
3484 |
col > lineLen ifTrue:[ |
|
3485 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3486 |
] ifFalse:[ |
|
3487 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3488 |
]. |
|
3489 |
self mergeLine:line removeBlanks:true. |
|
3490 |
self cursorLine:line col:col. |
|
3491 |
] |
|
3492 |
info:'Join' |
|
3542 | 3493 |
! |
3494 |
||
2952 | 3495 |
mergeLine:lineNr |
3496 |
"merge line lineNr with line lineNr+1" |
|
3497 |
||
3498 |
self mergeLine:lineNr removeBlanks:true |
|
3499 |
||
3500 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3501 |
! |
|
3502 |
||
4458 | 3503 |
mergeLine:lineNr removeBlanks:removeBlanks |
3504 |
"merge line lineNr with line lineNr+1" |
|
3505 |
||
3506 |
|len| |
|
3507 |
||
3508 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3509 |
||
3510 |
len := (self listAt:lineNr) size. |
|
3511 |
self nonUndoableDo:[ |
|
4823 | 3512 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3513 |
]. |
3514 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3515 |
! |
|
3516 |
||
2506 | 3517 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3518 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3519 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3520 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3521 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3522 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3523 |
|
2506 | 3524 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
4823 | 3525 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
3526 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
3527 |
newSelectionEnd := newSelectionEnd-1. |
|
3528 |
]. |
|
3529 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
3530 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3531 |
newSelectionEnd := newSelectionEnd-1. |
|
3532 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3533 |
] ifFalse:[ |
4823 | 3534 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
3535 |
newSelectionEnd := newSelectionEnd+1. |
|
3536 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
3537 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3538 |
newSelectionEnd := newSelectionEnd+1. |
|
3539 |
] |
|
3160 | 3540 |
]. |
3541 |
self |
|
4823 | 3542 |
selectFromLine:selectionStartLine col:selectionStartCol |
3543 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3544 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3545 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3546 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3547 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3548 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3549 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3550 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3551 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3552 |
lastLine := list size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3553 |
finished := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3554 |
[finished] whileFalse:[ |
4771 | 3555 |
(lastLine <= 1) ifTrue:[ |
3556 |
finished := true |
|
3557 |
] ifFalse:[ |
|
3558 |
line := list at:lastLine. |
|
3559 |
line notNil ifTrue:[ |
|
3560 |
line isBlank ifTrue:[ |
|
3561 |
self basicListAt:lastLine put:nil. |
|
3562 |
line := nil |
|
3563 |
] |
|
3564 |
]. |
|
3565 |
line notNil ifTrue:[ |
|
3566 |
finished := true |
|
3567 |
] ifFalse:[ |
|
3568 |
lastLine := lastLine - 1 |
|
3569 |
] |
|
3570 |
] |
|
118 | 3571 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3572 |
(lastLine ~~ list size) ifTrue:[ |
4771 | 3573 |
list grow:lastLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3574 |
"/ self textChanged |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3575 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3576 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3577 |
|
4458 | 3578 |
replace:aCharacter atLine:lineNr col:colNr |
3579 |
"replace a single character at lineNr/colNr" |
|
3580 |
||
3581 |
|originalChar| |
|
3582 |
||
3583 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3584 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3585 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3586 |
! |
|
3587 |
||
4713 | 3588 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3589 |
|pattern replacePattern| |
3590 |
||
3591 |
pattern := patternArg string. |
|
3592 |
replacePattern := replacePatternArg string. |
|
4630 | 3593 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3594 |
self rememberSearchPattern:pattern. |
|
3595 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3596 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3597 |
self |
3598 |
undoableDo:[ |
|
3599 |
all ifTrue:[ |
|
3600 |
self |
|
3601 |
replaceString:pattern |
|
3602 |
to:replacePattern |
|
4713 | 3603 |
ignoreCase:ignoreCase |
4630 | 3604 |
] ifFalse:[ |
3605 |
(self selectionAsString notNil |
|
4713 | 3606 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3607 |
ifTrue:[ |
4742 | 3608 |
self replaceSelectionBy:replacePattern. |
4630 | 3609 |
self |
3610 |
search:pattern |
|
4713 | 3611 |
ignoreCase:ignoreCase |
4630 | 3612 |
forward:(lastSearchDirection = #forward). |
3613 |
]. |
|
3614 |
] |
|
3615 |
] |
|
3616 |
info:'Replace' |
|
3430 | 3617 |
] |
3618 |
||
3619 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3620 |
! |
|
3621 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3622 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3623 |
"replace a single character at cursor-position - advance cursor" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3624 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3625 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3626 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3627 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3628 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3629 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3630 |
] ifFalse:[ |
4823 | 3631 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3632 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3633 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3634 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3635 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3636 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3637 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3638 |
|
4458 | 3639 |
replaceContentsWith:newContents |
3640 |
"replace everything" |
|
3641 |
||
3642 |
|originalContents| |
|
3643 |
||
3644 |
originalContents := self contents. |
|
3645 |
self contents:newContents keepUndoHistory:true. |
|
3646 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3647 |
! |
|
3648 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3649 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3650 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3651 |
|
4701 | 3652 |
"/ sigh - insert first, to avoid troible due to shifing-in virtual line ends |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3653 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3654 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3655 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3656 |
|
4458 | 3657 |
replaceLine:lineNr with:newText |
3658 |
"replace a line at lineNr" |
|
3659 |
||
3660 |
|originalLine| |
|
3661 |
||
3662 |
originalLine := self listAt:lineNr. |
|
3663 |
originalLine isNil ifTrue:[ |
|
4823 | 3664 |
self checkForExistingLine:lineNr |
4458 | 3665 |
]. |
3666 |
self list at:lineNr put:newText. |
|
3667 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3668 |
self invalidateLine:lineNr. |
|
3669 |
||
3670 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3671 |
! |
|
3672 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3673 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3674 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3675 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3676 |
If withCr is true, move to the beginning of the next line |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3677 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3678 |
|
1809 | 3679 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3680 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3681 |
lines notNil ifTrue:[ |
4661 | 3682 |
wasOn := self hideCursor. |
3683 |
nLines := lines size. |
|
3684 |
line := cursorLine. |
|
3685 |
col := cursorCol. |
|
3686 |
lines keysAndValuesDo:[:i :l | |
|
3687 |
self replaceString:(l ? '') atLine:line col:col. |
|
3688 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3689 |
line := line + 1. |
|
3690 |
col := 1. |
|
3691 |
] ifFalse:[ |
|
3692 |
col := col + (l size). |
|
3693 |
] |
|
3694 |
]. |
|
3695 |
self cursorLine:line col:col. |
|
3696 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3697 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3698 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3699 |
|
4661 | 3700 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3701 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3702 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3703 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3704 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3705 |
"delete the selection (if any) and insert something, a character or string; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3706 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3707 |
|
4666 | 3708 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3709 |
! |
3710 |
||
3711 |
replaceSelectionBy:something keepCursor:keep |
|
3712 |
"delete the selection (if any) and insert something, a character or string; |
|
3713 |
leave cursor after insertion or leave it, depending on keep" |
|
3714 |
||
4666 | 3715 |
self replaceSelectionBy:something keepCursor:keep select:false |
3716 |
||
3717 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3718 |
! |
|
3719 |
||
3720 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
3721 |
"delete the selection (if any) and insert something, a character or string; |
|
3722 |
leave cursor after insertion or leave it, depending on keep. |
|
3723 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3724 |
||
3725 |
|sel l c selStartLine selStartCol| |
|
105 | 3726 |
|
3727 |
l := cursorLine. |
|
3728 |
c := cursorCol. |
|
3729 |
||
4818 | 3730 |
sel := self selectionAsString. |
4666 | 3731 |
sel isNil ifTrue:[ |
3732 |
selStartLine := l. |
|
3733 |
selStartCol := c. |
|
3734 |
] ifFalse:[ |
|
3735 |
selStartLine := selectionStartLine. |
|
3736 |
selStartCol := selectionStartCol. |
|
3737 |
||
4053 | 3738 |
self setLastStringToReplace: sel. |
3739 |
||
4010 | 3740 |
self deleteSelection. |
3741 |
replacing := true. |
|
4818 | 3742 |
lastReplacementInfo rememberReplacement. |
4048 | 3743 |
lastReplacementInfo lastReplacement: ''. |
4818 | 3744 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 3745 |
undoSupport actionInfo:'replace'. |
3161 | 3746 |
]. |
3747 |
||
3748 |
something isCharacter ifTrue:[ |
|
4051 | 3749 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 3750 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 3751 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 3752 |
]. |
4010 | 3753 |
]. |
3754 |
self isInInsertMode ifTrue:[ |
|
3755 |
self insertCharAtCursor:something |
|
3756 |
] ifFalse:[ |
|
3757 |
self replaceCharAtCursor:something |
|
3758 |
] |
|
105 | 3759 |
] ifFalse:[ |
4010 | 3760 |
something isString ifTrue:[ |
4048 | 3761 |
lastReplacementInfo lastReplacement: something. |
4010 | 3762 |
self isInInsertMode ifTrue:[ |
3763 |
self insertStringAtCursor:something |
|
3764 |
] ifFalse:[ |
|
3765 |
self replaceStringAtCursor:something |
|
3766 |
] |
|
3767 |
] ifFalse:[ |
|
3768 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3769 |
]. |
|
105 | 3770 |
]. |
3771 |
keep ifTrue:[ |
|
4010 | 3772 |
self cursorLine:l col:c |
4666 | 3773 |
]. |
3774 |
selectNewText ifTrue:[ |
|
3775 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 3776 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3777 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3778 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3779 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3780 |
|
4458 | 3781 |
replaceString:aString atLine:lineNr col:colNr |
3782 |
"replace multiple characters starting at lineNr/colNr. |
|
3783 |
This is not prepared to encounter special chars (except TAB) in the string." |
|
3784 |
||
3785 |
|originalString| |
|
3786 |
||
3787 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3788 |
||
3789 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
3790 |
||
3791 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3792 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
3793 |
! |
|
3794 |
||
4713 | 3795 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 3796 |
|continue count| |
3797 |
||
3798 |
self cursorToTop. |
|
3799 |
self selectFromBeginning. |
|
3800 |
count := 0. |
|
3801 |
continue := true. |
|
3802 |
[ continue ] whileTrue:[ |
|
4713 | 3803 |
(self selectionAsString notNil |
3804 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
3805 |
ifTrue:[ |
|
4742 | 3806 |
self replaceSelectionBy:aNewString. |
4713 | 3807 |
count := count + 1. |
3808 |
]. |
|
3809 |
self |
|
3810 |
searchFwd:aString |
|
3811 |
ignoreCase:ignoreCase |
|
3812 |
ifAbsent:[ |
|
3813 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
3814 |
bindWith:aString with:aNewString with:count). |
|
3815 |
continue := false. |
|
3816 |
]. |
|
3549 | 3817 |
]. |
3430 | 3818 |
|
3819 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3820 |
! |
|
3821 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3822 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3823 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3824 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3825 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3826 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3827 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3828 |
(aString includes:Character tab) ifTrue:[ |
4823 | 3829 |
"/ need special care for TAB (to move cursor correctly) |
3830 |
i1 := 1. |
|
3831 |
[i1 ~~ 0] whileTrue:[ |
|
3832 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3833 |
i2 ~~ 0 ifTrue:[ |
|
3834 |
i1 ~~ i2 ifTrue:[ |
|
3835 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3836 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3837 |
]. |
|
3838 |
self replaceTABAtCursor. |
|
3839 |
i2 := i2 + 1. |
|
3840 |
] ifFalse:[ |
|
3841 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3842 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3843 |
]. |
|
3844 |
i1 := i2. |
|
3845 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3846 |
] ifFalse:[ |
4823 | 3847 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
3848 |
self cursorCol:(cursorCol + aString size). |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3849 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3850 |
self makeCursorVisibleAndShowCursor:wasOn. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3851 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3852 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3853 |
"Modified: / 20.6.1998 / 19:41:02 / cg" |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3854 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3855 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3856 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3857 |
"replace a single character at cursor-position by a TAB character" |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3858 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3859 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3860 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3861 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3862 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3863 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3864 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3865 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3866 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 3867 |
! |
3868 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3869 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3870 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3871 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3872 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3873 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3874 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3875 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3876 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3877 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3878 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3879 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3880 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3881 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3882 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3883 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3884 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3885 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3886 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3887 |
|
4458 | 3888 |
splitLine:lineNr before:colNr |
3889 |
"split the line linNr before colNr; the right part (from colNr) |
|
3890 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3891 |
||
3892 |
self basicSplitLine:lineNr before:colNr. |
|
3893 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
3894 |
! |
|
3895 |
||
3896 |
withoutRedrawAt:lineNr put:aString |
|
3897 |
"replace a line at lineNr" |
|
3898 |
||
3899 |
|originalLine| |
|
3900 |
||
3901 |
originalLine := self listAt:lineNr. |
|
3902 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3903 |
super withoutRedrawAt:lineNr put:aString. |
|
3904 |
! |
|
3905 |
||
3906 |
withoutRedrawInsertLine:aString before:lineNr |
|
3907 |
"insert the argument, aString before line lineNr; the string |
|
3908 |
becomes line lineNr; everything else is moved down; the view |
|
3909 |
is not redrawn" |
|
3910 |
||
4771 | 3911 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 3912 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
3913 |
! |
|
3914 |
||
3915 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
3916 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
3917 |
||
3918 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
3919 |
self isReadOnly ifFalse:[ |
|
4823 | 3920 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 3921 |
]. |
3922 |
! |
|
3923 |
||
3924 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
3925 |
"insert aString (which has no crs) at lineNr/colNr" |
|
3926 |
||
3927 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
3928 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
3929 |
! |
|
3930 |
||
3890 | 3931 |
wrapLines |
3932 |
"wrap lines (insert line-break)" |
|
3933 |
||
3934 |
|lineLength answerString string| |
|
3935 |
||
3936 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3937 |
||
3938 |
self hasSelection ifFalse:[ |
|
3939 |
self selectLine:cursorLine. |
|
3940 |
]. |
|
3941 |
string := self selectionAsString. |
|
3942 |
string isEmptyOrNil ifTrue:[ |
|
3943 |
Dialog information:(resources string:'Nothing selected.'). |
|
3944 |
^ self. |
|
3945 |
]. |
|
3946 |
||
3947 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
3948 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 3949 |
lineLength isNil ifTrue:[^ self]. |
3890 | 3950 |
lineLength < 1 ifTrue:[ |
3951 |
lineLength := 1. |
|
3952 |
]. |
|
3953 |
||
3954 |
self |
|
3955 |
undoableDo:[ |
|
3956 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
3957 |
||
3958 |
line := selectionStartLine. |
|
3959 |
col := selectionStartCol. |
|
3960 |
||
3961 |
self cutSelection. |
|
3962 |
self cursorLine:line col:col. |
|
3963 |
||
3964 |
lastGoodCol := col. |
|
3965 |
||
3966 |
inStream := string readStream. |
|
3967 |
[ inStream atEnd ] whileFalse:[ |
|
3968 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
3969 |
word := WriteStream on:(String new:10). |
|
3970 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
3971 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
3972 |
self insertCharAtCursor:(Character cr). |
|
3973 |
col := 1. |
|
3974 |
] ifFalse:[ |
|
3975 |
col ~~ 1 ifTrue:[ |
|
3976 |
self insertStringAtCursor:' '. |
|
3977 |
col := col + 1. |
|
3978 |
] |
|
3979 |
]. |
|
3980 |
self insertStringAtCursor:word contents. |
|
3981 |
col := col + word size. |
|
3982 |
]. |
|
3983 |
] |
|
3984 |
info:'Wrap' |
|
4388 | 3985 |
|
3986 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3987 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3988 |
|
2752 | 3989 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3990 |
|
2952 | 3991 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 3992 |
"delete characters from startCol to endCol in line lineNr" |
3993 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
3994 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
3995 |
|
4673 | 3996 |
self unselect. |
3997 |
||
3998 |
cursorLine == lineNr ifTrue:[ |
|
3999 |
cursorCol >= startCol ifTrue:[ |
|
4000 |
cursorCol >= endCol ifTrue:[ |
|
4001 |
cursorCol := startCol. |
|
4002 |
] ifFalse:[ |
|
4003 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
4004 |
] |
|
4005 |
]. |
|
4006 |
]. |
|
4007 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4008 |
line := self listAt:lineNr. |
827 | 4009 |
|
4673 | 4010 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4011 |
||
4012 |
lineSize := line size. |
|
4013 |
||
4014 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4015 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4016 |
||
4017 |
stop >= start ifTrue:[ |
|
4018 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
4019 |
ifFalse:[ newLine := '' ]. |
|
4020 |
||
4021 |
stop == lineSize ifFalse:[ |
|
4022 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4023 |
newLine := line string species fromString:newLine. |
|
4190 | 4024 |
]. |
4673 | 4025 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
4026 |
]. |
|
4027 |
||
4028 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4029 |
newLine := nil |
|
4030 |
]. |
|
4031 |
||
4032 |
prevWidth := self widthOfLine:lineNr. |
|
4033 |
||
4771 | 4034 |
self basicListAt:lineNr put:newLine. |
4673 | 4035 |
|
4036 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4037 |
"/ remember old width of this line, |
|
4038 |
"/ only clear widthOfWidestLine, if this lines |
|
4039 |
"/ length was (one of) the longest. |
|
4040 |
"/ avoids slow delete with huge texts. |
|
4041 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4042 |
||
4043 |
"/ scroll left if reqiured |
|
4044 |
viewOrigin x > 0 ifTrue:[ |
|
4045 |
newWidth := self widthOfLine:lineNr. |
|
4046 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4047 |
self scrollHorizontalTo:(newWidth |
|
4048 |
- width |
|
4049 |
+ margin + margin |
|
4889 | 4050 |
+ (gc font widthOf:' ')) |
4673 | 4051 |
] |
4190 | 4052 |
]. |
4673 | 4053 |
self textChanged. |
4054 |
] ifFalse:[ |
|
4055 |
self textChanged "/ textChangedButNoSizeChange |
|
4056 |
]. |
|
4889 | 4057 |
gc font hasOverlappingCharacters ifTrue:[ |
4673 | 4058 |
self invalidateLine:lineNr. |
4059 |
] ifFalse:[ |
|
4060 |
self redrawLine:lineNr from:start. |
|
4061 |
]. |
|
4062 |
]. |
|
827 | 4063 |
|
4191 | 4064 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4065 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4066 |
|
2952 | 4067 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4068 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4069 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4070 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4071 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4072 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4073 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4074 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4075 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4076 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4077 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4078 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4079 |
startLineNr <= list size ifTrue:[ |
4771 | 4080 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4081 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4082 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4083 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4084 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4085 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4086 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4087 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4088 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4089 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4090 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4091 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4092 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4093 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4094 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4095 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4096 |
|
4226 | 4097 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4098 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4099 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4100 |
|
2952 | 4101 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4102 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4103 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4104 |
|
2952 | 4105 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4106 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4107 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4108 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4109 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4110 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4111 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4112 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4113 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4114 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4115 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4116 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4117 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4118 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4119 |
|
2952 | 4120 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4121 |
"insert a single character at lineNr/colNr; |
827 | 4122 |
set emphasis to character at current position" |
4123 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4124 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4125 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4126 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4127 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4128 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4129 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4130 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4131 |
]. |
827 | 4132 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4133 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4134 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4135 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4136 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4137 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4138 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4139 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4140 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4141 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4142 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4143 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4144 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4145 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4146 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4147 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4148 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4149 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4150 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4151 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4152 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4153 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4154 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4155 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4156 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4157 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4158 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4159 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4160 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4161 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4162 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4163 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4164 |
]. |
827 | 4165 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4166 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4167 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4168 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4169 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4170 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4171 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4172 |
newLine at:colNr put:aCharacter. |
827 | 4173 |
|
4174 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4175 |
newLine emphasisAt:colNr put:attribute. |
827 | 4176 |
]. |
4177 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4178 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4179 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4180 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4181 |
]. |
827 | 4182 |
|
4771 | 4183 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4184 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4185 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4186 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4187 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4188 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4189 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4190 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4191 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4192 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4193 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4194 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4195 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4196 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4197 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4198 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 4199 |
|
4889 | 4200 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4201 |
self invalidateLine:lineNr. |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4202 |
] ifFalse:[ |
4190 | 4203 |
drawCharacterOnly ifTrue:[ |
4889 | 4204 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4190 | 4205 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4206 |
] ifFalse:[ |
|
4207 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4208 |
self redrawLine:lineNr from:colNr-1 |
|
4209 |
]. |
|
4210 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4211 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4212 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4213 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4214 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4215 |
]. |
4889 | 4216 |
gc font hasOverlappingCharacters ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4217 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4218 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4219 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4220 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4221 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4222 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4223 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4224 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4225 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4226 |
|
4191 | 4227 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4228 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4229 |
|
4771 | 4230 |
basicListAt:lineNr put:newLine |
4231 |
"redefinable for special subclasses (with virtual list)" |
|
4232 |
||
4233 |
list at:lineNr put:newLine. |
|
4234 |
! |
|
4235 |
||
4236 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4237 |
"redefinable for special subclasses (with virtual list)" |
|
4238 |
||
4239 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4240 |
! |
|
4241 |
||
2952 | 4242 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4243 |
"merge line lineNr with line lineNr+1" |
4244 |
||
827 | 4245 |
|leftPart rightPart bothParts nextLineNr i| |
4246 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4247 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
4771 | 4248 |
"/ empty list or beyond end of text |
4249 |
^ self |
|
827 | 4250 |
]. |
4251 |
leftPart := self listAt:lineNr. |
|
4252 |
||
4253 |
leftPart isNil ifTrue:[ |
|
4771 | 4254 |
leftPart := ''. |
4255 |
autoIndent ifTrue:[ |
|
4256 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4257 |
leftPart := String new:i |
|
4258 |
] |
|
4259 |
] |
|
827 | 4260 |
]. |
4261 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4262 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4263 |
||
4264 |
nextLineNr > (list size) ifFalse:[ |
|
4771 | 4265 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4266 |
rightPart := '' |
|
4267 |
] ifFalse:[ |
|
4268 |
removeBlanks ifTrue:[ |
|
4269 |
rightPart := rightPart withoutLeadingSeparators. |
|
4270 |
] |
|
4271 |
]. |
|
4272 |
||
4273 |
bothParts := leftPart , rightPart. |
|
4274 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4275 |
self basicListAt:lineNr put:bothParts. |
|
4276 |
self redrawLine:lineNr. |
|
4277 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4278 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4279 |
|
1319 | 4280 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4281 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4282 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4283 |
|
2952 | 4284 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4285 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4286 |
|
5045 | 4287 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4288 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4289 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4290 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4291 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4292 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4293 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4294 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4295 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4296 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4297 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4298 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4299 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4300 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4301 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4302 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4303 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4304 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4305 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4306 |
(lineSize == 0) ifTrue:[ |
4190 | 4307 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4308 |
] ifFalse: [ |
5045 | 4309 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4310 |
newLineSpecies := aCharacter stringSpecies |
|
4311 |
] ifFalse:[ |
|
4312 |
newLineSpecies := line species |
|
4313 |
]. |
|
4314 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4315 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4316 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4317 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4318 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4319 |
newLine := self withTabsExpanded:newLine. |
4320 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4321 |
]. |
4771 | 4322 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4323 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4324 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4325 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4326 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4327 |
shown ifTrue:[ |
4889 | 4328 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4329 |
self invalidateLine:lineNr. |
4330 |
] ifFalse:[ |
|
4331 |
drawCharacterOnly ifTrue:[ |
|
4332 |
self redrawLine:lineNr col:colNr |
|
4333 |
] ifFalse:[ |
|
4334 |
self redrawLine:lineNr from:colNr |
|
4335 |
] |
|
4336 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4337 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4338 |
|
4190 | 4339 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4340 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4341 |
! |
4342 |
||
3235 | 4343 |
basicReplaceString:aString atLine:lineNr col:colNr |
4344 |
"replace multiple characters starting at lineNr/colNr. |
|
4345 |
This is not prepared to encounter special chars (except TAB) |
|
4346 |
in the string." |
|
4347 |
||
5045 | 4348 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4349 |
|
4350 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4351 |
||
4352 |
self checkForExistingLine:lineNr. |
|
4353 |
line := list at:lineNr. |
|
4354 |
lineSize := line size. |
|
4355 |
||
4356 |
endCol := colNr + aString size - 1. |
|
4357 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4358 |
newLine := aString species new:endCol. |
3235 | 4359 |
] ifFalse: [ |
5045 | 4360 |
(aString isText or:[aString bitsPerCharacter > line bitsPerCharacter]) ifTrue:[ |
4361 |
newLineSpecies := aString stringSpecies |
|
4362 |
] ifFalse:[ |
|
4363 |
newLineSpecies := line species |
|
4364 |
]. |
|
4365 |
||
4366 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4367 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4368 |
]. |
4369 |
newLine replaceFrom:colNr with:aString. |
|
4370 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4371 |
newLine := self withTabsExpanded:newLine. |
3235 | 4372 |
]. |
4771 | 4373 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4374 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4375 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4376 |
]. |
4377 |
self textChanged. |
|
4378 |
shown ifTrue:[ |
|
4889 | 4379 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4380 |
self invalidateLine:lineNr. |
4381 |
] ifFalse:[ |
|
4382 |
self redrawLine:lineNr from:colNr |
|
4383 |
] |
|
3235 | 4384 |
] |
4385 |
||
4190 | 4386 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4387 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4388 |
! |
4389 |
||
2952 | 4390 |
basicSplitLine:lineNr before:colNr |
4391 |
"split the line linNr before colNr; the right part (from colNr) |
|
4392 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4393 |
||
3160 | 4394 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4395 |
srcY "{ Class: SmallInteger }" | |
4396 |
||
3027 | 4397 |
list isNil ifTrue:[ ^ self ]. |
4398 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4399 |
||
4400 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4401 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4402 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4403 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4404 |
^ self |
3027 | 4405 |
]. |
4406 |
||
4407 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4408 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4409 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4410 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4411 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4412 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4413 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4414 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4415 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4416 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4417 |
] |
3027 | 4418 |
]. |
4419 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4420 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4421 |
]. |
4771 | 4422 |
self basicListAt:lineNr put:leftRest. |
3027 | 4423 |
self nonUndoableDo:[ |
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4424 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4425 |
]. |
4426 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4427 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4428 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4429 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4430 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4431 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4432 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4433 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4434 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4435 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4436 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4437 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4438 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4439 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4440 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4441 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4442 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4443 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4444 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4445 |
]. |
4446 |
widthOfWidestLine := nil. "/ unknown |
|
4447 |
self textChanged. |
|
2952 | 4448 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4449 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4450 |
! |
4451 |
||
2954 | 4452 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4453 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4454 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4455 |
because the text might have been pasted from an alien view." |
|
2954 | 4456 |
|
4457 |
|newLine newLines nLines| |
|
4458 |
||
4459 |
nLines := end - start + 1. |
|
4460 |
newLines := Array new:(lines size). |
|
4461 |
start to:end do:[:index | |
|
4328 | 4462 |
newLine := lines at:index. |
4463 |
newLine notNil ifTrue:[ |
|
4464 |
newLine isString ifTrue:[ |
|
4465 |
newLine isBlank ifTrue:[ |
|
4466 |
newLine := nil |
|
4467 |
] ifFalse:[ |
|
4468 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4469 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4470 |
] |
|
4471 |
] |
|
4472 |
] |
|
4473 |
]. |
|
4474 |
newLines at:index put:newLine |
|
2954 | 4475 |
]. |
4476 |
list isNil ifTrue: [ |
|
4328 | 4477 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4478 |
] ifFalse: [ |
4328 | 4479 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4480 |
]. |
4481 |
||
4482 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4483 |
overlapping copy - if it didn't, we had to use:" |
4484 |
" |
|
4485 |
index := list size. |
|
4486 |
[index > lineNr] whileTrue: [ |
|
4328 | 4487 |
pIndex := index - 1. |
4488 |
list at:index put:(list at:pIndex). |
|
4489 |
index := pIndex |
|
2954 | 4490 |
]. |
4491 |
" |
|
4492 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4493 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4494 |
self contentsChanged |
|
4495 |
||
4328 | 4496 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4497 |
! |
4498 |
||
4499 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4500 |
"insert aString (which has no crs) at lineNr/colNr. |
4501 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4502 |
because the text might have been pasted from an alien view." |
|
2954 | 4503 |
|
4360 | 4504 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4505 |
|
4623 | 4506 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4507 |
|
4508 |
strLen := aString size. |
|
4509 |
self checkForExistingLine:lineNr. |
|
4510 |
||
4511 |
stringType := aString string species. |
|
4512 |
isText := aString isText. |
|
4513 |
line := list at:lineNr. |
|
4514 |
||
4515 |
line notNil ifTrue:[ |
|
4328 | 4516 |
lineSize := line size. |
4517 |
line isString ifFalse:[ |
|
4518 |
stringType := line species |
|
4519 |
] ifTrue:[ |
|
4360 | 4520 |
lineCharWidth := line bitsPerCharacter. |
4521 |
stringCharWidth := aString bitsPerCharacter. |
|
4522 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4523 |
stringType := line string species |
4360 | 4524 |
] ifFalse:[ |
4525 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4526 |
stringType := aString string species |
|
4527 |
] |
|
4328 | 4528 |
]. |
4529 |
line isText ifTrue:[ isText := true ] |
|
4530 |
]. |
|
2954 | 4531 |
] ifFalse:[ |
4328 | 4532 |
lineSize := 0 |
2954 | 4533 |
]. |
4534 |
||
4535 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4536 |
newLine := aString |
2954 | 4537 |
] ifFalse:[ |
4328 | 4538 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4539 |
sz := colNr + strLen - 1 |
|
4540 |
] ifFalse:[ |
|
4541 |
sz := lineSize + strLen |
|
4542 |
]. |
|
4543 |
||
4360 | 4544 |
newLine := stringType new:sz. |
4545 |
isText ifTrue:[ |
|
4546 |
newLine := Text string:newLine |
|
4328 | 4547 |
]. |
4548 |
||
4549 |
(lineSize ~~ 0) ifTrue: [ |
|
4550 |
(colNr > lineSize) ifTrue: [ |
|
4551 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4552 |
] ifFalse: [ |
|
4553 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4554 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4555 |
] |
|
4556 |
]. |
|
4557 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4558 |
]. |
4559 |
||
4560 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4561 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4562 |
]. |
4563 |
||
4771 | 4564 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4565 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4566 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4567 |
]. |
4568 |
self textChanged. |
|
4569 |
||
4360 | 4570 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4571 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4572 |
|
2752 | 4573 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4574 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4575 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4576 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4577 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4578 |
hasKeyboardFocus := true. |
2589 | 4579 |
dragIsActive := false. |
4580 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4581 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4582 |
"/ also give that guy a chance to close its popup view |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4583 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4584 |
]. |
4609 | 4585 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4586 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4587 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4588 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4589 |
|
4420 | 4590 |
"On X11, be nice and paste PRIMARY when middle click. |
4591 |
Note, that middle button on X11 is translated to button |
|
4592 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
4940 | 4593 |
(button == #paste and:[self graphicsDevice platformName == #X11]) ifTrue:[ |
4420 | 4594 |
self undoableDo:[ |
4595 |
self paste: (self getClipboardText:#selection). |
|
4596 |
]. |
|
4597 |
^self. |
|
4598 |
]. |
|
4599 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4600 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4601 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4602 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4603 |
"/ some very old code from times, when a right-click was a paste in X11 |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4604 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4605 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4606 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4607 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4608 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4609 |
super buttonPress:button x:x y:y |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4610 |
|
4420 | 4611 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4612 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4613 |
! |
4614 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4615 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4616 |
"move the cursor to the click-position of previous button press" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4617 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4618 |
|x1 x2 x2_3 newCursorCol| |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4619 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4620 |
(button == 1) ifTrue:[ |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4621 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4622 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4623 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4624 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4625 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4626 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4627 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4628 |
self cursorMovementAllowed ifTrue:[ |
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4629 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4630 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4631 |
cursorType ~~ #block ifTrue:[ |
3790 | 4632 |
clickPos notNil ifTrue:[ |
4633 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4634 |
"/ (i.e. if its an ibeam). |
|
4635 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4636 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4637 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4638 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4639 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4640 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4641 |
]. |
5056 | 4642 |
"/ the following fixes the ugly select behavior when double clicking on |
4643 |
"/ a partially visible last line (where the first click used to |
|
4644 |
"/ scroll the text so that the second click was handled on another |
|
4645 |
"/ line. An alternative (possibly better) solution would be to |
|
4646 |
"/ remember the last click posision and adjust in the double click |
|
4647 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
4648 |
"/ Time will show, if this hack works. |
|
5057 | 4649 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
4650 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
4651 |
Processor |
|
4652 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
4653 |
afterSeconds:0.3. |
|
4654 |
] ifFalse:[ |
|
4655 |
self cursorLine:clickLine col:newCursorCol. |
|
4656 |
]. |
|
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4657 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4658 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4659 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4660 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4661 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4662 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4663 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4664 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4665 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4666 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4667 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4668 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4669 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4670 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4671 |
] ifFalse:[ |
4048 | 4672 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4673 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4674 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4675 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4676 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4677 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4678 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4679 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4680 |
|
2580 | 4681 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4682 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4683 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4684 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4685 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4686 |
self changeTypeOfSelectionTo:nil. |
2580 | 4687 |
|
4688 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4689 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4690 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4691 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4692 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4693 |
self validateNewSelection. |
4420 | 4694 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4695 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4696 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4697 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4698 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4699 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4700 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4701 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4702 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4703 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4704 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4705 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4706 |
selectionEndCol == 0 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4707 |
selectionEndCol := 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4708 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4709 |
self setCursorCol:selectionEndCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4710 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4711 |
self expandSelectionRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4712 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4713 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4714 |
self unselect; makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4715 |
cursorCol == 1 ifTrue:[^ self]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4716 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4717 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4718 |
self cursorRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4719 |
^ self |
2580 | 4720 |
]. |
4721 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4722 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4723 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4724 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4725 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4726 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4727 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4728 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4729 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4730 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4731 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4732 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4733 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4734 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4735 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4736 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4737 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4738 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4739 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4740 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4741 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4742 |
self setCursorCol:selectionStartCol. |
4590 | 4743 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4744 |
self setCursorCol:1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4745 |
self setCursorLine:(cursorLine - 1). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4746 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4747 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4748 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4749 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4750 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4751 |
clickCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4752 |
self expandSelectionDown. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4753 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4754 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4755 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4756 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4757 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4758 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4759 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4760 |
self cursorDown:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4761 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4762 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4763 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4764 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4765 |
^ self |
2580 | 4766 |
]. |
4767 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4768 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4769 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4770 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4771 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4772 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4773 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4774 |
selectionStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4775 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4776 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4777 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4778 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4779 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4780 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4781 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4782 |
selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4783 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4784 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4785 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4786 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4787 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4788 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4789 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4790 |
self redrawFromLine:selectionStartLine to:cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4791 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4792 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4793 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4794 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4795 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4796 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4797 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4798 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4799 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4800 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4801 |
self setCursorLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4802 |
self setCursorCol:selectionStartCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4803 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4804 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4805 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4806 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4807 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4808 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4809 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4810 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4811 |
self expandSelectionUp. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4812 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4813 |
self expandSelectionLeft. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4814 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4815 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4816 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4817 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4818 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4819 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4820 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4821 |
self cursorLeft. ^self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4822 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4823 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4824 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4825 |
self cursorUp:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4826 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4827 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4828 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4829 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4830 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4831 |
]. |
2580 | 4832 |
]. |
4420 | 4833 |
|
4834 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2580 | 4835 |
! |
4836 |
||
2952 | 4837 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4838 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4839 |
|
4521 | 4840 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 4841 |
#Replace #Undo #Redo #Accept |
3780 | 4842 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 4843 |
#DeleteSpaces #Join |
3780 | 4844 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 4845 |
#SelectWord #ExpandSelectionByWord |
3780 | 4846 |
#SelectToEnd #SelectFromBeginning |
4707 | 4847 |
#SelectLine #ExpandSelectionByLine |
3780 | 4848 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
4849 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
4850 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
4851 |
#GotoLine #BeginOfText #EndOfText |
|
4852 |
#InsertLine #DeleteLine |
|
4853 |
#SelectLineFromBeginning |
|
4854 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
4162 | 4855 |
#OpenSpecialCharacterWindow |
3780 | 4856 |
#'F*' #'f*')> |
2017 | 4857 |
|
4730 | 4858 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
4818 | 4859 |
immediateCompletion currentUserPrefs| |
4860 |
||
4861 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4862 |
|
4701 | 4863 |
"/ experimental |
4818 | 4864 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 4865 |
(immediateCompletion |
4818 | 4866 |
or:[currentUserPrefs codeCompletionOnControlKey |
4867 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4868 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4869 |
self initializeCompletionSupport. |
4609 | 4870 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4871 |
]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4872 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4873 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4874 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4875 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4876 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4877 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4878 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4879 |
|
4818 | 4880 |
key isSymbol ifTrue:[ |
4940 | 4881 |
(self graphicsDevice modifierKeys includes:key) ifFalse:[ |
4818 | 4882 |
lastReplacementInfo stillCollectingInput:false. |
4883 |
] |
|
4884 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4885 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 4886 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4887 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4888 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4889 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4890 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 4891 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4892 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4893 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4894 |
]. |
3799 | 4895 |
(key == #Undo) ifTrue:[self undo. ^self]. |
4896 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
4897 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4898 |
self learnMode ifTrue:[ |
4482 | 4899 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4900 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4901 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4902 |
|
4238 | 4903 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
4904 |
"the macro named key exists" |
|
3780 | 4905 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4906 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4907 |
|
4482 | 4908 |
key isSymbol ifFalse:[ |
4909 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
4910 |
self handleNonCommandKey:key. |
|
4911 |
^ self |
|
4912 |
]. |
|
4913 |
||
4914 |
event isNil ifTrue:[ |
|
4915 |
event := WindowGroup lastEventQuerySignal query. |
|
4916 |
]. |
|
4917 |
shiftPressed := event hasShift. |
|
4918 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
4919 |
||
4253 | 4920 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
4921 |
self deleteWordBeforeCursor. |
|
4922 |
^ self. |
|
4923 |
]. |
|
4924 |
||
3257 | 4925 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 4926 |
selectionStartLine notNil ifTrue:[ |
4927 |
((key == #BasicBackspace) |
|
4818 | 4928 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 4929 |
ifTrue:[ |
4930 |
self deleteSelection. |
|
4931 |
] ifFalse: [ |
|
4932 |
self copyAndDeleteSelection. |
|
4933 |
]. |
|
4609 | 4934 |
] ifFalse:[ |
4935 |
self makeCursorVisible. |
|
4936 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
4937 |
"/ self deleteWordBeforeCursor. |
|
4938 |
"/ ] ifFalse:[ |
|
4939 |
self deleteCharBeforeCursor. |
|
4940 |
"/ ]. |
|
3780 | 4941 |
]. |
4738 | 4942 |
true "immediateCompletion" ifTrue:[ |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4943 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:key]. |
4731 | 4944 |
]. |
3780 | 4945 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
4946 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4947 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4948 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4949 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4950 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4951 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4952 |
|
3235 | 4953 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4954 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 4955 |
^ self. |
3160 | 4956 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4957 |
|
4162 | 4958 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
4959 |
CharacterSetView notNil ifTrue:[ |
|
4960 |
self specialCharacters. |
|
4961 |
^ self. |
|
4962 |
] |
|
4963 |
]. |
|
4964 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4965 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4966 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4967 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4968 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 4969 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4970 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4971 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4972 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
4973 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 4974 |
(('[fF][0-9]' match:key) |
4975 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
4976 |
shiftPressed ifFalse:[ |
|
4818 | 4977 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 4978 |
fKeyMacros notNil ifTrue:[ |
4979 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
4980 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
4981 |
^ self |
|
4982 |
] |
|
4983 |
] |
|
4984 |
] |
|
4985 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4986 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4987 |
|
2506 | 4988 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 4989 |
self parenthizeSelectionWith:$( and:$). |
4990 |
^ self. |
|
2506 | 4991 |
]. |
4992 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 4993 |
self parenthizeSelectionWith:$" and:$". |
4994 |
^ self. |
|
2506 | 4995 |
]. |
4996 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 4997 |
self parenthizeSelectionWith:$' and:$'. |
4998 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4999 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5000 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5001 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5002 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5003 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5004 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5005 |
(key == #Accept) ifTrue:[^ self accept]. |
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5006 |
|
4521 | 5007 |
((key == #Paste) or:[key == #Insert or:[key == #PasteFromHistory]]) ifTrue:[self pasteOrReplace. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5008 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5009 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5010 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5011 |
|
3542 | 5012 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5013 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5014 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5015 |
self makeCursorVisible. |
|
5016 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5017 |
^ self |
|
5018 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5019 |
(key == #SelectWord) ifTrue:[ |
3780 | 5020 |
self makeCursorVisible. |
5021 |
self selectWordUnderCursor. |
|
5022 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5023 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5024 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5025 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5026 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5027 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5028 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5029 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5030 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5031 |
and if you like it, its better done in the keymap. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5032 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5033 |
(key == #Ctrlb) ifTrue:[self unselect. self cursorLeft. ^ self]. |
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5034 |
(key == #Ctrlf) ifTrue:[self unselect. self cursorRight. ^ self]. |
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5035 |
(key == #Ctrln) ifTrue:[self unselect. self cursorDown. ^ self]. |
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5036 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5037 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5038 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5039 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5040 |
shiftPressed ifTrue: [ |
5041 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5042 |
"/ self unselect. |
|
5043 |
"/ self cursorHome. |
|
5044 |
"Jan's modification" |
|
4257 | 5045 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
5046 |
"/ Jan's modification modified by his own request ;-)) |
|
5047 |
self selectFromBeginOfLine. |
|
3780 | 5048 |
] ifFalse: [ |
5049 |
self unselect. |
|
5050 |
ctrlPressed ifTrue:[ |
|
5051 |
self cursorHome. |
|
5052 |
] ifFalse:[ |
|
5053 |
self cursorToBeginOfLine. |
|
5054 |
] |
|
5055 |
]. |
|
5056 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5057 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5058 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5059 |
shiftPressed ifTrue:[ |
5060 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5061 |
"/ self unselect. |
|
5062 |
"/ self cursorToBottom |
|
4257 | 5063 |
" Jan's modification" |
5064 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5065 |
"/ Jan's modification modified by his own request ;-)) |
|
5066 |
self selectToEndOfLine. |
|
3780 | 5067 |
] ifFalse:[ |
5068 |
self unselect. |
|
5069 |
ctrlPressed ifTrue:[ |
|
5070 |
self cursorToBottom |
|
5071 |
] ifFalse:[ |
|
5072 |
self cursorToEndOfLine. |
|
5073 |
] |
|
5074 |
]. |
|
5075 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5076 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5077 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5078 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5079 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5080 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5081 |
|
2580 | 5082 |
(key == #CursorRight |
5083 |
or:[key == #CursorDown |
|
5084 |
or:[key == #CursorLeft |
|
5085 |
or:[key == #CursorUp]]]) ifTrue:[ |
|
3780 | 5086 |
self cursorKeyPress:key shifted:shiftPressed. |
5087 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5088 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5089 |
|
3257 | 5090 |
(key == #NonInsertingReturn) ifTrue:[ |
3780 | 5091 |
self unselect. self cursorReturn. |
5092 |
^ self |
|
3257 | 5093 |
]. |
5094 |
||
5095 |
(key == #Return) ifTrue:[ |
|
3780 | 5096 |
shiftPressed ifTrue:[ |
5097 |
self unselect. self cursorReturn. |
|
5098 |
^ self |
|
5099 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5100 |
|
3780 | 5101 |
self isReadOnly ifTrue:[ |
5102 |
self unselect; makeCursorVisible. |
|
5103 |
self cursorReturn |
|
5104 |
] ifFalse:[ |
|
5105 |
self isInInsertMode ifFalse:[ |
|
5106 |
self cursorReturn. |
|
5107 |
autoIndent == true ifTrue:[ |
|
5108 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5109 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5110 |
self cursorCol:(i+1 max:1) |
5111 |
] |
|
3780 | 5112 |
] |
5113 |
] ifTrue:[ |
|
4826 | 5114 |
|left right oldIndent| |
4812 | 5115 |
|
3780 | 5116 |
"/ old version just unselected ... |
5117 |
"/ self unselect; makeCursorVisible. |
|
5118 |
||
5119 |
"/ new version deletes ... |
|
5120 |
typeOfSelection == #paste ifTrue:[ |
|
5121 |
self unselect; makeCursorVisible. |
|
5122 |
] ifFalse:[ |
|
5123 |
self copyAndDeleteSelection. |
|
5124 |
]. |
|
4816 | 5125 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5126 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5127 |
self insertCharAtCursor:(Character cr). |
5128 |
autoIndent == true ifTrue:[ |
|
4816 | 5129 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5130 |
"/ nothing to do. |
|
4812 | 5131 |
] ifFalse:[ |
5132 |
((self listAt:cursorLine) isEmptyOrNil |
|
5133 |
or:[ cursorCol == 1 ]) ifTrue:[ |
|
5134 |
i := (self leftIndentForLine:cursorLine). |
|
4823 | 5135 |
left := left withoutSeparators. |
5136 |
right := right withoutSeparators. |
|
5137 |
(left endsWith:'[') ifTrue:[ |
|
5138 |
"/ i := i + 4. |
|
4816 | 5139 |
] ifFalse:[ |
4823 | 5140 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5141 |
i := i - 4. |
5142 |
]. |
|
4812 | 5143 |
]. |
4826 | 5144 |
oldIndent := self leftIndentOfLine:cursorLine. |
5145 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5146 |
self st80EditMode ifTrue:[ |
|
5147 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5148 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5149 |
]. |
|
5150 |
]. |
|
4812 | 5151 |
self cursorCol:(i+1 max:1) |
5152 |
]. |
|
5153 |
] |
|
3780 | 5154 |
]. |
5155 |
]. |
|
5156 |
]. |
|
5157 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5158 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
5159 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5160 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5161 |
self unselect. self cursorTab. |
5162 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5163 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5164 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5165 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5166 |
||
5167 |
self hasSelection ifTrue:[ |
|
5168 |
selectStyle == #line ifTrue:[ |
|
4238 | 5169 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5170 |
macroName := #IndentBy4. |
|
5171 |
] ifFalse:[ |
|
5172 |
macroName := #UndentBy4. |
|
5173 |
]. |
|
5174 |
macroName notNil ifTrue:[ |
|
5175 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5176 |
]. |
5177 |
] |
|
5178 |
]. |
|
5179 |
||
5180 |
self unselect. |
|
5181 |
(key == #Tab) ifTrue:[ |
|
5182 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5183 |
self cursorTab. |
|
5184 |
^ self |
|
5185 |
]. |
|
5186 |
self insertTabAtCursor. |
|
5187 |
^ self |
|
5188 |
]. |
|
5189 |
self cursorBacktab. |
|
5190 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5191 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
5192 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5193 |
"/ key == #DeleteSpaces ifTrue:[ |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5194 |
(key == #Delete) ifTrue:[ |
3780 | 5195 |
shiftPressed ifTrue:[ |
5196 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5197 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5198 |
self makeCursorVisible. |
|
5199 |
self deleteCharAtCursor. |
|
5200 |
]. |
|
5201 |
^ self |
|
5202 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5203 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5204 |
|
870 | 5205 |
(key == #Delete |
5206 |
or:[key == #BasicDelete]) ifTrue:[ |
|
4129 | 5207 |
selectionStartLine notNil ifTrue:[ |
4130 | 5208 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5209 |
"/ To remove text repetetively, use Cut instead. |
|
5210 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5211 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5212 |
((key == #BasicDelete) |
4818 | 5213 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5214 |
self deleteSelection. |
5215 |
] ifFalse:[ |
|
5216 |
self copyAndDeleteSelection. |
|
5217 |
]. |
|
5218 |
^ self |
|
5219 |
]. |
|
5220 |
self makeCursorVisible. |
|
5221 |
self deleteCharAtCursor. |
|
5222 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5223 |
]. |
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
5224 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5225 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5226 |
self unselect. |
5227 |
cursorVisibleLine == 1 ifTrue:[ |
|
5228 |
self cursorHome. |
|
5229 |
] ifFalse:[ |
|
5230 |
self cursorToFirstVisibleLine |
|
5231 |
]. |
|
5232 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5233 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5234 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5235 |
self unselect. |
5236 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5237 |
self cursorToBottom. |
|
5238 |
] ifFalse:[ |
|
5239 |
self cursorToLastVisibleLine |
|
5240 |
]. |
|
5241 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5242 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5243 |
((key == #Escape) |
3257 | 5244 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5245 |
self makeCursorVisible. |
5246 |
self unselect. self selectCursorLineFromBeginning. |
|
5247 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5248 |
]. |
3257 | 5249 |
(key == #SelectLine) ifTrue:[ |
3780 | 5250 |
self makeCursorVisible. |
5251 |
self unselect. self selectCursorLine. |
|
5252 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5253 |
]. |
3257 | 5254 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5255 |
"/ self makeCursorVisible. |
3780 | 5256 |
self selectExpandCursorLine. |
5257 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5258 |
]. |
3257 | 5259 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5260 |
self makeCursorVisible. |
5261 |
self unselect. self deleteCursorLine. |
|
5262 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5263 |
]. |
3257 | 5264 |
(key == #InsertLine) ifTrue:[ |
3780 | 5265 |
self makeCursorVisible. |
5266 |
self unselect. self insertLine:nil before:cursorLine. |
|
5267 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5268 |
]. |
3781 | 5269 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5270 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5271 |
|
3310 | 5272 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5273 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5274 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5275 |
! |
5276 |
||
2952 | 5277 |
executeKeyboardMacro:cmdMacro |
5278 |
Error handle:[:ex | |
|
4823 | 5279 |
self warn:'Error in keyboard macro: ' , ex description. |
5280 |
ex return. |
|
2952 | 5281 |
] do:[ |
4823 | 5282 |
AbortOperationRequest handle:[:ex | |
5283 |
self warn:'Keyboard macro aborted'. |
|
5284 |
ex return. |
|
5285 |
] do:[ |
|
5286 |
Parser |
|
5287 |
evaluate:cmdMacro asString |
|
5288 |
receiver:self |
|
5289 |
notifying:nil |
|
5290 |
compile:false. |
|
5291 |
]. |
|
2952 | 5292 |
]. |
5293 |
! |
|
5294 |
||
5295 |
handleNonCommandKey:keyArg |
|
4700 | 5296 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5297 |
|
5298 |
self isReadOnly ifTrue:[ |
|
4988 | 5299 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5300 |
^ self. |
2952 | 5301 |
]. |
5302 |
||
5303 |
key := keyArg. |
|
5304 |
||
5305 |
typeOfSelection == #paste ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5306 |
"pasted selection will NOT be replaced by keystroke" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5307 |
self unselect |
2952 | 5308 |
]. |
5309 |
||
4700 | 5310 |
selStartLineBefore := selectionStartLine. |
5311 |
selStartColBefore := self selectionStartCol. |
|
5312 |
selEndLineBefore := selectionEndLine. |
|
5313 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5314 |
|
4940 | 5315 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 5316 |
key isCharacter ifTrue:[ |
4940 | 5317 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5318 |
] ifFalse:[ |
4940 | 5319 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5320 |
]. |
2952 | 5321 |
]. |
5322 |
||
5323 |
"replace selection by what is typed in - |
|
3235 | 5324 |
if word was selected with a space, keep it. |
4700 | 5325 |
if there was no selection, the key's character is inserted" |
3235 | 5326 |
|
5327 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5328 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5329 |
]. |
2952 | 5330 |
|
5331 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5332 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5333 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5334 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5335 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5336 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5337 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5338 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5339 |
] |
3160 | 5340 |
]. |
2952 | 5341 |
selectStyle := nil. |
5342 |
||
3235 | 5343 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5344 |
selectionStartLine := selStartLineBefore. |
5345 |
selectionStartCol := selStartColBefore. |
|
5346 |
selectionEndLine := selEndLineBefore. |
|
5347 |
selectionEndCol := selEndColBefore. |
|
3235 | 5348 |
]. |
5349 |
||
2952 | 5350 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5351 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5352 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5353 |
"claus: only do it for closing parenthesis - |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5354 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5355 |
" |
2952 | 5356 |
" |
4481 | 5357 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5358 |
" |
4481 | 5359 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5360 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5361 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5362 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5363 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5364 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5365 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5366 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5367 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5368 |
self cursorLine:line col:col. |
4940 | 5369 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5370 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5371 |
"/ want to wait 200ms, but not if another keyPress |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5372 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5373 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5374 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5375 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5376 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5377 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5378 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5379 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5380 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5381 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5382 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5383 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5384 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5385 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5386 |
] |
2952 | 5387 |
]. |
5388 |
||
5389 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5390 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5391 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5392 |
"/ |
|
5393 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5394 |
"/ self selection. |
|
5395 |
"/ typeOfSelection := #paste. |
|
3160 | 5396 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5397 |
"/ ]. |
3235 | 5398 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5399 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5400 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5401 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5402 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5403 |
]. |
3235 | 5404 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5405 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5406 |
|
5407 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
2952 | 5408 |
! |
5409 |
||
5410 |
keyPress:key x:x y:y |
|
5411 |
"handle keyboard input" |
|
5412 |
||
4771 | 5413 |
|wasOn| |
5414 |
||
5415 |
wasOn := cursorShown. |
|
5416 |
||
5417 |
NoModificationError handle:[:ex | |
|
4988 | 5418 |
self flashReadOnly. |
4771 | 5419 |
(cursorShown not and:[wasOn]) ifTrue:[ |
5420 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5421 |
]. |
|
5422 |
] do:[ |
|
5423 |
self undoableDo:[ |
|
5424 |
self doKeyPress:key x:x y:y |
|
5425 |
]. |
|
4242 | 5426 |
]. |
5427 |
self repairDamage |
|
5428 |
||
5429 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
2952 | 5430 |
! |
5431 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5432 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5433 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5434 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5435 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5436 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5437 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5438 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5439 |
requestAutoAccept |
5068 | 5440 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
5441 |
This forces my value to be accepted into my model. |
|
5442 |
Any widget may suppress the ok/cancel, by returning false." |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5443 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5444 |
acceptEnabled == false ifTrue:[ |
4823 | 5445 |
"/ nope - |
5446 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5447 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5448 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5449 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5450 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5451 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5452 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5453 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5454 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5455 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5456 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5457 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5458 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5459 |
cv notNil ifTrue:[ |
4823 | 5460 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5461 |
] |
4967 | 5462 |
! |
5463 |
||
5464 |
unmapped |
|
5465 |
super unmapped. |
|
5466 |
||
5467 |
completionSupport notNil ifTrue:[ |
|
5468 |
completionSupport release. |
|
5469 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5470 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5471 |
|
1807 | 5472 |
!EditTextView methodsFor:'focus handling'! |
5473 |
||
4818 | 5474 |
focusOut |
5475 |
super focusOut. |
|
5476 |
||
5477 |
completionSupport notNil ifTrue:[ |
|
5478 |
completionSupport release. |
|
5479 |
]. |
|
5480 |
! |
|
5481 |
||
1807 | 5482 |
hasKeyboardFocus:aBoolean |
5483 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5484 |
(otherwise, I would not know about this)" |
|
5485 |
||
5486 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5487 |
|
3160 | 5488 |
(cursorShown |
5489 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5490 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5491 |
self drawCursor |
5492 |
]. |
|
5493 |
||
5494 |
hasKeyboardFocus ifFalse:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5495 |
completionSupport notNil ifTrue:[ |
4821 | 5496 |
"/ this is a hack for Windows: |
5497 |
"/ on windows, an activate:false event is first sent to my textView, |
|
5498 |
"/ then an activate is sent to the completion popup. |
|
5499 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
5500 |
"/ therefore, allow for the activate of the completionMenu and it's button event to be processed. |
|
5501 |
"/ before forcing it to be closed... |
|
5502 |
Processor addTimedBlock:[completionSupport "release" editViewLostFocus] afterMilliseconds:200. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5503 |
]. |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5504 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5505 |
|
4821 | 5506 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 5507 |
! |
5508 |
||
5509 |
showFocus:explicit |
|
5510 |
"in addition to however my superclass thinks how a focusView is to be |
|
5511 |
displayed, show the cursor when I got the focus" |
|
5512 |
||
5513 |
self showCursor. |
|
5514 |
self hasKeyboardFocus:true. |
|
5515 |
super showFocus:explicit |
|
5516 |
||
5517 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5518 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5519 |
|
4967 | 5520 |
showNoFocus:explicit |
5521 |
"the view lost the keyboard focus |
|
5522 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
5523 |
- change any display attributes as req'd." |
|
5524 |
||
5525 |
super showNoFocus:explicit. |
|
4818 | 5526 |
completionSupport notNil ifTrue:[ |
5527 |
completionSupport release. |
|
5528 |
]. |
|
5529 |
! |
|
5530 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5531 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5532 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5533 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5534 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5535 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5536 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5537 |
and:[self enabled |
4781 | 5538 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5539 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5540 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5541 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5542 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5543 |
^ false |
1807 | 5544 |
! ! |
5545 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5546 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5547 |
|
4237 | 5548 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5549 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5550 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5551 |
|
4482 | 5552 |
|cmdMacro| |
5553 |
||
5554 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5555 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5556 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5557 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5558 |
^ true |
4238 | 5559 |
|
5560 |
" |
|
4483 | 5561 |
EditTextView open |
4238 | 5562 |
contents:'bla'; |
5563 |
selectAll; |
|
5564 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 5565 |
EditTextView open |
4238 | 5566 |
contents:'bla'; |
5567 |
selectAll; |
|
5568 |
executekeyboardMacroNamed:#blabla. |
|
5569 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5570 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5571 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 5572 |
! |
5573 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5574 |
indent |
3221 | 5575 |
"indent a line-range - this is done by searching for the |
5576 |
last non-empty line before the selection, and changing the indent |
|
4742 | 5577 |
of the selected line-range based on that line's indent." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5578 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5579 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5580 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5581 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 5582 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5583 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5584 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5585 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 5586 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5587 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5588 |
self unselect. |
3160 | 5589 |
self |
3786 | 5590 |
undoableDo:[self indentFromLine:start toLine:end] |
5591 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5592 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5593 |
|
4237 | 5594 |
indentBy4 |
5050 | 5595 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
5596 |
||
5597 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5598 |
! |
|
5599 |
||
5600 |
indentBy8 |
|
5601 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 5602 |
|
5603 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5604 |
! |
|
5605 |
||
5050 | 5606 |
indentBy:n |
5607 |
|line1 line2| |
|
5608 |
||
5609 |
line1 := self selectionStartLine. |
|
5610 |
line2 := self selectionEndLine. |
|
5611 |
line1 isNil ifTrue:[ |
|
5612 |
line1 := self cursorLine. |
|
5613 |
line1 notNil ifTrue:[ |
|
5614 |
line2 := line1+1 |
|
5615 |
] |
|
5616 |
]. |
|
5617 |
line1 notNil ifTrue:[ |
|
5618 |
self indentFromLine:line1 toLine:line2 by:n. |
|
5619 |
] |
|
5620 |
! |
|
5621 |
||
5622 |
indentByTab |
|
5623 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
5624 |
! |
|
5625 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5626 |
indentFromLine:start toLine:end |
3221 | 5627 |
"indent a line-range - this is done by searching for the |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5628 |
last non-empty line before start, and change the indent |
4742 | 5629 |
of the selected line-range based on that line's indent." |
5630 |
||
4811 | 5631 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5632 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5633 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5634 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5635 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5636 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5637 |
(delta == 0) ifTrue:[^ self]. |
4811 | 5638 |
self indentFromLine:start toLine:end by:delta |
5639 |
! |
|
5640 |
||
5641 |
indentFromLine:start toLine:end by:delta |
|
5642 |
"indent a line-range - this is done by searching for the |
|
5643 |
last non-empty line before start, and change the indent |
|
5644 |
of the selected line-range based on that line's indent." |
|
5645 |
||
5646 |
|d line spaces anyChange| |
|
5647 |
||
5648 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5649 |
(delta > 0) ifTrue:[ |
4742 | 5650 |
spaces := String new:delta |
5651 |
]. |
|
5652 |
||
5653 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5654 |
start to:end do:[:lineNr | |
4742 | 5655 |
line := self listAt:lineNr. |
5656 |
line notNil ifTrue:[ |
|
5657 |
line isBlank ifTrue:[ |
|
4771 | 5658 |
self basicListAt:lineNr put:nil |
4742 | 5659 |
] ifFalse:[ |
5660 |
(delta > 0) ifTrue:[ |
|
5661 |
line := spaces , line. |
|
5662 |
widthOfWidestLine notNil ifTrue:[ |
|
5663 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
5664 |
] |
|
5665 |
] ifFalse:[ |
|
5666 |
"check if deletion is ok" |
|
5667 |
d := delta negated + 1. |
|
5668 |
||
5669 |
line size > d ifTrue:[ |
|
5670 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
5671 |
line := line copyFrom:d |
|
5672 |
] |
|
5673 |
]. |
|
5674 |
widthOfWidestLine := nil |
|
5675 |
]. |
|
5676 |
self replaceLine:lineNr with:line. |
|
5677 |
anyChange := true. |
|
5678 |
] |
|
5679 |
] |
|
5680 |
]. |
|
5681 |
||
5682 |
anyChange ifTrue:[ self textChanged ]. |
|
5683 |
||
3221 | 5684 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5685 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5686 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5687 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5688 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5689 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5690 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5691 |
this is done by searching for the last non-empty line before it |
4823 | 5692 |
and returning its indent. |
5693 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5694 |
|
827 | 5695 |
"SHOULD GO TO ListView" |
5696 |
||
5697 |
|line lnr indent| |
|
5698 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5699 |
lnr := lineNr. |
827 | 5700 |
|
4823 | 5701 |
"/ [lnr ~~ 1] whileTrue:[ |
5702 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 5703 |
lnr := lnr - 1. |
5704 |
line := self listAt:lnr. |
|
5705 |
||
5706 |
line notNil ifTrue:[ |
|
5707 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
5708 |
indent ~~ 0 ifTrue:[ |
|
5709 |
(line endsWith:$[) ifTrue:[ |
|
5710 |
^ indent + 4 - 1 |
|
5711 |
]. |
|
5712 |
^ indent - 1 |
|
5713 |
] |
|
5714 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5715 |
]. |
827 | 5716 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5717 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5718 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 5719 |
! |
5720 |
||
5721 |
undentBy4 |
|
5050 | 5722 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
5723 |
||
5724 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5725 |
! |
|
5726 |
||
5727 |
undentBy8 |
|
5728 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 5729 |
|
5730 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 5731 |
! |
5732 |
||
5733 |
undentBy:n |
|
5734 |
self indentBy:(n negated) |
|
5735 |
! |
|
5736 |
||
5737 |
undentByTab |
|
5738 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 5739 |
! ! |
5740 |
||
0 | 5741 |
!EditTextView methodsFor:'initialization'! |
5742 |
||
941 | 5743 |
fetchDeviceResources |
5744 |
"fetch device colors, to avoid reallocation at redraw time" |
|
5745 |
||
5746 |
super fetchDeviceResources. |
|
5747 |
||
4940 | 5748 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:self graphicsDevice]. |
5749 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:self graphicsDevice]. |
|
5750 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:self graphicsDevice]. |
|
941 | 5751 |
|
5752 |
"Created: 14.1.1997 / 00:15:24 / cg" |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5753 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 5754 |
! |
5755 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5756 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5757 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5758 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5759 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5760 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5761 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5762 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5763 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5764 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5765 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5766 |
super initStyle. |
4576 | 5767 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5768 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5769 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5770 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5771 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5772 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5773 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 5774 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
5775 |
cursorTypeNoFocus isNil ifTrue:[ |
|
5776 |
cursorTypeNoFocus := cursorType. |
|
5777 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
5778 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
5779 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
5780 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5781 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5782 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 5783 |
cursorType ~~ #block ifTrue:[ |
5784 |
cursorNoFocusFgColor := cursorBgColor |
|
5785 |
] ifFalse:[ |
|
5786 |
cursorNoFocusFgColor := cursorFgColor |
|
5787 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5788 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5789 |
|
2088 | 5790 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5791 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5792 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5793 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5794 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5795 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5796 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5797 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5798 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5799 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5800 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5801 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5802 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5803 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5804 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5805 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5806 |
cursorCol := 1. |
2815 | 5807 |
cursorLineHolder := 1 asValue. |
5808 |
cursorColHolder := 1 asValue. |
|
2119 | 5809 |
modifiedChannel := ValueHolder with:false. |
5810 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
5811 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5812 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5813 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5814 |
tabMeansNextField := false. |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5815 |
autoIndent := false. |
3235 | 5816 |
editMode := EditMode insertMode asValue. |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5817 |
learnMode := false asValue. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5818 |
trimBlankLines := self st80EditMode not. |
2131 | 5819 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 5820 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
5821 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5822 |
"/ enable drop by default |
2589 | 5823 |
self allowDrop:true. "/ readOnly tested in #canDrop: |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5824 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5825 |
undoSupport := UndoSupport for:self. |
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5826 |
codeAspectHolder := nil asValue. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5827 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5828 |
"Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5829 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5830 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5831 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5832 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5833 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5834 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5835 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5836 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5837 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5838 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5839 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5840 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 5841 |
! |
5842 |
||
5843 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5844 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5845 |
completionSupport release |
4771 | 5846 |
]. |
5847 |
super release |
|
0 | 5848 |
! ! |
5849 |
||
2580 | 5850 |
!EditTextView methodsFor:'macros'! |
5851 |
||
5852 |
executeLearnedKeyboardMacro |
|
4673 | 5853 |
"replay the characters as learned previously" |
5854 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5855 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5856 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5857 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5858 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5859 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5860 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5861 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5862 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5863 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5864 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5865 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5866 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5867 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5868 |
]. |
2580 | 5869 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5870 |
self flash. |
2580 | 5871 |
]. |
5872 |
! |
|
5873 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5874 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5875 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5876 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5877 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5878 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5879 |
|
2580 | 5880 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5881 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5882 |
|
2580 | 5883 |
|fg bg| |
5884 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5885 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5886 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5887 |
aBoolean ifTrue:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5888 |
learnedMacro := OrderedCollection new. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5889 |
fg := Color white. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5890 |
bg := Color black. |
2580 | 5891 |
] ifFalse:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5892 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5893 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
2580 | 5894 |
]. |
5895 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
5896 |
! |
|
5897 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5898 |
learnModeHolder |
4673 | 5899 |
"a holder returning true, if in learn mode" |
5900 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5901 |
learnMode isNil ifTrue:[ |
4673 | 5902 |
learnMode := false asValue |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5903 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5904 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5905 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5906 |
|
4673 | 5907 |
rememberLearnedMacroAs: nameString |
5908 |
Macros isNil ifTrue:[ |
|
5909 |
Macros := Dictionary new. |
|
5910 |
]. |
|
5911 |
Macros at:nameString put:learnedMacro |
|
5912 |
! |
|
5913 |
||
2580 | 5914 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5915 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5916 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5917 |
self learnMode:(self learnMode not). |
2580 | 5918 |
! ! |
5919 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
5920 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 5921 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5922 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5923 |
"translate the selected text and paste it after the selection" |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5924 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5925 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5926 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5927 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5928 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5929 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5930 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
5931 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 5932 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
5933 |
] do:[ |
|
5934 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
5935 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5936 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5937 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5938 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5939 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5940 |
self unselect. |
3799 | 5941 |
self |
5942 |
undoablePaste:translated |
|
5943 |
info:'Translate' |
|
3495 | 5944 |
|
5945 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5946 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
5947 |
|
3517 | 5948 |
compareWithClipboard |
5949 |
"compare the selection against the clipboard contents" |
|
5950 |
||
5951 |
|t1 t2| |
|
5952 |
||
5953 |
t2 := self getClipboardText. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5954 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 5955 |
Dialog information:'Clipboard is empty.'. |
5956 |
^ self. |
|
3517 | 5957 |
]. |
5958 |
||
5959 |
self hasSelection ifTrue:[ |
|
4823 | 5960 |
t1 := self selectionAsString. |
3517 | 5961 |
] ifFalse:[ |
4823 | 5962 |
t1 := self contents asString |
3517 | 5963 |
]. |
5964 |
t1 := t1 string. |
|
5965 |
||
5966 |
t1 = t2 ifTrue:[ |
|
4823 | 5967 |
Dialog information:'Strings are equal.'. |
5968 |
^ self. |
|
3517 | 5969 |
]. |
5970 |
DiffTextView |
|
4823 | 5971 |
openOn:t1 label:'Editor' |
5972 |
and:t2 label:'Clipboard' |
|
3517 | 5973 |
! |
5974 |
||
121 | 5975 |
cut |
5976 |
"cut selection into copybuffer" |
|
5977 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5978 |
self deleteCopyToClipboard:true |
121 | 5979 |
! |
5980 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5981 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5982 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5983 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5984 |
cursorLine notNil ifTrue:[ |
4823 | 5985 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5986 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5987 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5988 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5989 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5990 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5991 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5992 |
|
4129 | 5993 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5994 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5995 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 5996 |
self flashReadOnly. |
3786 | 5997 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5998 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
5999 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6000 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6001 |
sel notNil ifTrue:[ |
4129 | 6002 |
self setLastStringToReplace: sel. |
4053 | 6003 |
|
3786 | 6004 |
line := selectionStartLine. |
6005 |
col := selectionStartCol. |
|
6006 |
||
6007 |
toClipboard ifTrue:[ |
|
6008 |
" |
|
6009 |
remember in CopyBuffer |
|
6010 |
" |
|
6011 |
self setClipboardText:sel. "/ lastString. |
|
6012 |
]. |
|
6013 |
||
6014 |
" |
|
6015 |
append to DeleteHistory (if there is one) |
|
6016 |
" |
|
6017 |
history := Smalltalk at:#DeleteHistory. |
|
6018 |
history notNil ifTrue:[ |
|
6019 |
history addAll:(sel asStringCollection). |
|
6020 |
history size > 1000 ifTrue:[ |
|
6021 |
history := history copyFrom:(history size - 1000) |
|
6022 |
]. |
|
6023 |
]. |
|
6024 |
||
6025 |
" |
|
6026 |
now, delete it |
|
6027 |
" |
|
6028 |
self |
|
6029 |
undoableDo:[self deleteSelection] |
|
6030 |
info:'Delete'. |
|
4048 | 6031 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6032 |
] ifFalse:[ |
3786 | 6033 |
" |
6034 |
a cut without selection will search&cut again |
|
6035 |
" |
|
6036 |
self undoableDo:[ |
|
6037 |
self again |
|
6038 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6039 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6040 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6041 |
"Modified: / 5.4.1998 / 16:51:53 / cg" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6042 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6043 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6044 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6045 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6046 |
|
3781 | 6047 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
6048 |
#Find #GotoLine #SaveAs #Print |
|
3890 | 6049 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6050 |
#ToggleAutoIndent #ToggleInsertMode |
6051 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6052 |
<resource: #programMenu> |
1054 | 6053 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6054 |
|items m sub translateItems sortItems miscItems toolItems subSub toolSub |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6055 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6056 |
|
2460 | 6057 |
items := #( |
3781 | 6058 |
('Redo' redo Redo ) |
6059 |
('Again (for All)' multipleAgain AgainForAll ) |
|
3731 | 6060 |
('-' ) |
6061 |
('Search...' search Find ) |
|
6062 |
('Goto Line...' gotoLine GotoLine ) |
|
6063 |
('-' ) |
|
4940 | 6064 |
('Tools' tools ) |
6065 |
('Insert Unicode...' insertUnicode ) |
|
6066 |
). |
|
4213 | 6067 |
CharacterSetView notNil ifTrue:[ |
6068 |
items := items , |
|
6069 |
#( |
|
6070 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6071 |
). |
|
6072 |
]. |
|
6073 |
items := items , #( |
|
3731 | 6074 |
('-' ) |
6075 |
('Save As...' save SaveAs ) |
|
6076 |
('Print' doPrint Print ) |
|
6077 |
('=' ) |
|
4213 | 6078 |
('Misc' misc ShiftCtrl) ). |
2460 | 6079 |
|
2866 | 6080 |
miscItems := #( |
3781 | 6081 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6082 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
3731 | 6083 |
('-' ) |
6084 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
3781 | 6085 |
('Join Lines' joinLines Join ) |
4388 | 6086 |
('Wrap Lines...' wrapLines Wrap ) |
3731 | 6087 |
('-' ) |
3781 | 6088 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
6089 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
3731 | 6090 |
('-' ) |
3811 | 6091 |
('Insert File...' insertFile ) |
6092 |
('Insert URL Contents...' insertURL ) |
|
3781 | 6093 |
('Insert new UUID' insertUUID ) |
6094 |
('Insert Date && Time' insertDateAndTime ) |
|
3732 | 6095 |
('-' ) |
6096 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6097 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
3731 | 6098 |
('-' ) |
6099 |
). |
|
4213 | 6100 |
"/ CharacterSetView notNil ifTrue:[ |
6101 |
"/ miscItems := miscItems , |
|
6102 |
"/ #( |
|
6103 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6104 |
"/ ). |
|
6105 |
"/ ]. |
|
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
6106 |
miscItems := miscItems , |
3731 | 6107 |
#( |
6108 |
('Font...' changeFont ) |
|
2870 | 6109 |
"/ ('Encoding...' changeEncoding ) |
3731 | 6110 |
). |
2866 | 6111 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6112 |
translateItems := #( |
3731 | 6113 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6114 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6115 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6116 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6117 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6118 |
('-' ) |
|
6119 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6120 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6121 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6122 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6123 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6124 |
). |
|
3221 | 6125 |
|
6126 |
sortItems := #( |
|
3731 | 6127 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6128 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4373 | 6129 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
6130 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6131 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
3731 | 6132 |
('Words' (sortSelection:ignoreCase: #words false) ) |
6133 |
('-' ) |
|
4373 | 6134 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
6135 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6136 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6137 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
4763 | 6138 |
('-' ) |
6139 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6140 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
3731 | 6141 |
). |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6142 |
|
2762 | 6143 |
toolItems := #( |
3731 | 6144 |
('Indent' indent ) |
4287 | 6145 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
3731 | 6146 |
('Sort' sort ) |
6147 |
('-' ) |
|
4742 | 6148 |
('Google Spell Check' googleSpellingSuggestion ) |
6149 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
3731 | 6150 |
('Translate' babelFishTranslate ) |
6151 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6152 |
). |
|
2762 | 6153 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6154 |
Smalltalk isStandAloneApp ifFalse:[ |
3731 | 6155 |
toolItems := toolItems , #( |
6156 |
('-' ) |
|
6157 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6158 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6159 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6160 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6161 |
|
2460 | 6162 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6163 |
sub receiver:self. |
2460 | 6164 |
|
2919 | 6165 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6166 |
toolSub receiver:self. |
|
6167 |
sub subMenuAt:#tools put:toolSub. |
|
6168 |
||
3495 | 6169 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6170 |
transSub receiver:self. |
|
6171 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6172 |
||
6173 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6174 |
sortSub receiver:self. |
|
6175 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6176 |
|
2866 | 6177 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6178 |
subSub receiver:self. |
|
2952 | 6179 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6180 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6181 |
subSub checkToggleAt:#learnMode: put:(self learnModeHolder value). |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
6182 |
|
2866 | 6183 |
sub subMenuAt:#misc put:subSub. |
6184 |
||
3495 | 6185 |
mainItems := #( |
3731 | 6186 |
('Undo' undo Undo ) |
6187 |
('Again' again Again ) |
|
6188 |
('-' ) |
|
6189 |
('Cut' cut Cut ) |
|
6190 |
('Copy' copySelection Copy ) |
|
6191 |
('Paste' pasteOrReplace Paste ) |
|
6192 |
('-' ) |
|
6193 |
('Accept' accept Accept ) |
|
6194 |
('=' ) |
|
6195 |
('More' others Ctrl ) |
|
6196 |
). |
|
3495 | 6197 |
main := PopUpMenu itemList:mainItems resources:resources. |
6198 |
main subMenuAt:#others put:sub. |
|
6199 |
||
6200 |
sensor := self sensor. |
|
6201 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6202 |
sensor shiftDown ifTrue:[ |
|
3731 | 6203 |
m := subSub |
6204 |
] ifFalse:[ |
|
6205 |
m := sub |
|
6206 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6207 |
] ifFalse:[ |
3731 | 6208 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6209 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6210 |
|
4742 | 6211 |
"/ the 'Smalltalk at:' code is here to |
6212 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6213 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
3731 | 6214 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6215 |
m disable:#googleSpellingSuggestion |
|
2676 | 6216 |
]. |
4742 | 6217 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
6218 |
m disable:#internalSpellingSuggestion |
|
6219 |
]. |
|
2676 | 6220 |
|
3811 | 6221 |
HTTPInterface isNil ifTrue:[ |
6222 |
m disableAll:#(insertURL) |
|
6223 |
]. |
|
6224 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6225 |
self isReadOnly ifTrue:[ |
4475 | 6226 |
m disableAll:#(accept undo again multipleAgain redo |
3731 | 6227 |
paste pasteOrReplace pasteOrReplaceFromHistory |
6228 |
cut indent autoIndent: insertMode: |
|
3811 | 6229 |
insertFile insertFileAsStringLiteral insertURL |
6230 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6231 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
4764 | 6232 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
4940 | 6233 |
insertUnicode specialCharacters) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6234 |
]. |
2817 | 6235 |
self hasSelectionForCopy ifFalse:[ |
3731 | 6236 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6237 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6238 |
self hasSelection ifFalse:[ |
3731 | 6239 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt openWorkspaceWithIt sort indent). |
2762 | 6240 |
] ifTrue:[ |
3731 | 6241 |
(Error handle:[:ex | |
6242 |
ex return:false |
|
6243 |
] do:[ |
|
4042 | 6244 |
|fn| |
6245 |
fn := self selectionAsString. |
|
6246 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
3731 | 6247 |
]) ifFalse:[ |
6248 |
m disableAll:#(openFileBrowserOnIt). |
|
6249 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6250 |
]. |
2569 | 6251 |
self hasUndoAction ifFalse:[ |
3731 | 6252 |
m disable:#undo. |
3115 | 6253 |
] ifTrue:[ |
3731 | 6254 |
what := undoSupport undoActionInfo. |
6255 |
what notNil ifTrue:[ |
|
6256 |
undoIdx := m indexOf:#undo. |
|
6257 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6258 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6259 |
]. |
2952 | 6260 |
self hasRedoAction ifFalse:[ |
3731 | 6261 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6262 |
] ifTrue:[ |
3731 | 6263 |
what := undoSupport redoActionInfo. |
6264 |
what notNil ifTrue:[ |
|
6265 |
redoIdx := sub indexOf:#redo. |
|
6266 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6267 |
] |
|
2952 | 6268 |
]. |
1108 | 6269 |
acceptEnabled == false ifTrue:[ |
3731 | 6270 |
m disable:#accept |
1108 | 6271 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6272 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6273 |
|
4388 | 6274 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6275 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6276 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6277 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6278 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6279 |
|
4940 | 6280 |
history := self graphicsDevice getCopyBufferHistory copy. |
3160 | 6281 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6282 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6283 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6284 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6285 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6286 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6287 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6288 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6289 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6290 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6291 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6292 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6293 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6294 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6295 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6296 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6297 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6298 |
box label:(resources string:'Select Previous Copybuffer String'). |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6299 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6300 |
box show. |
3160 | 6301 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6302 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6303 |
"Modified: / 25-08-2010 / 22:02:14 / cg" |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6304 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6305 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6306 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6307 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6308 |
self sensor shiftDown ifTrue:[ |
3855 | 6309 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6310 |
]. |
2724 | 6311 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6312 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6313 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6314 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6315 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6316 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6317 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6318 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6319 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6320 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6321 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6322 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6323 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6324 |
"Modified: / 13-07-2011 / 14:55:58 / cg" |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6325 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6326 |
|
2676 | 6327 |
googleSpellingSuggestion |
6328 |
"insert the google-spelling suggestion for the selected text. |
|
6329 |
Requires that the SOAP stuff is loaded and working." |
|
6330 |
||
2677 | 6331 |
|text suggestion| |
2676 | 6332 |
|
6333 |
self withWaitCursorDo:[ |
|
3799 | 6334 |
text := self selection asString string withoutSeparators. |
6335 |
text size == 0 ifTrue:[^ self]. |
|
6336 |
||
4742 | 6337 |
"/ the 'Smalltalk at:' code is here to |
6338 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6339 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6340 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6341 |
^ self. |
|
6342 |
] do:[ |
|
4742 | 6343 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6344 |
]. |
6345 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6346 |
self information:('No spelling suggestion from Google for: ' , text). |
6347 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6348 |
^ self. |
6349 |
]. |
|
6350 |
]. |
|
6351 |
self |
|
6352 |
undoablePaste:suggestion |
|
6353 |
info:'Spelling Suggestion'. |
|
3495 | 6354 |
|
6355 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6356 |
! |
6357 |
||
3595 | 6358 |
insertDateAndTime |
6359 |
"insert the curent date and time string" |
|
6360 |
||
6361 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6362 |
self |
3786 | 6363 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6364 |
info:'Paste Date and Time' |
3595 | 6365 |
! |
6366 |
||
2676 | 6367 |
insertFile |
3160 | 6368 |
"insert contents of a file |
2676 | 6369 |
- ask user for filename using a fileSelectionBox." |
6370 |
||
3731 | 6371 |
self insertFileAsStringLiteral:false |
6372 |
! |
|
6373 |
||
6374 |
insertFileAsStringLiteral |
|
6375 |
"insert a file's contents as a string literal. |
|
6376 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6377 |
to make it a legal string literal" |
|
6378 |
||
6379 |
self insertFileAsStringLiteral:true |
|
6380 |
! |
|
6381 |
||
6382 |
insertFileAsStringLiteral:asStringLiteral |
|
6383 |
"insert contents of a file; either as-is or as a string literal. |
|
6384 |
- ask user for filename using a fileSelectionBox." |
|
6385 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6386 |
|sel selFn file text ok initial| |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6387 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6388 |
((sel := self selectionAsString) notEmptyOrNil |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6389 |
and:[ (selFn := sel asFilename) exists |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6390 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6391 |
ifTrue:[ |
3731 | 6392 |
initial := selFn pathName. |
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6393 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6394 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6395 |
[ |
3731 | 6396 |
|why| |
6397 |
||
6398 |
file := Dialog |
|
6399 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6400 |
default:initial |
|
6401 |
ok:(resources string:'Insert') |
|
6402 |
abort:(resources string:'Cancel') |
|
6403 |
pattern:nil |
|
6404 |
fromDirectory:directoryForFileDialog. |
|
6405 |
file isNil ifTrue:[ |
|
6406 |
"cancel" |
|
6407 |
^ self. |
|
6408 |
]. |
|
6409 |
file := file asFilename. |
|
6410 |
directoryForFileDialog := file. |
|
6411 |
||
6412 |
ok := file isReadable and:[file isDirectory not]. |
|
6413 |
ok ifFalse:[ |
|
6414 |
file isReadable ifFalse:[ |
|
6415 |
why := '%1 is unreadable.\\Please try again.' |
|
6416 |
] ifTrue:[ |
|
6417 |
why := '%1 is a directory.\\Please try again.' |
|
6418 |
]. |
|
6419 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6420 |
]. |
|
2909 | 6421 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6422 |
|
5063 | 6423 |
text := file contentsAsString. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6424 |
self |
3786 | 6425 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6426 |
info:'Paste File' |
3495 | 6427 |
|
6428 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6429 |
! |
|
6430 |
||
3811 | 6431 |
insertURL |
6432 |
"insert contents of a URL |
|
6433 |
- ask user for URL using a dialog." |
|
6434 |
||
6435 |
self insertURLAsStringLiteral:false |
|
6436 |
! |
|
6437 |
||
6438 |
insertURLAsStringLiteral:asStringLiteral |
|
6439 |
"insert contents of a file; either as-is or as a string literal. |
|
6440 |
- ask user for filename using a fileSelectionBox." |
|
6441 |
||
6442 |
|sel url text response initial| |
|
6443 |
||
6444 |
(sel := self selectionAsString) notEmptyOrNil |
|
6445 |
ifTrue:[ |
|
6446 |
initial := sel. |
|
6447 |
]. |
|
6448 |
||
6449 |
url := Dialog |
|
6450 |
request:(resources string:'Insert Contents of URL:') |
|
6451 |
initialAnswer:initial |
|
6452 |
okLabel:(resources string:'Insert') |
|
6453 |
title:(resources string:'URL'). |
|
6454 |
url isNil ifTrue:[ |
|
6455 |
"cancel" |
|
6456 |
^ self. |
|
6457 |
]. |
|
6458 |
response := HTTPInterface get:url. |
|
6459 |
response isErrorResponse ifTrue:[ |
|
6460 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6461 |
^ self. |
|
6462 |
]. |
|
6463 |
text := response data asString. |
|
6464 |
||
6465 |
self |
|
6466 |
undoableDo:[ |
|
6467 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6468 |
] |
|
6469 |
info:'Insert Contents of URL' |
|
6470 |
! |
|
6471 |
||
3495 | 6472 |
insertUUID |
6473 |
"insert a new UUID's string" |
|
6474 |
||
6475 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6476 |
self |
3786 | 6477 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6478 |
info:'Paste New UUID' |
3495 | 6479 |
|
6480 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6481 |
! |
6482 |
||
4940 | 6483 |
insertUnicode |
6484 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
6485 |
||
6486 |
|unicodePoint unicodeChar unicodeString| |
|
6487 |
||
6488 |
unicodeString := Dialog request:'Enter unicode (U+01FF or decimal number):'. |
|
6489 |
unicodeString size < 2 ifTrue:[ |
|
6490 |
^ self. |
|
6491 |
]. |
|
6492 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
6493 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
|
6494 |
] ifFalse:[ |
|
6495 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
|
6496 |
]. |
|
6497 |
||
6498 |
unicodeChar := Character value:unicodePoint. |
|
6499 |
self keyPress:unicodeChar x:0 y:0. |
|
6500 |
self keyRelease:unicodeChar x:0 y:0. |
|
6501 |
! |
|
6502 |
||
4742 | 6503 |
internalSpellingSuggestion |
6504 |
"insert the internal-spelling suggestion for the selected text. |
|
6505 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
6506 |
||
6507 |
|text suggestions best| |
|
6508 |
||
6509 |
self withWaitCursorDo:[ |
|
6510 |
text := self selection asString string withoutSeparators. |
|
6511 |
text size == 0 ifTrue:[^ self]. |
|
6512 |
||
6513 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
6514 |
suggestions size == 0 ifTrue:[ |
|
6515 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
6516 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
6517 |
^ self. |
|
6518 |
]. |
|
6519 |
Transcript showCR:suggestions. |
|
6520 |
best := suggestions first. |
|
6521 |
]. |
|
6522 |
self |
|
6523 |
undoablePaste:best |
|
6524 |
info:'Spelling Suggestion'. |
|
6525 |
! |
|
6526 |
||
4884 | 6527 |
openFileBrowserOnFileNamed:fileNameString |
6528 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 6529 |
|
4630 | 6530 |
|fn| |
2762 | 6531 |
|
4884 | 6532 |
fn := fileNameString asFilename. |
2762 | 6533 |
fn exists ifFalse:[ |
4884 | 6534 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 6535 |
fn exists ifFalse:[ |
6536 |
^ self warn:'Oops - file is gone'. |
|
6537 |
]. |
|
2762 | 6538 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6539 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6540 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6541 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 6542 |
! |
6543 |
||
4884 | 6544 |
openFileBrowserOnIt |
6545 |
"open a fileBrowser on the selected fileName" |
|
6546 |
||
6547 |
|fileNameString| |
|
6548 |
||
6549 |
fileNameString := self selectionAsString. |
|
6550 |
self openFileBrowserOnFileNamed:fileNameString |
|
6551 |
||
6552 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
6553 |
! |
|
6554 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6555 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6556 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6557 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6558 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6559 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6560 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6561 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6562 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6563 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6564 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6565 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6566 |
paste |
1289 | 6567 |
"paste the copybuffer; if there is a selection, unselect first. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6568 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6569 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6570 |
self checkModificationsAllowed ifTrue:[ |
4823 | 6571 |
self withSelfAndTextForPasteDo:[:me :text | |
6572 |
me unselect. |
|
6573 |
me undoablePaste:text |
|
6574 |
] |
|
2952 | 6575 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6576 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6577 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6578 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6579 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6580 |
|
3825 | 6581 |
self paste:someText withCR:false |
6582 |
! |
|
6583 |
||
6584 |
paste:someText withCR:withCR |
|
6585 |
"paste someText at cursor" |
|
6586 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6587 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6588 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6589 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6590 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6591 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6592 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6593 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6594 |
CharacterEncoderError handle:[:ex | |
3825 | 6595 |
|code msg| |
6596 |
||
6597 |
code := ex parameter. |
|
6598 |
codingErrorReported ifFalse:[ |
|
4940 | 6599 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 6600 |
code notNil ifTrue:[ |
6601 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
6602 |
]. |
|
6603 |
Dialog warn:(resources stringWithCRs:msg). |
|
6604 |
codingErrorReported := true. |
|
6605 |
]. |
|
6606 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6607 |
] do:[ |
3825 | 6608 |
s isString ifTrue:[ |
4940 | 6609 |
s encoding ~~ gc characterEncoding ifTrue:[ |
6610 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 6611 |
]. |
6612 |
||
6613 |
s := s asStringCollection. |
|
6614 |
(someText endsWith:Character cr) ifTrue:[ |
|
6615 |
"/ s := s copyWith:nil. |
|
6616 |
s := s copyWith:'' "/ an empty line at the end |
|
6617 |
||
6618 |
] |
|
6619 |
] ifFalse:[ |
|
6620 |
s isStringCollection ifTrue:[ |
|
4940 | 6621 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 6622 |
] ifFalse:[ |
6623 |
(self |
|
6624 |
confirm:(resources |
|
6625 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
6626 |
with:s class name)) ifFalse:[^ self]. |
|
6627 |
s := StringCollection with:s storeString . |
|
6628 |
"/ ^ self |
|
6629 |
]. |
|
6630 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6631 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6632 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6633 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6634 |
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6635 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6636 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6637 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6638 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6639 |
startCol := c1 := cursorCol. |
3180 | 6640 |
|
4328 | 6641 |
"do not expand tabs into spaces here - |
3180 | 6642 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
6643 |
Some Subviews want to paste with unexpanded tabs!!" |
|
6644 |
||
3825 | 6645 |
self insertLines:s withCR:withCR. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6646 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6647 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6648 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6649 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6650 |
|
4328 | 6651 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 6652 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6653 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6654 |
|
3731 | 6655 |
pasteAsStringLiteral |
6656 |
"insert clipboard string as a string literal. |
|
6657 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
6658 |
to make it a legal string literal" |
|
6659 |
||
6660 |
typeOfSelection := nil. |
|
6661 |
self |
|
3786 | 6662 |
undoableDo:[ self pasteOrReplace:(self getClipboardText storeString) ] |
6663 |
info:'Paste as String Literal' |
|
3731 | 6664 |
! |
6665 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6666 |
pasteOrReplace |
1289 | 6667 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 6668 |
otherwise paste at cursor position. |
6669 |
Replace is not done for selections which were created by a paste, |
|
2010 | 6670 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6671 |
|
2724 | 6672 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6673 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6674 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6675 |
pasteOrReplace:someText |
1289 | 6676 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6677 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6678 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6679 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6680 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6681 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6682 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6683 |
self undoableDo:[ |
4823 | 6684 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
6685 |
self replace:someText |
|
6686 |
] ifFalse:[ |
|
6687 |
self paste:someText. |
|
6688 |
] |
|
3542 | 6689 |
] info:'Paste/Replace'. |
1289 | 6690 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
6691 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6692 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6693 |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6694 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6695 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6696 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6697 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6698 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6699 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6700 |
self checkModificationsAllowed ifFalse:[ |
4988 | 6701 |
self flashReadOnly. |
4823 | 6702 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6703 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6704 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6705 |
text notNil ifTrue:[ |
4823 | 6706 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6707 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6708 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6709 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6710 |
replace |
1289 | 6711 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6712 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6713 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6714 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6715 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6716 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 6717 |
me undoableDo:[ me replace:text ] |
6718 |
info:'Replace' |
|
2952 | 6719 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6720 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6721 |
|
121 | 6722 |
replace:someText |
1289 | 6723 |
"replace the selection by someText" |
121 | 6724 |
|
3160 | 6725 |
|selected selectedString |
6726 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 6727 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6728 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6729 |
|
3130 | 6730 |
self undoableDo:[ |
4010 | 6731 |
selected := self selection. |
6732 |
selected isNil ifTrue:[ |
|
6733 |
^ self paste:someText |
|
6734 |
]. |
|
6735 |
||
6736 |
self deleteSelection. |
|
6737 |
||
6738 |
"take care, if we replace a selection without space by a word selected |
|
6739 |
with one - in this case we usually do not want the space. |
|
6740 |
But, if we replace a word-selected selection by something without a |
|
6741 |
space, we DO want the space added." |
|
6742 |
||
6743 |
selected size == 1 ifTrue:[ |
|
6744 |
selectedString := selected at:1. |
|
6745 |
]. |
|
6746 |
||
6747 |
someText size == 1 ifTrue:[ |
|
6748 |
|cutOffSpace addSpace replacement replacementString| |
|
6749 |
||
6750 |
cutOffSpace := false. |
|
6751 |
addSpace := false. |
|
6752 |
replacement := someText copyFrom:1. |
|
6753 |
||
6754 |
selectedString notNil ifTrue:[ |
|
6755 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
6756 |
"selection has no space" |
|
6757 |
||
6758 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
6759 |
cutOffSpace := true |
|
6760 |
] |
|
6761 |
] ifTrue:[ |
|
6762 |
addSpace := true |
|
6763 |
] |
|
6764 |
]. |
|
6765 |
replacementString := replacement at:1. |
|
6766 |
cutOffSpace ifTrue:[ |
|
6767 |
(replacementString startsWith:' ') ifTrue:[ |
|
6768 |
replacementString := replacementString withoutSpaces |
|
6769 |
]. |
|
6770 |
] ifFalse:[ |
|
6771 |
selectStyle == #wordLeft ifTrue:[ |
|
6772 |
"want a space at left" |
|
6773 |
(replacementString startsWith:' ') ifFalse:[ |
|
6774 |
replacementString := replacementString withoutSpaces. |
|
6775 |
replacementString := ' ' , replacementString |
|
6776 |
] |
|
6777 |
]. |
|
6778 |
selectStyle == #wordRight ifTrue:[ |
|
6779 |
"want a space at right" |
|
6780 |
||
6781 |
(replacementString endsWith:' ') ifFalse:[ |
|
6782 |
replacementString := replacementString withoutSpaces. |
|
6783 |
replacementString := replacementString , ' ' |
|
6784 |
] |
|
6785 |
]. |
|
6786 |
]. |
|
6787 |
replacement at:1 put: replacementString. |
|
6788 |
self paste:replacement. |
|
6789 |
] ifFalse:[ |
|
6790 |
self paste:someText |
|
6791 |
]. |
|
4053 | 6792 |
self setLastStringToReplace: selectedString. |
6793 |
||
4048 | 6794 |
lastReplacementInfo lastReplacement: someText. |
4010 | 6795 |
|
6796 |
selStartLine := selectionStartLine. |
|
6797 |
selStartCol := self selectionStartCol. |
|
6798 |
selEndLine := selectionEndLine. |
|
6799 |
selEndCol := self selectionEndCol. |
|
3130 | 6800 |
] |
3542 | 6801 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
6802 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6803 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6804 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 6805 |
! |
6806 |
||
3430 | 6807 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6808 |
"search for a string - show a box to enter searchpattern |
3430 | 6809 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
6810 |
- currently no regular expressions are handled." |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6811 |
|
3430 | 6812 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
6813 |
||
6814 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
6815 |
lastSearchDirection := #forward. |
|
6816 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
6817 |
caseHolder := ign asValue. |
|
6818 |
patternHolder := '' asValue. |
|
6819 |
replacePatternHolder := '' asValue. |
|
6820 |
lastSearchPattern notNil ifTrue:[ |
|
4823 | 6821 |
initialString := lastSearchPattern |
3430 | 6822 |
]. |
6823 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 6824 |
initialString := self selectionAsString |
3430 | 6825 |
]. |
6826 |
initialString isNil ifTrue:[ |
|
4823 | 6827 |
LastSearchPatterns size > 0 ifTrue:[ |
6828 |
initialString := LastSearchPatterns first |
|
6829 |
] |
|
3430 | 6830 |
]. |
6831 |
initialString notNil ifTrue:[ |
|
4823 | 6832 |
patternHolder value:initialString. |
6833 |
replacePatternHolder value:initialString. |
|
3430 | 6834 |
]. |
6835 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6836 |
search := [:fwd | |
4823 | 6837 |
self |
6838 |
search:patternHolder value |
|
6839 |
ignoreCase:caseHolder value |
|
6840 |
forward:fwd. |
|
6841 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6842 |
replace := [:all | |
4823 | 6843 |
self |
6844 |
replace:patternHolder value |
|
6845 |
by:replacePatternHolder value |
|
6846 |
all:all |
|
6847 |
ignoreCase:caseHolder value |
|
6848 |
]. |
|
3430 | 6849 |
bindings := IdentityDictionary new. |
6850 |
bindings at:#searchPattern put:patternHolder. |
|
6851 |
bindings at:#replacePattern put:replacePatternHolder. |
|
6852 |
modal ifTrue:[ |
|
4823 | 6853 |
bindings at:#nextAction |
6854 |
put:[ |
|
6855 |
flag := true. |
|
6856 |
action := search. |
|
6857 |
searchBox doAccept. |
|
6858 |
]. |
|
6859 |
bindings at:#prevAction |
|
6860 |
put:[ |
|
6861 |
flag := false. |
|
6862 |
action := search. |
|
6863 |
searchBox doAccept. |
|
6864 |
]. |
|
6865 |
bindings at:#replaceAction |
|
6866 |
put:[ |
|
6867 |
flag := false. |
|
6868 |
action := replace. |
|
6869 |
searchBox doAccept. |
|
6870 |
]. |
|
6871 |
bindings at:#replaceAllAction |
|
6872 |
put:[ |
|
6873 |
flag := true. |
|
6874 |
action := replace. |
|
6875 |
searchBox doAccept. |
|
6876 |
]. |
|
3430 | 6877 |
] ifFalse:[ |
4823 | 6878 |
bindings at:#nextAction put:[ search value:true. ]. |
6879 |
bindings at:#prevAction put:[ search value:false. ]. |
|
6880 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
6881 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 6882 |
]. |
6883 |
bindings at:#ignoreCase put:caseHolder. |
|
6884 |
bindings at:#patternList put:LastSearchPatterns. |
|
6885 |
modal ifTrue:[ |
|
4823 | 6886 |
searchBox := SimpleDialog new. |
3430 | 6887 |
] ifFalse:[ |
4823 | 6888 |
searchBox := ApplicationModel new. |
6889 |
searchBox createBuilder. |
|
3430 | 6890 |
]. |
6891 |
searchBox resources:(self resources). |
|
6892 |
bldr := searchBox builder. |
|
6893 |
bldr addBindings:bindings. |
|
6894 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
6895 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
6896 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
6897 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
6898 |
modal ifTrue:[ |
|
4823 | 6899 |
searchBox openDialog. |
6900 |
searchBox accepted ifTrue:[ |
|
6901 |
action value:flag |
|
6902 |
]. |
|
3430 | 6903 |
] ifFalse:[ |
4823 | 6904 |
(bldr componentAt:#nextButton) isReturnButton:false. |
6905 |
(bldr componentAt:#cancelButton) |
|
6906 |
label:(resources string:'Close'); |
|
6907 |
action:[ searchBox closeRequest ]. |
|
6908 |
||
6909 |
"/ searchBox masterApplication:self application. |
|
6910 |
||
6911 |
self topView beMaster. |
|
6912 |
(searchBox window) |
|
6913 |
beSlave; |
|
6914 |
openInGroup:(self windowGroup). |
|
6915 |
||
6916 |
"/ searchBox window open. |
|
6917 |
||
6918 |
searchBox window assignKeyboardFocusToFirstInputField. |
|
3430 | 6919 |
] |
6920 |
||
6921 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
6922 |
! |
|
6923 |
||
121 | 6924 |
showDeleted |
6925 |
"open a readonly editor on all deleted text" |
|
6926 |
||
6927 |
|v| |
|
6928 |
||
6929 |
v := EditTextView openWith:(Smalltalk at:#DeleteHistory). |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6930 |
v readOnly:true. |
121 | 6931 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6932 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
6933 |
|
3221 | 6934 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 6935 |
"sort/reorder the selected lines. |
6936 |
how: |
|
6937 |
#lines |
|
6938 |
#linesByFirstWord |
|
6939 |
#linesByNthWord |
|
6940 |
#linesByNthNumber |
|
6941 |
#linesByNthHexNumber |
|
6942 |
#words |
|
6943 |
#linesByLength |
|
6944 |
#reverse |
|
6945 |
" |
|
6946 |
||
6947 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 6948 |
|
6949 |
lineWise := true. |
|
6950 |
||
4763 | 6951 |
how == #reverse ifTrue:[ |
6952 |
operation := [:lines | lines reverse]. |
|
6953 |
] ifFalse:[ |
|
6954 |
operation := [:linesOrWords | |
|
6955 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
6956 |
]. |
|
6957 |
||
6958 |
how == #linesByLength ifTrue:[ |
|
6959 |
fetcher := [:l | l size]. |
|
6960 |
] ifFalse:[ |
|
6961 |
how == #lines ifTrue:[ |
|
6962 |
extractor := [:l | l withoutLeadingSeparators]. |
|
6963 |
] ifFalse:[ |
|
6964 |
how == #linesByFirstWord ifTrue:[ |
|
6965 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
6966 |
] ifFalse:[ |
|
6967 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
6968 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
6969 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
6970 |
n := Integer readFrom:nStr onError:[^ self]. |
|
6971 |
LastColumnNumberForSort := n. |
|
6972 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
6973 |
how == #linesByNthNumber ifTrue:[ |
|
6974 |
innerExtractor := extractor. |
|
6975 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
6976 |
] ifFalse:[ |
|
6977 |
how == #linesByNthHexNumber ifTrue:[ |
|
6978 |
innerExtractor := extractor. |
|
6979 |
extractor := [:l | |
|
6980 |
|s| |
|
6981 |
s := innerExtractor value:l. |
|
6982 |
(s startsWith:'16r') ifTrue:[ |
|
6983 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
6984 |
] ifFalse:[ |
|
6985 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
6986 |
] |
|
6987 |
] |
|
4753 | 6988 |
] |
4763 | 6989 |
]. |
6990 |
] ifFalse:[ |
|
6991 |
how == #words ifTrue:[ |
|
6992 |
lineWise := false. |
|
6993 |
extractor := [:w | w]. |
|
6994 |
] ifFalse:[ |
|
6995 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 6996 |
] |
4373 | 6997 |
] |
6998 |
] |
|
4763 | 6999 |
]. |
7000 |
ignoreCase ifTrue:[ |
|
7001 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7002 |
] ifFalse:[ |
|
7003 |
fetcher := extractor. |
|
7004 |
]. |
|
7005 |
]. |
|
3221 | 7006 |
]. |
7007 |
||
7008 |
lineWise ifTrue:[ |
|
4763 | 7009 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7010 |
start == end ifTrue:[^ self ]. |
7011 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7012 |
lines := operation value:lines. |
4373 | 7013 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7014 |
] ifFalse:[ |
7015 |
"process the whole selection as a string" |
|
7016 |
s := self selectionAsString. |
|
7017 |
words := s asCollectionOfWords. |
|
7018 |
words := operation value:words. |
|
7019 |
s := words asStringCollection asStringWith:Character space. |
|
7020 |
self replace:s. |
|
7021 |
]. |
|
3221 | 7022 |
self textChanged. |
4373 | 7023 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7024 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7025 |
! |
7026 |
||
7027 |
sortSelection:how ignoreCase:ignoreCase |
|
7028 |
"sort the selected lines" |
|
7029 |
||
7030 |
|start end| |
|
7031 |
||
7032 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7033 |
||
7034 |
start := selectionStartLine. |
|
7035 |
end := selectionEndLine. |
|
7036 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7037 |
end := end - 1 |
3221 | 7038 |
]. |
7039 |
||
7040 |
self |
|
4373 | 7041 |
undoableDo:[ |
7042 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7043 |
] |
|
3786 | 7044 |
info:'Sort' |
4373 | 7045 |
|
7046 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7047 |
! |
7048 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7049 |
specialCharacters |
2915 | 7050 |
CharacterSetView |
4823 | 7051 |
openAsInputFor:self |
7052 |
label:'Special Character Input' |
|
7053 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7054 |
! |
7055 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7056 |
undoablePaste:someText |
3495 | 7057 |
self undoablePaste:someText info:nil. |
7058 |
||
7059 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7060 |
! |
|
7061 |
||
7062 |
undoablePaste:someText info:infoOrNil |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7063 |
self |
4823 | 7064 |
undoableDo:[ |
7065 |
self paste:someText. |
|
7066 |
] |
|
7067 |
info:infoOrNil |
|
3495 | 7068 |
|
7069 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7070 |
! |
|
7071 |
||
7072 |
undoablePasteOrReplace:someText info:infoOrNil |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7073 |
self |
4823 | 7074 |
undoableDo:[ |
7075 |
self pasteOrReplace:someText. |
|
7076 |
] |
|
7077 |
info:infoOrNil |
|
3495 | 7078 |
|
7079 |
"Created: / 28-07-2007 / 13:26:16 / cg" |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7080 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7081 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7082 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7083 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7084 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7085 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7086 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7087 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7088 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7089 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7090 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7091 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7092 |
|
2724 | 7093 |
withSelfAndTextForPasteDo:aBlock |
7094 |
"common code for paste/replace of the copybuffer" |
|
7095 |
||
7096 |
|sel| |
|
7097 |
||
7098 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7099 |
self flashReadOnly. |
4823 | 7100 |
^ self |
2724 | 7101 |
]. |
7102 |
||
7103 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7104 |
sel notNil ifTrue:[ |
|
4823 | 7105 |
aBlock value:self value:sel. |
2724 | 7106 |
] |
105 | 7107 |
! ! |
7108 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7109 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7110 |
|
3880 | 7111 |
beep |
7112 |
UserPreferences current beepInEditor ifTrue:[ |
|
7113 |
super beep |
|
7114 |
] |
|
7115 |
! |
|
7116 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7117 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7118 |
"check if the text can be modified (i.e. is not readOnly). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7119 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7120 |
This block should be provided by the application or user of the textView, |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7121 |
and may show a warnBox or whatever." |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7122 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7123 |
self isReadOnly ifTrue: [ |
4823 | 7124 |
exceptionBlock isNil ifTrue:[ |
7125 |
^ false |
|
7126 |
]. |
|
7127 |
||
7128 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7129 |
^ false |
|
7130 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7131 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7132 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7133 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7134 |
"Modified: / 17.6.1998 / 15:51:10 / cg" |
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7135 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7136 |
|
2596 | 7137 |
currentSelectionBgColor |
7138 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7139 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7140 |
]. |
7141 |
^ super currentSelectionBgColor |
|
7142 |
||
7143 |
" |
|
7144 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7145 |
" |
|
7146 |
! |
|
7147 |
||
7148 |
currentSelectionFgColor |
|
7149 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7150 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7151 |
]. |
7152 |
^ super currentSelectionFgColor |
|
7153 |
! |
|
7154 |
||
3996 | 7155 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7156 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7157 |
|
7158 |
super resetVariablesBeforeNewSearch. |
|
7159 |
||
7160 |
"/ new search invalidates remembered string |
|
4048 | 7161 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7162 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7163 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7164 |
! |
7165 |
||
4053 | 7166 |
setLastStringToReplace: aString |
7167 |
||
7168 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7169 |
||
7170 |
|lastReplaceIgnoredCase| |
|
7171 |
||
4064 | 7172 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7173 |
self clearSearchAction. |
|
7174 |
||
4053 | 7175 |
lastReplacementInfo lastStringToReplace: aString. |
7176 |
lastStringFromReplaceForNextSearch := aString. |
|
7177 |
||
7178 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7179 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7180 |
ifTrue: [lastSearchIgnoredCase] |
|
7181 |
ifFalse: [nil]. |
|
4053 | 7182 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7183 |
! |
|
7184 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7185 |
st80EditMode |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7186 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7187 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7188 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7189 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7190 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7191 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7192 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7193 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7194 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7195 |
textChanged |
522 | 7196 |
"my text was modified (internally). |
7197 |
Sent whenever text has been edited (not to confuse with |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7198 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7199 |
is used to notify scrollers, other views etc.). |
7200 |
||
7201 |
As some authors of this code have been very sloppy in tha past |
|
7202 |
(not sending contentsChanged, but textChanged), |
|
7203 |
we do it here despite what is written above, to ensure that scrollers update correctly." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7204 |
|
641 | 7205 |
self contentsChanged. |
1015 | 7206 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7207 |
contentsWasSaved := false |
641 | 7208 |
|
1015 | 7209 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7210 |
! |
7211 |
||
2617 | 7212 |
textChangedButNoSizeChange |
2207 | 7213 |
"my text was modified (internally). |
7214 |
Sent whenever text has been edited (not to confuse with |
|
7215 |
contentsChanged, which is triggered when the size has changed, and |
|
7216 |
is used to notify scrollers, other views etc.)" |
|
7217 |
||
7218 |
self modified:true. |
|
7219 |
contentsWasSaved := false |
|
7220 |
||
7221 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7222 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7223 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7224 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7225 |
|
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7226 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7227 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7228 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7229 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7230 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7231 |
"Created: / 17.5.1998 / 20:07:52 / cg" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7232 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7233 |
|
4064 | 7234 |
hasSearchActionSelection |
7235 |
||
7236 |
^ typeOfSelection == #searchAction |
|
7237 |
! |
|
7238 |
||
1878 | 7239 |
isKeyboardConsumer |
7240 |
"return true, if the receiver is a keyboard consumer; |
|
7241 |
Return true here, redefined from SimpleView." |
|
7242 |
||
3476 | 7243 |
^ self isReadOnly not |
1878 | 7244 |
! |
7245 |
||
997 | 7246 |
specClass |
1390 | 7247 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7248 |
||
997 | 7249 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7250 |
^ super specClass |
7251 |
||
1390 | 7252 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7253 |
! |
7254 |
||
324 | 7255 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7256 |
"return true, if a Tab character should shift focus." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7257 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7258 |
"if not readOnly, I want my tab keys ..." |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7259 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7260 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7261 |
|
7262 |
"Created: 7.2.1996 / 19:15:31 / cg" |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7263 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7264 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7265 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7266 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7267 |
Redefined to add the size of a space (for the cursor). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7268 |
this enables us to scroll one position further than the longest |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7269 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7270 |
|
697 | 7271 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7272 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7273 |
w := super widthOfContents. |
4889 | 7274 |
(dev := self graphicsDevice ) isNil ifTrue:[ |
7275 |
"/ really don't know ... |
|
4823 | 7276 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7277 |
]. |
4889 | 7278 |
^ w + (gc font widthOn:dev) |
697 | 7279 |
|
7280 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7281 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7282 |
|
1588 | 7283 |
!EditTextView methodsFor:'realization'! |
7284 |
||
7285 |
realize |
|
7286 |
"make the view visible - scroll to make the cursor visible." |
|
7287 |
||
7288 |
super realize. |
|
7289 |
||
7290 |
self makeCursorVisible. |
|
4940 | 7291 |
cursorFgColor := cursorFgColor onDevice:self graphicsDevice. |
7292 |
cursorBgColor := cursorBgColor onDevice:self graphicsDevice. |
|
1588 | 7293 |
|
7294 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7295 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7296 |
! ! |
|
7297 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7298 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7299 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7300 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7301 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7302 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7303 |
cursorShown ifTrue:[ |
4823 | 7304 |
cursorVisibleLine notNil ifTrue:[ |
7305 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7306 |
self drawCursorCharacter |
|
7307 |
] |
|
7308 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7309 |
] |
105 | 7310 |
! |
7311 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7312 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7313 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7314 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7315 |
cursorShown ifTrue:[ |
4823 | 7316 |
(visLine == cursorVisibleLine) ifTrue:[ |
7317 |
self drawCursorCharacter |
|
7318 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7319 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7320 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7321 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7322 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7323 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7324 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7325 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7326 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7327 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7328 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7329 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7330 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7331 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7332 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7333 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7334 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7335 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7336 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7337 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7338 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7339 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7340 |
cursorShown ifTrue:[ |
4823 | 7341 |
(visLine == cursorVisibleLine) ifTrue:[ |
7342 |
(colNr == cursorCol) ifTrue:[ |
|
7343 |
self drawCursorCharacter. |
|
7344 |
^ self |
|
7345 |
] |
|
7346 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7347 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7348 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7349 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7350 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7351 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7352 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7353 |
"redraw a visible line from startCol to the end of line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7354 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7355 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7356 |
cursorShown ifTrue:[ |
7357 |
self redrawCursorIfInVisibleLine:visLine |
|
7358 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7359 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7360 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7361 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7362 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7363 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7364 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7365 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7366 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7367 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7368 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7369 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7370 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7371 |
"return the number of pixels by which we may scroll more than the actual |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7372 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7373 |
This is redefined by editable textViews, to allo for the cursor |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7374 |
to be visible if it is positioned right behind the longest line of text. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7375 |
The default returned here is 10 pixels, which should be ok for most cursors" |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7376 |
|
4889 | 7377 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7378 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7379 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7380 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7381 |
"half a page down - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7382 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7383 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7384 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7385 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7386 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7387 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7388 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7389 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7390 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7391 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7392 |
"half a page up - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7393 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7394 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7395 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7396 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7397 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7398 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7399 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7400 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7401 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7402 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7403 |
"sent after scrolling - have to show the cursor if it was on before" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7404 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7405 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7406 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7407 |
should we move the cursor with the scroll - or leave it ? |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7408 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7409 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7410 |
prevCursorState ifTrue:[ |
4823 | 7411 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7412 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7413 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7414 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7415 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7416 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7417 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7418 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7419 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7420 |
prevCursorState := cursorShown. |
1601 | 7421 |
"/ cursorShown := false. |
1591 | 7422 |
cursorShown ifTrue:[ |
4823 | 7423 |
self hideCursor |
1591 | 7424 |
] |
7425 |
||
1601 | 7426 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7427 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7428 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7429 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7430 |
"page down - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7431 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7432 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7433 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7434 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7435 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7436 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7437 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7438 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7439 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7440 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7441 |
"page up - to keep cursor on same visible line, it has to be moved |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7442 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7443 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7444 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7445 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7446 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7447 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7448 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7449 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7450 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7451 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7452 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7453 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7454 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7455 |
|
2822 | 7456 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 7457 |
! |
7458 |
||
7459 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
7460 |
"do a backward search" |
|
7461 |
||
7462 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
7463 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 7464 |
! |
7465 |
||
7466 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7467 |
"do a backward search" |
|
7468 |
||
7469 |
cursorLine isNil ifTrue:[^ self]. |
|
7470 |
||
3160 | 7471 |
self |
4119 | 7472 |
searchBackwardFor:pattern |
7473 |
ignoreCase:ign |
|
7474 |
startingAtLine:startLine col:startCol |
|
7475 |
ifFound:[:line :col | |
|
7476 |
self cursorMovementAllowed ifTrue:[ |
|
7477 |
self cursorLine:line col:col. |
|
7478 |
]. |
|
7479 |
self showMatch:pattern isMatch:false atLine:line col:col. |
|
1339 | 7480 |
"/ self makeLineVisible:cursorLine |
4119 | 7481 |
typeOfSelection := #search] |
7482 |
ifAbsent:aBlock |
|
1339 | 7483 |
|
7484 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7485 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7486 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7487 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7488 |
"select characters enclosed by matching parenthesis if one is under cusor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7489 |
|
2554 | 7490 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7491 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7492 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7493 |
searchForMatchingParenthesis |
3160 | 7494 |
"search for a matching parenthesis starting at cursor position. |
7495 |
Search for the corresponding character is done forward if its an opening, |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7496 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7497 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7498 |
|
2822 | 7499 |
self cursorMovementAllowed ifFalse:[^ self]. |
7500 |
||
3160 | 7501 |
self |
4823 | 7502 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
7503 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
7504 |
ifNotFound:[self showNotFound] |
|
7505 |
onError:[self beep] |
|
1339 | 7506 |
|
7507 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7508 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7509 |
|
3967 | 7510 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 7511 |
"do a forward search" |
7512 |
||
7513 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 7514 |
self |
7515 |
searchForwardFor:pattern |
|
7516 |
ignoreCase:ign |
|
7517 |
match: match |
|
7518 |
startingAtLine:startLine col:startCol |
|
7519 |
ifFound:[:line :col | |
|
7520 |
self cursorMovementAllowed ifTrue:[ |
|
7521 |
self cursorLine:line col:col. |
|
7522 |
]. |
|
4119 | 7523 |
self showMatch:pattern isMatch:match atLine:line col:col. |
1339 | 7524 |
"/ self makeLineVisible:cursorLine |
3967 | 7525 |
typeOfSelection := #search |
7526 |
] |
|
7527 |
ifAbsent:aBlock |
|
1339 | 7528 |
|
7529 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
7530 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7531 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7532 |
|
3967 | 7533 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
7534 |
"do a forward search" |
|
7535 |
||
7536 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7537 |
! |
|
7538 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7539 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7540 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7541 |
|
2822 | 7542 |
self searchFwd:pattern ignoreCase:false startingAtLine:startLine col:startCol ifAbsent:aBlock |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7543 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7544 |
|
3982 | 7545 |
searchPatternForSearchBar |
7546 |
||
7547 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
7548 |
||
7549 |
|searchPattern| |
|
7550 |
||
4138 | 7551 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 7552 |
searchPattern isNil |
7553 |
ifTrue: [searchPattern := lastSearchPattern] |
|
7554 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
7555 |
^ searchPattern |
|
7556 |
! |
|
7557 |
||
3578 | 7558 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7559 |
"set the searchpattern from the selection if there is one, and position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7560 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7561 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7562 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7563 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7564 |
"/ |
3967 | 7565 |
"/ if the last operation was a replace, set pattern to last |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7566 |
"/ original string (for search after again) |
4121 | 7567 |
"/ for cut or delete actions allow lastReplacement with nil |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7568 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7569 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7570 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7571 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7572 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7573 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7574 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7575 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7576 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7577 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7578 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7579 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7580 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7581 |
"/ if there was no previous search, take it as search pattern. |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7582 |
"/ if there was a previous search, only take the selection if |
3967 | 7583 |
"/ it did not result from a paste or from the last search itself. |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7584 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7585 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7586 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7587 |
sel notNil ifTrue:[ |
3967 | 7588 |
(lastSearchPattern isNil |
4484 | 7589 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
7590 |
) ifTrue:[ |
|
3967 | 7591 |
self cursorLine:selectionStartLine col:selectionStartCol. |
7592 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
7593 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
7594 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7595 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7596 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7597 |
"Modified: / 07-05-2011 / 17:25:59 / cg" |
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7598 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7599 |
|
4484 | 7600 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
7601 |
super showMatch:pattern isMatch:isMatch atLine:line col:col. |
|
7602 |
typeOfSelection := #search. |
|
7603 |
! |
|
7604 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7605 |
startPositionForSearchBackward |
2822 | 7606 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
7607 |
! |
|
7608 |
||
7609 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7610 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7611 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7612 |
selectionStartLine notNil ifTrue:[ |
4823 | 7613 |
startLine := selectionStartLine. |
7614 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7615 |
] ifFalse:[ |
4823 | 7616 |
cursorLine isNil ifTrue:[ |
7617 |
startLine := list size. |
|
7618 |
startCol := self listAt:startLine size. |
|
7619 |
] ifFalse:[ |
|
7620 |
startLine := cursorLine min:list size. |
|
7621 |
startCol := cursorCol |
|
7622 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7623 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7624 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7625 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7626 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7627 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7628 |
startPositionForSearchForward |
2822 | 7629 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
7630 |
! |
|
7631 |
||
7632 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7633 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7634 |
|
3160 | 7635 |
"/ if there is no selection and the cursor is at the origin, |
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7636 |
"/ assume its the first search and do not skip the very first match |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7637 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7638 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7639 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7640 |
] ifFalse:[ |
4064 | 7641 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
7642 |
startCol := 0 |
|
7643 |
]. |
|
7644 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7645 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7646 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7647 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7648 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7649 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7650 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7651 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7652 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7653 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7654 |
addToSelectionAfter:aBlock |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7655 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7656 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7657 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7658 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7659 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7660 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7661 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7662 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7663 |
self hasSelection ifTrue: [ |
4823 | 7664 |
startLine := selectionStartLine . |
7665 |
startCol := selectionStartCol . |
|
7666 |
endLine := selectionEndLine . |
|
7667 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7668 |
] ifFalse: [ |
4823 | 7669 |
startLine := endLine := cursorLine . |
7670 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7671 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7672 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7673 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7674 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7675 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7676 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7677 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7678 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
4823 | 7679 |
ifTrue: [ |
7680 |
startCol := cursorCol. |
|
7681 |
] ifFalse: [ |
|
7682 |
endCol := cursorCol - 1. |
|
7683 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7684 |
self selectFromLine:startLine col:startCol toLine: endLine col:endCol . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7685 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7686 |
|
1850 | 7687 |
autoMoveCursorToEndOfSelection |
7688 |
"return true, if the cursor should be automatically moved to the |
|
7689 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
7690 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 7691 |
not be affected by selecting" |
7692 |
||
7693 |
^ true |
|
7694 |
! |
|
7695 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7696 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7697 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 7698 |
typeOfSelection := newType. |
7699 |
selectionStartLine notNil ifTrue:[ |
|
7700 |
self |
|
7701 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
7702 |
toLine:selectionEndLine col:selectionEndCol |
|
7703 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7704 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7705 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7706 |
|
4707 | 7707 |
findNextWordAfterSelectionAndAddToSelection |
7708 |
|selStartCol selStartLine selEndCol selEndLine| |
|
7709 |
||
7710 |
selectionStartCol isNil ifTrue:[ |
|
7711 |
self selectWordUnderCursor. |
|
7712 |
^ self |
|
7713 |
]. |
|
7714 |
||
7715 |
selStartCol := selectionStartCol. |
|
7716 |
selEndCol := selectionEndCol. |
|
7717 |
selStartLine := selectionStartLine. |
|
7718 |
selEndLine := selectionEndLine. |
|
7719 |
||
7720 |
self cursorToNextWord. |
|
7721 |
self selectWordUnderCursor. |
|
7722 |
||
7723 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
7724 |
! |
|
7725 |
||
4138 | 7726 |
searchPatternFromUserSelectionOrReplace |
7727 |
||
7728 |
|sel searchPattern| |
|
7729 |
||
7730 |
"/ |
|
7731 |
"/ if the last operation was a replace, set pattern to last |
|
7732 |
"/ original string (for search after again) |
|
7733 |
"/ |
|
7734 |
(lastStringFromReplaceForNextSearch notNil |
|
7735 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
7736 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
7737 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
7738 |
] ifFalse:[ |
|
7739 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
7740 |
]. |
|
7741 |
^ searchPattern |
|
7742 |
]. |
|
7743 |
||
7744 |
"/ |
|
7745 |
"/ if there is a selection: |
|
7746 |
"/ if there was no previous search, take it as search pattern. |
|
7747 |
"/ if there was a previous search, only take the selection if |
|
7748 |
"/ it did not result from a paste. |
|
7749 |
"/ (to allow search-paste to be repeated) |
|
7750 |
"/ |
|
7751 |
sel := self selection. |
|
7752 |
sel notNil ifTrue:[ |
|
7753 |
typeOfSelection ~~ #search ifTrue:[ |
|
7754 |
typeOfSelection ~~ #paste ifTrue:[ |
|
7755 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
7756 |
searchPattern := sel asStringWithoutFinalCR. |
|
7757 |
] |
|
7758 |
]. |
|
7759 |
]. |
|
7760 |
||
7761 |
^ searchPattern |
|
7762 |
! |
|
7763 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7764 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7765 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7766 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7767 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7768 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7769 |
list isNil ifTrue:[ |
4823 | 7770 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7771 |
] ifFalse:[ |
4823 | 7772 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
7773 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7774 |
] |
1082 | 7775 |
|
7776 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7777 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7778 |
|
4117 | 7779 |
selectAllInitially |
7780 |
"select the whole text. This is called only once during the initialization |
|
7781 |
for editFields which are shown in a table or tree. |
|
7782 |
The selectAll is called via this method to allow for easier redefinition and |
|
7783 |
to distinguish auto-select from user-initiated selects." |
|
7784 |
||
7785 |
self selectAll |
|
7786 |
! |
|
7787 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7788 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7789 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7790 |
|
3160 | 7791 |
self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7792 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7793 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7794 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7795 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7796 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7797 |
cursorCol > 1 ifTrue:[ |
4823 | 7798 |
self selectFromLine:cursorLine col:1 |
7799 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7800 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7801 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
7802 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7803 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7804 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7805 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7806 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7807 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7808 |
selectionStartLine isNil ifTrue:[ |
4823 | 7809 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7810 |
] ifFalse:[ |
4823 | 7811 |
self selectFromLine:selectionStartLine col:selectionStartCol |
7812 |
toLine:cursorLine+1 col:0. |
|
7813 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7814 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7815 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7816 |
|
4257 | 7817 |
selectFromBeginOfLine |
7818 |
"select the text from the beginning of the current line to the current cursor position." |
|
7819 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7820 |
| newCursorCol ln | |
4271 | 7821 |
|
4257 | 7822 |
list isNil ifTrue:[ |
7823 |
self unselect |
|
7824 |
] ifFalse:[ |
|
7825 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7826 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7827 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 7828 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
7829 |
cursorCol := newCursorCol. |
|
4257 | 7830 |
typeOfSelection := nil |
7831 |
] |
|
7832 |
] |
|
7833 |
||
7834 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
7835 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7836 |
! |
7837 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7838 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7839 |
"select the text from the beginning to the current cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7840 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7841 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7842 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7843 |
list isNil ifTrue:[ |
4823 | 7844 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7845 |
] ifFalse:[ |
4823 | 7846 |
cursorCol == 0 ifTrue:[ |
7847 |
col := 0 |
|
7848 |
] ifFalse:[ |
|
7849 |
col := cursorCol - 1 |
|
7850 |
]. |
|
7851 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
7852 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7853 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7854 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7855 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7856 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7857 |
"when a range is selected, position the cursor behind the selection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7858 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7859 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7860 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 7861 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
4823 | 7862 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 7863 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7864 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7865 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7866 |
|
4257 | 7867 |
selectToEndOfLine |
7868 |
"select the text from the current cursor position to the end of the current line" |
|
7869 |
||
4271 | 7870 |
| newCursorCol line | |
7871 |
||
4257 | 7872 |
list isNil ifTrue:[ |
7873 |
self unselect |
|
7874 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
7875 |
cursorCol >= 1 ifTrue:[ |
4271 | 7876 |
line := list at: cursorLine. |
7877 |
newCursorCol := line size. |
|
7878 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
7879 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
7880 |
||
7881 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
7882 |
cursorCol := newCursorCol. |
|
4257 | 7883 |
typeOfSelection := nil |
7884 |
] |
|
7885 |
] |
|
7886 |
||
7887 |
"Created: / 28-06-2011 / 23:07:07 / cg" |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
7888 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 7889 |
! |
7890 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7891 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7892 |
"select the text from the current cursor position to the end." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7893 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7894 |
list isNil ifTrue:[ |
4823 | 7895 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7896 |
] ifFalse:[ |
4823 | 7897 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
7898 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7899 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7900 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7901 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7902 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7903 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7904 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7905 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7906 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7907 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7908 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7909 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7910 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7911 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7912 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7913 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7914 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7915 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7916 |
wasOn ifTrue:[self showCursor] |
105 | 7917 |
! ! |
7918 |
||
7919 |
!EditTextView methodsFor:'undo & again'! |
|
7920 |
||
2952 | 7921 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7922 |
^ undoSupport addUndo:action. |
2952 | 7923 |
! |
7924 |
||
105 | 7925 |
again |
7926 |
"repeat the last action (which was a cut or replace). |
|
7927 |
If current selection is not last string, search forward to |
|
3160 | 7928 |
next occurrence of it before repeating the last operation." |
105 | 7929 |
|
4048 | 7930 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 7931 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 7932 |
|
7933 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 7934 |
lastStringToReplace isNil ifTrue:[ |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7935 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
7936 |
]. |
4048 | 7937 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
7938 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
7939 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
7940 |
self undoableDo:[ |
4010 | 7941 |
s := lastStringToReplace asString. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7942 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
7943 |
(s endsWith:Character cr) ifTrue:[s := s copyButLast:1]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
7944 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 7945 |
|
4053 | 7946 |
"set lastStringToReplace as the next search string |
7947 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 7948 |
lastStringFromReplaceForNextSearch := s. |
4053 | 7949 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 7950 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7951 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7952 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7953 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7954 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7955 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7956 |
"if we are already there (after a find), ommit search" |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7957 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7958 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7959 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7960 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7961 |
self deleteSelection. |
4051 | 7962 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
7963 |
self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false. |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7964 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 7965 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7966 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7967 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7968 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7969 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7970 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7971 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7972 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7973 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7974 |
startColForSearch := selectionEndCol ? (cursorCol - 1) |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7975 |
]. |
4048 | 7976 |
self |
7977 |
searchForwardFor:s |
|
7978 |
ignoreCase: lastReplaceIgnoredCase |
|
7979 |
match: lastReplaceWasMatch |
|
7980 |
startingAtLine:cursorLine col:startColForSearch |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7981 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7982 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7983 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7984 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7985 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7986 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7987 |
self selectFromLine:line col:col |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7988 |
toLine:line col:(col + s size - 1). |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7989 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7990 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7991 |
self deleteSelection. |
4051 | 7992 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
7993 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
7994 |
repl := lastReplacementInfo lastReplacement asString "withoutSpaces" |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7995 |
] ifTrue:[ |
4051 | 7996 |
repl := lastReplacementInfo lastReplacement "withoutSpaces". |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7997 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7998 |
self insertLines:repl asStringCollection withCR:false. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
7999 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8000 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8001 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8002 |
selectStyle := savedSelectStyle. |
4484 | 8003 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8004 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8005 |
] |
4048 | 8006 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8007 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8008 |
self sensor compressKeyPressEventsWithKey:#Again. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8009 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8010 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8011 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8012 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8013 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8014 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8015 |
^ true. |
501 | 8016 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8017 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8018 |
! |
8019 |
||
2952 | 8020 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8021 |
^ undoSupport hasRedoAction. |
2952 | 8022 |
! |
8023 |
||
8024 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8025 |
^ undoSupport hasUndoAction. |
2952 | 8026 |
! |
8027 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8028 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8029 |
"repeat the last action (which was a cut or replace) until search fails" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8030 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8031 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8032 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8033 |
|
2952 | 8034 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8035 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8036 |
! |
8037 |
||
8038 |
redo |
|
3780 | 8039 |
"undo the last undo" |
8040 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8041 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8042 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8043 |
] ifTrue:[ |
3780 | 8044 |
undoSupport redo. |
2952 | 8045 |
] |
8046 |
! |
|
8047 |
||
121 | 8048 |
undo |
3780 | 8049 |
"undo the last edit operation" |
8050 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8051 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 8052 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8053 |
] ifTrue:[ |
3780 | 8054 |
undoSupport undo. |
121 | 8055 |
] |
2952 | 8056 |
! |
8057 |
||
8058 |
undoableDo:aBlock |
|
3495 | 8059 |
self undoableDo:aBlock info:nil. |
8060 |
||
8061 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8062 |
! |
8063 |
||
8064 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8065 |
self checkModificationsAllowed ifFalse:[ |
4823 | 8066 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8067 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8068 |
] ifTrue:[ |
4823 | 8069 |
undoSupport undoableDo:aBlock info:aString. |
3495 | 8070 |
]. |
8071 |
||
8072 |
"Modified: / 28-07-2007 / 13:21:00 / cg" |
|
2952 | 8073 |
! ! |
8074 |
||
8075 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8076 |
||
8077 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8078 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8079 |
! |
|
8080 |
||
3115 | 8081 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8082 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8083 |
! |
8084 |
||
2952 | 8085 |
line:arg1 col:arg2 character:arg3 |
8086 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8087 |
! |
|
8088 |
||
3115 | 8089 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8090 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8091 |
! |
8092 |
||
3235 | 8093 |
line:arg1 col:arg2 characters:arg3 info:info |
8094 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8095 |
! |
|
8096 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8097 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8098 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8099 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8100 |
|
2952 | 8101 |
line:arg1 col:arg2 string:arg3 |
8102 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8103 |
! |
8104 |
||
8105 |
line:arg1 col:arg2 string:arg3 info:info |
|
8106 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8107 |
! |
8108 |
||
8109 |
line:arg1 string:arg3 info:info |
|
8110 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8111 |
! |
8112 |
||
8113 |
text:arg info:info |
|
8114 |
^ (self new text:arg) info:info |
|
3115 | 8115 |
! ! |
8116 |
||
8117 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8118 |
||
8119 |
info |
|
8120 |
^ userFriendlyInfo |
|
8121 |
! |
|
8122 |
||
8123 |
info:aString |
|
8124 |
userFriendlyInfo := aString |
|
2952 | 8125 |
! ! |
8126 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8127 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8128 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8129 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8130 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8131 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8132 |
"Created: / 25-09-2006 / 12:16:25 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8133 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8134 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8135 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8136 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8137 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8138 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8139 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8140 |
|
2952 | 8141 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8142 |
||
3160 | 8143 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8144 |
"set instance variables (automatically generated)" |
8145 |
||
8146 |
self assert:(line1Arg notNil). |
|
8147 |
self assert:(col1Arg notNil). |
|
8148 |
self assert:(line2Arg notNil). |
|
8149 |
self assert:(col2Arg notNil). |
|
8150 |
||
8151 |
line1 := line1Arg. |
|
8152 |
col1 := col1Arg. |
|
8153 |
line2 := line2Arg. |
|
8154 |
col2 := col2Arg. |
|
8155 |
! ! |
|
8156 |
||
8157 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8158 |
||
3160 | 8159 |
executeIn:editor |
2952 | 8160 |
editor unselect. |
3160 | 8161 |
editor |
4823 | 8162 |
deleteFromLine:line1 |
8163 |
col:col1 |
|
8164 |
toLine:line2 |
|
8165 |
col:col2. |
|
2952 | 8166 |
editor cursorLine:line1 col:col1. |
8167 |
! ! |
|
8168 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8169 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8170 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8171 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8172 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8173 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8174 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8175 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8176 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8177 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8178 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8179 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8180 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8181 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8182 |
|
3160 | 8183 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8184 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8185 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8186 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8187 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8188 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8189 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8190 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8191 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8192 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8193 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8194 |
|
3160 | 8195 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8196 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8197 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8198 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8199 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8200 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8201 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8202 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8203 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8204 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8205 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8206 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8207 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8208 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8209 |
|
3160 | 8210 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8211 |
"I will combine only if we both are single character deletes, |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8212 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8213 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8214 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8215 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8216 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8217 |
^ true |
|
8218 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8219 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8220 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8221 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8222 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8223 |
|
3160 | 8224 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8225 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8226 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8227 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8228 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8229 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8230 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8231 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8232 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8233 |
|
3160 | 8234 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8235 |
editor unselect. |
3160 | 8236 |
editor |
4823 | 8237 |
deleteFromLine:line |
8238 |
col:col1 |
|
8239 |
toLine:line |
|
8240 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8241 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8242 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8243 |
|
3235 | 8244 |
!EditTextView::EditMode class methodsFor:'constants'! |
8245 |
||
8246 |
insertAndSelectMode |
|
8247 |
^ InsertAndSelectMode |
|
8248 |
! |
|
8249 |
||
8250 |
insertMode |
|
8251 |
^ InsertMode |
|
8252 |
! |
|
8253 |
||
8254 |
overwriteMode |
|
8255 |
^ OverwriteMode |
|
8256 |
! ! |
|
8257 |
||
8258 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8259 |
||
8260 |
isInsertAndSelectMode |
|
8261 |
^ false |
|
8262 |
! |
|
8263 |
||
8264 |
isInsertMode |
|
8265 |
^ false |
|
8266 |
! |
|
8267 |
||
8268 |
symbolicName |
|
8269 |
self subclassResponsibility |
|
8270 |
! ! |
|
8271 |
||
8272 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8273 |
||
8274 |
infoPrintString |
|
8275 |
^ 'IS' |
|
8276 |
! ! |
|
8277 |
||
8278 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8279 |
||
8280 |
isInsertAndSelectMode |
|
8281 |
^ true |
|
8282 |
! |
|
8283 |
||
8284 |
isInsertMode |
|
8285 |
^ true |
|
8286 |
! ! |
|
8287 |
||
8288 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8289 |
||
8290 |
infoPrintString |
|
8291 |
^ 'I' |
|
8292 |
! ! |
|
8293 |
||
8294 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8295 |
||
8296 |
isInsertMode |
|
8297 |
^ true |
|
8298 |
! ! |
|
8299 |
||
8300 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8301 |
||
8302 |
infoPrintString |
|
8303 |
^ 'O' |
|
8304 |
! ! |
|
8305 |
||
4048 | 8306 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8307 |
||
8308 |
lastReplaceIgnoredCase |
|
8309 |
^ lastReplaceIgnoredCase ? false |
|
8310 |
! |
|
8311 |
||
8312 |
lastReplaceIgnoredCase:something |
|
8313 |
lastReplaceIgnoredCase := something. |
|
8314 |
! |
|
8315 |
||
8316 |
lastReplaceWasMatch |
|
8317 |
^ lastReplaceWasMatch ? false |
|
8318 |
! |
|
8319 |
||
8320 |
lastReplaceWasMatch:something |
|
8321 |
lastReplaceWasMatch := something. |
|
8322 |
! |
|
8323 |
||
8324 |
lastReplacement |
|
8325 |
^ lastReplacement |
|
8326 |
! |
|
8327 |
||
8328 |
lastReplacement:something |
|
4053 | 8329 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8330 |
lastReplacement := something. |
8331 |
! |
|
8332 |
||
8333 |
lastStringToReplace |
|
8334 |
^ lastStringToReplace |
|
8335 |
! |
|
8336 |
||
8337 |
lastStringToReplace:something |
|
8338 |
lastStringToReplace := something. |
|
4818 | 8339 |
! |
8340 |
||
8341 |
previousReplacements |
|
8342 |
^ previousReplacements ? #() |
|
8343 |
! |
|
8344 |
||
8345 |
stillCollectingInput |
|
8346 |
^ stillCollectingInput |
|
8347 |
! |
|
8348 |
||
8349 |
stillCollectingInput:aBoolean |
|
8350 |
stillCollectingInput := aBoolean. |
|
8351 |
! ! |
|
8352 |
||
8353 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
8354 |
||
8355 |
rememberReplacement |
|
8356 |
"remember the previous replacement (called when a new one appears). |
|
8357 |
Mostly for the benefit of the code completion..." |
|
8358 |
||
8359 |
|oldString newString| |
|
8360 |
||
8361 |
oldString := lastStringToReplace. |
|
8362 |
newString := lastReplacement. |
|
8363 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
8364 |
previousReplacements isNil ifTrue:[ |
|
8365 |
previousReplacements := OrderedCollection new. |
|
8366 |
]. |
|
8367 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
8368 |
previousReplacements addFirst:(oldString -> newString). |
|
8369 |
previousReplacements size > 20 ifTrue:[ |
|
8370 |
previousReplacements removeLast. |
|
8371 |
] |
|
8372 |
]. |
|
4048 | 8373 |
! ! |
8374 |
||
2952 | 8375 |
!EditTextView::PasteString methodsFor:'accessing'! |
8376 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8377 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8378 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8379 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8380 |
"Created: / 25-09-2006 / 12:19:59 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8381 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8382 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8383 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8384 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8385 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8386 |
"Created: / 25-09-2006 / 12:20:18 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8387 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8388 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8389 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8390 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8391 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8392 |
"Created: / 25-09-2006 / 12:21:08 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8393 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8394 |
|
3160 | 8395 |
line:lineArg col:colArg string:stringArg |
2952 | 8396 |
self assert:(lineArg notNil). |
8397 |
self assert:(colArg notNil). |
|
8398 |
self assert:(stringArg notNil). |
|
8399 |
||
8400 |
line := lineArg. |
|
8401 |
col := colArg. |
|
8402 |
string := stringArg. |
|
8403 |
! |
|
8404 |
||
8405 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
8406 |
self assert:(lineArg notNil). |
|
8407 |
self assert:(colArg notNil). |
|
8408 |
self assert:(stringArg notNil). |
|
8409 |
||
8410 |
line := lineArg. |
|
8411 |
col := colArg. |
|
8412 |
string := stringArg. |
|
8413 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8414 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8415 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8416 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8417 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8418 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8419 |
"Created: / 25-09-2006 / 12:25:59 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8420 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8421 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8422 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8423 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8424 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8425 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8426 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8427 |
"Created: / 25-09-2006 / 12:15:59 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8428 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8429 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8430 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8431 |
"I will combine only if we both are single character inserts, |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8432 |
and my col-to-insert is the next after anotherInsertActions end-col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8433 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8434 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8435 |
previousPasteAction line == line ifTrue:[ |
4823 | 8436 |
previousPasteAction col == (self col2+1) ifTrue:[ |
8437 |
^ true |
|
8438 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8439 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8440 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8441 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8442 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8443 |
"Modified: / 25-09-2006 / 12:22:21 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8444 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8445 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8446 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8447 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8448 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8449 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8450 |
self assert:((col - 1) == (nextPasteAction col2)). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8451 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8452 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8453 |
s1 isString ifFalse:[s1 := s1 asStringWith:nil]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8454 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8455 |
s2 isString ifFalse:[s2 := s2 asStringWith:nil]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8456 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8457 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8458 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8459 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8460 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8461 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 8462 |
! ! |
8463 |
||
8464 |
!EditTextView::PasteString methodsFor:'execution'! |
|
8465 |
||
3160 | 8466 |
executeIn:editor |
2952 | 8467 |
editor cursorLine:line col:col. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8468 |
editor paste:string. |
2952 | 8469 |
selected ~~ true ifTrue:[ |
4823 | 8470 |
editor unselect |
2952 | 8471 |
]. |
8472 |
! ! |
|
8473 |
||
8474 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
8475 |
||
3235 | 8476 |
col |
8477 |
^ col |
|
8478 |
! |
|
8479 |
||
8480 |
col1 |
|
8481 |
^ col |
|
8482 |
! |
|
8483 |
||
8484 |
col2 |
|
8485 |
^ col |
|
8486 |
! |
|
8487 |
||
8488 |
line |
|
8489 |
^ line |
|
8490 |
! |
|
8491 |
||
3160 | 8492 |
line:lineArg col:colArg character:characterArg |
2952 | 8493 |
line := lineArg. |
8494 |
col := colArg. |
|
8495 |
character := characterArg. |
|
8496 |
! ! |
|
8497 |
||
8498 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
8499 |
||
3160 | 8500 |
executeIn:editor |
8501 |
editor |
|
4823 | 8502 |
replace:character |
8503 |
atLine:line |
|
8504 |
col:col. |
|
2952 | 8505 |
editor cursorLine:line col:col. |
105 | 8506 |
! ! |
8507 |
||
3235 | 8508 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
8509 |
||
8510 |
characters |
|
8511 |
^ characters |
|
8512 |
! |
|
8513 |
||
8514 |
col1 |
|
8515 |
^ col1 |
|
8516 |
! |
|
8517 |
||
8518 |
col2 |
|
8519 |
^ col2 |
|
8520 |
! |
|
8521 |
||
8522 |
line |
|
8523 |
^ line |
|
8524 |
! |
|
8525 |
||
8526 |
line:lineArg col:colArg character:characterArg |
|
8527 |
line := lineArg. |
|
8528 |
col1 := col2 := colArg. |
|
8529 |
characters := characterArg asString. |
|
8530 |
! |
|
8531 |
||
8532 |
line:lineArg col:colArg characters:charactersArg |
|
8533 |
line := lineArg. |
|
8534 |
col1 := colArg. |
|
8535 |
characters := charactersArg asString. |
|
8536 |
col2 := col1 + charactersArg size - 1 |
|
8537 |
! ! |
|
8538 |
||
8539 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
8540 |
||
8541 |
canCombineWithNext:anotherAction |
|
8542 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
8543 |
! |
|
8544 |
||
8545 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
8546 |
"I will combine only if we both are single character deletes, |
|
8547 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
8548 |
(i.e. single-character typing)" |
|
8549 |
||
8550 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 8551 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
8552 |
^ true |
|
8553 |
]. |
|
3235 | 8554 |
]. |
8555 |
||
8556 |
^ false |
|
8557 |
! |
|
8558 |
||
8559 |
combineWithNext:nextReplaceAction |
|
8560 |
self assert:(line == nextReplaceAction line). |
|
8561 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
8562 |
||
8563 |
col2 := nextReplaceAction col2. |
|
8564 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
8565 |
characters := characters , nextReplaceAction characters. |
|
8566 |
! ! |
|
8567 |
||
8568 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
8569 |
||
8570 |
executeIn:editor |
|
8571 |
editor |
|
4823 | 8572 |
replaceString:characters |
8573 |
atLine:line |
|
8574 |
col:col1. |
|
3235 | 8575 |
editor cursorLine:line col:col1. |
8576 |
! ! |
|
8577 |
||
3131 | 8578 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
8579 |
||
8580 |
text:something |
|
8581 |
text := something. |
|
8582 |
! ! |
|
8583 |
||
8584 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
8585 |
||
3160 | 8586 |
executeIn:editor |
3131 | 8587 |
editor contents:text |
8588 |
! ! |
|
8589 |
||
3130 | 8590 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
8591 |
||
3160 | 8592 |
line:lineArg string:stringArg |
3130 | 8593 |
line := lineArg. |
8594 |
text := stringArg. |
|
8595 |
! ! |
|
8596 |
||
8597 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
8598 |
||
3160 | 8599 |
executeIn:editor |
3130 | 8600 |
editor list at:line put:text. |
8601 |
editor invalidateLine:line |
|
8602 |
! ! |
|
8603 |
||
3402 | 8604 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
8605 |
||
8606 |
line:lineArg lines:lineCollectionArg |
|
8607 |
line := lineArg. |
|
8608 |
text := lineCollectionArg. |
|
8609 |
||
8610 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
8611 |
! ! |
|
8612 |
||
8613 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
8614 |
||
8615 |
executeIn:editor |
|
8616 |
|lnr| |
|
8617 |
||
8618 |
lnr := line. |
|
8619 |
text do:[:eachLine | |
|
4823 | 8620 |
editor list at:lnr put:eachLine. |
8621 |
editor invalidateLine:lnr. |
|
8622 |
lnr := lnr + 1. |
|
3402 | 8623 |
]. |
8624 |
||
8625 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
8626 |
! ! |
|
8627 |
||
865 | 8628 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8629 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8630 |
version |
5068 | 8631 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.612 2014-06-18 16:55:30 cg Exp $' |
3945 | 8632 |
! |
8633 |
||
8634 |
version_CVS |
|
5068 | 8635 |
^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.612 2014-06-18 16:55:30 cg Exp $' |
0 | 8636 |
! ! |
4481 | 8637 |