author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 18 Nov 2016 21:15:56 +0000 | |
branch | jv |
changeset 5981 | 50c1bb3e9f98 |
parent 5899 | 4f8cd7f379e8 |
parent 5962 | 0636ffb5a147 |
child 5986 | 1fa5f049f917 |
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 |
|
5239 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
TextView subclass:#EditTextView |
4826 | 17 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
18 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
19 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
20 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
21 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
22 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
23 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
24 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
25 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
26 |
undoSupport lastStringFromReplaceForNextSearch |
|
27 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
28 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
29 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
30 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Views-Text' |
|
0 | 33 |
! |
34 |
||
2952 | 35 |
Object subclass:#EditAction |
4826 | 36 |
instanceVariableNames:'userFriendlyInfo' |
37 |
classVariableNames:'' |
|
38 |
poolDictionaries:'' |
|
39 |
privateIn:EditTextView |
|
2952 | 40 |
! |
41 |
||
42 |
EditTextView::EditAction subclass:#DeleteRange |
|
4826 | 43 |
instanceVariableNames:'line1 col1 line2 col2' |
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:EditTextView |
|
2952 | 47 |
! |
48 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
EditTextView::EditAction subclass:#DeleteCharacters |
4826 | 50 |
instanceVariableNames:'line col1 col2' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
54 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
55 |
|
3235 | 56 |
Object subclass:#EditMode |
4826 | 57 |
instanceVariableNames:'' |
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:EditTextView |
|
3235 | 61 |
! |
62 |
||
63 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
4826 | 64 |
instanceVariableNames:'' |
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:EditTextView::EditMode |
|
3235 | 68 |
! |
69 |
||
70 |
EditTextView::EditMode subclass:#InsertMode |
|
4826 | 71 |
instanceVariableNames:'' |
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:EditTextView::EditMode |
|
3235 | 75 |
! |
76 |
||
77 |
EditTextView::EditMode subclass:#OverwriteMode |
|
4826 | 78 |
instanceVariableNames:'' |
79 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
80 |
poolDictionaries:'' |
|
81 |
privateIn:EditTextView::EditMode |
|
3235 | 82 |
! |
83 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
84 |
Query subclass:#ExecutingMacroQuery |
4826 | 85 |
instanceVariableNames:'' |
86 |
classVariableNames:'' |
|
87 |
poolDictionaries:'' |
|
88 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
89 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
90 |
|
4048 | 91 |
Object subclass:#LastReplacementInfo |
4826 | 92 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
93 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
94 |
classVariableNames:'' |
|
95 |
poolDictionaries:'' |
|
96 |
privateIn:EditTextView |
|
4048 | 97 |
! |
98 |
||
2952 | 99 |
EditTextView::EditAction subclass:#PasteString |
4826 | 100 |
instanceVariableNames:'line col string selected' |
101 |
classVariableNames:'' |
|
102 |
poolDictionaries:'' |
|
103 |
privateIn:EditTextView |
|
2952 | 104 |
! |
105 |
||
106 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
4826 | 107 |
instanceVariableNames:'line col character' |
108 |
classVariableNames:'' |
|
109 |
poolDictionaries:'' |
|
110 |
privateIn:EditTextView |
|
2952 | 111 |
! |
112 |
||
3235 | 113 |
EditTextView::EditAction subclass:#ReplaceCharacters |
4826 | 114 |
instanceVariableNames:'line col1 col2 characters' |
115 |
classVariableNames:'' |
|
116 |
poolDictionaries:'' |
|
117 |
privateIn:EditTextView |
|
3235 | 118 |
! |
119 |
||
3131 | 120 |
EditTextView::EditAction subclass:#ReplaceContents |
4826 | 121 |
instanceVariableNames:'text' |
122 |
classVariableNames:'' |
|
123 |
poolDictionaries:'' |
|
124 |
privateIn:EditTextView |
|
3131 | 125 |
! |
126 |
||
3130 | 127 |
EditTextView::EditAction subclass:#ReplaceLine |
4826 | 128 |
instanceVariableNames:'line text' |
129 |
classVariableNames:'' |
|
130 |
poolDictionaries:'' |
|
131 |
privateIn:EditTextView |
|
3130 | 132 |
! |
133 |
||
3402 | 134 |
EditTextView::EditAction subclass:#ReplaceLines |
4826 | 135 |
instanceVariableNames:'line text' |
136 |
classVariableNames:'' |
|
137 |
poolDictionaries:'' |
|
138 |
privateIn:EditTextView |
|
3402 | 139 |
! |
140 |
||
5689 | 141 |
EditTextView::EditAction subclass:#RestoreSelectionAndCursor |
142 |
instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol |
|
143 |
selectionEndLine selectionEndCol' |
|
144 |
classVariableNames:'' |
|
145 |
poolDictionaries:'' |
|
146 |
privateIn:EditTextView |
|
147 |
! |
|
148 |
||
865 | 149 |
!EditTextView class methodsFor:'documentation'! |
0 | 150 |
|
33 | 151 |
copyright |
152 |
" |
|
153 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 154 |
All Rights Reserved |
33 | 155 |
|
156 |
This software is furnished under a license and may be used |
|
157 |
only in accordance with the terms of that license and with the |
|
158 |
inclusion of the above copyright notice. This software may not |
|
159 |
be provided or otherwise made available to, or used by, any |
|
160 |
other person. No title to or ownership of the software is |
|
161 |
hereby transferred. |
|
162 |
" |
|
163 |
! |
|
164 |
||
0 | 165 |
documentation |
166 |
" |
|
167 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 168 |
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
|
169 |
acceptAction to be performed for accept |
125 | 170 |
|
171 |
If used with a model, this is informed by sending it a changeMsg with |
|
172 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
173 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 174 |
|
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
|
175 |
Please read the historic notice in the ListView class. |
0 | 176 |
|
586 | 177 |
[Instance variables:] |
0 | 178 |
|
4010 | 179 |
cursorLine <Number> line where cursor sits (1..) |
180 |
||
181 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
182 |
||
183 |
cursorCol <Number> col where cursor sits (1..) |
|
184 |
||
185 |
cursorShown <Boolean> true, if cursor is currently shown |
|
186 |
||
187 |
readOnly <Boolean> true, if text may not be edited |
|
188 |
||
189 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
190 |
cleared on accept. |
|
191 |
||
192 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
193 |
||
194 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
195 |
||
196 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
197 |
if it returns true, the modification will be done anyway. |
|
198 |
if it returns anything else, the modification is not done. |
|
199 |
||
200 |
cursorFgColor <Color> color used for cursor drawing |
|
201 |
cursorBgColor <Color> color used for cursor drawing |
|
202 |
||
203 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 204 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 205 |
(vertical bar at insertion point) |
4721 | 206 |
and #caret (caret below insertion-point). |
207 |
see cursorType: for an up-to-date list. |
|
4010 | 208 |
|
209 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
210 |
nil means: hide the cursor. |
|
211 |
||
212 |
undoAction <Block> block which undoes last cut, paste or replace |
|
213 |
(not yet fully implemented) |
|
214 |
||
215 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
216 |
this affects the next keyPress: if #paste it does not |
|
217 |
replace; otherwise it replaces the selection. |
|
218 |
||
219 |
lastCut <String> last cut or replaced string |
|
220 |
||
4053 | 221 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
222 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
223 |
lastReplacement is the string to replace lastStringToReplace |
|
224 |
||
225 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
226 |
(cleared after a new selection) |
|
4010 | 227 |
|
228 |
replacing <Boolean> true if entered characters replace last selection |
|
229 |
||
230 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
231 |
when entering one; this is the default. |
|
232 |
||
233 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
234 |
||
235 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
236 |
argument |
|
237 |
||
238 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
239 |
focus to the next field. For editTextViews, this is false |
|
240 |
by default (i.e. tabs can be entered into the text). |
|
241 |
For some subclasses (inputFields), this may be true. |
|
242 |
||
243 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
244 |
removed when editing. |
|
245 |
Default is true. |
|
246 |
||
247 |
wordWrap <Boolean> Currently not used. |
|
248 |
||
249 |
lockUpdates <Boolean> internal, private |
|
250 |
||
251 |
prevCursorState <Boolean> temporary, private |
|
252 |
||
253 |
cursorMovementWhenUpdating |
|
254 |
<Symbol> defines where the cursor is to be positioned if the |
|
255 |
model changes its value by some outside activity |
|
256 |
(i.e. not by user input into the field). |
|
257 |
Can be one of: |
|
258 |
#keep / nil -> stay where it was |
|
259 |
#endOfText -> cursor to the end |
|
260 |
#endOfLine -> stay in the line, but move to end |
|
261 |
#beginOfText -> cursor to the beginning |
|
262 |
#beginOfLine -> stay in the line, but move to begin |
|
263 |
The default is #beginOfText |
|
264 |
||
265 |
||
266 |
||
267 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 268 |
|
269 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
270 |
userPreference values: |
4010 | 271 |
userPreferences.st80EditMode |
272 |
<Boolean> if true, cursor positioning is |
|
273 |
done as in vi or ST80; i.e. |
|
274 |
wysiwyg mode is somewhat relaxed, |
|
275 |
in that the cursor cannot be |
|
276 |
positioned behind a lines end. |
|
277 |
This is not yet completely implemented. |
|
33 | 278 |
used globals: |
279 |
||
4010 | 280 |
DeleteHistory <Text> last 1000 lines of deleted text |
281 |
(but only if this variable exists already) |
|
586 | 282 |
|
283 |
[styleSheet parameters:] |
|
121 | 284 |
|
4010 | 285 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
286 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
287 |
textCursorNoFocusForegroundColor |
|
288 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
289 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 290 |
|
291 |
[author:] |
|
4010 | 292 |
Claus Gittinger |
586 | 293 |
|
294 |
[see also:] |
|
4010 | 295 |
CodeView Workspace TextView ListView |
296 |
EditField |
|
0 | 297 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
298 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
299 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
300 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
301 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
302 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
303 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
304 |
basic setup: |
4823 | 305 |
[exBegin] |
306 |
|top textView| |
|
307 |
||
308 |
top := StandardSystemView new. |
|
309 |
top extent:300@200. |
|
310 |
||
311 |
textView := EditTextView new. |
|
312 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
313 |
top addSubView:textView. |
|
314 |
||
315 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
316 |
||
317 |
top open. |
|
318 |
[exEnd] |
|
594 | 319 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
320 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
321 |
with vertical scrollbar: |
4823 | 322 |
[exBegin] |
323 |
|top scrollView textView| |
|
324 |
||
325 |
top := StandardSystemView new. |
|
326 |
top extent:300@200. |
|
327 |
||
328 |
scrollView := ScrollableView for:EditTextView. |
|
329 |
textView := scrollView scrolledView. |
|
330 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
331 |
top addSubView:scrollView. |
|
332 |
||
333 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
334 |
||
335 |
top open. |
|
336 |
[exEnd] |
|
594 | 337 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
338 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
339 |
with horizontal & vertical scrollbars: |
4823 | 340 |
[exBegin] |
341 |
|top scrollView textView| |
|
342 |
||
343 |
top := StandardSystemView new. |
|
344 |
top extent:300@200. |
|
345 |
||
346 |
scrollView := HVScrollableView for:EditTextView. |
|
347 |
textView := scrollView scrolledView. |
|
348 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
349 |
top addSubView:scrollView. |
|
350 |
||
351 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
352 |
||
353 |
top open. |
|
354 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
355 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
356 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
357 |
set the action for accept: |
4823 | 358 |
[exBegin] |
359 |
|top textView| |
|
360 |
||
361 |
top := StandardSystemView new. |
|
362 |
top extent:300@200. |
|
363 |
||
364 |
textView := EditTextView new. |
|
365 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
366 |
top addSubView:textView. |
|
367 |
||
368 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
369 |
textView acceptAction:[:contents | |
|
370 |
Transcript showCR:'will not overwrite the file with:'. |
|
371 |
Transcript showCR:contents asString |
|
372 |
]. |
|
373 |
top open. |
|
374 |
[exEnd] |
|
594 | 375 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
376 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
377 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
378 |
non-string (text) items: |
4823 | 379 |
[exBegin] |
380 |
|top textView list| |
|
381 |
||
382 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
383 |
1 to:list size by:2 do:[:nr | |
|
384 |
list at:nr put:(Text string:(list at:nr) |
|
385 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
386 |
]. |
|
387 |
||
388 |
top := StandardSystemView new. |
|
389 |
top extent:300@200. |
|
390 |
||
391 |
textView := EditTextView new. |
|
392 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
393 |
top addSubView:textView. |
|
394 |
||
395 |
textView contents:list. |
|
396 |
top open. |
|
397 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
398 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
399 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
400 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
401 |
MVC operation: |
594 | 402 |
(the examples model here is a plug simulating a real model; |
403 |
real world applications would not use a plug ..) |
|
4823 | 404 |
[exBegin] |
405 |
|top textView model| |
|
406 |
||
407 |
model := Plug new. |
|
408 |
model respondTo:#accepted: |
|
409 |
with:[:newContents | |
|
410 |
Transcript showCR:'will not overwrite the file with:'. |
|
411 |
Transcript showCR:newContents asString |
|
412 |
]. |
|
413 |
model respondTo:#getList |
|
414 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
415 |
||
416 |
||
417 |
top := StandardSystemView new. |
|
418 |
top extent:300@200. |
|
419 |
||
420 |
textView := EditTextView new. |
|
421 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
422 |
top addSubView:textView. |
|
423 |
||
424 |
textView listMessage:#getList; |
|
425 |
model:model; |
|
426 |
changeMessage:#accepted:; |
|
427 |
aspect:#list. |
|
428 |
top open. |
|
429 |
[exEnd] |
|
594 | 430 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
431 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
432 |
two textViews on the same model: |
4823 | 433 |
[exBegin] |
434 |
|top1 textView1 top2 textView2 model currentContents| |
|
435 |
||
436 |
model := Plug new. |
|
437 |
model respondTo:#accepted: |
|
438 |
with:[:newContents | |
|
439 |
Transcript showCR:'accepted:'. |
|
440 |
Transcript showCR:newContents asString. |
|
441 |
currentContents := newContents. |
|
442 |
model changed:#contents |
|
443 |
]. |
|
444 |
model respondTo:#getList |
|
445 |
with:[Transcript showCR:'query'. |
|
446 |
currentContents]. |
|
447 |
||
448 |
||
449 |
top1 := StandardSystemView new. |
|
450 |
top1 extent:300@200. |
|
451 |
||
452 |
textView1 := EditTextView new. |
|
453 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
454 |
top1 addSubView:textView1. |
|
455 |
||
456 |
textView1 listMessage:#getList; |
|
457 |
model:model; |
|
458 |
aspect:#contents; |
|
459 |
changeMessage:#accepted:. |
|
460 |
top1 open. |
|
461 |
||
462 |
top2 := StandardSystemView new. |
|
463 |
top2 extent:300@200. |
|
464 |
||
465 |
textView2 := EditTextView new. |
|
466 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
467 |
top2 addSubView:textView2. |
|
468 |
||
469 |
textView2 listMessage:#getList; |
|
470 |
model:model; |
|
471 |
aspect:#contents; |
|
472 |
changeMessage:#accepted:. |
|
473 |
top2 open. |
|
474 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
475 |
" |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
476 |
! |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
477 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
478 |
selection_and_cursor_movement |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
479 |
" |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
480 |
Changes done to implement 'standard' behaviour (that's how vast majority of widgets used in todays desktops behaves) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
481 |
as opposed to 'traditional' which is what how it was in St/X 'ever since' |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
482 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
483 |
* Numerous off-by-one bugs |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
484 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
485 |
* Extending selection by dragging: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
486 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
487 |
1. Select & drag to expand beggining of the selection (i.e., drag from 'end' to 'beggining' |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
488 |
2. Stop dragging |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
489 |
3. Press Shift-Left / Shift-Right (to refine selection) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
490 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
491 |
Traditional ST/X: end of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
492 |
Standard: beginning of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
493 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
494 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
495 |
* Extending selection by Shift-Home / Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
496 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
497 |
1. Position cursor in the middle of the line |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
498 |
2. Press Shift-Home (line for beginning should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
499 |
3. Press Shift-Right (to refine selection) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
500 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
501 |
Traditional ST/X: end of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
502 |
Standard: beginning of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
503 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
504 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
505 |
* Selection flip by Shift-Home / Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
506 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
507 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
508 |
2. Press Shift-Home (line from beginning should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
509 |
2. Press Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
510 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
511 |
Traditional ST/X: end of selection is moved so whole line is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
512 |
Standard: Selection 'flips' so part of line from column C to the end is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
513 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
514 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
515 |
Scenario B: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
516 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
517 |
2. Press Shift-End (column C to the end of line should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
518 |
2. Press Shift-Home |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
519 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
520 |
Traditional ST/X: beginning of selection is moved so whole line is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
521 |
Standard: Selection 'flips' so part of line from the beginning to column C is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
522 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
523 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
524 |
NOTE: This could be controlled by |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
525 |
UserPreferences current selectionExtensionMode |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
526 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
527 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
528 |
* Extending selection with Ctrl-Shift-Left / Ctrl-Shift-Right |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
529 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
530 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
531 |
2. Select word |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
532 |
3. Press Ctrl-Shift-Right, Ctrl-Shift-Right |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
533 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
534 |
Traditional ST/X: nothing happens at all |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
535 |
Standard: Selection is extended to include a space (first press) and a word right to previously selected one |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
536 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
537 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
538 |
" |
0 | 539 |
! ! |
540 |
||
865 | 541 |
!EditTextView class methodsFor:'defaults'! |
59 | 542 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
543 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
544 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
545 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
546 |
"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
|
547 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
548 |
|
1419 | 549 |
st80Mode |
550 |
"return true, if the st80 editing mode is turned on. |
|
551 |
This setting affects the behavior of the cursor, when positioned |
|
5909 | 552 |
beyond the end of a line or the end of the text. |
553 |
This method is here for backward compatibility, when this flag was stored |
|
554 |
in a class var. It is now in the user's settings. |
|
555 |
Please do not call it, but go to the prefs directly, to make it easier to find those getters." |
|
1419 | 556 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
557 |
^ UserPreferences current st80EditMode |
1419 | 558 |
|
559 |
" |
|
560 |
EditTextView st80Mode:true |
|
561 |
EditTextView st80Mode:false |
|
562 |
" |
|
563 |
||
564 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
565 |
! |
|
566 |
||
567 |
st80Mode:aBoolean |
|
568 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
5909 | 569 |
beyond the end of a line or the last line. |
570 |
This method is here for backward compatibility, when this flag was stored |
|
571 |
in a class var. It is now in the user's settings. |
|
572 |
Please do not call it, but go to the prefs directly, to make it easier to find those setters." |
|
1419 | 573 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
574 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 575 |
|
576 |
" |
|
577 |
EditTextView st80Mode:true |
|
578 |
EditTextView st80Mode:false |
|
579 |
" |
|
580 |
||
581 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
582 |
! |
|
583 |
||
59 | 584 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
585 |
"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
|
586 |
|
1390 | 587 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 588 |
#'textCursor.noFocusForegroundColor' |
589 |
#'textCursor.type' |
|
590 |
#'textCursor.typeNoFocus' |
|
591 |
#'editText.st80Mode')> |
|
1355 | 592 |
|
593 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
594 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
595 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
596 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
597 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
598 |
|
1419 | 599 |
" |
600 |
self updateStyleCache |
|
601 |
" |
|
602 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
603 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 604 |
! ! |
605 |
||
3431 | 606 |
!EditTextView class methodsFor:'specs'! |
607 |
||
608 |
searchReplaceDialogSpec |
|
609 |
"This resource specification was automatically generated |
|
610 |
by the UIPainter of ST/X." |
|
611 |
||
612 |
"Do not manually edit this!! If it is corrupted, |
|
613 |
the UIPainter may not be able to read the specification." |
|
614 |
||
615 |
" |
|
616 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
617 |
" |
|
618 |
||
619 |
<resource: #canvas> |
|
620 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
621 |
^ |
3431 | 622 |
#(FullSpec |
4823 | 623 |
name: searchReplaceDialogSpec |
624 |
window: |
|
3431 | 625 |
(WindowSpec |
4823 | 626 |
label: 'String Search and Replace' |
627 |
name: 'String Search and Replace' |
|
628 |
min: (Point 283 196) |
|
629 |
max: (Point 283 196) |
|
630 |
bounds: (Rectangle 0 0 279 192) |
|
631 |
) |
|
632 |
component: |
|
3431 | 633 |
(SpecCollection |
4823 | 634 |
collection: ( |
635 |
(LabelSpec |
|
636 |
label: 'Search Pattern:' |
|
637 |
name: 'label' |
|
638 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
639 |
level: 0 |
|
640 |
translateLabel: true |
|
641 |
adjust: left |
|
642 |
) |
|
643 |
(ComboBoxSpec |
|
644 |
name: 'patternComboBox' |
|
645 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
646 |
tabable: true |
|
647 |
model: searchPattern |
|
648 |
immediateAccept: false |
|
649 |
acceptOnLeave: true |
|
650 |
acceptOnReturn: true |
|
651 |
acceptOnTab: true |
|
652 |
acceptOnLostFocus: true |
|
653 |
acceptOnPointerLeave: false |
|
654 |
autoSelectInitialText: true |
|
655 |
comboList: patternList |
|
656 |
) |
|
657 |
(ComboBoxSpec |
|
658 |
name: 'replaceComboBox' |
|
659 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
660 |
tabable: true |
|
661 |
model: replacePattern |
|
662 |
immediateAccept: false |
|
663 |
acceptOnLeave: true |
|
664 |
acceptOnReturn: true |
|
665 |
acceptOnTab: true |
|
666 |
acceptOnLostFocus: true |
|
667 |
acceptOnPointerLeave: false |
|
668 |
autoSelectInitialText: true |
|
669 |
comboList: patternList |
|
670 |
) |
|
671 |
(CheckBoxSpec |
|
672 |
label: 'Ignore Case' |
|
673 |
name: 'ignoreCaseCheckBox' |
|
674 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
675 |
level: 0 |
|
676 |
tabable: true |
|
677 |
model: ignoreCase |
|
678 |
translateLabel: true |
|
679 |
) |
|
680 |
(VariableVerticalPanelSpec |
|
681 |
name: 'VariableVerticalPanel1' |
|
682 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
683 |
component: |
|
684 |
(SpecCollection |
|
685 |
collection: ( |
|
686 |
(HorizontalPanelViewSpec |
|
687 |
name: 'HorizontalPanel1' |
|
688 |
level: 0 |
|
689 |
horizontalLayout: fitSpace |
|
690 |
verticalLayout: center |
|
691 |
horizontalSpace: 3 |
|
692 |
verticalSpace: 3 |
|
693 |
ignoreInvisibleComponents: true |
|
694 |
reverseOrderIfOKAtLeft: true |
|
695 |
component: |
|
696 |
(SpecCollection |
|
697 |
collection: ( |
|
698 |
(ActionButtonSpec |
|
699 |
label: 'Replace' |
|
700 |
name: 'replaceButton' |
|
701 |
level: 2 |
|
702 |
translateLabel: true |
|
703 |
tabable: true |
|
704 |
model: replaceAction |
|
705 |
extent: (Point 134 21) |
|
706 |
) |
|
707 |
(ActionButtonSpec |
|
708 |
label: 'Replace All' |
|
709 |
name: 'replaceAllButton' |
|
710 |
level: 2 |
|
711 |
borderWidth: 1 |
|
712 |
translateLabel: true |
|
713 |
tabable: true |
|
714 |
model: replaceAllAction |
|
715 |
extent: (Point 134 21) |
|
716 |
) |
|
717 |
) |
|
718 |
||
719 |
) |
|
720 |
) |
|
721 |
(HorizontalPanelViewSpec |
|
722 |
name: 'horizontalPanelView' |
|
723 |
level: 0 |
|
724 |
horizontalLayout: fitSpace |
|
725 |
verticalLayout: center |
|
726 |
horizontalSpace: 3 |
|
727 |
verticalSpace: 3 |
|
728 |
ignoreInvisibleComponents: true |
|
729 |
reverseOrderIfOKAtLeft: true |
|
730 |
component: |
|
731 |
(SpecCollection |
|
732 |
collection: ( |
|
733 |
(ActionButtonSpec |
|
734 |
label: 'Cancel' |
|
735 |
name: 'cancelButton' |
|
736 |
level: 2 |
|
737 |
translateLabel: true |
|
738 |
tabable: true |
|
739 |
model: cancel |
|
740 |
extent: (Point 88 21) |
|
741 |
) |
|
742 |
(ActionButtonSpec |
|
743 |
label: 'Prev' |
|
744 |
name: 'prevButton' |
|
745 |
level: 2 |
|
746 |
translateLabel: true |
|
747 |
tabable: true |
|
748 |
model: prevAction |
|
749 |
extent: (Point 89 21) |
|
750 |
) |
|
751 |
(ActionButtonSpec |
|
752 |
label: 'Next' |
|
753 |
name: 'nextButton' |
|
754 |
level: 2 |
|
755 |
borderWidth: 1 |
|
756 |
translateLabel: true |
|
757 |
tabable: true |
|
758 |
model: nextAction |
|
759 |
isDefault: true |
|
760 |
extent: (Point 88 21) |
|
761 |
) |
|
762 |
) |
|
763 |
||
764 |
) |
|
765 |
) |
|
766 |
) |
|
767 |
||
768 |
) |
|
769 |
handles: (Any 0.5 1.0) |
|
770 |
) |
|
771 |
(LabelSpec |
|
772 |
label: 'Replace By:' |
|
773 |
name: 'ReplaceLabel' |
|
774 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
775 |
level: 0 |
|
776 |
translateLabel: true |
|
777 |
adjust: left |
|
778 |
) |
|
779 |
) |
|
780 |
||
781 |
) |
|
3431 | 782 |
) |
783 |
||
784 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
785 |
! ! |
|
786 |
||
2744 | 787 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
788 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
789 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
790 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
791 |
|
2019 | 792 |
"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
|
793 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
794 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
795 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
796 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
797 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
798 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
799 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
800 |
|
1390 | 801 |
cutSelection |
802 |
self cut |
|
803 |
||
804 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
805 |
! |
|
806 |
||
1590 | 807 |
deselect |
808 |
"remove the selection" |
|
809 |
||
810 |
^ self unselect |
|
811 |
||
812 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
813 |
! |
|
814 |
||
2101 | 815 |
enabled:aBoolean |
816 |
||
817 |
self readOnly:aBoolean not |
|
818 |
||
819 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
820 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
821 |
! |
|
822 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
823 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
824 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
825 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
826 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
827 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
828 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
829 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
830 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
831 |
"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
|
832 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
833 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
834 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
835 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
836 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
837 |
col < 1 ifTrue:[ |
4823 | 838 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
839 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
840 |
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
|
841 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
842 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
843 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
844 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
845 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
846 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
847 |
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
|
848 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
849 |
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
|
850 |
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
|
851 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
852 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
853 |
"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
|
854 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
855 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
856 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
857 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
858 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
859 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
860 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
861 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 862 |
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
|
863 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
864 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 865 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
866 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
867 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
868 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
869 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
870 |
v insertAndSelect:'<- hello there' at:5. |
125 | 871 |
" |
1390 | 872 |
! |
873 |
||
874 |
pasteSelection |
|
875 |
self paste |
|
876 |
||
877 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 878 |
! |
879 |
||
880 |
replaceSelectionWith:aString |
|
881 |
^ self replaceSelectionBy:aString |
|
882 |
||
883 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
884 |
! |
|
885 |
||
886 |
selectAt:pos |
|
887 |
"move the cursor before cursorPosition." |
|
888 |
||
889 |
self cursorToCharacterPosition:pos |
|
890 |
||
891 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
892 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
893 |
! |
|
894 |
||
2101 | 895 |
textHasChanged |
896 |
^ self modified |
|
897 |
||
898 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
899 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
900 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
901 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
902 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
903 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
904 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
905 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
906 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
907 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
908 |
|
4585 | 909 |
!EditTextView methodsFor:'accessing'! |
910 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
911 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
912 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
913 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
914 |
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
|
915 |
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
|
916 |
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
|
917 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
918 |
"/ 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
|
919 |
"/ 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
|
920 |
^((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
|
921 |
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
|
922 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
923 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
924 |
"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
|
925 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
926 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
927 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
928 |
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
|
929 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
930 |
"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
|
931 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
932 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
933 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
934 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
935 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
936 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
937 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
938 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
939 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
940 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
941 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
942 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
943 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
944 |
"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
|
945 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
946 |
|
4609 | 947 |
editedClass |
948 |
|cm| |
|
949 |
||
950 |
cm := self editedMethodOrClass. |
|
951 |
cm isBehavior ifTrue:[^ cm]. |
|
952 |
cm isMethod ifTrue:[^ cm mclass]. |
|
953 |
^ nil |
|
954 |
! |
|
955 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
956 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
957 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
958 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
959 |
"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
|
960 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
961 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
962 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
963 |
"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
|
964 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
965 |
"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
|
966 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
967 |
|
4609 | 968 |
editedMethod |
969 |
|cm| |
|
970 |
||
971 |
cm := self editedMethodOrClass. |
|
972 |
cm isMethod ifTrue:[^ cm]. |
|
973 |
cm isBehavior ifTrue:[^ nil]. |
|
974 |
^ nil |
|
975 |
! |
|
976 |
||
977 |
editedMethodOrClass |
|
978 |
^ nil |
|
979 |
! |
|
980 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
981 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
982 |
"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
|
983 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
984 |
"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
|
985 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
986 |
|
4585 | 987 |
hasSelectionOrTextInCursorLine |
988 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
989 |
! |
|
990 |
||
4589 | 991 |
selectionOrTextOfCursorLine |
992 |
^ self selectionOrTextOfCursorLine:true |
|
993 |
! |
|
994 |
||
4585 | 995 |
selectionOrTextOfCursorLine:doSelect |
996 |
|sel lNr line| |
|
997 |
||
998 |
sel := self selectionAsString. |
|
999 |
sel notNil ifTrue:[^ sel]. |
|
1000 |
||
1001 |
lNr := self cursorLine. |
|
1002 |
line := self listAt:lNr. |
|
1003 |
line notEmptyOrNil ifTrue:[ |
|
1004 |
doSelect ifTrue:[ |
|
1005 |
self selectLine:lNr. |
|
1006 |
]. |
|
1007 |
^ line |
|
1008 |
]. |
|
1009 |
||
1010 |
^ nil |
|
1011 |
! ! |
|
1012 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1013 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1014 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1015 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1016 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1017 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1018 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1019 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1020 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1021 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1022 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1023 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1024 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1025 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1026 |
|
2792 | 1027 |
acceptChannel |
1028 |
"return the valueHolder holding true if text was accepted. |
|
1029 |
By placing a true into this channel, an accept can also be forced." |
|
1030 |
||
1031 |
^ acceptChannel |
|
1032 |
||
1033 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
1034 |
! |
|
1035 |
||
1036 |
acceptChannel:aValueHolder |
|
1037 |
"set the valueHolder holding true if text was accepted. |
|
1038 |
By placing a true into this channel, an accept can also be forced." |
|
1039 |
||
1040 |
|prev| |
|
1041 |
||
1042 |
prev := acceptChannel. |
|
1043 |
acceptChannel := aValueHolder. |
|
1044 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1045 |
||
1046 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
1047 |
! |
|
1048 |
||
1108 | 1049 |
acceptEnabled:aBoolean |
1050 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
1051 |
||
1052 |
acceptEnabled := aBoolean |
|
1053 |
||
1054 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
1055 |
! |
|
1056 |
||
2792 | 1057 |
accepted |
1058 |
"return true if text was accepted" |
|
1059 |
||
1060 |
^ acceptChannel value |
|
1061 |
||
1062 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1063 |
! |
|
1064 |
||
1065 |
accepted:aBoolean |
|
1066 |
"set/clear the accepted flag. |
|
1067 |
This may force my current contents to be placed into my model." |
|
1068 |
||
1069 |
acceptChannel value:aBoolean. |
|
1070 |
||
1071 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1072 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1073 |
! |
|
1074 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1075 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1076 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1077 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1078 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1079 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1080 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1081 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1082 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1083 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1084 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1085 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1086 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1087 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1088 |
|
2774 | 1089 |
cursorMovementWhenUpdating |
3160 | 1090 |
"return what is be done with the cursor, |
2774 | 1091 |
when I get a new text (via the model or the #contents/#list) |
1092 |
Allowed arguments are: |
|
4823 | 1093 |
#keep / nil -> stay where it was |
1094 |
#endOfText -> position cursor to the end |
|
1095 |
#beginOfText -> position cursor to the beginning |
|
1096 |
#endOfLine -> position cursor to the current lines end |
|
1097 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1098 |
The default is #beginOfText. |
1099 |
This may be useful for fields which get new values assigned from |
|
1100 |
the program (i.e. not from the user)" |
|
1101 |
||
1102 |
^ cursorMovementWhenUpdating |
|
1103 |
||
1104 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1105 |
! |
|
1106 |
||
2133 | 1107 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1108 |
"define what should be done with the cursor, |
2133 | 1109 |
when I get a new text (via the model or the #contents/#list) |
1110 |
Allowed arguments are: |
|
4823 | 1111 |
#keep / nil -> stay where it was |
1112 |
#endOfText -> position cursor to the end |
|
1113 |
#beginOfText -> position cursor to the beginning |
|
1114 |
#endOfLine -> position cursor to the current lines end |
|
1115 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1116 |
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
|
1117 |
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
|
1118 |
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
|
1119 |
|
2133 | 1120 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1121 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1122 |
"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
|
1123 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1124 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1125 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1126 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1127 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1128 |
|
2438 | 1129 |
dontReplaceSelectionOnInput |
4742 | 1130 |
"remember that the current selection was created by a paste operation |
1131 |
(as opposed to an explicit selection by the user). |
|
1132 |
This selection will not be replaced by followup user input, |
|
1133 |
so multiple pastes will be possible." |
|
1134 |
||
5342
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1135 |
self hasSelection ifTrue:[ |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1136 |
typeOfSelection := #paste |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1137 |
]. |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1138 |
|
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1139 |
"Modified: / 02-05-2015 / 21:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2438 | 1140 |
! |
1141 |
||
3235 | 1142 |
editModeHolder |
1143 |
^ editMode. |
|
1144 |
! |
|
1145 |
||
1146 |
editModeInsert |
|
1147 |
editMode value:EditMode insertMode |
|
1148 |
! |
|
1149 |
||
1150 |
editModeInsertAndSelect |
|
1151 |
editMode value:EditMode insertAndSelectMode |
|
1152 |
! |
|
1153 |
||
1154 |
editModeOverwrite |
|
1155 |
editMode value:EditMode overwriteMode |
|
1156 |
! |
|
1157 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1158 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1159 |
"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
|
1160 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1161 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1162 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1163 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1164 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1165 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1166 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1167 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1168 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1169 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1170 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1171 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1172 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1173 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1174 |
readOnly == true ifFalse:[ |
4823 | 1175 |
readOnly := true. |
1176 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1177 |
menu disableAll:#(cut paste replace indent) |
|
1178 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1179 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1180 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1181 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1182 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1183 |
|
5858 | 1184 |
generateTextAfterEndHook:aBlock |
1185 |
"some applications may want to dynamically generate lines below the bottom line, |
|
1186 |
when the cursor is moved there. |
|
1187 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1188 |
which want to automatically generate additional lines lazily, |
|
1189 |
but which cannot afford to generate the whole text in advance |
|
1190 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1191 |
If set, this hook is called whenever the cursor is about to be moved below the |
5859 | 1192 |
last line, getting the new lineNr (i.e > contents size) as argument. |
5858 | 1193 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1194 |
number, into which the cursor should be moved |
1195 |
(eg. if 10 additional lines are generated, it may want to return oldSize+1, |
|
5858 | 1196 |
to make the cursor end in the last line which was inserted)" |
5890 | 1197 |
|
5858 | 1198 |
self setAttribute:#generateTextAfterEndHook to:aBlock |
1199 |
! |
|
1200 |
||
1201 |
generateTextBeforeStartHook:aBlock |
|
1202 |
"some applications may want to dynamically generate lines above the top |
|
1203 |
line, when the cursor is moved there. |
|
1204 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1205 |
which want to automatically generate additional lines lazily, |
|
1206 |
but which cannot afford to generate the whole text in advance |
|
1207 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1208 |
If set, this hook is called whenever the cursor is about to be moved above the |
5859 | 1209 |
top, getting the new lineNr (i.e < 1) as argument. |
5858 | 1210 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1211 |
number, into which the cursor should be moved |
1212 |
(eg. if 10 additional lines are generated, it may want to return 10, to make the |
|
5858 | 1213 |
cursor end in the last line which was inserted)" |
5890 | 1214 |
|
5858 | 1215 |
self setAttribute:#generateTextBeforeStartHook to:aBlock |
1216 |
! |
|
1217 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1218 |
insertMode:aBoolean |
3235 | 1219 |
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
|
1220 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1221 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1222 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1223 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1224 |
insertModeHolder |
3235 | 1225 |
^ BlockValue |
4823 | 1226 |
with:[:m | m isInsertMode] |
1227 |
argument:(editMode). |
|
3465 | 1228 |
|
1229 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1230 |
! |
1231 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1232 |
isInInsertMode |
3235 | 1233 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1234 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1235 |
|
5216 | 1236 |
isNotReadOnly |
1237 |
"return true, if the text is not readonly." |
|
1238 |
||
1239 |
^ self isReadOnly not |
|
1240 |
! |
|
1241 |
||
2792 | 1242 |
isReadOnly |
1243 |
"return true, if the text is readonly." |
|
1244 |
||
1245 |
^ readOnly value |
|
1246 |
||
1247 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1248 |
! |
|
1249 |
||
2796 | 1250 |
modeLabelHolder |
1251 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1252 |
||
3160 | 1253 |
^ BlockValue |
4041 | 1254 |
with:[:e :l | |
1255 |
self isReadOnly ifTrue:[ |
|
1256 |
'' |
|
1257 |
] ifFalse:[ |
|
5724 | 1258 |
l ifTrue:[ 'L' allBold withColor:#red] |
4041 | 1259 |
ifFalse:[ e infoPrintString]]] |
1260 |
argument:(self editModeHolder) |
|
1261 |
argument:(self learnModeHolder). |
|
3465 | 1262 |
|
1263 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1264 |
! |
1265 |
||
2792 | 1266 |
modified |
1267 |
"return true if text was modified" |
|
1268 |
||
1269 |
^ modifiedChannel value |
|
1270 |
! |
|
1271 |
||
1272 |
modified:aBoolean |
|
1273 |
"set/clear the modified flag" |
|
1274 |
||
1275 |
modifiedChannel value:aBoolean |
|
1276 |
||
1277 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1278 |
! |
|
1279 |
||
1280 |
modifiedChannel |
|
1281 |
"return the valueHolder holding true if text was modified" |
|
1282 |
||
1283 |
^ modifiedChannel |
|
1284 |
! |
|
1285 |
||
1286 |
modifiedChannel:aValueHolder |
|
1287 |
"set the valueHolder holding true if text was modified" |
|
1288 |
||
1289 |
|prev| |
|
1290 |
||
1291 |
prev := modifiedChannel. |
|
1292 |
modifiedChannel := aValueHolder. |
|
1293 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1294 |
||
1295 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1296 |
! |
|
1297 |
||
1298 |
readOnly |
|
1299 |
"make the text readonly. |
|
4664 | 1300 |
Obsolete because it is obfuscating (looks like a getter) |
1301 |
- use #readOnly:" |
|
2792 | 1302 |
|
1303 |
<resource:#obsolete> |
|
1304 |
||
1305 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1306 |
self readOnly:true. |
2792 | 1307 |
|
4664 | 1308 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1309 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1310 |
! |
1311 |
||
1312 |
readOnly:aBoolean |
|
1313 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1314 |
The argument may also be a valueHolder." |
|
1315 |
||
1316 |
readOnly := aBoolean |
|
1317 |
||
1318 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1319 |
! |
|
1320 |
||
4782 | 1321 |
reallyModifiedChannel |
1322 |
"return the valueHolder holding true if text was really modified. |
|
1323 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1324 |
||
1325 |
^ self modifiedChannel |
|
1326 |
! |
|
1327 |
||
5909 | 1328 |
st80EditMode |
1329 |
"If on, the cursor wraps at the line end (like in vi or st80); |
|
1330 |
if off, we have the Rand-editor behavior (random access)" |
|
1331 |
||
1332 |
^ st80Mode ? (UserPreferences current st80EditMode) |
|
1333 |
! |
|
1334 |
||
1335 |
st80EditMode:aBooleanOrNil |
|
4192 | 1336 |
"set/clear the st80Mode flag. |
1337 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1338 |
if off, we have the Rand-editor behavior (random access) |
1339 |
if nil, the setting follows the current userPref setting." |
|
1340 |
||
1341 |
st80Mode := aBooleanOrNil |
|
4192 | 1342 |
|
1343 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1344 |
! |
|
1345 |
||
5909 | 1346 |
st80Mode:aBooleanOrNil |
1347 |
self obsoleteMethodWarning. |
|
1348 |
self st80EditMode:aBooleanOrNil |
|
1349 |
||
1350 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1351 |
! |
|
1352 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1353 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1354 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1355 |
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
|
1356 |
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
|
1357 |
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
|
1358 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1359 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1360 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1361 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1362 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1363 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1364 |
"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
|
1365 |
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
|
1366 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1367 |
|
3160 | 1368 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1369 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1370 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1371 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1372 |
"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
|
1373 |
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
|
1374 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1375 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1376 |
tabRequiresControl := aBoolean |
5909 | 1377 |
! |
1378 |
||
1379 |
trimBlankLines |
|
1380 |
"If on, the blank lines are trimmed to zero size; |
|
1381 |
if nil, the setting follows the current userPref setting." |
|
1382 |
||
1383 |
^ trimBlankLines ? (UserPreferences current trimBlankLines) |
|
1384 |
! |
|
1385 |
||
1386 |
trimBlankLines:aBooleanOrNil |
|
1387 |
"If on, the blank lines are trimmed to zero size; |
|
1388 |
if nil, the setting follows the current userPref setting." |
|
1389 |
||
1390 |
trimBlankLines := aBooleanOrNil. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1391 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1392 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1393 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1394 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1395 |
at:lineNr basicPut:aLine |
5413 | 1396 |
"change a line without change notification. |
1397 |
this is not undoably, unless you care for yourself" |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1398 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1399 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1400 |
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
|
1401 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1402 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1403 |
|
522 | 1404 |
at:lineNr put:aLine |
5413 | 1405 |
"replace a line by something new. |
1406 |
this is not undoably, unless you care for yourself" |
|
1407 |
||
5393 | 1408 |
|oldLine| |
1409 |
||
1410 |
oldLine := (self at:lineNr) ? ''. |
|
1411 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
4823 | 1412 |
super at:lineNr put:aLine. |
1413 |
self textChanged |
|
522 | 1414 |
]. |
1415 |
! |
|
1416 |
||
4700 | 1417 |
characterAfterCursor |
1418 |
"return the character one after the cursor - space if beyond line." |
|
1419 |
||
1420 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1421 |
! |
|
1422 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1423 |
characterBeforeCursor |
4700 | 1424 |
"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
|
1425 |
|
5142 | 1426 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1427 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1428 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1429 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1430 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1431 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1432 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1433 |
characterUnderCursor |
2707 | 1434 |
"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
|
1435 |
For non-block cursors, this is the character immediately to the right |
5413 | 1436 |
of the insertion-bar or caret. |
1437 |
For block cursors, this is the highlighted cursor-character" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1438 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1439 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1440 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1441 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1442 |
contents |
2213 | 1443 |
"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
|
1444 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1445 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1446 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1447 |
^ super contents. |
3313 | 1448 |
|
1449 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1450 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1451 |
|
5413 | 1452 |
contents:aStringOrStringCollectionOrNil |
1453 |
"replace the whole contents by something new. |
|
5414 | 1454 |
this is not undoably, unless you care for yourself. |
1455 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1456 |
|
1457 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1458 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1459 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1460 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1461 |
"set the contents and optionally clear the undo history. |
1462 |
The contents-change is not undoable." |
|
1463 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1464 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1465 |
keepUndoHistory ifFalse:[ |
4823 | 1466 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1467 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1468 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1469 |
|
2213 | 1470 |
contentsAsString |
1471 |
"return the contents as a String (i.e. without emphasis)" |
|
1472 |
||
1473 |
list isNil ifTrue:[^ '']. |
|
1474 |
self removeTrailingBlankLines. |
|
1475 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1476 |
ifFalse:[each string] |
1477 |
]) asStringWithCRs |
|
2213 | 1478 |
! |
1479 |
||
5067 | 1480 |
contentsAsStringWithTabs |
1481 |
"return the contents as a String (i.e. without emphasis) |
|
1482 |
and with leading spaces replaced by tab characters |
|
1483 |
(i.e. as would be written to a file)" |
|
1484 |
||
1485 |
list isNil ifTrue:[^ '']. |
|
1486 |
self removeTrailingBlankLines. |
|
1487 |
^ (list collect:[:each | |
|
1488 |
each isNil |
|
1489 |
ifTrue:[''] |
|
1490 |
ifFalse:[each string withTabs] |
|
1491 |
]) asStringWithCRs |
|
1492 |
! |
|
1493 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1494 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1495 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1496 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1497 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1498 |
^ cursorCol |
125 | 1499 |
! |
1500 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1501 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1502 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1503 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1504 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1505 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1506 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1507 |
cursorLine |
3160 | 1508 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1509 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1510 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1511 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1512 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1513 |
|
5400 | 1514 |
cursorLineAndColumnLabelHolder |
5399 | 1515 |
"return a valueHolder for the cursors line and column as an info string |
1516 |
of the form 'line : col'. |
|
1517 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
|
1518 |
||
1519 |
^ BlockValue |
|
1520 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
|
1521 |
argument:self cursorLineHolder |
|
1522 |
argument:self cursorColHolder |
|
1523 |
! |
|
1524 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1525 |
cursorLineHolder |
3160 | 1526 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1527 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1528 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1529 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1530 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1531 |
|
4713 | 1532 |
lineStringBeforeCursor |
1533 |
"return the line's string before the cursor. |
|
1534 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1535 |
||
1536 |
|line| |
|
1537 |
||
1538 |
line := ((self at:cursorLine) ? '') string. |
|
1539 |
line size < (cursorCol-1) ifTrue:[ |
|
1540 |
^ line paddedTo:(cursorCol-1) |
|
1541 |
]. |
|
1542 |
^ line copyTo:(cursorCol-1) |
|
1543 |
! |
|
1544 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1545 |
list:something |
5413 | 1546 |
"replace the whole contents by something new. |
1547 |
this is not undoably, unless you care for yourself. |
|
1548 |
position cursor home when setting contents" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1549 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1550 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1551 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1552 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1553 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1554 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1555 |
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
|
1556 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1557 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1558 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1559 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1560 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1561 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1562 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1563 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1564 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1565 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1566 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1567 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1568 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1569 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1570 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1571 |
^ 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
|
1572 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1573 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1574 |
"/ 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
|
1575 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1576 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1577 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1578 |
setContents:something |
5413 | 1579 |
"replace the whole contents by something new |
1580 |
AND clear the remembered undo actions" |
|
1581 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1582 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1583 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1584 |
undoSupport resetHistories. |
2955 | 1585 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1586 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1587 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1588 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1589 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1590 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1591 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1592 |
|
4609 | 1593 |
!EditTextView methodsFor:'accessing-dimensions'! |
1594 |
||
1595 |
xOfCursor |
|
4728 | 1596 |
|point| |
1597 |
||
1598 |
cursorVisibleLine isNil ifTrue:[ |
|
1599 |
"/ take the end of the selection, if any |
|
1600 |
(selectionStartLine notNil |
|
1601 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1602 |
ifTrue:[ |
|
1603 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1604 |
]. |
|
1605 |
||
1606 |
"/ point := device |
|
1607 |
"/ translatePoint:(device pointerPosition) |
|
1608 |
"/ fromView:nil |
|
1609 |
"/ toView:self. |
|
1610 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1611 |
"/ ^ point x |
|
1612 |
"/ ]. |
|
1613 |
"/ ^ 0 |
|
1614 |
^ nil |
|
1615 |
]. |
|
4609 | 1616 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1617 |
||
1618 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1619 |
! ! |
|
4590 | 1620 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1621 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1622 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1623 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1624 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1625 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1626 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1627 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1628 |
wasOn := self hideCursor. |
5643 | 1629 |
cursorFgColor := color1 onDevice:device. |
1630 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1631 |
wasOn ifTrue:[self showCursor] |
1333 | 1632 |
! |
1633 |
||
1899 | 1634 |
cursorType |
1635 |
"return the style of the text cursor. |
|
4721 | 1636 |
Currently, supported are: #none |
1637 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1638 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1639 |
|
1640 |
^ cursorType |
|
1641 |
||
1642 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1643 |
! |
|
1644 |
||
1333 | 1645 |
cursorType:aCursorTypeSymbol |
1646 |
"set the style of the text cursor. |
|
4721 | 1647 |
Currently, supported are: #none |
1648 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1649 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1650 |
|
1334 | 1651 |
cursorType := aCursorTypeSymbol. |
1333 | 1652 |
|
1653 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1654 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1655 |
! |
1656 |
||
1899 | 1657 |
cursorTypeNoFocus |
1658 |
"return the style of the text cursor when the view has no focus. |
|
1659 |
If left unspecified, this is the same as the regular cursorType." |
|
1660 |
||
1661 |
^ cursorTypeNoFocus |
|
1662 |
||
1663 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1664 |
! |
|
1665 |
||
1334 | 1666 |
cursorTypeNoFocus:aCursorTypeSymbol |
1667 |
"set the style of the text cursor when the view has no focus. |
|
1668 |
If left unspecified, this is the same as the regular cursorType." |
|
1669 |
||
1670 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1671 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1672 |
|
4048 | 1673 |
!EditTextView methodsFor:'accessing-replace'! |
1674 |
||
4746 | 1675 |
lastReplacementInfo |
1676 |
^ lastReplacementInfo |
|
1677 |
! |
|
1678 |
||
4048 | 1679 |
lastStringToReplace: aString |
4818 | 1680 |
! |
1681 |
||
1682 |
previousReplacements |
|
1683 |
"accessor for the code completion" |
|
1684 |
||
1685 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1686 |
! ! |
1687 |
||
2119 | 1688 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1689 |
|
125 | 1690 |
accept |
1691 |
"accept the current contents by executing the accept-action and/or |
|
5937 | 1692 |
changeMessage. |
1693 |
Historically, ST/X used a callBack (acceptAction); |
|
1694 |
and ST80/VW used the model, into which the text is stored. |
|
1695 |
We support both; if there is a mode, it gets a value: message, |
|
1696 |
If there is an acceptAction, it is called." |
|
125 | 1697 |
|
1108 | 1698 |
acceptEnabled == false ifTrue:[ |
5937 | 1699 |
self beep. |
1700 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1701 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1702 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
5937 | 1703 |
^ self |
1108 | 1704 |
]. |
1705 |
||
125 | 1706 |
lockUpdates := true. |
1013 | 1707 |
|
1708 |
"/ |
|
1709 |
"/ ST-80 way of doing it |
|
1710 |
"/ |
|
1711 |
model notNil ifTrue:[ |
|
5937 | 1712 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
1713 |
acceptChannel notNil ifTrue:[ |
|
1714 |
acceptChannel value:true withoutNotifying:self. |
|
5525 | 1715 |
]. |
2999 | 1716 |
]. |
1717 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1718 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1719 |
"/ ST/X way of doing things |
5937 | 1720 |
"/ as a historic leftover, |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1721 |
"/ 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
|
1722 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1723 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1724 |
acceptAction notNil ifTrue:[ |
5937 | 1725 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1726 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1727 |
|
125 | 1728 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1729 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1730 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1731 |
! |
1732 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1733 |
argForChangeMessage |
597 | 1734 |
"return the argument to be passed with the change notification. |
1735 |
Defined as separate method for easier subclassability." |
|
1736 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1737 |
^ self contents |
597 | 1738 |
|
1739 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1740 |
! |
1741 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1742 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1743 |
"get my contents from the model. |
597 | 1744 |
Redefined to ignore updates resulting from my own changes |
1745 |
(i.e. if lockUpdates is true)." |
|
121 | 1746 |
|
1747 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1748 |
ignore updates from my own change |
121 | 1749 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1750 |
lockUpdates ifTrue:[ |
4823 | 1751 |
lockUpdates := false. |
1752 |
^ self |
|
121 | 1753 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1754 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1755 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1756 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1757 |
"/ validate the cursorLine |
3160 | 1758 |
(cursorLine notNil |
2310 | 1759 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1760 |
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
|
1761 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1762 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1763 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1764 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1765 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1766 |
acceptChannel value == true ifTrue:[ |
1767 |
self accept. |
|
1768 |
]. |
|
1769 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1770 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1771 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1772 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1773 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1774 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1775 |
! ! |
1776 |
||
1777 |
!EditTextView methodsFor:'cursor handling'! |
|
1778 |
||
4820 | 1779 |
basicCursorReturn |
1780 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1781 |
||
1782 |
|wasOn| |
|
1783 |
||
1784 |
self checkForExistingLine:(cursorLine + 1). |
|
1785 |
cursorVisibleLine notNil ifTrue:[ |
|
1786 |
nFullLinesShown notNil ifTrue:[ |
|
1787 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1788 |
] |
|
1789 |
]. |
|
1790 |
||
1791 |
wasOn := self hideCursor. |
|
1792 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1793 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1794 |
||
1795 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1796 |
! |
|
1797 |
||
2406 | 1798 |
characterPositionOfCursor |
1799 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1800 |
! |
|
1801 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1802 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1803 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1804 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1805 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1806 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1807 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1808 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1809 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1810 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1811 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1812 |
|
2822 | 1813 |
(cursorCol == newCol) ifTrue:[^ self]. |
1814 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1815 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1816 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1817 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1818 |
|
1819 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1820 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1821 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1822 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1823 |
"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
|
1824 |
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
|
1825 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1826 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1827 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1828 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1829 |
|
2707 | 1830 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1831 |
cursorLine > list size ifTrue:[ |
4595 | 1832 |
wasOn := self hideCursor. |
1833 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1834 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1835 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1836 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1837 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1838 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1841 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1842 |
"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
|
1843 |
|
5857 | 1844 |
|inLastLine wasOn nv nL cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1845 |
|
4595 | 1846 |
(nL := cursorLine) isNil ifTrue:[ |
5857 | 1847 |
nL := firstLineShown |
1848 |
]. |
|
1849 |
||
1850 |
inLastLine := (nL == list size). |
|
5890 | 1851 |
|
5857 | 1852 |
inLastLine ifTrue:[ |
5858 | 1853 |
|generateTextAfterEndHook| |
5857 | 1854 |
|
1855 |
cursorColBefore := cursorCol. |
|
5858 | 1856 |
(generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[ |
5860 | 1857 |
wasOn := self hideCursor. |
1858 |
nL := generateTextAfterEndHook value:(nL + n). |
|
1859 |
self setValidatedCursorLine:nL col:cursorColBefore. |
|
1860 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1861 |
^ self. |
|
5890 | 1862 |
]. |
4595 | 1863 |
]. |
1864 |
||
1865 |
self st80EditMode ifTrue:[ |
|
5857 | 1866 |
nL == list size ifTrue:[ |
1867 |
wasOn := self hideCursor. |
|
1868 |
self setValidatedCursorLine:nL col:(self listAt:nL) size + 1. |
|
1869 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1870 |
self beep. |
|
1871 |
^ self. |
|
1872 |
] |
|
4595 | 1873 |
]. |
1874 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1875 |
cursorVisibleLine notNil ifTrue:[ |
5857 | 1876 |
wasOn := self hideCursor. |
1877 |
nv := cursorVisibleLine + n - 1. |
|
1878 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1879 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1880 |
]. |
|
1881 |
self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol). |
|
1882 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1883 |
] ifFalse:[ |
5857 | 1884 |
self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol). |
1885 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1886 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1887 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1888 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1889 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1890 |
|
121 | 1891 |
cursorHome |
597 | 1892 |
"scroll to top AND move cursor to first line of text." |
121 | 1893 |
|
674 | 1894 |
self cursorLine:1 col:1 |
1895 |
||
1896 |
"/ |wasOn| |
|
1897 |
"/ |
|
1898 |
"/ wasOn := self hideCursor. |
|
1899 |
"/ self scrollToTop. |
|
1900 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1901 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1902 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1903 |
||
1904 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1905 |
! |
1906 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1907 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1908 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1909 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1910 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1911 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1912 |
] ifFalse:[ |
4823 | 1913 |
cursorLine ~~ 1 ifTrue:[ |
1914 |
self st80EditMode ifTrue:[ |
|
1915 |
self cursorUp. |
|
1916 |
self cursorToEndOfLine. |
|
1917 |
] |
|
1918 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1919 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1920 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1921 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1922 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1923 |
|
4126 | 1924 |
cursorLeft:n |
1925 |
"move cursor to left" |
|
1926 |
||
1927 |
n timesRepeat:[ |
|
1928 |
self cursorLeft |
|
1929 |
]. |
|
1930 |
! |
|
1931 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1932 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1933 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1934 |
|
5056 | 1935 |
self cursorLine:line col:col makeVisible:true |
1936 |
! |
|
1937 |
||
1938 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
1939 |
"this positions onto physical - not visible - line" |
|
1940 |
||
676 | 1941 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1942 |
|
2822 | 1943 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1944 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1945 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1946 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1947 |
|
672 | 1948 |
(col < 1) ifTrue:[ |
4823 | 1949 |
newCol := 1 |
672 | 1950 |
] ifFalse:[ |
4823 | 1951 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1952 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1953 |
self st80EditMode ifTrue:[ |
4823 | 1954 |
(cursorLine == list size |
1955 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1956 |
newCol := (self listAt:(list size)) size + 1. |
|
1957 |
] |
|
1419 | 1958 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1959 |
self setValidatedCursorCol:newCol. |
5056 | 1960 |
makeVisibleBoolean ifTrue:[ |
1961 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1962 |
] ifFalse:[ |
|
1963 |
wasOn ifTrue:[self showCursor] |
|
1964 |
]. |
|
672 | 1965 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1966 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1967 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1968 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1969 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1970 |
"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
|
1971 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1972 |
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
|
1973 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1974 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1975 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1976 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1977 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1978 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1979 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1980 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1981 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1982 |
"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
|
1983 |
|
4820 | 1984 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1985 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1986 |
|
5529 | 1987 |
cursorReturn:withPossibleAutoIndent |
1988 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1989 |
||
1990 |
self basicCursorReturn |
|
1991 |
! |
|
1992 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1993 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1994 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1995 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1996 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1997 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1998 |
self st80EditMode ifTrue:[ |
4823 | 1999 |
l := (self listAt:cursorLine). |
2000 |
cursorCol >= (l size + 1) ifTrue:[ |
|
5529 | 2001 |
cursorLine <= list size ifTrue:[ |
2002 |
self cursorReturn:false. "/ no autoindent |
|
4823 | 2003 |
]. |
2004 |
^ self |
|
2005 |
] |
|
3160 | 2006 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2007 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2008 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2009 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2010 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2011 |
|
4126 | 2012 |
cursorRight:n |
2013 |
"move cursor to right" |
|
2014 |
||
2015 |
n timesRepeat:[ |
|
2016 |
self cursorRight |
|
2017 |
]. |
|
2018 |
! |
|
2019 |
||
1833 | 2020 |
cursorShown:aBoolean |
2021 |
"change cursor visibility |
|
2022 |
return true if cursor was visible before." |
|
2023 |
||
2024 |
|oldState| |
|
2025 |
||
4494 | 2026 |
aBoolean == cursorShown ifTrue:[ |
2027 |
^ cursorShown |
|
2028 |
]. |
|
1833 | 2029 |
oldState := cursorShown. |
2030 |
||
2031 |
aBoolean ifTrue:[ |
|
4494 | 2032 |
self drawCursor. |
1833 | 2033 |
] ifFalse:[ |
4494 | 2034 |
(cursorShown and:[shown]) ifTrue: [ |
2035 |
self undrawCursor. |
|
2036 |
]. |
|
1833 | 2037 |
]. |
2038 |
cursorShown := aBoolean. |
|
2039 |
||
2040 |
^ oldState |
|
2041 |
||
2042 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
2043 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
2044 |
! |
|
2045 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2046 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2047 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2048 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2049 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2050 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2051 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2052 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2053 |
"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
|
2054 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2055 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2056 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2057 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2058 |
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
|
2059 |
cursorCol > textStart ifTrue:[ |
4823 | 2060 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2061 |
] ifFalse:[ |
4823 | 2062 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2063 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2064 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2065 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2066 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2067 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2068 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2069 |
"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
|
2070 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2071 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2072 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2073 |
wasOn := self hideCursor. |
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 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2076 |
(newTop < 1) ifTrue:[ |
4823 | 2077 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2078 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2079 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2080 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2081 |
self setValidatedCursorLine:(list size) col:1. |
259
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 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2084 |
|
674 | 2085 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
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 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2088 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2089 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2090 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2091 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2092 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2093 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2094 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2095 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2096 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2097 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2098 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2099 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2100 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2101 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2102 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2103 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2104 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2105 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2106 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2107 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2108 |
cursorLine >= lineNr ifTrue:[ |
4823 | 2109 |
line := self listAt:cursorLine. |
2110 |
(line isEmptyOrNil) ifTrue:[ |
|
2111 |
^ self |
|
2112 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2113 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2114 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2115 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2116 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2117 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2118 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2119 |
(newTop < 1) ifTrue:[ |
4823 | 2120 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2121 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2122 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2123 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2124 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2125 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2126 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2127 |
|
674 | 2128 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2129 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2130 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2131 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2132 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2133 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2134 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2135 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2136 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2137 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2138 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2139 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2140 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2141 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2142 |
cursorToEndOfText |
4288 | 2143 |
"move cursor to the end of the text (behind the last character in last line)" |
2144 |
||
2145 |
|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
|
2146 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2147 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2148 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2149 |
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
|
2150 |
(newTop < 1) ifTrue:[ |
4288 | 2151 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2152 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2153 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2154 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2155 |
self setValidatedCursorLine:list size. |
4288 | 2156 |
lastLineLength := (self listAt:cursorLine) size. |
2157 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2158 |
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
|
2159 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2160 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2161 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2162 |
"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
|
2163 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2164 |
|
3310 | 2165 |
cursorToEndOfWord |
2166 |
"move the cursor to the end of the word" |
|
2167 |
||
2168 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2169 |
||
2170 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2171 |
:beginLine :beginCol :endLine :endCol :style | |
2172 |
||
2173 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2174 |
] |
2175 |
||
2176 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2177 |
! |
|
2178 |
||
131 | 2179 |
cursorToFirstVisibleLine |
2180 |
"place cursor into the first visible line; do not scroll." |
|
2181 |
||
2182 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2183 |
! |
|
2184 |
||
2185 |
cursorToLastVisibleLine |
|
2186 |
"place cursor into the first visible line; do not scroll." |
|
2187 |
||
2188 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2189 |
! |
|
2190 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2191 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2192 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2193 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2194 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2195 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2196 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2197 |
|
3890 | 2198 |
self |
4707 | 2199 |
wordAtLine:cursorLine col:cursorCol |
2200 |
do:[ |
|
3890 | 2201 |
:beginLine :beginCol :endLine :endCol :style | |
2202 |
||
2203 |
line := endLine. |
|
2204 |
col := endCol + 1. |
|
2205 |
searching := true. |
|
4707 | 2206 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2207 |
self wordAtLine:line col:col do:[ |
2208 |
:beginLine :beginCol :endLine :endCol :style | |
|
2209 |
||
2210 |
(line > list size) ifTrue:[ |
|
2211 |
"break out" |
|
2212 |
searching := false |
|
2213 |
] ifFalse:[ |
|
2214 |
line := endLine. |
|
2215 |
col := endCol + 1. |
|
2216 |
] |
|
2217 |
] |
|
2218 |
]. |
|
2219 |
self cursorLine:line col:col |
|
4707 | 2220 |
] |
121 | 2221 |
! |
2222 |
||
499 | 2223 |
cursorToPreviousWord |
2224 |
"move the cursor to the beginning of this or the previous word" |
|
2225 |
||
2226 |
|col line searching l| |
|
2227 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2228 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2229 |
|
2230 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2231 |
:beginLine :beginCol :endLine :endCol :style | |
2232 |
||
2233 |
line := beginLine. |
|
2234 |
col := beginCol. |
|
2235 |
style == #wordLeft ifTrue:[ |
|
2236 |
col := col + 1 |
|
2237 |
]. |
|
2238 |
||
2239 |
(cursorLine == line |
|
2240 |
and:[cursorCol == col]) ifTrue:[ |
|
2241 |
searching := true. |
|
2242 |
||
2243 |
col > 1 ifTrue:[ |
|
2244 |
col := col - 1. |
|
2245 |
]. |
|
2246 |
||
2247 |
[searching] whileTrue:[ |
|
2248 |
(col == 1) ifTrue:[ |
|
2249 |
line == 1 ifTrue:[ |
|
2250 |
searching := false |
|
2251 |
] ifFalse:[ |
|
2252 |
line := line - 1. |
|
2253 |
l := list at:line. |
|
2254 |
col := l size + 1. |
|
2255 |
] |
|
2256 |
] ifFalse:[ |
|
2257 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2258 |
self wordAtLine:line col:col do:[ |
|
2259 |
:beginLine :beginCol :endLine :endCol :style | |
|
2260 |
||
2261 |
line := beginLine. |
|
2262 |
col := beginCol. |
|
2263 |
style == #wordLeft ifTrue:[ |
|
2264 |
col := col + 1 |
|
2265 |
]. |
|
2266 |
searching := false. |
|
2267 |
] |
|
2268 |
] ifTrue:[ |
|
2269 |
col := col - 1 |
|
2270 |
] |
|
2271 |
] |
|
2272 |
] |
|
2273 |
]. |
|
2274 |
self cursorLine:line col:col |
|
499 | 2275 |
] |
2276 |
||
2277 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2278 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2279 |
! |
|
2280 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2281 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2282 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2283 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2284 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2285 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2286 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2287 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2288 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2289 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2290 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2291 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2292 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2293 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2294 |
"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
|
2295 |
|
5856 | 2296 |
|wasOn nv nl cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2297 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2298 |
cursorLine isNil ifTrue:[ |
5850 | 2299 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
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 |
nl := cursorLine - n. |
5850 | 2302 |
nl < 1 ifTrue:[ |
5858 | 2303 |
|generateTextBeforeStartHook| |
5890 | 2304 |
|
5856 | 2305 |
cursorColBefore := cursorCol. |
5858 | 2306 |
(generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[ |
2307 |
nl := generateTextBeforeStartHook value:nl |
|
5890 | 2308 |
]. |
5850 | 2309 |
nl := nl max:1 |
2310 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2311 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2312 |
(nl ~~ cursorLine) ifTrue: [ |
5850 | 2313 |
wasOn := self hideCursor. |
2314 |
cursorVisibleLine notNil ifTrue:[ |
|
2315 |
nv := cursorVisibleLine - n. |
|
2316 |
nv < 1 ifTrue:[ |
|
2317 |
self scrollUp:(nv negated + 1) |
|
2318 |
]. |
|
2319 |
]. |
|
5856 | 2320 |
self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol). |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2321 |
"/ wasOn ifTrue:[self showCursor]. |
5850 | 2322 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2323 |
] |
672 | 2324 |
|
674 | 2325 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2326 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2327 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2328 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2329 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2330 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2331 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2332 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2333 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2334 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2335 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2336 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2337 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2338 |
|
676 | 2339 |
newCol := colNr. |
2340 |
(newCol < 1) ifTrue:[ |
|
4823 | 2341 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2342 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2343 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2344 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2345 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2346 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2347 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2348 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2349 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2350 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2351 |
"put cursor to position next to x/y coordinate in view" |
121 | 2352 |
|
2353 |
|line col| |
|
2354 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2355 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2356 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2357 |
self cursorVisibleLine:line col:col. |
121 | 2358 |
! |
2359 |
||
2360 |
drawCursor |
|
2361 |
"draw the cursor if shown and cursor is visible. |
|
2362 |
(but not, if there is a selection - to avoid confusion)" |
|
2363 |
||
2364 |
shown ifTrue:[ |
|
4823 | 2365 |
cursorVisibleLine notNil ifTrue:[ |
2366 |
self hasSelection ifFalse:[ |
|
2367 |
self drawCursorCharacter |
|
2368 |
] |
|
2369 |
] |
|
121 | 2370 |
] |
2371 |
! |
|
2372 |
||
2373 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2374 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2375 |
of cursor should be drawn. |
4721 | 2376 |
Currently, supported are: #none, |
2377 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2378 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2379 |
|
2570 | 2380 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2381 |
|
2382 |
self hasSelection ifTrue:[ |
|
4580 | 2383 |
" |
2384 |
hide cursor, if there is a selection |
|
2385 |
" |
|
2386 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2387 |
]. |
2388 |
||
1334 | 2389 |
cursorType == #none ifTrue:[ |
4580 | 2390 |
^ self |
1334 | 2391 |
]. |
2392 |
||
121 | 2393 |
cursorType == #block ifTrue:[ |
4829 | 2394 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2395 |
^ self |
121 | 2396 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2397 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2398 |
y := self yOfVisibleLine:cursorVisibleLine. |
2399 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2400 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2401 |
cursorType == #frame ifTrue:[ |
4580 | 2402 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2403 |
||
2404 |
char := self characterUnderCursor asString. |
|
4829 | 2405 |
self paint:bgColor. |
4889 | 2406 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2407 |
] ifFalse:[ |
4580 | 2408 |
self paint:bgColor. |
2409 |
cursorType == #ibeam ifTrue:[ |
|
2410 |
x1 := x - 1. |
|
5581 | 2411 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2412 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2413 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2414 |
^ self |
|
2415 |
]. |
|
2416 |
||
2417 |
cursorType == #Ibeam ifTrue:[ |
|
2418 |
x1 := x - 1. |
|
2419 |
y := y + 1. |
|
5581 | 2420 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2421 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2422 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2423 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2424 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2425 |
^ self |
|
2426 |
]. |
|
2427 |
||
2428 |
y := y + fontHeight - 3. |
|
2429 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2430 |
w := (fontWidth * 2 // 3) max:4. |
|
2431 |
y2 := y + w + (w//2). |
|
2432 |
] ifFalse:[ |
|
2433 |
w := (fontWidth // 2) max:4. |
|
2434 |
y2 := y + w. |
|
2435 |
]. |
|
2436 |
x1 := x - w. |
|
2437 |
x2 := x + w. |
|
2438 |
||
2439 |
oldClip := self clippingRectangleOrNil. |
|
2440 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2441 |
||
2442 |
cursorType == #caret ifTrue:[ |
|
2443 |
self lineWidth:2. |
|
2444 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2445 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2446 |
] ifFalse:[ |
|
2447 |
"anything else: solidCaret" |
|
2448 |
||
2449 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2450 |
with:(x @ y) |
|
2451 |
with:(x2 @ y2)) |
|
2452 |
]. |
|
2453 |
||
2454 |
self clippingRectangle:oldClip |
|
121 | 2455 |
]. |
133 | 2456 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2457 |
|
2088 | 2458 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2459 |
! |
2460 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2461 |
drawCursorCharacter |
3160 | 2462 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2463 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2464 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2465 |
|
3160 | 2466 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2467 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2468 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2469 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2470 |
] ifFalse:[ |
4823 | 2471 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2472 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2473 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2474 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2475 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2476 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2477 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2478 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2479 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2480 |
self hasSelection ifTrue:[ |
5260 | 2481 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2482 |
]. |
2483 |
cursorType == #none ifTrue:[ |
|
4823 | 2484 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2485 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2486 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2487 |
|
2488 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2489 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2490 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2491 |
drawNoFocusCursor |
3160 | 2492 |
"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
|
2493 |
|
1334 | 2494 |
|cType| |
2495 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2496 |
self hasSelection ifTrue:[ |
4823 | 2497 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2498 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2499 |
|
1334 | 2500 |
cType := cursorTypeNoFocus ? cursorType. |
2501 |
cType == #none ifTrue:[ |
|
4823 | 2502 |
^ self undrawCursor |
1334 | 2503 |
]. |
2504 |
||
2505 |
cType == #block ifTrue:[ |
|
4823 | 2506 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2507 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2508 |
|
1334 | 2509 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2510 |
||
2511 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2512 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2513 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2514 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2515 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2516 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2517 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2518 |
self makeLineVisible:aLineNumber. |
2951 | 2519 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2520 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2521 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2522 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2523 |
hideCursor |
1833 | 2524 |
"make cursor invisible if currently invisible" |
2525 |
||
2526 |
^ self cursorShown:false |
|
2527 |
||
2528 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2529 |
! |
2530 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2531 |
makeCursorVisible |
3160 | 2532 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2533 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2534 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2535 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2536 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2537 |
cursorLine notNil ifTrue:[ |
4823 | 2538 |
line := cursorLine. |
2539 |
col := cursorCol. |
|
2540 |
" |
|
2541 |
if there is a selection, its better to |
|
2542 |
have its start being visible, instead of the end |
|
2543 |
" |
|
2544 |
(selectionStartLine notNil |
|
2545 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2546 |
expandingTop ~~ false ifTrue:[ |
|
2547 |
line := selectionStartLine. |
|
2548 |
col := selectionStartCol. |
|
2549 |
] ifFalse:[ |
|
2550 |
line := selectionEndLine. |
|
2551 |
col := selectionEndCol |
|
2552 |
] |
|
2553 |
]. |
|
2554 |
self makeLineVisible:line. |
|
2555 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2556 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2557 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2558 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2559 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2560 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2561 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2562 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2563 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2564 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2565 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2566 |
flag ifTrue:[self showCursor] |
121 | 2567 |
! |
2568 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2569 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2570 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2571 |
|
2815 | 2572 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2573 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2574 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2575 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2576 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2577 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2578 |
|
3303 | 2579 |
"/ self assert:(lineNr notNil). |
2580 |
||
2581 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2582 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2583 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2584 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2585 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2586 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2587 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2588 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2589 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2590 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2591 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2592 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2593 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2594 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2595 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2596 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2597 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2598 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2599 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2600 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2601 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2602 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2603 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2604 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2605 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2606 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2607 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2608 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2609 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2610 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2611 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2612 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2613 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2614 |
|
1833 | 2615 |
^ self cursorShown:true |
2616 |
||
2617 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2618 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2619 |
|
5761 | 2620 |
singleQuoteSelection |
2621 |
"place single quotes around the selected text" |
|
2622 |
||
2623 |
|line1 col1 line2 col2| |
|
2624 |
||
2625 |
line1 := self selectionStartLine. |
|
2626 |
col1 := self selectionStartCol. |
|
2627 |
line2 := self selectionEndLine. |
|
2628 |
col2 := self selectionEndCol. |
|
2629 |
(line1 notNil |
|
2630 |
and:[ col1 notNil |
|
2631 |
and:[ line2 notNil |
|
2632 |
and:[ col2 notNil ]]]) |
|
2633 |
ifTrue:[ |
|
2634 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
|
2635 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2636 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
2637 |
] ifFalse:[ |
|
2638 |
self beep. |
|
2639 |
] |
|
2640 |
||
2641 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2642 |
! |
|
2643 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2644 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2645 |
"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
|
2646 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2647 |
|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
|
2648 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2649 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2650 |
prevCol := cursorCol - 1. |
2651 |
||
2652 |
"/ if there is any italic stuff in the cursor line, |
|
2653 |
"/ redraw it completely (because characters overlap). |
|
2654 |
cursorCol > 1 ifTrue:[ |
|
2655 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2656 |
line hasChangeOfEmphasis ifTrue:[ |
|
2657 |
line size >= (cursorCol-1) ifTrue:[ |
|
2658 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2659 |
line size >= (cursorCol) ifTrue:[ |
|
2660 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2661 |
line size >= (cursorCol+1) ifTrue:[ |
|
2662 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2663 |
]. |
|
2664 |
]. |
|
2665 |
]. |
|
2666 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2667 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2668 |
] |
|
2669 |
] |
|
2670 |
] |
|
2671 |
]. |
|
2672 |
||
2673 |
((cursorType == #caret) |
|
2674 |
or:[cursorType == #solidCaret |
|
2675 |
or:[cursorType == #bigSolidCaret |
|
2676 |
or:[cursorType == #bigCaret |
|
2677 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2678 |
"caret-cursor touches 4 characters" |
|
2679 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2680 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2681 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2682 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2683 |
] ifFalse:[ |
|
2684 |
"care for left margin" |
|
2685 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2686 |
]. |
|
2687 |
^ self |
|
2688 |
]. |
|
2689 |
||
2690 |
cursorType == #ibeam ifTrue:[ |
|
2691 |
"ibeam-cursor touches 2 characters" |
|
2692 |
cursorCol > 1 ifTrue:[ |
|
2693 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2694 |
] ifFalse:[ |
|
2695 |
"care for left margin" |
|
2696 |
super redrawVisibleLine:cursorVisibleLine. |
|
2697 |
]. |
|
2698 |
^ self |
|
2699 |
]. |
|
2700 |
||
2701 |
"block cursor is simple - just one character under cursor" |
|
2702 |
||
2703 |
"/ however, if italic characters are involved, we must care |
|
2704 |
"/ for the chars before/after the cursor. |
|
2705 |
"/ We redraw the part of the previous character which got |
|
2706 |
"/ detroyed by the block cursor. |
|
2707 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2708 |
||
2709 |
line := self visibleAt:cursorVisibleLine. |
|
2710 |
(line notNil and:[line isText]) ifTrue:[ |
|
2711 |
cursorCol > 1 ifTrue:[ |
|
2712 |
oldClip := self clippingRectangleOrNil. |
|
2713 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2714 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2715 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2716 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2717 |
self clippingRectangle:oldClip. |
|
2718 |
^ self. |
|
2719 |
]. |
|
2720 |
]. |
|
2721 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2722 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2723 |
|
2088 | 2724 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2725 |
! |
2726 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2727 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2728 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2729 |
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
|
2730 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2731 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2732 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2733 |
|
672 | 2734 |
validateCursorCol:col inLine:line |
674 | 2735 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2736 |
Here, no limits are enforced (and col is returned), |
5593 | 2737 |
but it may be redefined in EditFields or views which don't like the |
674 | 2738 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2739 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2740 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2741 |
|
1419 | 2742 |
"/ in ST80 mode, |
2707 | 2743 |
"/ the cursor may not be positioned beyond the |
2744 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2745 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2746 |
self st80EditMode ifTrue:[ |
4823 | 2747 |
l := (self listAt:line). |
2748 |
max := l size + 1. |
|
2749 |
col > max ifTrue:[ |
|
2750 |
^ max |
|
2751 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2752 |
]. |
672 | 2753 |
^ col |
2754 |
||
1419 | 2755 |
"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
|
2756 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2757 |
! |
2758 |
||
2759 |
validateCursorLine:line |
|
2760 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2761 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2762 |
redefined in views which don't like the cursor to be positioned |
674 | 2763 |
behind the end of the text (vi/st-80 behavior), or want to |
2764 |
skip reserved regions" |
|
2765 |
||
1419 | 2766 |
"/ |
2767 |
"/ in st80Mode, the cursor may not be positioned |
|
5367 | 2768 |
"/ beyond the last line |
2769 |
"/ (but it must be posible to place it on one line below the last one |
|
2770 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
|
1419 | 2771 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2772 |
self st80EditMode ifTrue:[ |
5367 | 2773 |
^ (line min:(list size + 1)) max:1 |
1419 | 2774 |
]. |
674 | 2775 |
^ line |
2776 |
||
1419 | 2777 |
"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
|
2778 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2779 |
! |
2780 |
||
121 | 2781 |
withCursorOffDo:aBlock |
2782 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2783 |
||
2784 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2785 |
^ aBlock value |
121 | 2786 |
]. |
2787 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2788 |
aBlock ensure:[ |
4823 | 2789 |
self showCursor |
121 | 2790 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2791 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2792 |
|
2589 | 2793 |
!EditTextView methodsFor:'drag & drop'! |
2794 |
||
2795 |
allowDrop:aBoolean |
|
3236 | 2796 |
"enable/disable drop support" |
2797 |
||
2589 | 2798 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2799 |
dropTarget := nil. |
2589 | 2800 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2801 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2802 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2803 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2804 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2805 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2806 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2807 |
] |
3236 | 2808 |
]. |
2809 |
! |
|
2810 |
||
3412 | 2811 |
canDrop:aDropContext |
2812 |
"public from d&d. |
|
2813 |
I accept textObjects and fileObjects only." |
|
2814 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2815 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2816 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2817 |
^ self canDropObjects:aDropContext dropObjects |
|
2818 |
||
2819 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2820 |
! |
|
2821 |
||
2822 |
canDropObjects:aCollectionOfDropObjects |
|
2823 |
"public from d&d. |
|
2824 |
I accept textObjects and fileObjects only." |
|
2589 | 2825 |
|
2826 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2827 |
||
3412 | 2828 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2829 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2830 |
||
2831 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2832 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2833 |
! |
|
2834 |
||
2835 |
drop:aDropContext |
|
2836 |
"public from d&d. |
|
2837 |
drop objects (new API)" |
|
2838 |
||
2839 |
self dropObjects:(aDropContext dropObjects) |
|
2840 |
||
2841 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2842 |
! |
|
2843 |
||
2844 |
dropFileObject:aDropObject |
|
2589 | 2845 |
"drop objects |
3236 | 2846 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2847 |
||
4136 | 2848 |
|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
|
2849 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2850 |
pasteWhat := #name. |
3412 | 2851 |
|
2852 |
fn := aDropObject asFilename. |
|
2853 |
(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
|
2854 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2855 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2856 |
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
|
2857 |
pasteWhat := enforcedDropMode. |
3886 | 2858 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2859 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2860 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2861 |
pasteWhat := #name. |
3886 | 2862 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2863 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2864 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2865 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2866 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2867 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2868 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2869 |
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
|
2870 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2871 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2872 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2873 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2874 |
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
|
2875 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2876 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2877 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2878 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2879 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2880 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2881 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2882 |
] |
3886 | 2883 |
] |
2884 |
]. |
|
2885 |
]. |
|
2886 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2887 |
pasteWhat == #name ifTrue:[ |
3886 | 2888 |
text := fn pathName |
2889 |
] ifFalse:[ |
|
2890 |
self withWaitCursorDo:[ |
|
5063 | 2891 |
text := fn contentsAsString |
4136 | 2892 |
]. |
2893 |
(app := self application) notNil ifTrue:[ |
|
2894 |
app droppedFile:fn in:self |
|
2895 |
]. |
|
3886 | 2896 |
]. |
2897 |
||
3799 | 2898 |
self |
2899 |
undoablePaste:text |
|
2900 |
info:'Drop File'. |
|
3412 | 2901 |
|
2902 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2903 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2904 |
! |
2905 |
||
2906 |
dropObject:aDropObject |
|
2907 |
"drop objects |
|
2908 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2909 |
||
3415 | 2910 |
|text| |
2911 |
||
3412 | 2912 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2913 |
self dropFileObject:aDropObject |
3412 | 2914 |
] ifFalse:[ |
3799 | 2915 |
aDropObject isTextObject ifTrue:[ |
2916 |
text := aDropObject theObject. |
|
2917 |
text isStringCollection ifTrue:[ |
|
2918 |
text := text asStringWithoutFinalCR |
|
2919 |
]. |
|
2920 |
] ifFalse:[ |
|
2921 |
text := aDropObject theObject asString |
|
2922 |
]. |
|
2923 |
self |
|
2924 |
undoablePaste:text |
|
2925 |
info:'Drop'. |
|
3412 | 2926 |
]. |
2927 |
||
2928 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2929 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2930 |
! |
2931 |
||
2932 |
dropObjects:aCollectionOfDropObjects |
|
2933 |
"public from d&d. |
|
2934 |
drop objects (old API)" |
|
2935 |
||
3868 | 2936 |
aCollectionOfDropObjects do:[:el | |
2937 |
self dropObject:el |
|
3412 | 2938 |
]. |
2939 |
||
2940 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2941 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2942 |
! ! |
2943 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2944 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2945 |
|
5761 | 2946 |
applyConverterToSelection:converter |
2947 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2948 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2949 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2950 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2951 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2952 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2953 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2954 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2955 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2956 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2957 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2958 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2959 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2960 |
line1 to:line2 do:[:lineNr | |
5761 | 2961 |
|line col1 col2 newLine| |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2962 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2963 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2964 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2965 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2966 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2967 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2968 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2969 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2970 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2971 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2972 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2973 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2974 |
]. |
5761 | 2975 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
2976 |
self withoutRedrawAt:lineNr put:newLine. |
|
2977 |
self invalidateLine:lineNr. |
|
2978 |
]. |
|
2979 |
]. |
|
2980 |
] |
|
2981 |
||
2982 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
2983 |
! |
|
2984 |
||
2985 |
convertSelectionToLowercase |
|
2986 |
"to-lower selected text" |
|
2987 |
||
2988 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
2989 |
col1 to:col2 do:[:col | |
|
2990 |
|ch| |
|
2991 |
||
2992 |
ch := line at:col. |
|
2993 |
line at:col put:ch asLowercase. |
|
2994 |
]. |
|
2995 |
line. |
|
2996 |
]. |
|
2997 |
||
2998 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
2999 |
! |
|
3000 |
||
3001 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
3002 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
3003 |
||
3004 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
3005 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
|
3006 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
3007 |
||
3008 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
3009 |
col1 to:col2 do:[:col | |
|
3010 |
|ch| |
|
3011 |
||
3012 |
ch := line at:col. |
|
3013 |
ch isUppercase ifTrue:[ |
|
3014 |
isAllLower := false. |
|
3015 |
col == col1 ifTrue:[ |
|
3016 |
isLowerFirst := false. |
|
3017 |
]. |
|
3018 |
] ifFalse:[ |
|
3019 |
ch isLowercase ifTrue:[ |
|
3020 |
isAllUpper := false. |
|
3021 |
col == col1 ifTrue:[ |
|
3022 |
isUpperFirst := false. |
|
3023 |
]. |
|
3024 |
] |
|
3025 |
]. |
|
3026 |
]. |
|
3027 |
||
3028 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
3029 |
isLowerFirst ifTrue:[ |
|
3030 |
makeUppercaseFirst := true. |
|
3031 |
] ifFalse:[ |
|
3032 |
"/ must remember where we come from - otherwise, we end up |
|
3033 |
"/ in upperFirst - lowerFirst cycle. |
|
3034 |
"/ think about a good place to store this state |
|
3035 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
3036 |
makeLowercaseFirst := true. |
|
3037 |
] ifFalse:[ |
|
3038 |
isAllUpper ifTrue:[ |
|
3039 |
makeLowercase := true. |
|
3040 |
] ifFalse:[ |
|
3041 |
makeUppercase := true. |
|
3042 |
] |
|
3043 |
] |
|
3044 |
]. |
|
3045 |
makeUppercaseFirst ifTrue:[ |
|
3046 |
line at:col1 put:(line at:col1) asUppercase. |
|
3047 |
] ifFalse:[ |
|
3048 |
makeLowercaseFirst ifTrue:[ |
|
3049 |
line at:col1 put:(line at:col1) asLowercase. |
|
3050 |
] ifFalse:[ |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3051 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3052 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3053 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3054 |
ch := line at:col. |
5761 | 3055 |
ch := makeLowercase |
3056 |
ifTrue:[ ch asLowercase ] |
|
3057 |
ifFalse:[ |
|
3058 |
makeUppercase |
|
3059 |
ifTrue:[ ch asUppercase ] |
|
3060 |
ifFalse:[ |
|
3061 |
col == col1 |
|
3062 |
ifTrue:[ ch asUppercase ] |
|
3063 |
ifFalse:[ ch asLowercase ] |
|
3064 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3065 |
]. |
5761 | 3066 |
line at:col put:ch. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3067 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3068 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3069 |
]. |
5761 | 3070 |
line |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3071 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3072 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3073 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 3074 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
3075 |
! |
|
3076 |
||
3077 |
convertSelectionToUppercase |
|
3078 |
"to-upper selected text" |
|
3079 |
||
3080 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3081 |
col1 to:col2 do:[:col | |
|
3082 |
|ch| |
|
3083 |
||
3084 |
ch := line at:col. |
|
3085 |
line at:col put:ch asUppercase. |
|
3086 |
]. |
|
3087 |
line. |
|
3088 |
]. |
|
3089 |
||
3090 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
3091 |
! |
|
3092 |
||
3093 |
convertSelectionToUppercaseFirst |
|
3094 |
"to-upperFirst selected text" |
|
3095 |
||
3096 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3097 |
|state| |
|
3098 |
||
3099 |
state := #first. |
|
3100 |
col1 to:col2 do:[:col | |
|
3101 |
|ch| |
|
3102 |
||
3103 |
ch := line at:col. |
|
3104 |
ch isSeparator ifFalse:[ |
|
3105 |
state == #first ifTrue:[ |
|
3106 |
line at:col put:ch asUppercase. |
|
3107 |
state := #skipRest |
|
3108 |
] |
|
3109 |
] ifTrue:[ |
|
3110 |
state := #first |
|
3111 |
] |
|
3112 |
]. |
|
3113 |
line. |
|
3114 |
]. |
|
3115 |
||
3116 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3117 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3118 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3119 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3120 |
"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
|
3121 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3122 |
selectionStartLine notNil ifTrue:[ |
4823 | 3123 |
self setClipboardText:(self selection). |
3124 |
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
|
3125 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3126 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3127 |
"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
|
3128 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3129 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3130 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3131 |
"delete single character under cursor; does not merge lines" |
121 | 3132 |
|
3133 |
|wasOn| |
|
3134 |
||
3135 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3136 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3137 |
wasOn ifTrue:[self showCursor] |
3138 |
! |
|
3139 |
||
827 | 3140 |
deleteCharAtLine:lineNr col:colNr |
3141 |
"delete a single character at colNr in line lineNr" |
|
3142 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3143 |
self st80EditMode ifTrue:[ |
4823 | 3144 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3145 |
| wasOn | |
|
3146 |
wasOn := self hideCursor. |
|
3147 |
self |
|
3148 |
cursorReturn; |
|
3149 |
cursorCol:1; |
|
3150 |
deleteCharBeforeCursor. |
|
3151 |
wasOn ifTrue:[ self showCursor]. |
|
3152 |
^ self. |
|
3153 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3154 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3155 |
|
827 | 3156 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3157 |
! |
|
3158 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3159 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3160 |
"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
|
3161 |
|
4592 | 3162 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3163 |
|
3164 |
wasOn := self hideCursor. |
|
4814 | 3165 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 3166 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
4966 | 3167 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
4592 | 3168 |
ln size < prevTab ifTrue:[ |
3169 |
ln := ln , (String new:prevTab withAll:Character space). |
|
3170 |
]. |
|
3171 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3172 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3173 |
cursorCol > prevTab ifTrue:[ |
|
3174 |
self st80EditMode ifTrue:[ |
|
3175 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3176 |
"/ not allow a cursor position beyond the end of line, |
|
5742 | 3177 |
"/ so ensure that cursorLine:col: will force us to the beginning of the line |
4592 | 3178 |
originalLine size < prevTab ifTrue:[ |
5742 | 3179 |
self checkForExistingLine:cursorLine. |
4771 | 3180 |
self basicListAt:cursorLine put:ln |
4592 | 3181 |
] |
3182 |
]. |
|
3183 |
self cursorLine:cursorLine col:prevTab. |
|
3184 |
wasOn ifTrue:[ self showCursor ]. |
|
3185 |
^ self |
|
3186 |
]. |
|
3187 |
] ifFalse:[ |
|
3188 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
3189 |
self cursorLine:cursorLine col:prevTab. |
|
3190 |
wasOn ifTrue:[ self showCursor ]. |
|
3191 |
^ self. |
|
3192 |
] |
|
3193 |
]. |
|
827 | 3194 |
]. |
3195 |
||
2491 | 3196 |
"/ (autoIndent |
3197 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3198 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3199 |
"/ ifTrue:[ |
3200 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3201 |
"/ |
|
3202 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3203 |
"/ ln := list at:cursorLine. |
|
3204 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3205 |
"/ soCol := 1 |
|
3206 |
"/ ] |
|
3207 |
"/ ] |
|
3208 |
"/ ] ifFalse:[ |
|
4592 | 3209 |
soCol := 1. |
2491 | 3210 |
"/ ]. |
3211 |
||
1419 | 3212 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 3213 |
" |
3214 |
somewhere in the middle of a line |
|
3215 |
" |
|
3216 |
self cursorLeft. |
|
3217 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3218 |
] ifFalse:[ |
4592 | 3219 |
" |
3220 |
at begin of line - merge with previous line; |
|
3221 |
except for the very first line. |
|
3222 |
" |
|
3223 |
(cursorLine == 1) ifFalse:[ |
|
3224 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3225 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3226 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3227 |
"/ we are beyond the end of the text. |
|
3228 |
"/ move the cursor to the previous line. |
|
3229 |
self cursorLine:lineNrAboveCursor col:1. |
|
3230 |
] ifFalse:[ |
|
3231 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3232 |
] |
|
3233 |
] |
|
3234 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3235 |
]. |
827 | 3236 |
wasOn ifTrue:[ self showCursor ] |
3237 |
||
1419 | 3238 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 3239 |
! |
3240 |
||
3241 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3242 |
"delete characters from colNr up to the end in line lineNr" |
|
3243 |
||
3244 |
|line| |
|
3245 |
||
3246 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 3247 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3248 |
] |
3249 |
||
3250 |
! |
|
3251 |
||
4458 | 3252 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3253 |
"delete characters from startCol to endCol in line lineNr" |
|
3254 |
||
3255 |
|deleted| |
|
3256 |
||
3257 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3258 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3259 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3260 |
! |
|
3261 |
||
827 | 3262 |
deleteCharsAtLine:lineNr toCol:colNr |
3263 |
"delete characters from start up to colNr in line lineNr" |
|
3264 |
||
3265 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3266 |
||
3267 |
||
121 | 3268 |
! |
3269 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3270 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3271 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3272 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3273 |
self deleteLine:cursorLine |
121 | 3274 |
! |
3275 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3276 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3277 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3278 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3279 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3280 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3281 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3282 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3283 |
col1 == 0 ifTrue:[ |
4823 | 3284 |
line1 := line1 - 1. |
3285 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3286 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3287 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3288 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3289 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3290 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3291 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3292 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3293 |
|
2954 | 3294 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3295 |
"delete all text from startLine/startCol to endLine/endCol - |
|
3296 |
joining lines if nescessary" |
|
3297 |
||
3298 |
|line newLine lineSize nMore| |
|
3299 |
||
3300 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3301 |
list isNil ifTrue:[^ self]. |
|
3302 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3303 |
||
3304 |
(startLine == endLine) ifTrue:[ |
|
4225 | 3305 |
"/ delete chars within a line |
3306 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3307 |
^ self |
|
2954 | 3308 |
]. |
3309 |
||
3310 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3311 |
"/ delete full lines only |
3312 |
endLine > startLine ifTrue:[ |
|
3313 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3314 |
]. |
|
3315 |
^ self |
|
2954 | 3316 |
]. |
3317 |
||
3318 |
"/ delete right rest of 1st line |
|
4786 | 3319 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3320 |
|
3321 |
"/ delete the inner lines ... |
|
3322 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3323 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3324 |
]. |
3325 |
||
3326 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3327 |
"/ delete the left rest of the last line |
3328 |
||
3329 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3330 |
||
3331 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3332 |
startLine <= list size ifTrue:[ |
|
3333 |
line := list at:startLine. |
|
3334 |
lineSize := line size. |
|
3335 |
(startCol > lineSize) ifTrue:[ |
|
3336 |
newLine := line. |
|
3337 |
line isNil ifTrue:[ |
|
3338 |
newLine := String new:(startCol - 1) |
|
3339 |
] ifFalse:[ |
|
3340 |
nMore := startCol - 1 - lineSize. |
|
3341 |
nMore > 0 ifTrue:[ |
|
3342 |
newLine := line , (line species new:nMore) |
|
3343 |
] |
|
3344 |
]. |
|
3345 |
newLine ~~ line ifTrue:[ |
|
4771 | 3346 |
self basicListAt:startLine put:newLine. |
4225 | 3347 |
]. |
3348 |
"/ TODO: remember old maxwidth of linerange, |
|
3349 |
"/ only clear widthOfWidestLine, if this max |
|
3350 |
"/ length was (one of) the longest. |
|
3351 |
"/ avoids slow delete with huge texts. |
|
3352 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3353 |
self textChanged. |
|
3354 |
] |
|
3355 |
] |
|
2954 | 3356 |
]. |
3357 |
||
3358 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3359 |
self mergeLine:startLine removeBlanks:false |
|
3360 |
||
4225 | 3361 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3362 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3363 |
! |
3364 |
||
4458 | 3365 |
deleteFromLine:startLineNr toLine:endLineNr |
3366 |
"delete some lines" |
|
3367 |
||
3368 |
|deleted| |
|
3369 |
||
3370 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3371 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3372 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3373 |
! |
|
3374 |
||
827 | 3375 |
deleteLine:lineNr |
3376 |
"delete line" |
|
3377 |
||
3378 |
self deleteFromLine:lineNr toLine:lineNr |
|
3379 |
||
3380 |
||
3381 |
! |
|
3382 |
||
4458 | 3383 |
deleteLineWithoutRedraw:lineNr |
3384 |
"delete line - no redraw; |
|
3385 |
return true, if something was really deleted" |
|
3386 |
||
3387 |
|deleted ret| |
|
3388 |
||
3389 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3390 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3391 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3392 |
^ ret. |
|
3393 |
! |
|
3394 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3395 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3396 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3397 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3398 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3399 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3400 |
|
4771 | 3401 |
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
|
3402 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3403 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3404 |
(endLine > list size) ifTrue:[ |
4771 | 3405 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3406 |
] ifFalse:[ |
4771 | 3407 |
lastLine := endLine |
3408 |
]. |
|
3409 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3410 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3411 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3412 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3413 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3414 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3415 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3416 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3417 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3418 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3419 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3420 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3421 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3422 |
"delete the selection" |
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 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3425 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3426 |
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
|
3427 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3428 |
selectionStartLine notNil ifTrue:[ |
4823 | 3429 |
wasOn := self hideCursor. |
3430 |
||
3431 |
startLine := selectionStartLine. |
|
3432 |
startCol := selectionStartCol. |
|
3433 |
endLine := selectionEndLine. |
|
3434 |
endCol := selectionEndCol. |
|
3435 |
self unselectWithoutRedraw. |
|
3436 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3437 |
self setCursorLine:startLine col:startCol. |
|
3438 |
||
3439 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3440 |
] |
121 | 3441 |
! |
3442 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3443 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3444 |
"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
|
3445 |
|
2952 | 3446 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3447 |
|
3799 | 3448 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3449 |
cursorCol <= 1 ifTrue:[ |
3450 |
self deleteCharBeforeCursor. |
|
3451 |
^ self |
|
3452 |
]. |
|
3799 | 3453 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3454 |
wasOn := self hideCursor. |
3799 | 3455 |
self |
3456 |
undoableDo:[ |
|
3457 |
endCol := cursorCol-1. |
|
3458 |
endLine := cursorLine. |
|
3459 |
self cursorToPreviousWord. |
|
3460 |
beginCol := cursorCol. |
|
3461 |
beginLine := cursorLine. |
|
3462 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5361 | 3463 |
self cursorLine:cursorLine col:beginCol. |
3799 | 3464 |
] |
3465 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3466 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3467 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3468 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3469 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3470 |
|
5761 | 3471 |
indentSelectionBy1 |
3472 |
"indent selected line-range |
|
3473 |
by 1 space (i.e. to the right)" |
|
3474 |
||
3475 |
self indentBy:1 |
|
3476 |
||
3477 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3478 |
! |
|
3479 |
||
4458 | 3480 |
insert:aCharacter atLine:lineNr col:colNr |
3481 |
"insert a single character at lineNr/colNr; |
|
3482 |
set emphasis to character at current position" |
|
3483 |
||
3484 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3485 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3486 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3487 |
] |
3488 |
! |
|
3489 |
||
121 | 3490 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3491 |
"insert a single character at cursor-position - advance cursor." |
121 | 3492 |
|
3493 |
|wasOn| |
|
3494 |
||
3495 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3496 |
aCharacter == Character tab ifTrue:[ |
4820 | 3497 |
"/ needs special care to advance cursor correctly |
3498 |
self insertTabAtCursor |
|
121 | 3499 |
] ifFalse:[ |
4820 | 3500 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3501 |
aCharacter == (Character cr) ifTrue:[ |
|
3502 |
self basicCursorReturn |
|
3503 |
] ifFalse:[ |
|
3504 |
self cursorRight. |
|
3505 |
]. |
|
121 | 3506 |
]. |
3507 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3508 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3509 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3510 |
! |
3511 |
||
641 | 3512 |
insertLine:aString before:lineNr |
3513 |
"insert the line aString before line lineNr" |
|
3514 |
||
3515 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3516 |
||
3517 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3518 |
! |
|
3519 |
||
155 | 3520 |
insertLines:aStringCollection before:lineNr |
3521 |
"insert a bunch before line lineNr" |
|
3522 |
||
3523 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3524 |
||
3525 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3526 |
! |
|
3527 |
||
4771 | 3528 |
insertLines:someText from:start to:end before:lineNr |
3529 |
"insert a bunch of lines before line lineNr. |
|
3530 |
The cursor position is left unchanged." |
|
3531 |
||
3532 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3533 |
srcY "{ Class: SmallInteger }" |
|
3534 |
dstY "{ Class: SmallInteger }" | |
|
3535 |
||
5357 | 3536 |
"wrong when pasting multiple lines" |
3537 |
false "autoIndent" ifTrue:[ |
|
4771 | 3538 |
indent := self leftIndentForLine:lineNr. |
3539 |
||
4812 | 3540 |
text := someText |
3541 |
collect:[:ln||line| |
|
3542 |
ln notNil ifTrue:[ |
|
3543 |
line := ln withoutLeadingSeparators. |
|
3544 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3545 |
line := (String new:indent), line |
|
3546 |
]. |
|
3547 |
line |
|
3548 |
] ifFalse:[ |
|
3549 |
nil |
|
3550 |
] |
|
3551 |
]. |
|
4771 | 3552 |
] ifFalse:[ |
3553 |
text := someText |
|
3554 |
]. |
|
3555 |
||
3556 |
visLine := self listLineToVisibleLine:lineNr. |
|
3557 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3558 |
self withoutRedrawInsertLines:text |
|
3559 |
from:start to:end |
|
3560 |
before:lineNr. |
|
3561 |
] ifFalse:[ |
|
3562 |
nLines := end - start + 1. |
|
3563 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3564 |
self withoutRedrawInsertLines:text |
|
3565 |
from:start to:end |
|
3566 |
before:lineNr. |
|
3567 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3568 |
] ifFalse:[ |
|
3569 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3570 |
and:(firstLineShown + nLines + nLinesShown). |
|
3571 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3572 |
dstY := srcY + (nLines * fontHeight). |
|
3573 |
||
3574 |
"/ |
|
3575 |
"/ scroll ... |
|
3576 |
"/ |
|
3577 |
" |
|
3578 |
stupid: must catchExpose before inserting new |
|
3579 |
stuff - since catchExpose may perform redraws |
|
3580 |
" |
|
3581 |
self catchExpose. |
|
3582 |
self withoutRedrawInsertLines:text |
|
3583 |
from:start to:end |
|
3584 |
before:lineNr. |
|
3585 |
self |
|
3586 |
copyFrom:self |
|
3587 |
x:textStartLeft y:srcY |
|
3588 |
toX:textStartLeft y:dstY |
|
3589 |
width:w |
|
3590 |
height:(height - dstY) |
|
3591 |
async:true. |
|
3592 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3593 |
self waitForExpose |
|
3594 |
]. |
|
3595 |
]. |
|
3596 |
widthOfWidestLine notNil ifTrue:[ |
|
3597 |
text do:[:line | |
|
3598 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3599 |
] |
|
3600 |
]. |
|
3601 |
self textChanged. |
|
3602 |
||
3603 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3604 |
! |
|
3605 |
||
654 | 3606 |
insertLines:lines withCR:withCr |
3160 | 3607 |
"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
|
3608 |
Cursor is moved behind insertion. |
641 | 3609 |
If withCr is true, append cr after last line" |
3610 |
||
3611 |
|start end nLines wasOn| |
|
3612 |
||
3613 |
lines notNil ifTrue:[ |
|
4649 | 3614 |
nLines := lines size. |
3615 |
(nLines == 1) ifTrue:[ |
|
3616 |
self insertStringAtCursor:(lines at:1). |
|
3617 |
withCr ifTrue:[ |
|
3618 |
self insertCharAtCursor:(Character cr) |
|
3619 |
] |
|
3620 |
] ifFalse:[ |
|
3621 |
(cursorCol ~~ 1) ifTrue:[ |
|
3622 |
self insertStringAtCursor:(lines at:1). |
|
3623 |
self insertCharAtCursor:(Character cr). |
|
3624 |
start := 2 |
|
3625 |
] ifFalse:[ |
|
3626 |
start := 1 |
|
3627 |
]. |
|
3628 |
withCr ifTrue:[ |
|
3629 |
end := nLines |
|
3630 |
] ifFalse:[ |
|
3631 |
end := nLines - 1 |
|
3632 |
]. |
|
3633 |
(start <= nLines) ifTrue:[ |
|
3634 |
(end >= start) ifTrue:[ |
|
3635 |
wasOn := self hideCursor. |
|
3636 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3637 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3638 |
wasOn ifTrue:[self showCursor]. |
|
3639 |
] |
|
3640 |
]. |
|
3641 |
withCr ifFalse:[ |
|
3642 |
"last line without cr" |
|
3643 |
self insertStringAtCursor:(lines at:nLines) |
|
3644 |
] |
|
3645 |
] |
|
641 | 3646 |
] |
654 | 3647 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3648 |
"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
|
3649 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3650 |
! |
3651 |
||
3652 |
insertLines:lines withCr:withCr |
|
3653 |
"insert a bunch of lines at cursor position. Cursor |
|
3654 |
is moved behind insertion. |
|
3655 |
If withCr is true, append cr after last line" |
|
3656 |
||
2363 | 3657 |
<resource:#obsolete> |
3658 |
||
1292 | 3659 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3660 |
self insertLines:lines withCR:withCr. |
|
3661 |
||
3662 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3663 |
! |
3664 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3665 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3666 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3667 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3668 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3669 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3670 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3671 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3672 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3673 |
self selectFromLine:startLine col:startCol |
4823 | 3674 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3675 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3676 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3677 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3678 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3679 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3680 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3681 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3682 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3683 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3684 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3685 |
col == 0 ifTrue:[ |
3686 |
line > 1 ifTrue:[ |
|
3687 |
line := line - 1. |
|
5216 | 3688 |
col := (self listAt:line) size + 1. |
5060 | 3689 |
] ifFalse:[ |
3690 |
col := 1. |
|
3691 |
] |
|
3692 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3693 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3694 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3695 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3696 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3697 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3698 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3699 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3700 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3701 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3702 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3703 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3704 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3705 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3706 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3707 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3708 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3709 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3710 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3711 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3712 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3713 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3714 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3715 |
[start <= end] whileTrue:[ |
4823 | 3716 |
stop := aString indexOf:(Character cr) startingAt:start. |
3717 |
stop == 0 ifTrue:[ |
|
3718 |
stop := end + 1 |
|
3719 |
]. |
|
3720 |
subString := aString copyFrom:start to:(stop - 1). |
|
3721 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3722 |
(stop <= end) ifTrue:[ |
|
3723 |
c := c + subString size. |
|
3724 |
self insert:(Character cr) atLine:l col:c. |
|
3725 |
l := l + 1. |
|
3726 |
c := 1 |
|
3727 |
]. |
|
3728 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3729 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3730 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3731 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3732 |
! |
3733 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3734 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3735 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3736 |
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
|
3737 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3738 |
aString isNil ifTrue:[ |
4823 | 3739 |
"new:" |
3740 |
self insertCharAtCursor:(Character cr). |
|
3741 |
^ self |
|
105 | 3742 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3743 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3744 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3745 |
]. |
3746 |
||
654 | 3747 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3748 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3749 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3750 |
! |
3751 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3752 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3753 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3754 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3755 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3756 |
shown ifTrue:[ |
4889 | 3757 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3758 |
self invalidateLine:lineNr. |
3759 |
] ifFalse:[ |
|
3760 |
self redrawLine:lineNr from:colNr |
|
3761 |
] |
|
3762 |
] |
|
3763 |
||
4191 | 3764 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3765 |
! |
3766 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3767 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3768 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3769 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3770 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3771 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3772 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3773 |
aString size > 0 ifTrue:[ |
4823 | 3774 |
wasOn := self hideCursor. |
3775 |
(aString includes:Character tab) ifTrue:[ |
|
3776 |
self checkForExistingLine:cursorLine. |
|
3777 |
oldLen := (list at:cursorLine) size. |
|
3778 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3779 |
newLen := (list at:cursorLine) size. |
|
3780 |
deltaLen := newLen - oldLen. |
|
3781 |
] ifFalse:[ |
|
3782 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3783 |
deltaLen := aString size. |
|
3784 |
]. |
|
3785 |
self setCursorCol:(cursorCol + deltaLen). |
|
3786 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3787 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3788 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3789 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3790 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3791 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3792 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3793 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3794 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3795 |
|wasOn nextTab| |
105 | 3796 |
|
121 | 3797 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3798 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3799 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3800 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3801 |
! |
3802 |
||
3542 | 3803 |
joinLines |
3890 | 3804 |
"join lines (remove line-break)" |
3805 |
||
3583 | 3806 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3807 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3808 |
self |
3890 | 3809 |
undoableDo:[ |
3810 |
|line col lineLen| |
|
3811 |
||
3812 |
line := cursorLine. |
|
3813 |
col := cursorCol. |
|
3814 |
lineLen := (list at:line) size. |
|
3815 |
col > lineLen ifTrue:[ |
|
3816 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3817 |
] ifFalse:[ |
|
3818 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3819 |
]. |
|
3820 |
self mergeLine:line removeBlanks:true. |
|
3821 |
self cursorLine:line col:col. |
|
3822 |
] |
|
3823 |
info:'Join' |
|
3542 | 3824 |
! |
3825 |
||
2952 | 3826 |
mergeLine:lineNr |
3827 |
"merge line lineNr with line lineNr+1" |
|
3828 |
||
3829 |
self mergeLine:lineNr removeBlanks:true |
|
3830 |
||
3831 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3832 |
! |
|
3833 |
||
4458 | 3834 |
mergeLine:lineNr removeBlanks:removeBlanks |
3835 |
"merge line lineNr with line lineNr+1" |
|
3836 |
||
3837 |
|len| |
|
3838 |
||
3839 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3840 |
||
3841 |
len := (self listAt:lineNr) size. |
|
3842 |
self nonUndoableDo:[ |
|
4823 | 3843 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3844 |
]. |
3845 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3846 |
! |
|
3847 |
||
5761 | 3848 |
parenthizeSelection |
3849 |
"place parenthesis around the selected text. |
|
3850 |
if already parenthized, de-parenthize it" |
|
3851 |
||
3852 |
self parenthizeSelectionWith:$( and:$) |
|
3853 |
||
3854 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
3855 |
! |
|
3856 |
||
2506 | 3857 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 3858 |
"if already parenthized, de-parenthize it" |
3859 |
||
5560 | 3860 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3861 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3862 |
self hasSelection ifFalse:[^ self]. |
5560 | 3863 |
startLine := selectionStartLine. |
3864 |
endLine := selectionEndLine. |
|
3865 |
startCol := selectionStartCol. |
|
3866 |
endCol := selectionEndCol. |
|
3867 |
||
3868 |
newSelectionEnd := endCol. |
|
3869 |
||
3870 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
|
3871 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
|
3872 |
self deleteCharAtLine:endLine col:endCol. |
|
4823 | 3873 |
newSelectionEnd := newSelectionEnd-1. |
3874 |
]. |
|
5560 | 3875 |
self deleteCharAtLine:startLine col:startCol. |
3876 |
startLine == endLine ifTrue:[ |
|
4823 | 3877 |
newSelectionEnd := newSelectionEnd-1. |
3878 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3879 |
] ifFalse:[ |
5560 | 3880 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4823 | 3881 |
newSelectionEnd := newSelectionEnd+1. |
5560 | 3882 |
self insert:openingCharacter atLine:startLine col:startCol. |
3883 |
startLine == endLine ifTrue:[ |
|
4823 | 3884 |
newSelectionEnd := newSelectionEnd+1. |
3885 |
] |
|
3160 | 3886 |
]. |
3887 |
self |
|
5560 | 3888 |
selectFromLine:startLine col:startCol |
3889 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 3890 |
|
3891 |
"Modified (comment): / 06-06-2016 / 11:00:37 / cg" |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3892 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3893 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3894 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3895 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3896 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3897 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3898 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3899 |
|
5114 | 3900 |
NoModificationError handle:[:ex | |
3901 |
^ self |
|
3902 |
] do:[ |
|
3903 |
lastLine := list size. |
|
3904 |
finished := false. |
|
3905 |
[finished] whileFalse:[ |
|
3906 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 3907 |
finished := true |
3908 |
] ifFalse:[ |
|
5114 | 3909 |
line := list at:lastLine. |
3910 |
line notNil ifTrue:[ |
|
3911 |
line isBlank ifTrue:[ |
|
3912 |
self basicListAt:lastLine put:nil. |
|
3913 |
line := nil |
|
3914 |
] |
|
3915 |
]. |
|
3916 |
line notNil ifTrue:[ |
|
3917 |
finished := true |
|
3918 |
] ifFalse:[ |
|
3919 |
lastLine := lastLine - 1 |
|
3920 |
] |
|
4771 | 3921 |
] |
5114 | 3922 |
]. |
3923 |
(lastLine ~~ list size) ifTrue:[ |
|
3924 |
list grow:lastLine. |
|
3925 |
"/ self textChanged |
|
4771 | 3926 |
] |
118 | 3927 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3928 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3929 |
|
4458 | 3930 |
replace:aCharacter atLine:lineNr col:colNr |
3931 |
"replace a single character at lineNr/colNr" |
|
3932 |
||
3933 |
|originalChar| |
|
3934 |
||
3935 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3936 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3937 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3938 |
! |
|
3939 |
||
4713 | 3940 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3941 |
|pattern replacePattern| |
3942 |
||
3943 |
pattern := patternArg string. |
|
3944 |
replacePattern := replacePatternArg string. |
|
4630 | 3945 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3946 |
self rememberSearchPattern:pattern. |
|
3947 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3948 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3949 |
self |
3950 |
undoableDo:[ |
|
3951 |
all ifTrue:[ |
|
3952 |
self |
|
3953 |
replaceString:pattern |
|
3954 |
to:replacePattern |
|
4713 | 3955 |
ignoreCase:ignoreCase |
4630 | 3956 |
] ifFalse:[ |
3957 |
(self selectionAsString notNil |
|
4713 | 3958 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3959 |
ifTrue:[ |
4742 | 3960 |
self replaceSelectionBy:replacePattern. |
4630 | 3961 |
self |
3962 |
search:pattern |
|
4713 | 3963 |
ignoreCase:ignoreCase |
4630 | 3964 |
forward:(lastSearchDirection = #forward). |
3965 |
]. |
|
3966 |
] |
|
3967 |
] |
|
3968 |
info:'Replace' |
|
3430 | 3969 |
] |
3970 |
||
3971 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3972 |
! |
|
3973 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3974 |
replaceCharAtCursor:aCharacter |
5413 | 3975 |
"undoably replace a single character at cursor-position - advance cursor" |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3976 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3977 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3978 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3979 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3980 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3981 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3982 |
] ifFalse:[ |
4823 | 3983 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3984 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3985 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3986 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3987 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3988 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3989 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3990 |
|
4458 | 3991 |
replaceContentsWith:newContents |
5413 | 3992 |
"undoably replace everything" |
4458 | 3993 |
|
3994 |
|originalContents| |
|
3995 |
||
3996 |
originalContents := self contents. |
|
3997 |
self contents:newContents keepUndoHistory:true. |
|
3998 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3999 |
! |
|
4000 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4001 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 4002 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4003 |
|
5216 | 4004 |
"/ sigh - insert first, to avoid trouble due to shifing-in virtual line ends |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4005 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4006 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4007 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4008 |
|
4458 | 4009 |
replaceLine:lineNr with:newText |
5413 | 4010 |
"undoably replace a line at lineNr" |
4458 | 4011 |
|
4012 |
|originalLine| |
|
4013 |
||
4014 |
originalLine := self listAt:lineNr. |
|
4015 |
originalLine isNil ifTrue:[ |
|
4823 | 4016 |
self checkForExistingLine:lineNr |
4458 | 4017 |
]. |
4018 |
self list at:lineNr put:newText. |
|
4019 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4020 |
self invalidateLine:lineNr. |
|
4021 |
||
4022 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
4023 |
! |
|
4024 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4025 |
replaceLines:lines withCR:withCr |
5413 | 4026 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4027 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4028 |
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
|
4029 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4030 |
|
1809 | 4031 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4032 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4033 |
lines notNil ifTrue:[ |
4661 | 4034 |
wasOn := self hideCursor. |
4035 |
nLines := lines size. |
|
4036 |
line := cursorLine. |
|
4037 |
col := cursorCol. |
|
4038 |
lines keysAndValuesDo:[:i :l | |
|
4039 |
self replaceString:(l ? '') atLine:line col:col. |
|
4040 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
4041 |
line := line + 1. |
|
4042 |
col := 1. |
|
4043 |
] ifFalse:[ |
|
4044 |
col := col + (l size). |
|
4045 |
] |
|
4046 |
]. |
|
4047 |
self cursorLine:line col:col. |
|
4048 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
4049 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4050 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4051 |
|
4661 | 4052 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
4053 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4054 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4055 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4056 |
replaceSelectionBy:something |
5413 | 4057 |
"undoably delete the selection (if any) and insert something, a character or string; |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4058 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4059 |
|
4666 | 4060 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 4061 |
! |
4062 |
||
4063 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 4064 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 4065 |
leave cursor after insertion or leave it, depending on keep" |
4066 |
||
4666 | 4067 |
self replaceSelectionBy:something keepCursor:keep select:false |
4068 |
||
4069 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
4070 |
! |
|
4071 |
||
4072 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 4073 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 4074 |
leave cursor after insertion or leave it, depending on keep. |
4075 |
If selectNewText is true, select the new text; otherwise deselect" |
|
4076 |
||
4077 |
|sel l c selStartLine selStartCol| |
|
105 | 4078 |
|
4079 |
l := cursorLine. |
|
4080 |
c := cursorCol. |
|
4081 |
||
4818 | 4082 |
sel := self selectionAsString. |
4666 | 4083 |
sel isNil ifTrue:[ |
4084 |
selStartLine := l. |
|
4085 |
selStartCol := c. |
|
4086 |
] ifFalse:[ |
|
4087 |
selStartLine := selectionStartLine. |
|
4088 |
selStartCol := selectionStartCol. |
|
4089 |
||
4053 | 4090 |
self setLastStringToReplace: sel. |
4091 |
||
4010 | 4092 |
self deleteSelection. |
4093 |
replacing := true. |
|
4818 | 4094 |
lastReplacementInfo rememberReplacement. |
4048 | 4095 |
lastReplacementInfo lastReplacement: ''. |
4818 | 4096 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 4097 |
undoSupport actionInfo:'replace'. |
3161 | 4098 |
]. |
4099 |
||
4100 |
something isCharacter ifTrue:[ |
|
4051 | 4101 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 4102 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 4103 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 4104 |
]. |
4010 | 4105 |
]. |
4106 |
self isInInsertMode ifTrue:[ |
|
4107 |
self insertCharAtCursor:something |
|
4108 |
] ifFalse:[ |
|
4109 |
self replaceCharAtCursor:something |
|
4110 |
] |
|
105 | 4111 |
] ifFalse:[ |
4010 | 4112 |
something isString ifTrue:[ |
4048 | 4113 |
lastReplacementInfo lastReplacement: something. |
4010 | 4114 |
self isInInsertMode ifTrue:[ |
4115 |
self insertStringAtCursor:something |
|
4116 |
] ifFalse:[ |
|
4117 |
self replaceStringAtCursor:something |
|
4118 |
] |
|
4119 |
] ifFalse:[ |
|
4120 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4121 |
]. |
|
105 | 4122 |
]. |
4123 |
keep ifTrue:[ |
|
4010 | 4124 |
self cursorLine:l col:c |
4666 | 4125 |
]. |
4126 |
selectNewText ifTrue:[ |
|
4127 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 4128 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4129 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4130 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4131 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4132 |
|
4458 | 4133 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4134 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4135 |
This is not prepared to encounter special chars (except TAB) in the string." |
4136 |
||
4137 |
|originalString| |
|
4138 |
||
4139 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4140 |
||
4141 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4142 |
||
4143 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4144 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4145 |
! |
|
4146 |
||
4713 | 4147 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4148 |
|continue count| |
4149 |
||
4150 |
self cursorToTop. |
|
4151 |
self selectFromBeginning. |
|
4152 |
count := 0. |
|
4153 |
continue := true. |
|
4154 |
[ continue ] whileTrue:[ |
|
4713 | 4155 |
(self selectionAsString notNil |
4156 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4157 |
ifTrue:[ |
|
4742 | 4158 |
self replaceSelectionBy:aNewString. |
4713 | 4159 |
count := count + 1. |
4160 |
]. |
|
4161 |
self |
|
4162 |
searchFwd:aString |
|
4163 |
ignoreCase:ignoreCase |
|
4164 |
ifAbsent:[ |
|
4165 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4166 |
bindWith:aString with:aNewString with:count). |
|
4167 |
continue := false. |
|
4168 |
]. |
|
3549 | 4169 |
]. |
3430 | 4170 |
|
4171 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4172 |
! |
|
4173 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4174 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4175 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4176 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4177 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4178 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4179 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4180 |
(aString includes:Character tab) ifTrue:[ |
4823 | 4181 |
"/ need special care for TAB (to move cursor correctly) |
4182 |
i1 := 1. |
|
4183 |
[i1 ~~ 0] whileTrue:[ |
|
4184 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4185 |
i2 ~~ 0 ifTrue:[ |
|
4186 |
i1 ~~ i2 ifTrue:[ |
|
4187 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4188 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4189 |
]. |
|
4190 |
self replaceTABAtCursor. |
|
4191 |
i2 := i2 + 1. |
|
4192 |
] ifFalse:[ |
|
4193 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4194 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4195 |
]. |
|
4196 |
i1 := i2. |
|
4197 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4198 |
] ifFalse:[ |
4823 | 4199 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
5325 | 4200 |
self setValidatedCursorCol:(cursorCol + aString size). |
4201 |
"/ self cursorCol:(cursorCol + aString size). |
|
4202 |
]. |
|
4203 |
wasOn ifTrue:[ |
|
4204 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
|
4205 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
4206 |
]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4207 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4208 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4209 |
"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
|
4210 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4211 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4212 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4213 |
"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
|
4214 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4215 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4216 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4217 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4218 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4219 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4220 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4221 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4222 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4223 |
! |
4224 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4225 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4226 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4227 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4228 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4229 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4230 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4231 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4232 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4233 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4234 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4235 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4236 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4237 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4238 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4239 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4240 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4241 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4242 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4243 |
|
4458 | 4244 |
splitLine:lineNr before:colNr |
4245 |
"split the line linNr before colNr; the right part (from colNr) |
|
4246 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4247 |
||
4248 |
self basicSplitLine:lineNr before:colNr. |
|
4249 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4250 |
! |
|
4251 |
||
5761 | 4252 |
toggleTabSetting |
4253 |
"toggle between 4-col |
|
4254 |
and 8-col tabs" |
|
4255 |
||
4256 |
(tabPositions == self class tab4Positions) |
|
4257 |
ifTrue:[self setTab8] |
|
4258 |
ifFalse:[self setTab4] |
|
4259 |
||
4260 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4261 |
! |
|
4262 |
||
4263 |
undentSelectionBy1 |
|
4264 |
"undent selected line-range |
|
4265 |
by 1 space (i.e. to the left)" |
|
4266 |
||
4267 |
self undentBy:1 |
|
4268 |
||
4269 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4270 |
! |
|
4271 |
||
5146 | 4272 |
withAutoIndent:aBoolean do:aBlock |
4273 |
|sav| |
|
4274 |
||
4275 |
sav := autoIndent. |
|
4276 |
autoIndent := aBoolean. |
|
4277 |
aBlock ensure:[ autoIndent := sav ]. |
|
4278 |
! |
|
4279 |
||
4458 | 4280 |
withoutRedrawAt:lineNr put:aString |
4281 |
"replace a line at lineNr" |
|
4282 |
||
4283 |
|originalLine| |
|
4284 |
||
4285 |
originalLine := self listAt:lineNr. |
|
4286 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4287 |
super withoutRedrawAt:lineNr put:aString. |
|
4288 |
! |
|
4289 |
||
4290 |
withoutRedrawInsertLine:aString before:lineNr |
|
4291 |
"insert the argument, aString before line lineNr; the string |
|
4292 |
becomes line lineNr; everything else is moved down; the view |
|
4293 |
is not redrawn" |
|
4294 |
||
4771 | 4295 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4296 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4297 |
! |
|
4298 |
||
4299 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4300 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4301 |
||
4302 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4303 |
self isReadOnly ifFalse:[ |
|
4823 | 4304 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4305 |
]. |
4306 |
! |
|
4307 |
||
4308 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4309 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4310 |
||
4311 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4312 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4313 |
! |
|
4314 |
||
3890 | 4315 |
wrapLines |
4316 |
"wrap lines (insert line-break)" |
|
4317 |
||
4318 |
|lineLength answerString string| |
|
4319 |
||
4320 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4321 |
||
4322 |
self hasSelection ifFalse:[ |
|
4323 |
self selectLine:cursorLine. |
|
4324 |
]. |
|
4325 |
string := self selectionAsString. |
|
4326 |
string isEmptyOrNil ifTrue:[ |
|
4327 |
Dialog information:(resources string:'Nothing selected.'). |
|
4328 |
^ self. |
|
4329 |
]. |
|
4330 |
||
4331 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4332 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4333 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4334 |
lineLength < 1 ifTrue:[ |
4335 |
lineLength := 1. |
|
4336 |
]. |
|
4337 |
||
4338 |
self |
|
4339 |
undoableDo:[ |
|
4340 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4341 |
||
4342 |
line := selectionStartLine. |
|
4343 |
col := selectionStartCol. |
|
4344 |
||
4345 |
self cutSelection. |
|
4346 |
self cursorLine:line col:col. |
|
4347 |
||
4348 |
lastGoodCol := col. |
|
4349 |
||
4350 |
inStream := string readStream. |
|
4351 |
[ inStream atEnd ] whileFalse:[ |
|
4352 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4353 |
word := WriteStream on:(String new:10). |
|
4354 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4355 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4356 |
self insertCharAtCursor:(Character cr). |
|
4357 |
col := 1. |
|
4358 |
] ifFalse:[ |
|
4359 |
col ~~ 1 ifTrue:[ |
|
4360 |
self insertStringAtCursor:' '. |
|
4361 |
col := col + 1. |
|
4362 |
] |
|
4363 |
]. |
|
4364 |
self insertStringAtCursor:word contents. |
|
4365 |
col := col + word size. |
|
4366 |
]. |
|
4367 |
] |
|
4368 |
info:'Wrap' |
|
4388 | 4369 |
|
4370 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4371 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4372 |
|
2752 | 4373 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4374 |
|
2952 | 4375 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4376 |
"delete characters from startCol to endCol in line lineNr" |
4377 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4378 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4379 |
|
4673 | 4380 |
self unselect. |
4381 |
||
4382 |
cursorLine == lineNr ifTrue:[ |
|
5909 | 4383 |
cursorCol >= startCol ifTrue:[ |
4384 |
cursorCol >= endCol ifTrue:[ |
|
4385 |
cursorCol := startCol. |
|
4386 |
] ifFalse:[ |
|
4387 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
4388 |
"/ self assert:(cursorCol >= 0). |
|
4389 |
cursorCol := cursorCol max:1. |
|
4390 |
] |
|
4391 |
]. |
|
4673 | 4392 |
]. |
4393 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4394 |
line := self listAt:lineNr. |
827 | 4395 |
|
4673 | 4396 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4397 |
||
4398 |
lineSize := line size. |
|
4399 |
||
4400 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4401 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4402 |
||
4403 |
stop >= start ifTrue:[ |
|
5909 | 4404 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
4405 |
ifFalse:[ newLine := '' ]. |
|
4406 |
||
4407 |
stop == lineSize ifFalse:[ |
|
4408 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4409 |
newLine := line string species fromString:newLine. |
|
4410 |
]. |
|
4411 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
4412 |
]. |
|
4413 |
||
4414 |
(self trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4415 |
newLine := nil |
|
4416 |
]. |
|
4417 |
||
4418 |
prevWidth := self widthOfLine:lineNr. |
|
4419 |
||
4420 |
self basicListAt:lineNr put:newLine. |
|
4421 |
||
4422 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4423 |
"/ remember old width of this line, |
|
4424 |
"/ only clear widthOfWidestLine, if this lines |
|
4425 |
"/ length was (one of) the longest. |
|
4426 |
"/ avoids slow delete with huge texts. |
|
4427 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4428 |
||
4429 |
"/ scroll left if reqiured |
|
4430 |
viewOrigin x > 0 ifTrue:[ |
|
4431 |
newWidth := self widthOfLine:lineNr. |
|
4432 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4433 |
self scrollHorizontalTo:(newWidth |
|
4434 |
- width |
|
4435 |
+ margin + margin |
|
4436 |
+ (gc font widthOf:' ')) |
|
4437 |
] |
|
4438 |
]. |
|
4439 |
self textChanged. |
|
4440 |
] ifFalse:[ |
|
4441 |
self textChanged "/ textChangedButNoSizeChange |
|
4442 |
]. |
|
4443 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4444 |
self invalidateLine:lineNr. |
|
4445 |
] ifFalse:[ |
|
4446 |
self redrawLine:lineNr from:start. |
|
4447 |
]. |
|
4673 | 4448 |
]. |
827 | 4449 |
|
4191 | 4450 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4451 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4452 |
|
2952 | 4453 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4454 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4455 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4456 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4457 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4458 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4459 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4460 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4461 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4462 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4463 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4464 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4465 |
startLineNr <= list size ifTrue:[ |
4771 | 4466 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4467 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4468 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4469 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4470 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4471 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4472 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4473 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4474 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4475 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4476 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4477 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4478 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4479 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4480 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4481 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4482 |
|
4226 | 4483 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4484 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4485 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4486 |
|
2952 | 4487 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4488 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4489 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4490 |
|
2952 | 4491 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4492 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4493 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4494 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4495 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4496 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4497 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4498 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4499 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4500 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4501 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4502 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4503 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4504 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4505 |
|
2952 | 4506 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4507 |
"insert a single character at lineNr/colNr; |
827 | 4508 |
set emphasis to character at current position" |
4509 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4510 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4511 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4512 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4513 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4514 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4515 |
self splitLine:lineNr before:colNr. |
4516 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4517 |
]. |
827 | 4518 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4519 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4520 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4521 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4522 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4523 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4524 |
self st80EditMode ifFalse:[ |
5909 | 4525 |
(self trimBlankLines |
4526 |
and:[colNr > lineSize |
|
4527 |
and:[aCharacter == Character space]]) ifTrue:[ |
|
4528 |
^ self |
|
4529 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4530 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4531 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4532 |
(lineSize == 0) ifTrue:[ |
5909 | 4533 |
newLine := aCharacter asString species new:colNr. |
4534 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4535 |
] ifFalse: [ |
5909 | 4536 |
(colNr > lineSize) ifTrue: [ |
4537 |
colNr == (lineSize +1) ifTrue:[ |
|
4538 |
attribute := line emphasisAt:lineSize |
|
4539 |
]. |
|
4540 |
newLine := line species new:colNr. |
|
4541 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4542 |
drawCharacterOnly := true |
|
4543 |
] ifFalse: [ |
|
4544 |
attribute := line emphasisAt:colNr. |
|
4545 |
newLine := line species new:(lineSize + 1). |
|
4546 |
||
4547 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4548 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
4549 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4550 |
]. |
827 | 4551 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4552 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
5909 | 4553 |
newLine := aCharacter asString species fromString:newLine. |
4554 |
line isText ifTrue:[ |
|
4555 |
newLine := newLine asText |
|
4556 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4557 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4558 |
newLine at:colNr put:aCharacter. |
827 | 4559 |
|
4560 |
attribute notNil ifTrue:[ |
|
5909 | 4561 |
newLine emphasisAt:colNr put:attribute. |
827 | 4562 |
]. |
4563 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4564 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4565 |
newLine := self withTabsExpanded:newLine. |
4566 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4567 |
]. |
827 | 4568 |
|
4771 | 4569 |
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
|
4570 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4571 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4572 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4573 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4574 |
shown ifTrue:[ |
5909 | 4575 |
"/ care for italic text - in this case, we must also |
4576 |
"/ redraw the character before the insertion in order |
|
4577 |
"/ to fix the slanted piece of the character. |
|
4578 |
"/ (but we must clip, to avoid destoying the character before) |
|
4579 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
4580 |
colNr > 1 ifTrue:[ |
|
4581 |
cursorVisibleLine notNil ifTrue:[ |
|
4582 |
oldClip := self clippingRectangleOrNil. |
|
4583 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
4584 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4585 |
||
4586 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4587 |
self invalidateLine:lineNr. |
|
4588 |
] ifFalse:[ |
|
4589 |
drawCharacterOnly ifTrue:[ |
|
4590 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
|
4591 |
self redrawLine:lineNr from:colNr-1 to:colNr |
|
4592 |
] ifFalse:[ |
|
4593 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4594 |
self redrawLine:lineNr from:colNr-1 |
|
4595 |
]. |
|
4596 |
self clippingRectangle:oldClip. |
|
4597 |
]. |
|
4598 |
]. |
|
4599 |
^ self. |
|
4600 |
]. |
|
4601 |
]. |
|
4602 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4603 |
self invalidateLine:lineNr. |
|
4604 |
] ifFalse:[ |
|
4605 |
drawCharacterOnly ifTrue:[ |
|
4606 |
self redrawLine:lineNr col:colNr |
|
4607 |
] ifFalse:[ |
|
4608 |
self redrawLine:lineNr from:colNr |
|
4609 |
] |
|
4610 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4611 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4612 |
|
4191 | 4613 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4614 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4615 |
|
4771 | 4616 |
basicListAt:lineNr put:newLine |
4617 |
"redefinable for special subclasses (with virtual list)" |
|
4618 |
||
4619 |
list at:lineNr put:newLine. |
|
4620 |
! |
|
4621 |
||
4622 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4623 |
"redefinable for special subclasses (with virtual list)" |
|
4624 |
||
4625 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4626 |
! |
|
4627 |
||
2952 | 4628 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4629 |
"merge line lineNr with line lineNr+1" |
4630 |
||
827 | 4631 |
|leftPart rightPart bothParts nextLineNr i| |
4632 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4633 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
5909 | 4634 |
"/ empty list or beyond end of text |
4635 |
^ self |
|
827 | 4636 |
]. |
4637 |
leftPart := self listAt:lineNr. |
|
4638 |
||
4639 |
leftPart isNil ifTrue:[ |
|
5909 | 4640 |
leftPart := ''. |
4641 |
autoIndent ifTrue:[ |
|
4642 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4643 |
leftPart := String new:i |
|
4644 |
] |
|
4645 |
] |
|
827 | 4646 |
]. |
4647 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4648 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4649 |
||
4650 |
nextLineNr > (list size) ifFalse:[ |
|
5909 | 4651 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4652 |
rightPart := '' |
|
4653 |
] ifFalse:[ |
|
4654 |
removeBlanks ifTrue:[ |
|
4655 |
rightPart := rightPart withoutLeadingSeparators. |
|
4656 |
] |
|
4657 |
]. |
|
4658 |
||
4659 |
bothParts := leftPart , rightPart. |
|
4660 |
(self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4661 |
self basicListAt:lineNr put:bothParts. |
|
4662 |
self redrawLine:lineNr. |
|
4663 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4664 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4665 |
|
1319 | 4666 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4667 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4668 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4669 |
|
2952 | 4670 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4671 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4672 |
|
5045 | 4673 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4674 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4675 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4676 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4677 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4678 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4679 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4680 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4681 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4682 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4683 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4684 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4685 |
|
5909 | 4686 |
(self trimBlankLines |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4687 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4688 |
and:[aCharacter == Character space]]) ifTrue:[ |
5909 | 4689 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4690 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4691 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4692 |
(lineSize == 0) ifTrue:[ |
5909 | 4693 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4694 |
] ifFalse: [ |
5045 | 4695 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5909 | 4696 |
newLineSpecies := aCharacter stringSpecies |
4697 |
] ifFalse:[ |
|
4698 |
newLineSpecies := line species |
|
4699 |
]. |
|
4700 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4701 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4702 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4703 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4704 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4705 |
newLine := self withTabsExpanded:newLine. |
4706 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4707 |
]. |
4771 | 4708 |
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
|
4709 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4710 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4711 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4712 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4713 |
shown ifTrue:[ |
5909 | 4714 |
gc font hasOverlappingCharacters ifTrue:[ |
4715 |
self invalidateLine:lineNr. |
|
4716 |
] ifFalse:[ |
|
4717 |
drawCharacterOnly ifTrue:[ |
|
4718 |
self redrawLine:lineNr col:colNr |
|
4719 |
] ifFalse:[ |
|
4720 |
self redrawLine:lineNr from:colNr |
|
4721 |
] |
|
4722 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4723 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4724 |
|
4190 | 4725 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4726 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4727 |
! |
4728 |
||
3235 | 4729 |
basicReplaceString:aString atLine:lineNr col:colNr |
4730 |
"replace multiple characters starting at lineNr/colNr. |
|
4731 |
This is not prepared to encounter special chars (except TAB) |
|
4732 |
in the string." |
|
4733 |
||
5045 | 4734 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4735 |
|
4736 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4737 |
||
4738 |
self checkForExistingLine:lineNr. |
|
4739 |
line := list at:lineNr. |
|
4740 |
lineSize := line size. |
|
4741 |
||
4742 |
endCol := colNr + aString size - 1. |
|
4743 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4744 |
newLine := aString species new:endCol. |
3235 | 4745 |
] ifFalse: [ |
5571 | 4746 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5045 | 4747 |
newLineSpecies := aString stringSpecies |
4748 |
] ifFalse:[ |
|
4749 |
newLineSpecies := line species |
|
4750 |
]. |
|
4751 |
||
4752 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4753 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4754 |
]. |
4755 |
newLine replaceFrom:colNr with:aString. |
|
4756 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4757 |
newLine := self withTabsExpanded:newLine. |
3235 | 4758 |
]. |
4771 | 4759 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4760 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4761 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4762 |
]. |
4763 |
self textChanged. |
|
4764 |
shown ifTrue:[ |
|
4889 | 4765 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4766 |
self invalidateLine:lineNr. |
4767 |
] ifFalse:[ |
|
4768 |
self redrawLine:lineNr from:colNr |
|
4769 |
] |
|
3235 | 4770 |
] |
4771 |
||
4190 | 4772 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4773 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4774 |
! |
4775 |
||
2952 | 4776 |
basicSplitLine:lineNr before:colNr |
4777 |
"split the line linNr before colNr; the right part (from colNr) |
|
4778 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4779 |
||
3160 | 4780 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4781 |
srcY "{ Class: SmallInteger }" | |
4782 |
||
3027 | 4783 |
list isNil ifTrue:[ ^ self ]. |
4784 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4785 |
||
4786 |
(colNr == 1) ifTrue:[ |
|
5909 | 4787 |
self nonUndoableDo:[ |
4788 |
self insertLine:nil before:lineNr. |
|
4789 |
]. |
|
4790 |
^ self |
|
3027 | 4791 |
]. |
4792 |
||
4793 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4794 |
line notNil ifTrue:[ |
5909 | 4795 |
lineSize := line size. |
4796 |
(colNr <= lineSize) ifTrue:[ |
|
4797 |
rightRest := line copyFrom:colNr to:lineSize. |
|
4798 |
(colNr > 1) ifTrue:[ |
|
4799 |
leftRest := line copyTo:(colNr - 1) |
|
4800 |
] |
|
4801 |
] ifFalse:[ |
|
4802 |
leftRest := line |
|
4803 |
] |
|
3027 | 4804 |
]. |
4805 |
leftRest notNil ifTrue:[ |
|
5909 | 4806 |
(self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4807 |
]. |
4771 | 4808 |
self basicListAt:lineNr put:leftRest. |
3027 | 4809 |
self nonUndoableDo:[ |
5909 | 4810 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4811 |
]. |
4812 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4813 |
visLine notNil ifTrue:[ |
|
5909 | 4814 |
w := self widthForScrollBetween:lineNr |
4815 |
and:(firstLineShown + nLinesShown). |
|
4816 |
srcY := topMargin + (visLine * fontHeight). |
|
4817 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
4818 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
4819 |
self catchExpose. |
|
4820 |
self |
|
4821 |
copyFrom:self |
|
4822 |
x:textStartLeft y:srcY |
|
4823 |
toX:textStartLeft y:(srcY + fontHeight) |
|
4824 |
width:w |
|
4825 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
4826 |
async:true. |
|
4827 |
]. |
|
4828 |
self redrawLine:lineNr. |
|
4829 |
self redrawLine:(lineNr + 1). |
|
4830 |
mustWait ifTrue:[self waitForExpose] |
|
3027 | 4831 |
]. |
4832 |
widthOfWidestLine := nil. "/ unknown |
|
4833 |
self textChanged. |
|
2952 | 4834 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4835 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4836 |
! |
4837 |
||
2954 | 4838 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4839 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4840 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4841 |
because the text might have been pasted from an alien view." |
|
2954 | 4842 |
|
4843 |
|newLine newLines nLines| |
|
4844 |
||
4845 |
nLines := end - start + 1. |
|
4846 |
newLines := Array new:(lines size). |
|
4847 |
start to:end do:[:index | |
|
4328 | 4848 |
newLine := lines at:index. |
4849 |
newLine notNil ifTrue:[ |
|
4850 |
newLine isString ifTrue:[ |
|
4851 |
newLine isBlank ifTrue:[ |
|
4852 |
newLine := nil |
|
4853 |
] ifFalse:[ |
|
4854 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4855 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4856 |
] |
|
4857 |
] |
|
4858 |
] |
|
4859 |
]. |
|
4860 |
newLines at:index put:newLine |
|
2954 | 4861 |
]. |
4862 |
list isNil ifTrue: [ |
|
4328 | 4863 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4864 |
] ifFalse: [ |
4328 | 4865 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4866 |
]. |
4867 |
||
4868 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4869 |
overlapping copy - if it didn't, we had to use:" |
4870 |
" |
|
4871 |
index := list size. |
|
4872 |
[index > lineNr] whileTrue: [ |
|
4328 | 4873 |
pIndex := index - 1. |
4874 |
list at:index put:(list at:pIndex). |
|
4875 |
index := pIndex |
|
2954 | 4876 |
]. |
4877 |
" |
|
4878 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4879 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4880 |
self contentsChanged |
|
4881 |
||
4328 | 4882 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4883 |
! |
4884 |
||
4885 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4886 |
"insert aString (which has no crs) at lineNr/colNr. |
4887 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4888 |
because the text might have been pasted from an alien view." |
|
2954 | 4889 |
|
4360 | 4890 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4891 |
|
4623 | 4892 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4893 |
|
4894 |
strLen := aString size. |
|
4895 |
self checkForExistingLine:lineNr. |
|
4896 |
||
4897 |
stringType := aString string species. |
|
4898 |
isText := aString isText. |
|
4899 |
line := list at:lineNr. |
|
4900 |
||
4901 |
line notNil ifTrue:[ |
|
4328 | 4902 |
lineSize := line size. |
4903 |
line isString ifFalse:[ |
|
4904 |
stringType := line species |
|
4905 |
] ifTrue:[ |
|
4360 | 4906 |
lineCharWidth := line bitsPerCharacter. |
4907 |
stringCharWidth := aString bitsPerCharacter. |
|
4908 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4909 |
stringType := line string species |
4360 | 4910 |
] ifFalse:[ |
4911 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4912 |
stringType := aString string species |
|
4913 |
] |
|
4328 | 4914 |
]. |
4915 |
line isText ifTrue:[ isText := true ] |
|
4916 |
]. |
|
2954 | 4917 |
] ifFalse:[ |
4328 | 4918 |
lineSize := 0 |
2954 | 4919 |
]. |
4920 |
||
4921 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4922 |
newLine := aString |
2954 | 4923 |
] ifFalse:[ |
4328 | 4924 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4925 |
sz := colNr + strLen - 1 |
|
4926 |
] ifFalse:[ |
|
4927 |
sz := lineSize + strLen |
|
4928 |
]. |
|
4929 |
||
4360 | 4930 |
newLine := stringType new:sz. |
4931 |
isText ifTrue:[ |
|
4932 |
newLine := Text string:newLine |
|
4328 | 4933 |
]. |
4934 |
||
4935 |
(lineSize ~~ 0) ifTrue: [ |
|
4936 |
(colNr > lineSize) ifTrue: [ |
|
4937 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4938 |
] ifFalse: [ |
|
4939 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4940 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4941 |
] |
|
4942 |
]. |
|
4943 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4944 |
]. |
4945 |
||
4946 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4947 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4948 |
]. |
4949 |
||
4771 | 4950 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4951 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4952 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4953 |
]. |
4954 |
self textChanged. |
|
4955 |
||
4360 | 4956 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4957 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4958 |
|
2752 | 4959 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4960 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4961 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4962 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4963 |
|
5216 | 4964 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 4965 |
dragIsActive := false. |
4966 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4967 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4968 |
"/ 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
|
4969 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4970 |
]. |
4609 | 4971 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4972 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4973 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4974 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4975 |
|
4420 | 4976 |
"On X11, be nice and paste PRIMARY when middle click. |
4977 |
Note, that middle button on X11 is translated to button |
|
4978 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 4979 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 4980 |
self undoableDo:[ |
4981 |
self paste: (self getClipboardText:#selection). |
|
4982 |
]. |
|
4983 |
^self. |
|
4984 |
]. |
|
4985 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4986 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4987 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4988 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4989 |
"/ 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
|
4990 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4991 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4992 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4993 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4994 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4995 |
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
|
4996 |
|
4420 | 4997 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4998 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4999 |
! |
5000 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5001 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5002 |
"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
|
5003 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
5004 |
|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
|
5005 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5006 |
(button == 1) ifTrue:[ |
5882 | 5007 |
typeOfSelection := nil. |
5008 |
||
5009 |
dragIsActive ifTrue:[ |
|
5010 |
self unselect |
|
5011 |
]. |
|
5012 |
selectionStartLine isNil ifTrue:[ |
|
5013 |
clickCol notNil ifTrue:[ |
|
5014 |
self cursorMovementAllowed ifTrue:[ |
|
5015 |
newCursorCol := clickCol. |
|
5016 |
||
5017 |
cursorType ~~ #block ifTrue:[ |
|
5018 |
clickPos notNil ifTrue:[ |
|
5019 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
5020 |
"/ (i.e. if its an ibeam). |
|
5021 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
3790 | 5022 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
5882 | 5023 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
5024 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
5025 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
5026 |
]. |
|
5027 |
]. |
|
5028 |
"/ the following fixes the ugly select behavior when double clicking on |
|
5029 |
"/ a partially visible last line (where the first click used to |
|
5030 |
"/ scroll the text so that the second click was handled on another |
|
5031 |
"/ line. An alternative (possibly better) solution would be to |
|
5032 |
"/ remember the last click position and adjust in the double click |
|
5033 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
5034 |
"/ Time will show, if this hack works. |
|
5035 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
|
5036 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
5057 | 5037 |
Processor |
5882 | 5038 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
5039 |
after:0.3 seconds. |
|
5040 |
] ifFalse:[ |
|
5041 |
self cursorLine:clickLine col:newCursorCol. |
|
5042 |
]. |
|
5043 |
]. |
|
5044 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
|
5045 |
list notEmptyOrNil ifTrue:[ |
|
5046 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
|
5047 |
(clickLine >= list size) ifTrue:[ |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5048 |
(clickLine > (self list size + 2) |
5882 | 5049 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
5050 |
self selectAll |
|
5051 |
]. |
|
5052 |
]. |
|
5053 |
] |
|
5054 |
] |
|
5055 |
] |
|
5056 |
] |
|
5057 |
] ifFalse:[ |
|
5058 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
|
5059 |
]. |
|
5060 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5061 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5062 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
5063 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5064 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5065 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5066 |
|
2580 | 5067 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5068 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5069 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5070 |
| n oldTypeOfSelection | |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5071 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5072 |
oldTypeOfSelection := typeOfSelection. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5073 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5074 |
self changeTypeOfSelectionTo:nil. |
2580 | 5075 |
|
5076 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5077 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5078 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5079 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5080 |
cursorCol := cursorCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5081 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5082 |
self validateNewSelection. |
4420 | 5083 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5084 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5085 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5086 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5087 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5088 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5089 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5090 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5091 |
self addToSelectionAfter:[ self cursorRight ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5092 |
] ifFalse:[ |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5093 |
"/ Compensate for Claus paste-cursordown-paste feature. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5094 |
"/ Right after paste the cursor is at the beginning of the |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5095 |
"/ selection. But if immediately after paste user moves cursor right |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5096 |
"/ (but without shift!!!!!!), she probably wants to move past the |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5097 |
"/ pasted text, not into it. This is how every other editor behaves. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5098 |
oldTypeOfSelection == #paste ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5099 |
cursorLine := selectionEndLine. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5100 |
cursorCol := selectionEndCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5101 |
]. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5102 |
|
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5103 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5104 |
"/ to the end of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5105 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5106 |
self setCursorLine: selectionEndLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5107 |
self setCursorCol: selectionEndCol + 1. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5108 |
self unselect; makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5109 |
^ self. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5110 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5111 |
self unselect; makeCursorVisible. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5112 |
self cursorRight. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5113 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5114 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5115 |
^ self |
2580 | 5116 |
]. |
5117 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5118 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5119 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5120 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5121 |
selectionEndCol := cursorCol - 1. |
4970 | 5122 |
"/ selectionEndCol == 1 ifTrue:[ |
5123 |
"/ selectionEndCol := 0. |
|
5124 |
"/ ]. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5125 |
self setCursorLine: cursorLine + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5126 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5127 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5128 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5129 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5130 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5131 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5132 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5133 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5134 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5135 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5136 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5137 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5138 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5139 |
"/ self setCursorLine:(selectionEndLine ? selectionStartLine). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5140 |
"/ self setCursorCol:selectionStartCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5141 |
"/ (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5142 |
"/ self setCursorCol:1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5143 |
"/ self setCursorLine:(cursorLine - 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5144 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5145 |
"/ self makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5146 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5147 |
"/ shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5148 |
"/ clickLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5149 |
"/ clickCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5150 |
"/ self setCursorLine: cursorLine + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5151 |
"/ self expandSelectionDown. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5152 |
"/ ^ self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5153 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5154 |
"/ self unselect. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5155 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5156 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5157 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5158 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5159 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5160 |
self addToSelectionAfter:[ self cursorDown:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5161 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5162 |
"/ If there's selection, unselect and move cursor |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5163 |
"/ one line below last selection line but at the |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5164 |
"/ selectionStartCol column. This behavior is |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5165 |
"/ useful when pasting... |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5166 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5167 |
self setCursorLine: selectionEndLine. |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5168 |
self setCursorCol: selectionStartCol. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5169 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5170 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5171 |
self cursorDown:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5172 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5173 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5174 |
"/ flush keyboard to avoid runaway cursor |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5175 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5176 |
self sensor flushKeyboardFor:self. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5177 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5178 |
^ self |
2580 | 5179 |
]. |
5180 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5181 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5182 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5183 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5184 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5185 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5186 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5187 |
selectionStartCol := cursorCol-1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5188 |
self setCursorCol: cursorCol-1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5189 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5190 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5191 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5192 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5193 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5194 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5195 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5196 |
selectionEndLine := clickStartLine := cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5197 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5198 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5199 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5200 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5201 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5202 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5203 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5204 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5205 |
self redrawFromLine:selectionStartLine to:cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5206 |
self setCursorLine: cursorLine - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5207 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5208 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5209 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5210 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5211 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5212 |
self hasSelection ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5213 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5214 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5215 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5216 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5217 |
"/ self setCursorLine:selectionStartLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5218 |
"/ self setCursorCol:selectionStartCol. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5219 |
"/ self makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5220 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5221 |
"/ shifted ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5222 |
"/ self unselect. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5223 |
"/ ] |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5224 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5225 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5226 |
(key == #CursorLeft) ifTrue:[ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5227 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5228 |
self addToSelectionAfter:[self cursorLeft]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5229 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5230 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5231 |
"/ to the end of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5232 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5233 |
self setCursorLine:selectionStartLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5234 |
self setCursorCol:selectionStartCol. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5235 |
self unselect; makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5236 |
^ self. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5237 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5238 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5239 |
self cursorLeft. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5240 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5241 |
^self |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5242 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5243 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5244 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5245 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5246 |
self addToSelectionAfter: [ self cursorUp:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5247 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5248 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5249 |
"/ to the beggining of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5250 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5251 |
self setCursorLine:selectionStartLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5252 |
self setCursorCol:selectionStartCol. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5253 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5254 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5255 |
self cursorUp:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5256 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5257 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5258 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5259 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5260 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5261 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5262 |
]. |
2580 | 5263 |
]. |
4420 | 5264 |
|
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5265 |
"Modified: / 28-03-2014 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2580 | 5266 |
! |
5267 |
||
2952 | 5268 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5269 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5270 |
|
4521 | 5271 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 5272 |
#Replace #Undo #Redo #Accept |
3780 | 5273 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 5274 |
#DeleteSpaces #Join |
3780 | 5275 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 5276 |
#SelectWord #ExpandSelectionByWord |
3780 | 5277 |
#SelectToEnd #SelectFromBeginning |
4707 | 5278 |
#SelectLine #ExpandSelectionByLine |
3780 | 5279 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
5280 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5281 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5282 |
#GotoLine #BeginOfText #EndOfText |
|
5283 |
#InsertLine #DeleteLine |
|
5284 |
#SelectLineFromBeginning |
|
5285 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 5286 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 5287 |
#'F*' #'f*')> |
2017 | 5288 |
|
4730 | 5289 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5290 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5291 |
|
5292 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5293 |
|
4701 | 5294 |
"/ experimental |
4818 | 5295 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 5296 |
(immediateCompletion |
4818 | 5297 |
or:[currentUserPrefs codeCompletionOnControlKey |
5298 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5299 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5300 |
self initializeCompletionSupport. |
4609 | 5301 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5302 |
]. |
5394 | 5303 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5304 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5305 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5306 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5307 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5308 |
completionSupport notNil ifTrue:[ |
5394 | 5309 |
completionSupport stopCompletionProcess. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5310 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5311 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5312 |
|
4818 | 5313 |
key isSymbol ifTrue:[ |
5643 | 5314 |
(device modifierKeys includes:key) ifFalse:[ |
4818 | 5315 |
lastReplacementInfo stillCollectingInput:false. |
5316 |
] |
|
5317 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5318 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 5319 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5320 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5321 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5322 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5323 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 5324 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5325 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5326 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5327 |
]. |
3799 | 5328 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5329 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5330 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5331 |
self learnMode ifTrue:[ |
4482 | 5332 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5333 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5334 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5335 |
|
4238 | 5336 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
5337 |
"the macro named key exists" |
|
3780 | 5338 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5339 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5340 |
|
4482 | 5341 |
key isSymbol ifFalse:[ |
5342 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
5343 |
self handleNonCommandKey:key. |
|
5344 |
^ self |
|
5345 |
]. |
|
5346 |
||
5347 |
event isNil ifTrue:[ |
|
5348 |
event := WindowGroup lastEventQuerySignal query. |
|
5349 |
]. |
|
5350 |
shiftPressed := event hasShift. |
|
5351 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5352 |
rawKey := event rawKey. |
4482 | 5353 |
|
5133 | 5354 |
key == #InsertUUID ifTrue:[ |
5355 |
self insertUUID. |
|
5356 |
^ self. |
|
5357 |
]. |
|
5358 |
||
4253 | 5359 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
5360 |
self deleteWordBeforeCursor. |
|
5361 |
^ self. |
|
5362 |
]. |
|
5363 |
||
5119 | 5364 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 5365 |
selectionStartLine notNil ifTrue:[ |
5366 |
((key == #BasicBackspace) |
|
4818 | 5367 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 5368 |
ifTrue:[ |
5369 |
self deleteSelection. |
|
5370 |
] ifFalse: [ |
|
5371 |
self copyAndDeleteSelection. |
|
5372 |
]. |
|
4609 | 5373 |
] ifFalse:[ |
5374 |
self makeCursorVisible. |
|
5375 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
5376 |
"/ self deleteWordBeforeCursor. |
|
5377 |
"/ ] ifFalse:[ |
|
5378 |
self deleteCharBeforeCursor. |
|
5379 |
"/ ]. |
|
3780 | 5380 |
]. |
4738 | 5381 |
true "immediateCompletion" ifTrue:[ |
5394 | 5382 |
completionSupport notNil ifTrue:[ |
5383 |
completionSupport postKeyPress:key |
|
5384 |
]. |
|
4731 | 5385 |
]. |
3780 | 5386 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5387 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5388 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5389 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5390 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5391 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5392 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5393 |
|
3235 | 5394 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5395 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 5396 |
^ self. |
3160 | 5397 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5398 |
|
4162 | 5399 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
5400 |
CharacterSetView notNil ifTrue:[ |
|
5401 |
self specialCharacters. |
|
5402 |
^ self. |
|
5403 |
] |
|
5404 |
]. |
|
5405 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5406 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5407 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5408 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5409 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 5410 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5411 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5412 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5413 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5414 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5415 |
(('[fF][0-9]' match:key) |
5416 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5417 |
shiftPressed ifFalse:[ |
|
4818 | 5418 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5419 |
fKeyMacros notNil ifTrue:[ |
5420 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5421 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5422 |
^ self |
|
5423 |
] |
|
5424 |
] |
|
5425 |
] |
|
5426 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5427 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5428 |
|
2506 | 5429 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5430 |
self parenthizeSelectionWith:$( and:$). |
5431 |
^ self. |
|
2506 | 5432 |
]. |
5433 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5434 |
self parenthizeSelectionWith:$" and:$". |
5435 |
^ self. |
|
2506 | 5436 |
]. |
5437 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5438 |
self parenthizeSelectionWith:$' and:$'. |
5439 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5440 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5441 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5442 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5443 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5444 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5445 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5446 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5447 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5448 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5449 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5450 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5451 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5452 |
|
3542 | 5453 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5454 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5455 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5456 |
self makeCursorVisible. |
|
5457 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5458 |
^ self |
|
5459 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5460 |
(key == #SelectWord) ifTrue:[ |
3780 | 5461 |
self makeCursorVisible. |
5462 |
self selectWordUnderCursor. |
|
5463 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5464 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5465 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5466 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5467 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5468 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5469 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
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 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5472 |
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
|
5473 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5474 |
(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
|
5475 |
(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
|
5476 |
(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
|
5477 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5478 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5479 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5480 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5481 |
shiftPressed ifTrue: [ |
5482 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5483 |
"/ self unselect. |
|
5484 |
"/ self cursorHome. |
|
5485 |
"Jan's modification" |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5486 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
4257 | 5487 |
"/ Jan's modification modified by his own request ;-)) |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5488 |
"/ JV: Well, does not work correctly. Better to fix addToSelectionAfter: |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5489 |
"/ self selectFromBeginOfLine. |
3780 | 5490 |
] ifFalse: [ |
5491 |
self unselect. |
|
5492 |
ctrlPressed ifTrue:[ |
|
5493 |
self cursorHome. |
|
5494 |
] ifFalse:[ |
|
5495 |
self cursorToBeginOfLine. |
|
5496 |
] |
|
5497 |
]. |
|
5498 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5499 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5500 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5501 |
shiftPressed ifTrue:[ |
5502 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5503 |
"/ self unselect. |
|
5504 |
"/ self cursorToBottom |
|
4257 | 5505 |
" Jan's modification" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5506 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
4257 | 5507 |
"/ Jan's modification modified by his own request ;-)) |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5508 |
"/ JV: Well, does not work correctly. Better to fix addToSelectionAfter: |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5509 |
"/ self selectToEndOfLine. |
3780 | 5510 |
] ifFalse:[ |
5511 |
self unselect. |
|
5512 |
ctrlPressed ifTrue:[ |
|
5513 |
self cursorToBottom |
|
5514 |
] ifFalse:[ |
|
5515 |
self cursorToEndOfLine. |
|
5516 |
] |
|
5517 |
]. |
|
5518 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5519 |
]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5520 |
(key == #NextWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5521 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5522 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5523 |
self cursorToNextWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5524 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5525 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5526 |
self cursorToNextWord |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5527 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5528 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5529 |
]. |
3310 | 5530 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5531 |
(key == #PreviousWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5532 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5533 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5534 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5535 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5536 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5537 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5538 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5539 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5540 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5541 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5542 |
|
5119 | 5543 |
(rawKey == #CursorRight |
5544 |
or:[rawKey == #CursorDown |
|
5545 |
or:[rawKey == #CursorLeft |
|
5546 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5547 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5548 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5549 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5550 |
|
5119 | 5551 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5552 |
self unselect. self cursorReturn. |
5553 |
^ self |
|
3257 | 5554 |
]. |
5555 |
||
5556 |
(key == #Return) ifTrue:[ |
|
3780 | 5557 |
shiftPressed ifTrue:[ |
5558 |
self unselect. self cursorReturn. |
|
5559 |
^ self |
|
5560 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5561 |
|
3780 | 5562 |
self isReadOnly ifTrue:[ |
5563 |
self unselect; makeCursorVisible. |
|
5564 |
self cursorReturn |
|
5565 |
] ifFalse:[ |
|
5566 |
self isInInsertMode ifFalse:[ |
|
5529 | 5567 |
self cursorReturn:true. |
3780 | 5568 |
autoIndent == true ifTrue:[ |
5569 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5570 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5571 |
self cursorCol:(i+1 max:1) |
5572 |
] |
|
3780 | 5573 |
] |
5574 |
] ifTrue:[ |
|
4826 | 5575 |
|left right oldIndent| |
4812 | 5576 |
|
3780 | 5577 |
"/ old version just unselected ... |
5578 |
"/ self unselect; makeCursorVisible. |
|
5579 |
||
5580 |
"/ new version deletes ... |
|
5581 |
typeOfSelection == #paste ifTrue:[ |
|
5582 |
self unselect; makeCursorVisible. |
|
5583 |
] ifFalse:[ |
|
5584 |
self copyAndDeleteSelection. |
|
5585 |
]. |
|
4816 | 5586 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5587 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5588 |
self insertCharAtCursor:(Character cr). |
5112 | 5589 |
|
3780 | 5590 |
autoIndent == true ifTrue:[ |
4816 | 5591 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5592 |
"/ nothing to do. |
|
4812 | 5593 |
] ifFalse:[ |
5594 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5595 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5596 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5597 |
left := left withoutSeparators. |
5598 |
right := right withoutSeparators. |
|
5599 |
(left endsWith:'[') ifTrue:[ |
|
5600 |
"/ i := i + 4. |
|
4816 | 5601 |
] ifFalse:[ |
4823 | 5602 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5603 |
i := i - 4. |
5604 |
]. |
|
4812 | 5605 |
]. |
4826 | 5606 |
oldIndent := self leftIndentOfLine:cursorLine. |
5607 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5608 |
self st80EditMode ifTrue:[ |
|
5609 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5610 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5611 |
]. |
|
5612 |
]. |
|
4812 | 5613 |
self cursorCol:(i+1 max:1) |
5614 |
]. |
|
5615 |
] |
|
3780 | 5616 |
]. |
5617 |
]. |
|
5618 |
]. |
|
5619 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5620 |
]. |
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
|
5621 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5622 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5623 |
self unselect. self cursorTab. |
5624 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5625 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5626 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5627 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5628 |
||
5629 |
self hasSelection ifTrue:[ |
|
5630 |
selectStyle == #line ifTrue:[ |
|
4238 | 5631 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5632 |
macroName := #IndentBy4. |
|
5633 |
] ifFalse:[ |
|
5634 |
macroName := #UndentBy4. |
|
5635 |
]. |
|
5636 |
macroName notNil ifTrue:[ |
|
5637 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5638 |
]. |
5639 |
] |
|
5640 |
]. |
|
5641 |
||
5642 |
self unselect. |
|
5643 |
(key == #Tab) ifTrue:[ |
|
5644 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5645 |
self cursorTab. |
|
5646 |
^ self |
|
5647 |
]. |
|
5648 |
self insertTabAtCursor. |
|
5649 |
^ self |
|
5650 |
]. |
|
5651 |
self cursorBacktab. |
|
5652 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5653 |
]. |
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
|
5654 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5655 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5656 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5657 |
shiftPressed ifTrue:[ |
5658 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5659 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5660 |
self makeCursorVisible. |
|
5661 |
self deleteCharAtCursor. |
|
5662 |
]. |
|
5663 |
^ self |
|
5664 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5665 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5666 |
|
5119 | 5667 |
(rawKey == #Delete |
870 | 5668 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5669 |
selectionStartLine notNil ifTrue:[ |
4130 | 5670 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5671 |
"/ To remove text repetetively, use Cut instead. |
|
5672 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5673 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5674 |
((key == #BasicDelete) |
4818 | 5675 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5676 |
self deleteSelection. |
5677 |
] ifFalse:[ |
|
5678 |
self copyAndDeleteSelection. |
|
5679 |
]. |
|
5680 |
^ self |
|
5681 |
]. |
|
5682 |
self makeCursorVisible. |
|
5683 |
self deleteCharAtCursor. |
|
5684 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5685 |
]. |
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
|
5686 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5687 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5688 |
self unselect. |
5689 |
cursorVisibleLine == 1 ifTrue:[ |
|
5690 |
self cursorHome. |
|
5691 |
] ifFalse:[ |
|
5692 |
self cursorToFirstVisibleLine |
|
5693 |
]. |
|
5694 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5695 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5696 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5697 |
self unselect. |
5698 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5699 |
self cursorToBottom. |
|
5700 |
] ifFalse:[ |
|
5701 |
self cursorToLastVisibleLine |
|
5702 |
]. |
|
5703 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5704 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5705 |
((key == #Escape) |
3257 | 5706 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5707 |
self makeCursorVisible. |
5708 |
self unselect. self selectCursorLineFromBeginning. |
|
5709 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5710 |
]. |
3257 | 5711 |
(key == #SelectLine) ifTrue:[ |
3780 | 5712 |
self makeCursorVisible. |
5713 |
self unselect. self selectCursorLine. |
|
5714 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5715 |
]. |
3257 | 5716 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5717 |
"/ self makeCursorVisible. |
3780 | 5718 |
self selectExpandCursorLine. |
5719 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5720 |
]. |
3257 | 5721 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5722 |
self makeCursorVisible. |
5723 |
self unselect. self deleteCursorLine. |
|
5724 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5725 |
]. |
3257 | 5726 |
(key == #InsertLine) ifTrue:[ |
3780 | 5727 |
self makeCursorVisible. |
5728 |
self unselect. self insertLine:nil before:cursorLine. |
|
5729 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5730 |
]. |
3781 | 5731 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5732 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5733 |
|
3310 | 5734 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5735 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5736 |
"Modified: / 31-03-2014 / 16:27:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5737 |
! |
5738 |
||
2952 | 5739 |
executeKeyboardMacro:cmdMacro |
5740 |
Error handle:[:ex | |
|
4823 | 5741 |
self warn:'Error in keyboard macro: ' , ex description. |
5742 |
ex return. |
|
2952 | 5743 |
] do:[ |
4823 | 5744 |
AbortOperationRequest handle:[:ex | |
5745 |
self warn:'Keyboard macro aborted'. |
|
5746 |
ex return. |
|
5747 |
] do:[ |
|
5748 |
Parser |
|
5749 |
evaluate:cmdMacro asString |
|
5750 |
receiver:self |
|
5751 |
notifying:nil |
|
5752 |
compile:false. |
|
5753 |
]. |
|
2952 | 5754 |
]. |
5755 |
! |
|
5756 |
||
5340
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5757 |
extendSelectionToX:x y:y setPrimarySelection:aBoolean |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5758 |
| movedVisibleLine movedLine movedCol movedUp | |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5759 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5760 |
movedVisibleLine := self visibleLineOfY:y. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5761 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5762 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5763 |
(x < leftMargin) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5764 |
movedCol := 0 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5765 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5766 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5767 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5768 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5769 |
"find out if we are before or after initial click" |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5770 |
movedUp := false. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5771 |
(movedLine < (clickStartLine ? movedLine)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5772 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5773 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5774 |
(movedLine == (clickStartLine ? movedLine)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5775 |
(movedCol < (clickStartCol ? movedCol)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5776 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5777 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5778 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5779 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5780 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5781 |
self hasSelection ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5782 |
movedUp ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5783 |
"/ Set cursor to selection start |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5784 |
self setCursorLine: selectionStartLine col: selectionStartCol |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5785 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5786 |
"/ Set cursor to selection end |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5787 |
self setCursorLine: selectionEndLine col: selectionEndCol + 1 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5788 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5789 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5790 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5791 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5792 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5793 |
super extendSelectionToX:x y:y setPrimarySelection:aBoolean. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5794 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5795 |
"Created: / 02-05-2015 / 07:33:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 5796 |
! |
5797 |
||
5798 |
handleNonCommandKey:keyArg |
|
4700 | 5799 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5800 |
|
5801 |
self isReadOnly ifTrue:[ |
|
4988 | 5802 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5803 |
^ self. |
2952 | 5804 |
]. |
5805 |
||
5806 |
key := keyArg. |
|
5807 |
||
5808 |
typeOfSelection == #paste ifTrue:[ |
|
4846
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5809 |
"Pasted selection will NOT be replaced by keystroke (non-standard, St/X feature)" |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5810 |
|
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5811 |
"/ After paste, the cursor is at the beginning to support |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5812 |
"/ paste-cursordown-paste. Compensate for this here - we want |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5813 |
"/ to continue editing after the end of the selection. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5814 |
"/ This is |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5815 |
cursorLine := selectionEndLine. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5816 |
cursorCol := selectionEndCol + 1. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5817 |
|
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5818 |
"/ Cursor position set, we can unselect. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5819 |
self unselect. |
2952 | 5820 |
]. |
5821 |
||
4700 | 5822 |
selStartLineBefore := selectionStartLine. |
5823 |
selStartColBefore := self selectionStartCol. |
|
5824 |
selEndLineBefore := selectionEndLine. |
|
5825 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5826 |
|
4940 | 5827 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 5828 |
key isCharacter ifTrue:[ |
4940 | 5829 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5830 |
] ifFalse:[ |
4940 | 5831 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5832 |
]. |
2952 | 5833 |
]. |
5834 |
||
5835 |
"replace selection by what is typed in - |
|
3235 | 5836 |
if word was selected with a space, keep it. |
4700 | 5837 |
if there was no selection, the key's character is inserted" |
3235 | 5838 |
|
5839 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5840 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5841 |
]. |
2952 | 5842 |
|
5843 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5844 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5845 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5846 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5847 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5848 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5849 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5850 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5851 |
] |
3160 | 5852 |
]. |
2952 | 5853 |
selectStyle := nil. |
5854 |
||
3235 | 5855 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5856 |
selectionStartLine := selStartLineBefore. |
5857 |
selectionStartCol := selStartColBefore. |
|
5858 |
selectionEndLine := selEndLineBefore. |
|
5859 |
selectionEndCol := selEndColBefore. |
|
3235 | 5860 |
]. |
5861 |
||
2952 | 5862 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5863 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5864 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5865 |
"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
|
5866 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5867 |
" |
2952 | 5868 |
" |
4481 | 5869 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5870 |
" |
4481 | 5871 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5872 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5873 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5874 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5875 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5876 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5877 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5878 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5879 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5880 |
self cursorLine:line col:col. |
4940 | 5881 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5882 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5883 |
"/ 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
|
5884 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5885 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5886 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5887 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5888 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5889 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5890 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5891 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5892 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5893 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5894 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5895 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5896 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5897 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5898 |
] |
2952 | 5899 |
]. |
5900 |
||
5901 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5902 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5903 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5904 |
"/ |
|
5905 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5906 |
"/ self selection. |
|
5907 |
"/ typeOfSelection := #paste. |
|
3160 | 5908 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5909 |
"/ ]. |
3235 | 5910 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5911 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5912 |
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
|
5913 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5914 |
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
|
5915 |
]. |
3235 | 5916 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5917 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5918 |
|
5919 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
4846
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5920 |
"Modified: / 30-08-2013 / 20:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 5921 |
! |
5922 |
||
5923 |
keyPress:key x:x y:y |
|
5924 |
"handle keyboard input" |
|
5925 |
||
4771 | 5926 |
|wasOn| |
5927 |
||
5928 |
wasOn := cursorShown. |
|
5929 |
||
5689 | 5930 |
NoModificationError |
5931 |
handle:[:ex | |
|
5932 |
self flashReadOnly. |
|
5933 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
5934 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5935 |
]. |
|
5936 |
] |
|
5937 |
do:[ |
|
5938 |
self undoableDo:[ |
|
5939 |
self doKeyPress:key x:x y:y |
|
5940 |
]. |
|
5941 |
]. |
|
5942 |
||
4242 | 5943 |
self repairDamage |
5944 |
||
5945 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 5946 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 5947 |
! |
5948 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5949 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5950 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5952 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5953 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5954 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5955 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5956 |
requestAutoAccept |
5068 | 5957 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
5958 |
This forces my value to be accepted into my model. |
|
5959 |
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
|
5960 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5961 |
acceptEnabled == false ifTrue:[ |
4823 | 5962 |
"/ nope - |
5963 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5964 |
]. |
5404 | 5965 |
"/ cg: only do this if modified. |
5966 |
"/ otherwise, users would have to make sure that the contents is |
|
5967 |
"/ always correct (which they don't). If you change this back, |
|
5968 |
"/ please check the expecco file-save or file-reimport dialog, |
|
5969 |
"/ which has a problem with that behavior. |
|
5970 |
self modified ifTrue:[ |
|
5971 |
self accept. |
|
5972 |
]. |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5973 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5974 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5975 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5976 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5977 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5978 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5979 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5980 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5981 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5982 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5983 |
cv notNil ifTrue:[ |
4823 | 5984 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5985 |
] |
4967 | 5986 |
! |
5987 |
||
5988 |
unmapped |
|
5989 |
super unmapped. |
|
5990 |
||
5991 |
completionSupport notNil ifTrue:[ |
|
5992 |
completionSupport release. |
|
5993 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5994 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5995 |
|
1807 | 5996 |
!EditTextView methodsFor:'focus handling'! |
5997 |
||
4818 | 5998 |
focusOut |
5999 |
super focusOut. |
|
6000 |
||
6001 |
completionSupport notNil ifTrue:[ |
|
6002 |
completionSupport release. |
|
6003 |
]. |
|
6004 |
! |
|
6005 |
||
1807 | 6006 |
hasKeyboardFocus:aBoolean |
6007 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
6008 |
(otherwise, I would not know about this)" |
|
6009 |
||
6010 |
hasKeyboardFocus := aBoolean. |
|
4609 | 6011 |
|
3160 | 6012 |
(cursorShown |
6013 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6014 |
and:[self isReadOnly not]]) ifTrue:[ |
5890 | 6015 |
self drawCursor |
4609 | 6016 |
]. |
6017 |
||
6018 |
hasKeyboardFocus ifFalse:[ |
|
5890 | 6019 |
completionSupport notNil ifTrue:[ |
6020 |
"/ this is a hack for Windows: |
|
6021 |
"/ on windows, an activate:false event is first sent to my textView, |
|
6022 |
"/ then an activate is sent to the completion popup. |
|
6023 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
6024 |
"/ therefore, allow for the activate of the completionMenu and its button event to be processed. |
|
6025 |
"/ before forcing it to be closed... |
|
6026 |
completionSupport startTimeoutForEditViewLostFocus. |
|
6027 |
]. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6028 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6029 |
|
4821 | 6030 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 6031 |
! |
6032 |
||
6033 |
showFocus:explicit |
|
6034 |
"in addition to however my superclass thinks how a focusView is to be |
|
6035 |
displayed, show the cursor when I got the focus" |
|
6036 |
||
5239 | 6037 |
self hasKeyboardFocus:true. |
1807 | 6038 |
self showCursor. |
6039 |
super showFocus:explicit |
|
6040 |
||
6041 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6042 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6043 |
|
4967 | 6044 |
showNoFocus:explicit |
6045 |
"the view lost the keyboard focus |
|
6046 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
6047 |
- change any display attributes as req'd." |
|
6048 |
||
6049 |
super showNoFocus:explicit. |
|
5149 | 6050 |
|
6051 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
6052 |
"/ not when the focus is lost normally (because this also happens when |
|
6053 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
6054 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
6055 |
explicit ifTrue:[ |
|
6056 |
completionSupport notNil ifTrue:[ |
|
6057 |
completionSupport release. |
|
6058 |
]. |
|
4818 | 6059 |
]. |
6060 |
! |
|
6061 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6062 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6063 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6064 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6065 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6066 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6067 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6068 |
and:[self enabled |
4781 | 6069 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6070 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6071 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6072 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6073 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6074 |
^ false |
1807 | 6075 |
! ! |
6076 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6077 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6078 |
|
4237 | 6079 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6080 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6081 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6082 |
|
4482 | 6083 |
|cmdMacro| |
6084 |
||
6085 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6086 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6087 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6088 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6089 |
^ true |
4238 | 6090 |
|
6091 |
" |
|
4483 | 6092 |
EditTextView open |
4238 | 6093 |
contents:'bla'; |
6094 |
selectAll; |
|
6095 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6096 |
EditTextView open |
4238 | 6097 |
contents:'bla'; |
6098 |
selectAll; |
|
6099 |
executekeyboardMacroNamed:#blabla. |
|
6100 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6101 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6102 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6103 |
! |
6104 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6105 |
indent |
3221 | 6106 |
"indent a line-range - this is done by searching for the |
6107 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6108 |
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
|
6109 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6110 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6111 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6112 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6113 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6114 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6115 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6116 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 6117 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6118 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6119 |
self unselect. |
3160 | 6120 |
self |
3786 | 6121 |
undoableDo:[self indentFromLine:start toLine:end] |
6122 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6123 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6124 |
|
4237 | 6125 |
indentBy4 |
5050 | 6126 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6127 |
||
6128 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6129 |
! |
|
6130 |
||
6131 |
indentBy8 |
|
6132 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6133 |
|
6134 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6135 |
! |
|
6136 |
||
5050 | 6137 |
indentBy:n |
6138 |
|line1 line2| |
|
6139 |
||
6140 |
line1 := self selectionStartLine. |
|
6141 |
line2 := self selectionEndLine. |
|
6142 |
line1 isNil ifTrue:[ |
|
5833 | 6143 |
line1 := self cursorLine. |
6144 |
line1 notNil ifTrue:[ |
|
6145 |
line2 := line1 |
|
6146 |
] |
|
5769 | 6147 |
] ifFalse:[ |
5833 | 6148 |
line2 notNil ifTrue:[ |
6149 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
5769 | 6150 |
]. |
6151 |
]. |
|
5050 | 6152 |
line1 notNil ifTrue:[ |
5833 | 6153 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6154 |
] |
6155 |
! |
|
6156 |
||
6157 |
indentByTab |
|
6158 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6159 |
! |
|
6160 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6161 |
indentFromLine:start toLine:end |
3221 | 6162 |
"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
|
6163 |
last non-empty line before start, and change the indent |
4742 | 6164 |
of the selected line-range based on that line's indent." |
6165 |
||
4811 | 6166 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6167 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6168 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6169 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6170 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6171 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6172 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6173 |
self indentFromLine:start toLine:end by:delta |
6174 |
! |
|
6175 |
||
6176 |
indentFromLine:start toLine:end by:delta |
|
6177 |
"indent a line-range - this is done by searching for the |
|
6178 |
last non-empty line before start, and change the indent |
|
6179 |
of the selected line-range based on that line's indent." |
|
6180 |
||
6181 |
|d line spaces anyChange| |
|
6182 |
||
6183 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6184 |
(delta > 0) ifTrue:[ |
4742 | 6185 |
spaces := String new:delta |
6186 |
]. |
|
6187 |
||
6188 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6189 |
start to:end do:[:lineNr | |
4742 | 6190 |
line := self listAt:lineNr. |
6191 |
line notNil ifTrue:[ |
|
6192 |
line isBlank ifTrue:[ |
|
4771 | 6193 |
self basicListAt:lineNr put:nil |
4742 | 6194 |
] ifFalse:[ |
6195 |
(delta > 0) ifTrue:[ |
|
6196 |
line := spaces , line. |
|
6197 |
widthOfWidestLine notNil ifTrue:[ |
|
6198 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6199 |
] |
|
6200 |
] ifFalse:[ |
|
6201 |
"check if deletion is ok" |
|
6202 |
d := delta negated + 1. |
|
6203 |
||
6204 |
line size > d ifTrue:[ |
|
6205 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
6206 |
line := line copyFrom:d |
|
6207 |
] |
|
6208 |
]. |
|
6209 |
widthOfWidestLine := nil |
|
6210 |
]. |
|
6211 |
self replaceLine:lineNr with:line. |
|
6212 |
anyChange := true. |
|
6213 |
] |
|
6214 |
] |
|
6215 |
]. |
|
6216 |
||
6217 |
anyChange ifTrue:[ self textChanged ]. |
|
6218 |
||
3221 | 6219 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6220 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6221 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6222 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6223 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6224 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6225 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6226 |
this is done by searching for the last non-empty line before it |
4823 | 6227 |
and returning its indent. |
6228 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6229 |
|
827 | 6230 |
"SHOULD GO TO ListView" |
6231 |
||
6232 |
|line lnr indent| |
|
6233 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6234 |
lnr := lineNr. |
827 | 6235 |
|
4823 | 6236 |
"/ [lnr ~~ 1] whileTrue:[ |
6237 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 6238 |
lnr := lnr - 1. |
6239 |
line := self listAt:lnr. |
|
6240 |
||
6241 |
line notNil ifTrue:[ |
|
6242 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
6243 |
indent ~~ 0 ifTrue:[ |
|
6244 |
(line endsWith:$[) ifTrue:[ |
|
6245 |
^ indent + 4 - 1 |
|
6246 |
]. |
|
6247 |
^ indent - 1 |
|
6248 |
] |
|
6249 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6250 |
]. |
827 | 6251 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6252 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6253 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 6254 |
! |
6255 |
||
6256 |
undentBy4 |
|
5050 | 6257 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6258 |
||
6259 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6260 |
! |
|
6261 |
||
6262 |
undentBy8 |
|
6263 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6264 |
|
6265 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6266 |
! |
6267 |
||
6268 |
undentBy:n |
|
6269 |
self indentBy:(n negated) |
|
6270 |
! |
|
6271 |
||
6272 |
undentByTab |
|
6273 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6274 |
! ! |
6275 |
||
0 | 6276 |
!EditTextView methodsFor:'initialization'! |
6277 |
||
941 | 6278 |
fetchDeviceResources |
6279 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6280 |
||
6281 |
super fetchDeviceResources. |
|
6282 |
||
5643 | 6283 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6284 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6285 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6286 |
|
6287 |
"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
|
6288 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6289 |
! |
6290 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6291 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6292 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6293 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6294 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6295 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6296 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6297 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6298 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6299 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6300 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6301 |
super initStyle. |
4576 | 6302 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6303 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6304 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6305 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6306 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6307 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6308 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6309 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6310 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6311 |
cursorTypeNoFocus := cursorType. |
|
6312 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6313 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6314 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6315 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6316 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6317 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 6318 |
cursorType ~~ #block ifTrue:[ |
6319 |
cursorNoFocusFgColor := cursorBgColor |
|
6320 |
] ifFalse:[ |
|
6321 |
cursorNoFocusFgColor := cursorFgColor |
|
6322 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6323 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6324 |
|
2088 | 6325 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6326 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6327 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6328 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6329 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6330 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6331 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6332 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6333 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6334 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6335 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6336 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6337 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6338 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6339 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6340 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6341 |
cursorCol := 1. |
5251 | 6342 |
cursorLineHolder := ValueHolder with:1. |
6343 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6344 |
modifiedChannel := ValueHolder with:false. |
6345 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6346 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6347 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6348 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6349 |
tabMeansNextField := false. |
5106 | 6350 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6351 |
autoIndent := false. |
|
5251 | 6352 |
editMode := ValueHolder with:EditMode insertMode. |
6353 |
learnMode := ValueHolder with:false. |
|
2131 | 6354 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6355 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6356 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6357 |
"/ enable drop by default |
2589 | 6358 |
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
|
6359 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6360 |
undoSupport := UndoSupport for:self. |
5251 | 6361 |
codeAspectHolder := ValueHolder with:nil. |
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6362 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6363 |
"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
|
6364 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6365 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6366 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6367 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6368 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6369 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6370 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6371 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6372 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6373 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6374 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6375 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6376 |
! |
6377 |
||
6378 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6379 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6380 |
completionSupport release |
4771 | 6381 |
]. |
6382 |
super release |
|
0 | 6383 |
! ! |
6384 |
||
2580 | 6385 |
!EditTextView methodsFor:'macros'! |
6386 |
||
6387 |
executeLearnedKeyboardMacro |
|
4673 | 6388 |
"replay the characters as learned previously" |
6389 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6390 |
(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
|
6391 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6392 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6393 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6394 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6395 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6396 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6397 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6398 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6399 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6400 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6401 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6402 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6403 |
]. |
2580 | 6404 |
] ifFalse:[ |
5153 | 6405 |
self flash:'no macro'. |
2580 | 6406 |
]. |
6407 |
! |
|
6408 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6409 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6410 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6411 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6412 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6413 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6414 |
|
2580 | 6415 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6416 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6417 |
|
2580 | 6418 |
|fg bg| |
6419 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6420 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6421 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6422 |
aBoolean ifTrue:[ |
5795 | 6423 |
learnedMacro := OrderedCollection new. |
6424 |
fg := self whiteColor. |
|
6425 |
bg := self blackColor. |
|
2580 | 6426 |
] ifFalse:[ |
5795 | 6427 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6428 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6429 |
]. |
6430 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6431 |
! |
|
6432 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6433 |
learnModeHolder |
4673 | 6434 |
"a holder returning true, if in learn mode" |
6435 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6436 |
learnMode isNil ifTrue:[ |
5251 | 6437 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6438 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6439 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6440 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6441 |
|
4673 | 6442 |
rememberLearnedMacroAs: nameString |
6443 |
Macros isNil ifTrue:[ |
|
6444 |
Macros := Dictionary new. |
|
6445 |
]. |
|
6446 |
Macros at:nameString put:learnedMacro |
|
6447 |
! |
|
6448 |
||
2580 | 6449 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6450 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6451 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6452 |
self learnMode:(self learnMode not). |
2580 | 6453 |
! ! |
6454 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6455 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6456 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6457 |
babelFishTranslate:fromToModeString |
5962 | 6458 |
"translate the selected text and paste it after the selection. |
6459 |
This is now obsolete, as that web service no longer exists (sigh)" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6460 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6461 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6462 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6463 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6464 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6465 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6466 |
self withWaitCursorDo:[ |
5962 | 6467 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
6468 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
6469 |
] do:[ |
|
6470 |
translated := SOAP::BabelFishClient new |
|
6471 |
translate:original mode:fromToModeString. |
|
6472 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6473 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6474 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6475 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6476 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6477 |
self unselect. |
3799 | 6478 |
self |
6479 |
undoablePaste:translated |
|
5962 | 6480 |
info:'Translate' |
3495 | 6481 |
|
6482 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6483 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6484 |
|
3517 | 6485 |
compareWithClipboard |
6486 |
"compare the selection against the clipboard contents" |
|
6487 |
||
6488 |
|t1 t2| |
|
6489 |
||
6490 |
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
|
6491 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6492 |
Dialog information:'Clipboard is empty.'. |
6493 |
^ self. |
|
3517 | 6494 |
]. |
6495 |
||
6496 |
self hasSelection ifTrue:[ |
|
4823 | 6497 |
t1 := self selectionAsString. |
3517 | 6498 |
] ifFalse:[ |
4823 | 6499 |
t1 := self contents asString |
3517 | 6500 |
]. |
6501 |
t1 := t1 string. |
|
6502 |
||
6503 |
t1 = t2 ifTrue:[ |
|
4823 | 6504 |
Dialog information:'Strings are equal.'. |
6505 |
^ self. |
|
3517 | 6506 |
]. |
6507 |
DiffTextView |
|
4823 | 6508 |
openOn:t1 label:'Editor' |
6509 |
and:t2 label:'Clipboard' |
|
3517 | 6510 |
! |
6511 |
||
5826 | 6512 |
compareWithFile |
6513 |
"compare the selection or the whole text against the contents of a file" |
|
6514 |
||
6515 |
|fn t1 t2| |
|
6516 |
||
6517 |
fn := Dialog requestFileName:'Compare against file:' default:defaultFileNameForFileDialog. |
|
6518 |
fn isEmptyOrNil ifTrue:[^ self]. |
|
6519 |
||
6520 |
t2 := fn asFilename contentsOfEntireFile. |
|
6521 |
t2 isEmptyOrNil ifTrue:[ |
|
6522 |
Dialog information:'File is empty.'. |
|
6523 |
^ self. |
|
6524 |
]. |
|
6525 |
||
6526 |
self hasSelection ifTrue:[ |
|
6527 |
t1 := self selectionAsString. |
|
6528 |
] ifFalse:[ |
|
6529 |
t1 := self contents asString |
|
6530 |
]. |
|
6531 |
t1 := t1 string. |
|
6532 |
||
6533 |
t1 = t2 ifTrue:[ |
|
6534 |
Dialog information:'Same contents.'. |
|
6535 |
^ self. |
|
6536 |
]. |
|
6537 |
DiffTextView |
|
6538 |
openOn:t1 label:'Editor' |
|
6539 |
and:t2 label:'File' |
|
6540 |
! |
|
6541 |
||
5689 | 6542 |
copySelection |
6543 |
"copy contents into smalltalk copybuffer. |
|
6544 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6545 |
||
6546 |
self hasSelection ifTrue:[ |
|
6547 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
|
6548 |
]. |
|
6549 |
super copySelection. |
|
6550 |
||
6551 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6552 |
! |
|
6553 |
||
121 | 6554 |
cut |
6555 |
"cut selection into copybuffer" |
|
6556 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6557 |
self deleteCopyToClipboard:true |
121 | 6558 |
! |
6559 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6560 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6561 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6562 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6563 |
cursorLine notNil ifTrue:[ |
4823 | 6564 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6565 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6566 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6567 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6568 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6569 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6570 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6571 |
|
4129 | 6572 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6573 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6574 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6575 |
self flashReadOnly. |
3786 | 6576 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6577 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6578 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6579 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6580 |
sel notNil ifTrue:[ |
4129 | 6581 |
self setLastStringToReplace: sel. |
4053 | 6582 |
|
3786 | 6583 |
line := selectionStartLine. |
6584 |
col := selectionStartCol. |
|
6585 |
||
6586 |
toClipboard ifTrue:[ |
|
6587 |
" |
|
6588 |
remember in CopyBuffer |
|
6589 |
" |
|
6590 |
self setClipboardText:sel. "/ lastString. |
|
6591 |
]. |
|
6592 |
||
6593 |
" |
|
6594 |
append to DeleteHistory (if there is one) |
|
6595 |
" |
|
6596 |
history := Smalltalk at:#DeleteHistory. |
|
6597 |
history notNil ifTrue:[ |
|
6598 |
history addAll:(sel asStringCollection). |
|
6599 |
history size > 1000 ifTrue:[ |
|
6600 |
history := history copyFrom:(history size - 1000) |
|
6601 |
]. |
|
6602 |
]. |
|
6603 |
||
6604 |
" |
|
6605 |
now, delete it |
|
6606 |
" |
|
6607 |
self |
|
6608 |
undoableDo:[self deleteSelection] |
|
6609 |
info:'Delete'. |
|
4048 | 6610 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6611 |
] ifFalse:[ |
3786 | 6612 |
" |
6613 |
a cut without selection will search&cut again |
|
6614 |
" |
|
6615 |
self undoableDo:[ |
|
6616 |
self again |
|
6617 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6618 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6619 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6620 |
"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
|
6621 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6622 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6623 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6624 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6625 |
|
3781 | 6626 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 6627 |
#Find #GotoLine #SaveAs #Print |
3890 | 6628 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6629 |
#ToggleAutoIndent #ToggleInsertMode |
5826 | 6630 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6631 |
<resource: #programMenu> |
1054 | 6632 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6633 |
|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
|
6634 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6635 |
|
2460 | 6636 |
items := #( |
5826 | 6637 |
('Redo' redo Redo ) |
6638 |
('Again (for All)' multipleAgain AgainForAll ) |
|
6639 |
('-' ) |
|
6640 |
('Search...' search Find ) |
|
6641 |
('Goto Line...' gotoLine GotoLine ) |
|
6642 |
('-' ) |
|
6643 |
('Tools' tools ) |
|
6644 |
('Font...' changeFont ) |
|
6645 |
('Insert Unicode...' insertUnicode ) |
|
6646 |
). |
|
4213 | 6647 |
CharacterSetView notNil ifTrue:[ |
5826 | 6648 |
items := items , |
6649 |
#( |
|
6650 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6651 |
). |
|
4213 | 6652 |
]. |
6653 |
items := items , #( |
|
5826 | 6654 |
('-' ) |
6655 |
('Save As...' save SaveAs ) |
|
6656 |
('Print' doPrint Print ) |
|
6657 |
('=' ) |
|
6658 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 6659 |
|
2866 | 6660 |
miscItems := #( |
5826 | 6661 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6662 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
6663 |
('-' ) |
|
6664 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
6665 |
('Join Lines' joinLines Join ) |
|
6666 |
('Wrap Lines...' wrapLines Wrap ) |
|
6667 |
('-' ) |
|
6668 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
6669 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
6670 |
('-' ) |
|
6671 |
('Insert File...' insertFile ) |
|
6672 |
('Insert URL Contents...' insertURL ) |
|
6673 |
('Insert new UUID' insertUUID ) |
|
6674 |
('Insert Date && Time' insertDateAndTime ) |
|
6675 |
('-' ) |
|
6676 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6677 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
6678 |
). |
|
4213 | 6679 |
"/ CharacterSetView notNil ifTrue:[ |
6680 |
"/ miscItems := miscItems , |
|
6681 |
"/ #( |
|
5529 | 6682 |
"/ ('-' ) |
4213 | 6683 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6684 |
"/ ('Font...' changeFont ) |
4213 | 6685 |
"/ ). |
5529 | 6686 |
"/ ] ifFalse:[ |
6687 |
"/ miscItems := miscItems , |
|
6688 |
"/ #( |
|
6689 |
"/ ('Font...' changeFont ) |
|
6690 |
"/"/ ('Encoding...' changeEncoding ) |
|
6691 |
"/ ). |
|
6692 |
"/ ]. |
|
2866 | 6693 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6694 |
translateItems := #( |
5826 | 6695 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6696 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6697 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6698 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6699 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6700 |
('-' ) |
|
6701 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6702 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6703 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6704 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6705 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6706 |
). |
|
3221 | 6707 |
|
6708 |
sortItems := #( |
|
5826 | 6709 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6710 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
6711 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
6712 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6713 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
6714 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
6715 |
('-' ) |
|
6716 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
6717 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6718 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6719 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
6720 |
('-' ) |
|
6721 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6722 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
6723 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6724 |
|
2762 | 6725 |
toolItems := #( |
5826 | 6726 |
('Indent' indent ) |
6727 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6728 |
('Sort' sort ) |
|
6729 |
('Split...' splitLinesAtCharacterOrString ) |
|
6730 |
('-' ) |
|
6731 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6732 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
6733 |
('Translate' babelFishTranslate ) |
|
6734 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6735 |
('Compare with File...' compareWithFile ) |
|
6736 |
). |
|
2762 | 6737 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6738 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 6739 |
toolItems := toolItems , #( |
6740 |
('-' ) |
|
6741 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6742 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6743 |
('Inspect Selected String' inspectSelectedString ) |
|
6744 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6745 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6746 |
|
2460 | 6747 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6748 |
sub receiver:self. |
2460 | 6749 |
|
2919 | 6750 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6751 |
toolSub receiver:self. |
|
6752 |
sub subMenuAt:#tools put:toolSub. |
|
6753 |
||
3495 | 6754 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6755 |
transSub receiver:self. |
|
6756 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6757 |
||
6758 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6759 |
sortSub receiver:self. |
|
6760 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6761 |
|
2866 | 6762 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6763 |
subSub receiver:self. |
|
2952 | 6764 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6765 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6766 |
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
|
6767 |
|
2866 | 6768 |
sub subMenuAt:#misc put:subSub. |
6769 |
||
3495 | 6770 |
mainItems := #( |
5826 | 6771 |
('Undo' undo Undo ) |
6772 |
('Again' again Again ) |
|
6773 |
('-' ) |
|
6774 |
('Cut' cut Cut ) |
|
6775 |
('Copy' copySelection Copy ) |
|
6776 |
('Paste' pasteOrReplace Paste ) |
|
6777 |
('-' ) |
|
6778 |
('Accept' accept Accept ) |
|
6779 |
('=' ) |
|
6780 |
('More' others Ctrl ) |
|
6781 |
). |
|
3495 | 6782 |
main := PopUpMenu itemList:mainItems resources:resources. |
6783 |
main subMenuAt:#others put:sub. |
|
6784 |
||
6785 |
sensor := self sensor. |
|
6786 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6787 |
sensor shiftDown ifTrue:[ |
|
5826 | 6788 |
m := subSub |
6789 |
] ifFalse:[ |
|
6790 |
m := sub |
|
6791 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6792 |
] ifFalse:[ |
5826 | 6793 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6794 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6795 |
|
4742 | 6796 |
"/ the 'Smalltalk at:' code is here to |
6797 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6798 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 6799 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6800 |
m disable:#googleSpellingSuggestion |
|
2676 | 6801 |
]. |
4742 | 6802 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 6803 |
m disable:#internalSpellingSuggestion |
4742 | 6804 |
]. |
2676 | 6805 |
|
3811 | 6806 |
HTTPInterface isNil ifTrue:[ |
5826 | 6807 |
m disableAll:#(insertURL) |
3811 | 6808 |
]. |
6809 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6810 |
self isReadOnly ifTrue:[ |
5826 | 6811 |
m disableAll:#(accept undo again multipleAgain redo |
6812 |
paste pasteOrReplace pasteOrReplaceFromHistory |
|
6813 |
cut indent autoIndent: insertMode: |
|
6814 |
insertFile insertFileAsStringLiteral insertURL |
|
6815 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6816 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
5826 | 6817 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
6818 |
insertUnicode specialCharacters) |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6819 |
]. |
2817 | 6820 |
self hasSelectionForCopy ifFalse:[ |
5826 | 6821 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6822 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6823 |
self hasSelection ifFalse:[ |
5371 | 6824 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
5826 | 6825 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString). |
2762 | 6826 |
] ifTrue:[ |
5826 | 6827 |
(Error handle:[:ex | |
6828 |
ex return:false |
|
6829 |
] do:[ |
|
6830 |
|fn| |
|
6831 |
fn := self selectionAsString. |
|
6832 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
6833 |
]) ifFalse:[ |
|
6834 |
m disableAll:#(openFileBrowserOnIt). |
|
6835 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6836 |
]. |
2569 | 6837 |
self hasUndoAction ifFalse:[ |
5826 | 6838 |
m disable:#undo. |
3115 | 6839 |
] ifTrue:[ |
5826 | 6840 |
what := undoSupport undoActionInfo. |
6841 |
what notNil ifTrue:[ |
|
6842 |
undoIdx := m indexOf:#undo. |
|
6843 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6844 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6845 |
]. |
2952 | 6846 |
self hasRedoAction ifFalse:[ |
5826 | 6847 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6848 |
] ifTrue:[ |
5826 | 6849 |
what := undoSupport redoActionInfo. |
6850 |
what notNil ifTrue:[ |
|
6851 |
redoIdx := sub indexOf:#redo. |
|
6852 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6853 |
] |
|
2952 | 6854 |
]. |
5216 | 6855 |
self canAccept ifFalse:[ |
5826 | 6856 |
m disable:#accept |
1108 | 6857 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6858 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6859 |
|
4388 | 6860 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6861 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6862 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6863 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6864 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6865 |
|
5643 | 6866 |
history := device getCopyBufferHistory copy. |
3160 | 6867 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6868 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6869 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6870 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6871 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6872 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6873 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6874 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6875 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6876 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6877 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6878 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6879 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6880 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6881 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6882 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6883 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6884 |
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
|
6885 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6886 |
box show. |
3160 | 6887 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6888 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6889 |
"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
|
6890 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6891 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6892 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6893 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6894 |
self sensor shiftDown ifTrue:[ |
3855 | 6895 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6896 |
]. |
2724 | 6897 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6898 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6899 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6900 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6901 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6902 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6903 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6904 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6905 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6906 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6907 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6908 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6909 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6910 |
"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
|
6911 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6912 |
|
2676 | 6913 |
googleSpellingSuggestion |
6914 |
"insert the google-spelling suggestion for the selected text. |
|
6915 |
Requires that the SOAP stuff is loaded and working." |
|
6916 |
||
2677 | 6917 |
|text suggestion| |
2676 | 6918 |
|
6919 |
self withWaitCursorDo:[ |
|
3799 | 6920 |
text := self selection asString string withoutSeparators. |
6921 |
text size == 0 ifTrue:[^ self]. |
|
6922 |
||
4742 | 6923 |
"/ the 'Smalltalk at:' code is here to |
6924 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6925 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6926 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6927 |
^ self. |
|
6928 |
] do:[ |
|
4742 | 6929 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6930 |
]. |
6931 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6932 |
self information:('No spelling suggestion from Google for: ' , text). |
6933 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6934 |
^ self. |
6935 |
]. |
|
6936 |
]. |
|
6937 |
self |
|
6938 |
undoablePaste:suggestion |
|
6939 |
info:'Spelling Suggestion'. |
|
3495 | 6940 |
|
6941 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6942 |
! |
6943 |
||
3595 | 6944 |
insertDateAndTime |
6945 |
"insert the curent date and time string" |
|
6946 |
||
6947 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6948 |
self |
3786 | 6949 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6950 |
info:'Paste Date and Time' |
3595 | 6951 |
! |
6952 |
||
2676 | 6953 |
insertFile |
3160 | 6954 |
"insert contents of a file |
2676 | 6955 |
- ask user for filename using a fileSelectionBox." |
6956 |
||
3731 | 6957 |
self insertFileAsStringLiteral:false |
6958 |
! |
|
6959 |
||
6960 |
insertFileAsStringLiteral |
|
6961 |
"insert a file's contents as a string literal. |
|
6962 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6963 |
to make it a legal string literal" |
|
6964 |
||
6965 |
self insertFileAsStringLiteral:true |
|
6966 |
! |
|
6967 |
||
6968 |
insertFileAsStringLiteral:asStringLiteral |
|
6969 |
"insert contents of a file; either as-is or as a string literal. |
|
6970 |
- ask user for filename using a fileSelectionBox." |
|
6971 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6972 |
|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
|
6973 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6974 |
((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
|
6975 |
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
|
6976 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6977 |
ifTrue:[ |
3731 | 6978 |
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
|
6979 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6980 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6981 |
[ |
3731 | 6982 |
|why| |
6983 |
||
6984 |
file := Dialog |
|
6985 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6986 |
default:initial |
|
6987 |
ok:(resources string:'Insert') |
|
6988 |
abort:(resources string:'Cancel') |
|
6989 |
pattern:nil |
|
6990 |
fromDirectory:directoryForFileDialog. |
|
6991 |
file isNil ifTrue:[ |
|
6992 |
"cancel" |
|
6993 |
^ self. |
|
6994 |
]. |
|
6995 |
file := file asFilename. |
|
6996 |
directoryForFileDialog := file. |
|
6997 |
||
6998 |
ok := file isReadable and:[file isDirectory not]. |
|
6999 |
ok ifFalse:[ |
|
7000 |
file isReadable ifFalse:[ |
|
7001 |
why := '%1 is unreadable.\\Please try again.' |
|
7002 |
] ifTrue:[ |
|
7003 |
why := '%1 is a directory.\\Please try again.' |
|
7004 |
]. |
|
7005 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
7006 |
]. |
|
2909 | 7007 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7008 |
|
5063 | 7009 |
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
|
7010 |
self |
3786 | 7011 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 7012 |
info:'Paste File' |
3495 | 7013 |
|
7014 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
7015 |
! |
|
7016 |
||
3811 | 7017 |
insertURL |
7018 |
"insert contents of a URL |
|
7019 |
- ask user for URL using a dialog." |
|
7020 |
||
7021 |
self insertURLAsStringLiteral:false |
|
7022 |
! |
|
7023 |
||
7024 |
insertURLAsStringLiteral:asStringLiteral |
|
7025 |
"insert contents of a file; either as-is or as a string literal. |
|
7026 |
- ask user for filename using a fileSelectionBox." |
|
7027 |
||
7028 |
|sel url text response initial| |
|
7029 |
||
7030 |
(sel := self selectionAsString) notEmptyOrNil |
|
7031 |
ifTrue:[ |
|
7032 |
initial := sel. |
|
7033 |
]. |
|
7034 |
||
7035 |
url := Dialog |
|
7036 |
request:(resources string:'Insert Contents of URL:') |
|
7037 |
initialAnswer:initial |
|
7038 |
okLabel:(resources string:'Insert') |
|
7039 |
title:(resources string:'URL'). |
|
7040 |
url isNil ifTrue:[ |
|
7041 |
"cancel" |
|
7042 |
^ self. |
|
7043 |
]. |
|
7044 |
response := HTTPInterface get:url. |
|
7045 |
response isErrorResponse ifTrue:[ |
|
7046 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
7047 |
^ self. |
|
7048 |
]. |
|
7049 |
text := response data asString. |
|
7050 |
||
7051 |
self |
|
7052 |
undoableDo:[ |
|
7053 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
7054 |
] |
|
7055 |
info:'Insert Contents of URL' |
|
7056 |
! |
|
7057 |
||
3495 | 7058 |
insertUUID |
7059 |
"insert a new UUID's string" |
|
7060 |
||
7061 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7062 |
self |
3786 | 7063 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 7064 |
info:'Paste New UUID' |
3495 | 7065 |
|
7066 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 7067 |
! |
7068 |
||
4940 | 7069 |
insertUnicode |
7070 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
7071 |
||
7072 |
|unicodePoint unicodeChar unicodeString| |
|
7073 |
||
5904 | 7074 |
unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):'). |
4940 | 7075 |
unicodeString size < 2 ifTrue:[ |
5904 | 7076 |
^ self. |
4940 | 7077 |
]. |
7078 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
5904 | 7079 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
4940 | 7080 |
] ifFalse:[ |
5904 | 7081 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
5787 | 7082 |
]. |
4940 | 7083 |
|
7084 |
unicodeChar := Character value:unicodePoint. |
|
7085 |
self keyPress:unicodeChar x:0 y:0. |
|
7086 |
self keyRelease:unicodeChar x:0 y:0. |
|
7087 |
! |
|
7088 |
||
5331 | 7089 |
inspectSelectedString |
7090 |
"inspect the selected text" |
|
7091 |
||
7092 |
self selectionAsString inspect. |
|
7093 |
! |
|
7094 |
||
4742 | 7095 |
internalSpellingSuggestion |
7096 |
"insert the internal-spelling suggestion for the selected text. |
|
7097 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7098 |
||
7099 |
|text suggestions best| |
|
7100 |
||
7101 |
self withWaitCursorDo:[ |
|
7102 |
text := self selection asString string withoutSeparators. |
|
7103 |
text size == 0 ifTrue:[^ self]. |
|
7104 |
||
7105 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7106 |
suggestions size == 0 ifTrue:[ |
|
7107 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7108 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7109 |
^ self. |
|
7110 |
]. |
|
7111 |
Transcript showCR:suggestions. |
|
7112 |
best := suggestions first. |
|
7113 |
]. |
|
7114 |
self |
|
7115 |
undoablePaste:best |
|
7116 |
info:'Spelling Suggestion'. |
|
7117 |
! |
|
7118 |
||
4884 | 7119 |
openFileBrowserOnFileNamed:fileNameString |
7120 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 7121 |
|
4630 | 7122 |
|fn| |
2762 | 7123 |
|
4884 | 7124 |
fn := fileNameString asFilename. |
2762 | 7125 |
fn exists ifFalse:[ |
4884 | 7126 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 7127 |
fn exists ifFalse:[ |
5082 | 7128 |
^ self warn:(resources |
7129 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
7130 |
with:fn baseName allBold |
|
7131 |
with:fn directory baseName allBold). |
|
4042 | 7132 |
]. |
2762 | 7133 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7134 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7135 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7136 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 7137 |
! |
7138 |
||
4884 | 7139 |
openFileBrowserOnIt |
7140 |
"open a fileBrowser on the selected fileName" |
|
7141 |
||
7142 |
|fileNameString| |
|
7143 |
||
7144 |
fileNameString := self selectionAsString. |
|
7145 |
self openFileBrowserOnFileNamed:fileNameString |
|
7146 |
||
7147 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
7148 |
! |
|
7149 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7150 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7151 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7152 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7153 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7154 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7155 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7156 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7157 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7158 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7159 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7160 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7161 |
paste |
1289 | 7162 |
"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
|
7163 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7164 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7165 |
self checkModificationsAllowed ifTrue:[ |
4823 | 7166 |
self withSelfAndTextForPasteDo:[:me :text | |
7167 |
me unselect. |
|
7168 |
me undoablePaste:text |
|
7169 |
] |
|
2952 | 7170 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7171 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7172 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7173 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7174 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7175 |
|
3825 | 7176 |
self paste:someText withCR:false |
7177 |
! |
|
7178 |
||
7179 |
paste:someText withCR:withCR |
|
7180 |
"paste someText at cursor" |
|
7181 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7182 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7183 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7184 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7185 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7186 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7187 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7188 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7189 |
CharacterEncoderError handle:[:ex | |
3825 | 7190 |
|code msg| |
7191 |
||
7192 |
code := ex parameter. |
|
7193 |
codingErrorReported ifFalse:[ |
|
4940 | 7194 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 7195 |
code notNil ifTrue:[ |
7196 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7197 |
]. |
|
7198 |
Dialog warn:(resources stringWithCRs:msg). |
|
7199 |
codingErrorReported := true. |
|
7200 |
]. |
|
7201 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7202 |
] do:[ |
3825 | 7203 |
s isString ifTrue:[ |
4940 | 7204 |
s encoding ~~ gc characterEncoding ifTrue:[ |
7205 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 7206 |
]. |
7207 |
||
7208 |
s := s asStringCollection. |
|
7209 |
(someText endsWith:Character cr) ifTrue:[ |
|
7210 |
"/ s := s copyWith:nil. |
|
7211 |
s := s copyWith:'' "/ an empty line at the end |
|
7212 |
||
7213 |
] |
|
7214 |
] ifFalse:[ |
|
7215 |
s isStringCollection ifTrue:[ |
|
4940 | 7216 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 7217 |
] ifFalse:[ |
7218 |
(self |
|
7219 |
confirm:(resources |
|
7220 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7221 |
with:s class name)) ifFalse:[^ self]. |
|
7222 |
s := StringCollection with:s storeString . |
|
7223 |
"/ ^ self |
|
7224 |
]. |
|
7225 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7226 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7227 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7228 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7229 |
(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
|
7230 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7231 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7232 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7233 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7234 |
startCol := c1 := cursorCol. |
3180 | 7235 |
|
5194 | 7236 |
"do not autoindent here. |
7237 |
It does make things very ugly, in the inspector |
|
7238 |
(try inspecting a multiline string)..." |
|
7239 |
self withAutoIndent:false do:[ |
|
7240 |
"do not expand tabs into spaces here - |
|
7241 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7242 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7243 |
||
7244 |
self insertLines:s withCR:withCR. |
|
7245 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7246 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7247 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7248 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7249 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7250 |
"/ For Claus to support paste-cursordown-paste :-) |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7251 |
"/ Move cursor the the beggining of the selection so subsequent |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7252 |
"/ cursor move will start there. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7253 |
self setCursorLine: l1. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7254 |
self setCursorCol: c1. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7255 |
|
4328 | 7256 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7257 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7258 |
"Modified: / 30-08-2013 / 00:09:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7259 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7260 |
|
3731 | 7261 |
pasteAsStringLiteral |
7262 |
"insert clipboard string as a string literal. |
|
7263 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7264 |
to make it a legal string literal" |
|
7265 |
||
7266 |
typeOfSelection := nil. |
|
7267 |
self |
|
5107 | 7268 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 7269 |
info:'Paste as String Literal' |
3731 | 7270 |
! |
7271 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7272 |
pasteOrReplace |
1289 | 7273 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7274 |
otherwise paste at cursor position. |
7275 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7276 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7277 |
|
2724 | 7278 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7279 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7280 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7281 |
pasteOrReplace:someText |
1289 | 7282 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7283 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7284 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7285 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7286 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7287 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7288 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7289 |
self undoableDo:[ |
4823 | 7290 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7291 |
self replace:someText |
|
7292 |
] ifFalse:[ |
|
7293 |
self paste:someText. |
|
7294 |
] |
|
3542 | 7295 |
] info:'Paste/Replace'. |
1289 | 7296 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7297 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7298 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7299 |
|
5387 | 7300 |
pasteOrReplaceByKeyPress |
7301 |
"paste a previous item from the copybuffer history. |
|
7302 |
(i.e. repaste some previously deleted or copied text)" |
|
7303 |
||
7304 |
|text| |
|
7305 |
||
7306 |
self checkModificationsAllowed ifFalse:[ |
|
7307 |
self flashReadOnly. |
|
7308 |
^ self |
|
7309 |
]. |
|
7310 |
text := self getClipboardText:#clipboard. |
|
7311 |
text notNil ifTrue:[ |
|
7312 |
self pasteOrReplace:text |
|
7313 |
] |
|
7314 |
! |
|
7315 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7316 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7317 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7318 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7319 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7320 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7321 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7322 |
self checkModificationsAllowed ifFalse:[ |
4988 | 7323 |
self flashReadOnly. |
4823 | 7324 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7325 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7326 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7327 |
text notNil ifTrue:[ |
4823 | 7328 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7329 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7330 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7331 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7332 |
replace |
1289 | 7333 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7334 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7335 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7336 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7337 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7338 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 7339 |
me undoableDo:[ me replace:text ] |
7340 |
info:'Replace' |
|
2952 | 7341 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7342 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7343 |
|
121 | 7344 |
replace:someText |
1289 | 7345 |
"replace the selection by someText" |
121 | 7346 |
|
3160 | 7347 |
|selected selectedString |
7348 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7349 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7350 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7351 |
|
3130 | 7352 |
self undoableDo:[ |
4010 | 7353 |
selected := self selection. |
7354 |
selected isNil ifTrue:[ |
|
7355 |
^ self paste:someText |
|
7356 |
]. |
|
7357 |
||
7358 |
self deleteSelection. |
|
7359 |
||
7360 |
"take care, if we replace a selection without space by a word selected |
|
7361 |
with one - in this case we usually do not want the space. |
|
7362 |
But, if we replace a word-selected selection by something without a |
|
7363 |
space, we DO want the space added." |
|
7364 |
||
7365 |
selected size == 1 ifTrue:[ |
|
7366 |
selectedString := selected at:1. |
|
7367 |
]. |
|
7368 |
||
7369 |
someText size == 1 ifTrue:[ |
|
7370 |
|cutOffSpace addSpace replacement replacementString| |
|
7371 |
||
7372 |
cutOffSpace := false. |
|
7373 |
addSpace := false. |
|
7374 |
replacement := someText copyFrom:1. |
|
7375 |
||
7376 |
selectedString notNil ifTrue:[ |
|
7377 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7378 |
"selection has no space" |
|
7379 |
||
7380 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7381 |
cutOffSpace := true |
|
7382 |
] |
|
7383 |
] ifTrue:[ |
|
7384 |
addSpace := true |
|
7385 |
] |
|
7386 |
]. |
|
7387 |
replacementString := replacement at:1. |
|
7388 |
cutOffSpace ifTrue:[ |
|
7389 |
(replacementString startsWith:' ') ifTrue:[ |
|
7390 |
replacementString := replacementString withoutSpaces |
|
7391 |
]. |
|
7392 |
] ifFalse:[ |
|
7393 |
selectStyle == #wordLeft ifTrue:[ |
|
7394 |
"want a space at left" |
|
7395 |
(replacementString startsWith:' ') ifFalse:[ |
|
7396 |
replacementString := replacementString withoutSpaces. |
|
7397 |
replacementString := ' ' , replacementString |
|
7398 |
] |
|
7399 |
]. |
|
7400 |
selectStyle == #wordRight ifTrue:[ |
|
7401 |
"want a space at right" |
|
7402 |
||
7403 |
(replacementString endsWith:' ') ifFalse:[ |
|
7404 |
replacementString := replacementString withoutSpaces. |
|
7405 |
replacementString := replacementString , ' ' |
|
7406 |
] |
|
7407 |
]. |
|
7408 |
]. |
|
7409 |
replacement at:1 put: replacementString. |
|
7410 |
self paste:replacement. |
|
7411 |
] ifFalse:[ |
|
7412 |
self paste:someText |
|
7413 |
]. |
|
4053 | 7414 |
self setLastStringToReplace: selectedString. |
7415 |
||
4048 | 7416 |
lastReplacementInfo lastReplacement: someText. |
4010 | 7417 |
|
7418 |
selStartLine := selectionStartLine. |
|
7419 |
selStartCol := self selectionStartCol. |
|
7420 |
selEndLine := selectionEndLine. |
|
7421 |
selEndCol := self selectionEndCol. |
|
3130 | 7422 |
] |
3542 | 7423 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7424 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7425 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7426 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7427 |
! |
7428 |
||
3430 | 7429 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7430 |
"search for a string - show a box to enter searchpattern |
3430 | 7431 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7432 |
- 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
|
7433 |
|
3430 | 7434 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7435 |
||
7436 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7437 |
lastSearchDirection := #forward. |
|
7438 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7439 |
caseHolder := ValueHolder with:ign. |
7440 |
patternHolder := ValueHolder with:''. |
|
7441 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7442 |
lastSearchPattern notNil ifTrue:[ |
4823 | 7443 |
initialString := lastSearchPattern |
3430 | 7444 |
]. |
7445 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 7446 |
initialString := self selectionAsString |
3430 | 7447 |
]. |
7448 |
initialString isNil ifTrue:[ |
|
4823 | 7449 |
LastSearchPatterns size > 0 ifTrue:[ |
7450 |
initialString := LastSearchPatterns first |
|
7451 |
] |
|
3430 | 7452 |
]. |
7453 |
initialString notNil ifTrue:[ |
|
4823 | 7454 |
patternHolder value:initialString. |
7455 |
replacePatternHolder value:initialString. |
|
3430 | 7456 |
]. |
7457 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7458 |
search := [:fwd | |
4823 | 7459 |
self |
7460 |
search:patternHolder value |
|
7461 |
ignoreCase:caseHolder value |
|
7462 |
forward:fwd. |
|
7463 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7464 |
replace := [:all | |
4823 | 7465 |
self |
7466 |
replace:patternHolder value |
|
7467 |
by:replacePatternHolder value |
|
7468 |
all:all |
|
7469 |
ignoreCase:caseHolder value |
|
7470 |
]. |
|
3430 | 7471 |
bindings := IdentityDictionary new. |
7472 |
bindings at:#searchPattern put:patternHolder. |
|
7473 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7474 |
modal ifTrue:[ |
|
4823 | 7475 |
bindings at:#nextAction |
7476 |
put:[ |
|
7477 |
flag := true. |
|
7478 |
action := search. |
|
7479 |
searchBox doAccept. |
|
7480 |
]. |
|
7481 |
bindings at:#prevAction |
|
7482 |
put:[ |
|
7483 |
flag := false. |
|
7484 |
action := search. |
|
7485 |
searchBox doAccept. |
|
7486 |
]. |
|
7487 |
bindings at:#replaceAction |
|
7488 |
put:[ |
|
7489 |
flag := false. |
|
7490 |
action := replace. |
|
7491 |
searchBox doAccept. |
|
7492 |
]. |
|
7493 |
bindings at:#replaceAllAction |
|
7494 |
put:[ |
|
7495 |
flag := true. |
|
7496 |
action := replace. |
|
7497 |
searchBox doAccept. |
|
7498 |
]. |
|
3430 | 7499 |
] ifFalse:[ |
4823 | 7500 |
bindings at:#nextAction put:[ search value:true. ]. |
7501 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7502 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7503 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7504 |
]. |
7505 |
bindings at:#ignoreCase put:caseHolder. |
|
7506 |
bindings at:#patternList put:LastSearchPatterns. |
|
7507 |
modal ifTrue:[ |
|
4823 | 7508 |
searchBox := SimpleDialog new. |
3430 | 7509 |
] ifFalse:[ |
4823 | 7510 |
searchBox := ApplicationModel new. |
7511 |
searchBox createBuilder. |
|
3430 | 7512 |
]. |
7513 |
searchBox resources:(self resources). |
|
7514 |
bldr := searchBox builder. |
|
7515 |
bldr addBindings:bindings. |
|
7516 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7517 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7518 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7519 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7520 |
modal ifTrue:[ |
|
4823 | 7521 |
searchBox openDialog. |
7522 |
searchBox accepted ifTrue:[ |
|
7523 |
action value:flag |
|
7524 |
]. |
|
3430 | 7525 |
] ifFalse:[ |
4823 | 7526 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7527 |
(bldr componentAt:#cancelButton) |
|
7528 |
label:(resources string:'Close'); |
|
7529 |
action:[ searchBox closeRequest ]. |
|
7530 |
||
7531 |
"/ searchBox masterApplication:self application. |
|
7532 |
||
7533 |
self topView beMaster. |
|
7534 |
(searchBox window) |
|
7535 |
beSlave; |
|
7536 |
openInGroup:(self windowGroup). |
|
7537 |
||
7538 |
"/ searchBox window open. |
|
7539 |
||
5283 | 7540 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
3430 | 7541 |
] |
7542 |
||
7543 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7544 |
! |
|
7545 |
||
121 | 7546 |
showDeleted |
7547 |
"open a readonly editor on all deleted text" |
|
7548 |
||
7549 |
|v| |
|
7550 |
||
7551 |
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
|
7552 |
v readOnly:true. |
121 | 7553 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7554 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7555 |
|
3221 | 7556 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7557 |
"sort/reorder the selected lines. |
7558 |
how: |
|
7559 |
#lines |
|
7560 |
#linesByFirstWord |
|
7561 |
#linesByNthWord |
|
7562 |
#linesByNthNumber |
|
7563 |
#linesByNthHexNumber |
|
7564 |
#words |
|
7565 |
#linesByLength |
|
7566 |
#reverse |
|
7567 |
" |
|
7568 |
||
7569 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7570 |
|
7571 |
lineWise := true. |
|
7572 |
||
4763 | 7573 |
how == #reverse ifTrue:[ |
7574 |
operation := [:lines | lines reverse]. |
|
7575 |
] ifFalse:[ |
|
7576 |
operation := [:linesOrWords | |
|
7577 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7578 |
]. |
|
7579 |
||
7580 |
how == #linesByLength ifTrue:[ |
|
7581 |
fetcher := [:l | l size]. |
|
7582 |
] ifFalse:[ |
|
7583 |
how == #lines ifTrue:[ |
|
7584 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7585 |
] ifFalse:[ |
|
7586 |
how == #linesByFirstWord ifTrue:[ |
|
7587 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7588 |
] ifFalse:[ |
|
7589 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7590 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7591 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7592 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7593 |
LastColumnNumberForSort := n. |
|
7594 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7595 |
how == #linesByNthNumber ifTrue:[ |
|
7596 |
innerExtractor := extractor. |
|
7597 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7598 |
] ifFalse:[ |
|
7599 |
how == #linesByNthHexNumber ifTrue:[ |
|
7600 |
innerExtractor := extractor. |
|
7601 |
extractor := [:l | |
|
7602 |
|s| |
|
7603 |
s := innerExtractor value:l. |
|
7604 |
(s startsWith:'16r') ifTrue:[ |
|
7605 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7606 |
] ifFalse:[ |
|
7607 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7608 |
] |
|
7609 |
] |
|
4753 | 7610 |
] |
4763 | 7611 |
]. |
7612 |
] ifFalse:[ |
|
7613 |
how == #words ifTrue:[ |
|
7614 |
lineWise := false. |
|
7615 |
extractor := [:w | w]. |
|
7616 |
] ifFalse:[ |
|
7617 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7618 |
] |
4373 | 7619 |
] |
7620 |
] |
|
4763 | 7621 |
]. |
7622 |
ignoreCase ifTrue:[ |
|
7623 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7624 |
] ifFalse:[ |
|
7625 |
fetcher := extractor. |
|
7626 |
]. |
|
7627 |
]. |
|
3221 | 7628 |
]. |
7629 |
||
7630 |
lineWise ifTrue:[ |
|
4763 | 7631 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7632 |
start == end ifTrue:[^ self ]. |
7633 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7634 |
lines := operation value:lines. |
4373 | 7635 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7636 |
] ifFalse:[ |
7637 |
"process the whole selection as a string" |
|
7638 |
s := self selectionAsString. |
|
7639 |
words := s asCollectionOfWords. |
|
7640 |
words := operation value:words. |
|
7641 |
s := words asStringCollection asStringWith:Character space. |
|
7642 |
self replace:s. |
|
7643 |
]. |
|
3221 | 7644 |
self textChanged. |
4373 | 7645 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7646 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7647 |
! |
7648 |
||
7649 |
sortSelection:how ignoreCase:ignoreCase |
|
7650 |
"sort the selected lines" |
|
7651 |
||
7652 |
|start end| |
|
7653 |
||
7654 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7655 |
||
7656 |
start := selectionStartLine. |
|
7657 |
end := selectionEndLine. |
|
7658 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7659 |
end := end - 1 |
3221 | 7660 |
]. |
7661 |
||
7662 |
self |
|
4373 | 7663 |
undoableDo:[ |
7664 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7665 |
] |
|
3786 | 7666 |
info:'Sort' |
4373 | 7667 |
|
7668 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7669 |
! |
7670 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7671 |
specialCharacters |
2915 | 7672 |
CharacterSetView |
4823 | 7673 |
openAsInputFor:self |
7674 |
label:'Special Character Input' |
|
7675 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7676 |
! |
7677 |
||
5370 | 7678 |
splitLinesAtCharacterOrString |
7679 |
"ask user for the character and split after it" |
|
7680 |
||
7681 |
|sel in out separator record| |
|
7682 |
||
7683 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7684 |
||
7685 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7686 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7687 |
||
7688 |
sel := self selectionAsString. |
|
7689 |
in := sel readStream. |
|
5887 | 7690 |
out := CharacterWriteStream on:''. |
5370 | 7691 |
[in atEnd] whileFalse:[ |
5887 | 7692 |
record := in throughAll:separator. |
7693 |
out nextPutLine:record. |
|
5370 | 7694 |
]. |
7695 |
self |
|
7696 |
undoableDo:[ |
|
5887 | 7697 |
self replaceSelectionBy:(out contents). |
7698 |
] |
|
7699 |
info:'Split Selection' |
|
5370 | 7700 |
! |
7701 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7702 |
undoablePaste:someText |
3495 | 7703 |
self undoablePaste:someText info:nil. |
7704 |
||
7705 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7706 |
! |
|
7707 |
||
7708 |
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
|
7709 |
self |
4823 | 7710 |
undoableDo:[ |
7711 |
self paste:someText. |
|
7712 |
] |
|
7713 |
info:infoOrNil |
|
3495 | 7714 |
|
7715 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7716 |
! |
|
7717 |
||
7718 |
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
|
7719 |
self |
4823 | 7720 |
undoableDo:[ |
7721 |
self pasteOrReplace:someText. |
|
7722 |
] |
|
7723 |
info:infoOrNil |
|
3495 | 7724 |
|
7725 |
"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
|
7726 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7727 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7728 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7729 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7730 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7731 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7732 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7733 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7734 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7735 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7736 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7737 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7738 |
|
2724 | 7739 |
withSelfAndTextForPasteDo:aBlock |
7740 |
"common code for paste/replace of the copybuffer" |
|
7741 |
||
7742 |
|sel| |
|
7743 |
||
7744 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7745 |
self flashReadOnly. |
4823 | 7746 |
^ self |
2724 | 7747 |
]. |
7748 |
||
7749 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7750 |
sel notNil ifTrue:[ |
|
4823 | 7751 |
aBlock value:self value:sel. |
2724 | 7752 |
] |
105 | 7753 |
! ! |
7754 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7755 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7756 |
|
3880 | 7757 |
beep |
5244 | 7758 |
"output an audible beep or bell on my screen device" |
7759 |
||
3880 | 7760 |
UserPreferences current beepInEditor ifTrue:[ |
7761 |
super beep |
|
7762 |
] |
|
7763 |
! |
|
7764 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7765 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7766 |
"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
|
7767 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7768 |
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
|
7769 |
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
|
7770 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7771 |
self isReadOnly ifTrue: [ |
4823 | 7772 |
exceptionBlock isNil ifTrue:[ |
7773 |
^ false |
|
7774 |
]. |
|
7775 |
||
7776 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7777 |
^ false |
|
7778 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7779 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7780 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7781 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7782 |
"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
|
7783 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7784 |
|
2596 | 7785 |
currentSelectionBgColor |
7786 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7787 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7788 |
]. |
5216 | 7789 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 7790 |
^ super currentSelectionBgColor |
7791 |
||
7792 |
" |
|
7793 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7794 |
" |
|
7795 |
! |
|
7796 |
||
7797 |
currentSelectionFgColor |
|
7798 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7799 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7800 |
]. |
7801 |
^ super currentSelectionFgColor |
|
7802 |
! |
|
7803 |
||
3996 | 7804 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7805 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7806 |
|
7807 |
super resetVariablesBeforeNewSearch. |
|
7808 |
||
7809 |
"/ new search invalidates remembered string |
|
4048 | 7810 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7811 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7812 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7813 |
! |
7814 |
||
4053 | 7815 |
setLastStringToReplace: aString |
7816 |
||
7817 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7818 |
||
7819 |
|lastReplaceIgnoredCase| |
|
7820 |
||
4064 | 7821 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7822 |
self clearSearchAction. |
|
7823 |
||
4053 | 7824 |
lastReplacementInfo lastStringToReplace: aString. |
7825 |
lastStringFromReplaceForNextSearch := aString. |
|
7826 |
||
7827 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7828 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7829 |
ifTrue: [lastSearchIgnoredCase] |
|
7830 |
ifFalse: [nil]. |
|
4053 | 7831 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7832 |
! |
|
7833 |
||
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7834 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7835 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7836 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7837 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7838 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7839 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7840 |
textChanged |
522 | 7841 |
"my text was modified (internally). |
7842 |
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
|
7843 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7844 |
is used to notify scrollers, other views etc.). |
7845 |
||
7846 |
As some authors of this code have been very sloppy in tha past |
|
7847 |
(not sending contentsChanged, but textChanged), |
|
7848 |
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
|
7849 |
|
641 | 7850 |
self contentsChanged. |
1015 | 7851 |
self modified:true. |
5774 | 7852 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7853 |
contentsWasSaved := false |
641 | 7854 |
|
1015 | 7855 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7856 |
! |
7857 |
||
2617 | 7858 |
textChangedButNoSizeChange |
2207 | 7859 |
"my text was modified (internally). |
7860 |
Sent whenever text has been edited (not to confuse with |
|
7861 |
contentsChanged, which is triggered when the size has changed, and |
|
7862 |
is used to notify scrollers, other views etc.)" |
|
7863 |
||
7864 |
self modified:true. |
|
7865 |
contentsWasSaved := false |
|
7866 |
||
7867 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7868 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7869 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7870 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7871 |
|
5216 | 7872 |
canAccept |
7873 |
"true if text can be accepts. |
|
7874 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7875 |
||
7876 |
^ acceptEnabled ~~ false |
|
7877 |
! |
|
7878 |
||
7879 |
canCut |
|
7880 |
"true if there is a selection possibly to be cut. |
|
7881 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7882 |
||
7883 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7884 |
^ self hasSelection |
|
7885 |
! |
|
7886 |
||
7887 |
canDoAgain |
|
7888 |
"true if there is a possible repeat last edit operation. |
|
7889 |
Used to disable the menu if there is nothing" |
|
7890 |
||
7891 |
|lastStringToReplace| |
|
7892 |
||
7893 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7894 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
7895 |
^ lastStringToReplace notNil |
|
7896 |
! |
|
7897 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7898 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7899 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7900 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7901 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7902 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7903 |
"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
|
7904 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7905 |
|
4064 | 7906 |
hasSearchActionSelection |
7907 |
||
7908 |
^ typeOfSelection == #searchAction |
|
7909 |
! |
|
7910 |
||
1878 | 7911 |
isKeyboardConsumer |
7912 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 7913 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 7914 |
|
3476 | 7915 |
^ self isReadOnly not |
1878 | 7916 |
! |
7917 |
||
997 | 7918 |
specClass |
1390 | 7919 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7920 |
||
997 | 7921 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7922 |
^ super specClass |
7923 |
||
1390 | 7924 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7925 |
! |
7926 |
||
324 | 7927 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7928 |
"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
|
7929 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7930 |
"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
|
7931 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7932 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7933 |
|
7934 |
"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
|
7935 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7936 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7937 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7938 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7939 |
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
|
7940 |
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
|
7941 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7942 |
|
697 | 7943 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7944 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7945 |
w := super widthOfContents. |
5643 | 7946 |
(dev := device ) isNil ifTrue:[ |
4889 | 7947 |
"/ really don't know ... |
4823 | 7948 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7949 |
]. |
4889 | 7950 |
^ w + (gc font widthOn:dev) |
697 | 7951 |
|
7952 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7953 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7954 |
|
1588 | 7955 |
!EditTextView methodsFor:'realization'! |
7956 |
||
7957 |
realize |
|
7958 |
"make the view visible - scroll to make the cursor visible." |
|
7959 |
||
7960 |
super realize. |
|
7961 |
||
7962 |
self makeCursorVisible. |
|
5643 | 7963 |
cursorFgColor := cursorFgColor onDevice:device. |
7964 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 7965 |
|
7966 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7967 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7968 |
! ! |
|
7969 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7970 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7971 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7972 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7973 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7974 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7975 |
cursorShown ifTrue:[ |
4823 | 7976 |
cursorVisibleLine notNil ifTrue:[ |
7977 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7978 |
self drawCursorCharacter |
|
7979 |
] |
|
7980 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7981 |
] |
105 | 7982 |
! |
7983 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7984 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7985 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7986 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7987 |
cursorShown ifTrue:[ |
4823 | 7988 |
(visLine == cursorVisibleLine) ifTrue:[ |
7989 |
self drawCursorCharacter |
|
7990 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7991 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7992 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7993 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7994 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7995 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7996 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7997 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7998 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7999 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8000 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8001 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8002 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8003 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8004 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8005 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8006 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8007 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8008 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8009 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8010 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8011 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8012 |
cursorShown ifTrue:[ |
4823 | 8013 |
(visLine == cursorVisibleLine) ifTrue:[ |
8014 |
(colNr == cursorCol) ifTrue:[ |
|
8015 |
self drawCursorCharacter. |
|
8016 |
^ self |
|
8017 |
] |
|
8018 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8019 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8020 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8021 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8022 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8023 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8024 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8025 |
"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
|
8026 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8027 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 8028 |
cursorShown ifTrue:[ |
8029 |
self redrawCursorIfInVisibleLine:visLine |
|
8030 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8031 |
! |
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 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8034 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8035 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8036 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8037 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8038 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8039 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8040 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8041 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8042 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8043 |
"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
|
8044 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8045 |
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
|
8046 |
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
|
8047 |
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
|
8048 |
|
4889 | 8049 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8050 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8051 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8052 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8053 |
"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
|
8054 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8055 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8056 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8057 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8058 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8059 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8060 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8061 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8062 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8063 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8064 |
"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
|
8065 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8066 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8067 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8068 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8069 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8070 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8071 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8072 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8073 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8074 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8075 |
"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
|
8076 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8077 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8078 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8079 |
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
|
8080 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
8081 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8082 |
prevCursorState ifTrue:[ |
4823 | 8083 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8084 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8085 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8086 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8087 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8088 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8089 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8090 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8091 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8092 |
prevCursorState := cursorShown. |
1601 | 8093 |
"/ cursorShown := false. |
1591 | 8094 |
cursorShown ifTrue:[ |
4823 | 8095 |
self hideCursor |
1591 | 8096 |
] |
8097 |
||
1601 | 8098 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8099 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8100 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8101 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8102 |
"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
|
8103 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8104 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8105 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8106 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8107 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8108 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8109 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8110 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8111 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8112 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8113 |
"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
|
8114 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8115 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8116 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8117 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8118 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8119 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8120 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8121 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8122 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8123 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8124 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8125 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8126 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8127 |
|
2822 | 8128 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8129 |
! |
8130 |
||
8131 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8132 |
"do a backward search" |
|
8133 |
||
8134 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8135 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8136 |
! |
8137 |
||
8138 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8139 |
"do a backward search" |
|
8140 |
||
8141 |
cursorLine isNil ifTrue:[^ self]. |
|
8142 |
||
3160 | 8143 |
self |
4119 | 8144 |
searchBackwardFor:pattern |
8145 |
ignoreCase:ign |
|
8146 |
startingAtLine:startLine col:startCol |
|
5717 | 8147 |
ifFound:[:line :col :endColOrNil | |
4119 | 8148 |
self cursorMovementAllowed ifTrue:[ |
8149 |
self cursorLine:line col:col. |
|
8150 |
]. |
|
5717 | 8151 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
1339 | 8152 |
"/ self makeLineVisible:cursorLine |
4119 | 8153 |
typeOfSelection := #search] |
8154 |
ifAbsent:aBlock |
|
1339 | 8155 |
|
8156 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8157 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8158 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8159 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8160 |
"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
|
8161 |
|
2554 | 8162 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8163 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8164 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8165 |
searchForMatchingParenthesis |
3160 | 8166 |
"search for a matching parenthesis starting at cursor position. |
8167 |
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
|
8168 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8169 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8170 |
|
2822 | 8171 |
self cursorMovementAllowed ifFalse:[^ self]. |
8172 |
||
3160 | 8173 |
self |
4823 | 8174 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8175 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8176 |
ifNotFound:[self showNotFound] |
|
8177 |
onError:[self beep] |
|
1339 | 8178 |
|
8179 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8180 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8181 |
|
3967 | 8182 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8183 |
"do a forward search" |
8184 |
||
8185 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 8186 |
self |
8187 |
searchForwardFor:pattern |
|
8188 |
ignoreCase:ign |
|
8189 |
match: match |
|
8190 |
startingAtLine:startLine col:startCol |
|
5717 | 8191 |
ifFound:[:line :col :endColOrNil| |
3967 | 8192 |
self cursorMovementAllowed ifTrue:[ |
8193 |
self cursorLine:line col:col. |
|
8194 |
]. |
|
5717 | 8195 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
1339 | 8196 |
"/ self makeLineVisible:cursorLine |
3967 | 8197 |
typeOfSelection := #search |
8198 |
] |
|
8199 |
ifAbsent:aBlock |
|
1339 | 8200 |
|
8201 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8202 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8203 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8204 |
|
3967 | 8205 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8206 |
"do a forward search" |
|
8207 |
||
8208 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8209 |
! |
|
8210 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8211 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8212 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8213 |
|
2822 | 8214 |
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
|
8215 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8216 |
|
3982 | 8217 |
searchPatternForSearchBar |
8218 |
||
8219 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8220 |
||
8221 |
|searchPattern| |
|
8222 |
||
4138 | 8223 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 8224 |
searchPattern isNil |
8225 |
ifTrue: [searchPattern := lastSearchPattern] |
|
8226 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
8227 |
^ searchPattern |
|
8228 |
! |
|
8229 |
||
3578 | 8230 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8231 |
"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
|
8232 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8233 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8234 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8235 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8236 |
"/ |
3967 | 8237 |
"/ 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
|
8238 |
"/ original string (for search after again) |
4121 | 8239 |
"/ 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
|
8240 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8241 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8242 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8243 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8244 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8245 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8246 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8247 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8248 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8249 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8250 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8251 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8252 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8253 |
"/ 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
|
8254 |
"/ if there was a previous search, only take the selection if |
3967 | 8255 |
"/ 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
|
8256 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8257 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8258 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8259 |
sel notNil ifTrue:[ |
3967 | 8260 |
(lastSearchPattern isNil |
4484 | 8261 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
8262 |
) ifTrue:[ |
|
3967 | 8263 |
self cursorLine:selectionStartLine col:selectionStartCol. |
8264 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8265 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8266 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8267 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8268 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8269 |
"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
|
8270 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8271 |
|
5717 | 8272 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8273 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8274 |
typeOfSelection := #search. |
8275 |
! |
|
8276 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8277 |
startPositionForSearchBackward |
2822 | 8278 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8279 |
! |
|
8280 |
||
8281 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8282 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8283 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8284 |
selectionStartLine notNil ifTrue:[ |
4823 | 8285 |
startLine := selectionStartLine. |
8286 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8287 |
] ifFalse:[ |
4823 | 8288 |
cursorLine isNil ifTrue:[ |
8289 |
startLine := list size. |
|
8290 |
startCol := self listAt:startLine size. |
|
8291 |
] ifFalse:[ |
|
8292 |
startLine := cursorLine min:list size. |
|
8293 |
startCol := cursorCol |
|
8294 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8295 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8296 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8297 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8298 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8299 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8300 |
startPositionForSearchForward |
2822 | 8301 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8302 |
! |
|
8303 |
||
8304 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8305 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8306 |
|
3160 | 8307 |
"/ 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
|
8308 |
"/ 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
|
8309 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8310 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8311 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8312 |
] ifFalse:[ |
4064 | 8313 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8314 |
startCol := 0 |
|
8315 |
]. |
|
8316 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8317 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8318 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8319 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8320 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8321 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8322 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8323 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8324 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8325 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8326 |
addToSelectionAfter:aBlock |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8327 |
"Extends the selection accroding to cursor position |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8328 |
after evaluation of `aBlock`. Used to implement |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8329 |
Shift-Up/Down/Left/Right, Shift-Home & Shift-End." |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8330 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8331 |
"/ Following comment is in czech and thus now very useful. |
4970 | 8332 |
"/ However I (JV) kept it here as this is one of the very |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8333 |
"/ first fix/hack we made to Smalltalk/X ages ago, if not |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8334 |
"/ the very first one. Actually, this method and comment was |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8335 |
"/ written by Martin Dvorak. Yeah, being bit nostalgic... |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8336 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8337 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8338 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8339 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8340 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8341 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8342 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8343 |
| startLine startCol endLine endCol curLine curCol cursorAtTheBeginning cursorAtTheEnd cursorWasShown flip extModeStandard | |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8344 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8345 |
curLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8346 |
curCol := cursorCol. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8347 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8348 |
self hasSelection ifTrue: [ |
4970 | 8349 |
startLine := selectionStartLine. |
8350 |
startCol := selectionStartCol. |
|
8351 |
endLine := selectionEndLine. |
|
8352 |
endCol := selectionEndCol. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8353 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8354 |
startLine := endLine := curLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8355 |
startCol := curCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8356 |
endCol := curCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8357 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8358 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8359 |
cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8360 |
cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8361 |
self assert: cursorAtTheBeginning | cursorAtTheEnd. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8362 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8363 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8364 |
cursorWasShown := self hideCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8365 |
aBlock value. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8366 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8367 |
cursorAtTheBeginning ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8368 |
(cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8369 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8370 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8371 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8372 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8373 |
flip := cursorLine == endLine and:[cursorCol > endCol]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8374 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8375 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8376 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8377 |
(cursorLine > endLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8378 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8379 |
startLine := endLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8380 |
startCol := endCol + 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8381 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8382 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8383 |
endCol := cursorCol - 1 |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8384 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8385 |
startLine := cursorLine. |
4823 | 8386 |
startCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8387 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8388 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8389 |
cursorAtTheEnd ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8390 |
(cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8391 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8392 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8393 |
]. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8394 |
flip := cursorLine == startLine and:[cursorCol < startCol]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8395 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8396 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8397 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8398 |
(cursorLine < startLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8399 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8400 |
endLine := startLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8401 |
endCol := startCol - 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8402 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8403 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8404 |
startCol := cursorCol |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8405 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8406 |
endLine := cursorLine. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8407 |
endCol := cursorCol - 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8408 |
] |
4823 | 8409 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8410 |
]. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8411 |
self selectFromLine:startLine col:startCol toLine: endLine col:endCol . |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8412 |
cursorWasShown ifTrue:[self showCursor]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8413 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8414 |
"Modified: / 27-03-2014 / 10:05:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4970 | 8415 |
"Modified (comment): / 25-03-2014 / 17:18:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8416 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8417 |
|
1850 | 8418 |
autoMoveCursorToEndOfSelection |
8419 |
"return true, if the cursor should be automatically moved to the |
|
8420 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8421 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8422 |
not be affected by selecting" |
8423 |
||
8424 |
^ true |
|
8425 |
! |
|
8426 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8427 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8428 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 8429 |
typeOfSelection := newType. |
8430 |
selectionStartLine notNil ifTrue:[ |
|
8431 |
self |
|
8432 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8433 |
toLine:selectionEndLine col:selectionEndCol |
|
8434 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8435 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8436 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8437 |
|
4707 | 8438 |
findNextWordAfterSelectionAndAddToSelection |
8439 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8440 |
||
8441 |
selectionStartCol isNil ifTrue:[ |
|
8442 |
self selectWordUnderCursor. |
|
8443 |
^ self |
|
8444 |
]. |
|
8445 |
||
8446 |
selStartCol := selectionStartCol. |
|
8447 |
selEndCol := selectionEndCol. |
|
8448 |
selStartLine := selectionStartLine. |
|
8449 |
selEndLine := selectionEndLine. |
|
8450 |
||
8451 |
self cursorToNextWord. |
|
8452 |
self selectWordUnderCursor. |
|
8453 |
||
8454 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8455 |
! |
|
8456 |
||
4138 | 8457 |
searchPatternFromUserSelectionOrReplace |
8458 |
||
8459 |
|sel searchPattern| |
|
8460 |
||
8461 |
"/ |
|
8462 |
"/ if the last operation was a replace, set pattern to last |
|
8463 |
"/ original string (for search after again) |
|
8464 |
"/ |
|
8465 |
(lastStringFromReplaceForNextSearch notNil |
|
8466 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
8467 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
8468 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8469 |
] ifFalse:[ |
|
8470 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8471 |
]. |
|
8472 |
^ searchPattern |
|
8473 |
]. |
|
8474 |
||
8475 |
"/ |
|
8476 |
"/ if there is a selection: |
|
8477 |
"/ if there was no previous search, take it as search pattern. |
|
8478 |
"/ if there was a previous search, only take the selection if |
|
8479 |
"/ it did not result from a paste. |
|
8480 |
"/ (to allow search-paste to be repeated) |
|
8481 |
"/ |
|
8482 |
sel := self selection. |
|
8483 |
sel notNil ifTrue:[ |
|
8484 |
typeOfSelection ~~ #search ifTrue:[ |
|
8485 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8486 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8487 |
searchPattern := sel asStringWithoutFinalCR. |
|
8488 |
] |
|
8489 |
]. |
|
8490 |
]. |
|
8491 |
||
8492 |
^ searchPattern |
|
8493 |
! |
|
8494 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8495 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8496 |
"select the whole text. |
5593 | 8497 |
redefined to send super selectFrom... since we don't want the |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8498 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8499 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8500 |
list isNil ifTrue:[ |
4823 | 8501 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8502 |
] ifFalse:[ |
4823 | 8503 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8504 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8505 |
] |
1082 | 8506 |
|
8507 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8508 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8509 |
|
4117 | 8510 |
selectAllInitially |
8511 |
"select the whole text. This is called only once during the initialization |
|
8512 |
for editFields which are shown in a table or tree. |
|
8513 |
The selectAll is called via this method to allow for easier redefinition and |
|
8514 |
to distinguish auto-select from user-initiated selects." |
|
8515 |
||
8516 |
self selectAll |
|
8517 |
! |
|
8518 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8519 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8520 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8521 |
|
3160 | 8522 |
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
|
8523 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8524 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8525 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8526 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8527 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8528 |
cursorCol > 1 ifTrue:[ |
4823 | 8529 |
self selectFromLine:cursorLine col:1 |
8530 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8531 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8532 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8533 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8534 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8535 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8536 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8537 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8538 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8539 |
selectionStartLine isNil ifTrue:[ |
4823 | 8540 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8541 |
] ifFalse:[ |
4823 | 8542 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8543 |
toLine:cursorLine+1 col:0. |
|
8544 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8545 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8546 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8547 |
|
4257 | 8548 |
selectFromBeginOfLine |
8549 |
"select the text from the beginning of the current line to the current cursor position." |
|
8550 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8551 |
| newCursorCol ln | |
4271 | 8552 |
|
4257 | 8553 |
list isNil ifTrue:[ |
8554 |
self unselect |
|
8555 |
] ifFalse:[ |
|
8556 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8557 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8558 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 8559 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
8560 |
cursorCol := newCursorCol. |
|
4257 | 8561 |
typeOfSelection := nil |
8562 |
] |
|
8563 |
] |
|
8564 |
||
8565 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8566 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8567 |
! |
8568 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8569 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8570 |
"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
|
8571 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8572 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8573 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8574 |
list isNil ifTrue:[ |
4823 | 8575 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8576 |
] ifFalse:[ |
4823 | 8577 |
cursorCol == 0 ifTrue:[ |
8578 |
col := 0 |
|
8579 |
] ifFalse:[ |
|
8580 |
col := cursorCol - 1 |
|
8581 |
]. |
|
8582 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8583 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8584 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8585 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8586 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8587 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8588 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8589 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
5293
bb7a5aa59ddb
Merged 5251ecf0c9bb and 9d85f8e1e20c (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
8590 |
"JV: That's actually rubbish as then you loose the original positon |
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8591 |
and if user wants to extend/shring the selection further, you don't know |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8592 |
from which end to do it!!" |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8593 |
"/ (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8594 |
"/ self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8595 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8596 |
typeOfSelection := nil |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8597 |
|
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8598 |
"Modified: / 27-08-2013 / 13:28:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8599 |
"Modified (comment): / 27-08-2013 / 15:58:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8600 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8601 |
|
4257 | 8602 |
selectToEndOfLine |
8603 |
"select the text from the current cursor position to the end of the current line" |
|
8604 |
||
4271 | 8605 |
| newCursorCol line | |
8606 |
||
4257 | 8607 |
list isNil ifTrue:[ |
8608 |
self unselect |
|
8609 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
8610 |
cursorCol >= 1 ifTrue:[ |
4271 | 8611 |
line := list at: cursorLine. |
8612 |
newCursorCol := line size. |
|
8613 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8614 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8615 |
||
8616 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
8617 |
cursorCol := newCursorCol. |
|
4257 | 8618 |
typeOfSelection := nil |
8619 |
] |
|
8620 |
] |
|
8621 |
||
8622 |
"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
|
8623 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8624 |
! |
8625 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8626 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8627 |
"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
|
8628 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8629 |
list isNil ifTrue:[ |
4823 | 8630 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8631 |
] ifFalse:[ |
4823 | 8632 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8633 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8634 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8635 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8636 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8637 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8638 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8639 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8640 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8641 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8642 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8643 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8644 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8645 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8646 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8647 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8648 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8649 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8650 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8651 |
wasOn ifTrue:[self showCursor] |
105 | 8652 |
! ! |
8653 |
||
8654 |
!EditTextView methodsFor:'undo & again'! |
|
8655 |
||
2952 | 8656 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8657 |
^ undoSupport addUndo:action. |
2952 | 8658 |
! |
8659 |
||
105 | 8660 |
again |
8661 |
"repeat the last action (which was a cut or replace). |
|
8662 |
If current selection is not last string, search forward to |
|
3160 | 8663 |
next occurrence of it before repeating the last operation." |
105 | 8664 |
|
4048 | 8665 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8666 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8667 |
|
8668 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8669 |
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
|
8670 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8671 |
]. |
4048 | 8672 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8673 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8674 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8675 |
self undoableDo:[ |
4010 | 8676 |
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
|
8677 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8678 |
(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
|
8679 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8680 |
|
4053 | 8681 |
"set lastStringToReplace as the next search string |
8682 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8683 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8684 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8685 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8686 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8687 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8688 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8689 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8690 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8691 |
"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
|
8692 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8693 |
(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
|
8694 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8695 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8696 |
self deleteSelection. |
4051 | 8697 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8698 |
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
|
8699 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8700 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8701 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8702 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8703 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8704 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8705 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8706 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8707 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8708 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8709 |
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
|
8710 |
]. |
4048 | 8711 |
self |
8712 |
searchForwardFor:s |
|
8713 |
ignoreCase: lastReplaceIgnoredCase |
|
8714 |
match: lastReplaceWasMatch |
|
8715 |
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
|
8716 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8717 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8718 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8719 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8720 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8721 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8722 |
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
|
8723 |
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
|
8724 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8725 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8726 |
self deleteSelection. |
4051 | 8727 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8728 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8729 |
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
|
8730 |
] ifTrue:[ |
4051 | 8731 |
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
|
8732 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8733 |
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
|
8734 |
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
|
8735 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8736 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8737 |
selectStyle := savedSelectStyle. |
4484 | 8738 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8739 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8740 |
] |
4048 | 8741 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8742 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8743 |
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
|
8744 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8745 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8746 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8747 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8748 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8749 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8750 |
^ true. |
501 | 8751 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8752 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8753 |
! |
8754 |
||
2952 | 8755 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8756 |
^ undoSupport hasRedoAction. |
2952 | 8757 |
! |
8758 |
||
8759 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8760 |
^ undoSupport hasUndoAction. |
2952 | 8761 |
! |
8762 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8763 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8764 |
"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
|
8765 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8766 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8767 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8768 |
|
2952 | 8769 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8770 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8771 |
! |
8772 |
||
8773 |
redo |
|
3780 | 8774 |
"undo the last undo" |
8775 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8776 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8777 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8778 |
] ifTrue:[ |
3780 | 8779 |
undoSupport redo. |
2952 | 8780 |
] |
8781 |
! |
|
8782 |
||
121 | 8783 |
undo |
3780 | 8784 |
"undo the last edit operation" |
8785 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8786 |
undoSupport hasUndoAction ifFalse:[ |
5834 | 8787 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8788 |
] ifTrue:[ |
5834 | 8789 |
undoSupport undo. |
8790 |
self makeSelectionVisible. |
|
8791 |
self makeCursorVisible. |
|
121 | 8792 |
] |
2952 | 8793 |
! |
8794 |
||
8795 |
undoableDo:aBlock |
|
3495 | 8796 |
self undoableDo:aBlock info:nil. |
8797 |
||
8798 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8799 |
! |
8800 |
||
8801 |
undoableDo:aBlock info:aString |
|
5689 | 8802 |
|selectionRestore| |
8803 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8804 |
self checkModificationsAllowed ifFalse:[ |
4823 | 8805 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8806 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8807 |
] ifTrue:[ |
5689 | 8808 |
undoSupport isInTransaction ifFalse:[ |
8809 |
selectionRestore := RestoreSelectionAndCursor new |
|
8810 |
cursorLine:cursorLine cursorCol:cursorCol |
|
8811 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
8812 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
8813 |
info:nil. |
|
8814 |
]. |
|
8815 |
undoSupport |
|
8816 |
undoableDo:[ |
|
8817 |
aBlock value. |
|
8818 |
selectionRestore notNil ifTrue:[ |
|
8819 |
undoSupport transactionNotEmpty ifTrue:[ |
|
8820 |
undoSupport addUndoFirst:selectionRestore |
|
8821 |
]. |
|
8822 |
]. |
|
8823 |
] |
|
8824 |
info:aString. |
|
8825 |
]. |
|
8826 |
||
8827 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 8828 |
! ! |
8829 |
||
8830 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8831 |
||
8832 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8833 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8834 |
! |
|
8835 |
||
3115 | 8836 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8837 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8838 |
! |
8839 |
||
2952 | 8840 |
line:arg1 col:arg2 character:arg3 |
8841 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8842 |
! |
|
8843 |
||
3115 | 8844 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8845 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8846 |
! |
8847 |
||
3235 | 8848 |
line:arg1 col:arg2 characters:arg3 info:info |
8849 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8850 |
! |
|
8851 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8852 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8853 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8854 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8855 |
|
2952 | 8856 |
line:arg1 col:arg2 string:arg3 |
8857 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8858 |
! |
8859 |
||
8860 |
line:arg1 col:arg2 string:arg3 info:info |
|
8861 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8862 |
! |
8863 |
||
8864 |
line:arg1 string:arg3 info:info |
|
8865 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8866 |
! |
8867 |
||
8868 |
text:arg info:info |
|
8869 |
^ (self new text:arg) info:info |
|
3115 | 8870 |
! ! |
8871 |
||
8872 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8873 |
||
8874 |
info |
|
8875 |
^ userFriendlyInfo |
|
8876 |
! |
|
8877 |
||
8878 |
info:aString |
|
8879 |
userFriendlyInfo := aString |
|
2952 | 8880 |
! ! |
8881 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8882 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8883 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8884 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8885 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8886 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8887 |
"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
|
8888 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8889 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8890 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8891 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8892 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8893 |
^ false |
5710 | 8894 |
! |
8895 |
||
8896 |
isRestoreSelectionAndCursor |
|
8897 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8898 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8899 |
|
2952 | 8900 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8901 |
||
3160 | 8902 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8903 |
"set instance variables (automatically generated)" |
8904 |
||
8905 |
self assert:(line1Arg notNil). |
|
8906 |
self assert:(col1Arg notNil). |
|
8907 |
self assert:(line2Arg notNil). |
|
8908 |
self assert:(col2Arg notNil). |
|
8909 |
||
8910 |
line1 := line1Arg. |
|
8911 |
col1 := col1Arg. |
|
8912 |
line2 := line2Arg. |
|
8913 |
col2 := col2Arg. |
|
8914 |
! ! |
|
8915 |
||
8916 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8917 |
||
3160 | 8918 |
executeIn:editor |
2952 | 8919 |
editor unselect. |
3160 | 8920 |
editor |
4823 | 8921 |
deleteFromLine:line1 |
8922 |
col:col1 |
|
8923 |
toLine:line2 |
|
8924 |
col:col2. |
|
2952 | 8925 |
editor cursorLine:line1 col:col1. |
8926 |
! ! |
|
8927 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8928 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8929 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8930 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8931 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8932 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8933 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8934 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8935 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8936 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8937 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8938 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8939 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8940 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8941 |
|
3160 | 8942 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8943 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8944 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8945 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8946 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8947 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8948 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8949 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8950 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8951 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8952 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8953 |
|
3160 | 8954 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8955 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8956 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8957 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8958 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8959 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8960 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8961 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8962 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8963 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8964 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8965 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8966 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8967 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8968 |
|
3160 | 8969 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8970 |
"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
|
8971 |
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
|
8972 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8973 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8974 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8975 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8976 |
^ true |
|
8977 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8978 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8979 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8980 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8981 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8982 |
|
3160 | 8983 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8984 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8985 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8986 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8987 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8988 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8989 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8990 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8991 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8992 |
|
3160 | 8993 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8994 |
editor unselect. |
3160 | 8995 |
editor |
4823 | 8996 |
deleteFromLine:line |
8997 |
col:col1 |
|
8998 |
toLine:line |
|
8999 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9000 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9001 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9002 |
|
3235 | 9003 |
!EditTextView::EditMode class methodsFor:'constants'! |
9004 |
||
9005 |
insertAndSelectMode |
|
9006 |
^ InsertAndSelectMode |
|
9007 |
! |
|
9008 |
||
9009 |
insertMode |
|
9010 |
^ InsertMode |
|
9011 |
! |
|
9012 |
||
9013 |
overwriteMode |
|
9014 |
^ OverwriteMode |
|
9015 |
! ! |
|
9016 |
||
9017 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
9018 |
||
9019 |
isInsertAndSelectMode |
|
9020 |
^ false |
|
9021 |
! |
|
9022 |
||
9023 |
isInsertMode |
|
9024 |
^ false |
|
9025 |
! |
|
9026 |
||
9027 |
symbolicName |
|
9028 |
self subclassResponsibility |
|
9029 |
! ! |
|
9030 |
||
9031 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
9032 |
||
9033 |
infoPrintString |
|
9034 |
^ 'IS' |
|
9035 |
! ! |
|
9036 |
||
9037 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
9038 |
||
9039 |
isInsertAndSelectMode |
|
9040 |
^ true |
|
9041 |
! |
|
9042 |
||
9043 |
isInsertMode |
|
9044 |
^ true |
|
9045 |
! ! |
|
9046 |
||
9047 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
9048 |
||
9049 |
infoPrintString |
|
9050 |
^ 'I' |
|
9051 |
! ! |
|
9052 |
||
9053 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
9054 |
||
9055 |
isInsertMode |
|
9056 |
^ true |
|
9057 |
! ! |
|
9058 |
||
9059 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
9060 |
||
9061 |
infoPrintString |
|
9062 |
^ 'O' |
|
9063 |
! ! |
|
9064 |
||
4048 | 9065 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
9066 |
||
9067 |
lastReplaceIgnoredCase |
|
9068 |
^ lastReplaceIgnoredCase ? false |
|
9069 |
! |
|
9070 |
||
9071 |
lastReplaceIgnoredCase:something |
|
9072 |
lastReplaceIgnoredCase := something. |
|
9073 |
! |
|
9074 |
||
9075 |
lastReplaceWasMatch |
|
9076 |
^ lastReplaceWasMatch ? false |
|
9077 |
! |
|
9078 |
||
9079 |
lastReplaceWasMatch:something |
|
9080 |
lastReplaceWasMatch := something. |
|
9081 |
! |
|
9082 |
||
9083 |
lastReplacement |
|
9084 |
^ lastReplacement |
|
9085 |
! |
|
9086 |
||
9087 |
lastReplacement:something |
|
4053 | 9088 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 9089 |
lastReplacement := something. |
9090 |
! |
|
9091 |
||
9092 |
lastStringToReplace |
|
9093 |
^ lastStringToReplace |
|
9094 |
! |
|
9095 |
||
9096 |
lastStringToReplace:something |
|
9097 |
lastStringToReplace := something. |
|
4818 | 9098 |
! |
9099 |
||
9100 |
previousReplacements |
|
9101 |
^ previousReplacements ? #() |
|
9102 |
! |
|
9103 |
||
9104 |
stillCollectingInput |
|
9105 |
^ stillCollectingInput |
|
9106 |
! |
|
9107 |
||
9108 |
stillCollectingInput:aBoolean |
|
9109 |
stillCollectingInput := aBoolean. |
|
9110 |
! ! |
|
9111 |
||
9112 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9113 |
||
9114 |
rememberReplacement |
|
9115 |
"remember the previous replacement (called when a new one appears). |
|
9116 |
Mostly for the benefit of the code completion..." |
|
9117 |
||
9118 |
|oldString newString| |
|
9119 |
||
9120 |
oldString := lastStringToReplace. |
|
9121 |
newString := lastReplacement. |
|
9122 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
9123 |
previousReplacements isNil ifTrue:[ |
|
9124 |
previousReplacements := OrderedCollection new. |
|
9125 |
]. |
|
9126 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9127 |
previousReplacements addFirst:(oldString -> newString). |
|
9128 |
previousReplacements size > 20 ifTrue:[ |
|
9129 |
previousReplacements removeLast. |
|
9130 |
] |
|
9131 |
]. |
|
4048 | 9132 |
! ! |
9133 |
||
2952 | 9134 |
!EditTextView::PasteString methodsFor:'accessing'! |
9135 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9136 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9137 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9138 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9139 |
"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
|
9140 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9141 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9142 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9143 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9144 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9145 |
"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
|
9146 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9147 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9148 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9149 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9150 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9151 |
"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
|
9152 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9153 |
|
3160 | 9154 |
line:lineArg col:colArg string:stringArg |
2952 | 9155 |
self assert:(lineArg notNil). |
9156 |
self assert:(colArg notNil). |
|
9157 |
self assert:(stringArg notNil). |
|
9158 |
||
9159 |
line := lineArg. |
|
9160 |
col := colArg. |
|
9161 |
string := stringArg. |
|
9162 |
! |
|
9163 |
||
9164 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9165 |
self assert:(lineArg notNil). |
|
9166 |
self assert:(colArg notNil). |
|
9167 |
self assert:(stringArg notNil). |
|
9168 |
||
9169 |
line := lineArg. |
|
9170 |
col := colArg. |
|
9171 |
string := stringArg. |
|
9172 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9173 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9174 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9175 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9176 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9177 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9178 |
"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
|
9179 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9180 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9181 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9182 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9183 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9184 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9185 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9186 |
"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
|
9187 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9188 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9189 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9190 |
"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
|
9191 |
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
|
9192 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9193 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9194 |
previousPasteAction line == line ifTrue:[ |
4823 | 9195 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9196 |
^ true |
|
9197 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9198 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9199 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9200 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9201 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9202 |
"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
|
9203 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9204 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9205 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9206 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9207 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9208 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9209 |
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
|
9210 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9211 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9212 |
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
|
9213 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9214 |
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
|
9215 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9216 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9217 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9218 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9219 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9220 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9221 |
! ! |
9222 |
||
9223 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9224 |
||
3160 | 9225 |
executeIn:editor |
2952 | 9226 |
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
|
9227 |
editor paste:string. |
2952 | 9228 |
selected ~~ true ifTrue:[ |
4823 | 9229 |
editor unselect |
2952 | 9230 |
]. |
9231 |
! ! |
|
9232 |
||
9233 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9234 |
||
3235 | 9235 |
col |
9236 |
^ col |
|
9237 |
! |
|
9238 |
||
9239 |
col1 |
|
9240 |
^ col |
|
9241 |
! |
|
9242 |
||
9243 |
col2 |
|
9244 |
^ col |
|
9245 |
! |
|
9246 |
||
9247 |
line |
|
9248 |
^ line |
|
9249 |
! |
|
9250 |
||
3160 | 9251 |
line:lineArg col:colArg character:characterArg |
2952 | 9252 |
line := lineArg. |
9253 |
col := colArg. |
|
9254 |
character := characterArg. |
|
9255 |
! ! |
|
9256 |
||
9257 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9258 |
||
3160 | 9259 |
executeIn:editor |
9260 |
editor |
|
4823 | 9261 |
replace:character |
9262 |
atLine:line |
|
9263 |
col:col. |
|
2952 | 9264 |
editor cursorLine:line col:col. |
105 | 9265 |
! ! |
9266 |
||
3235 | 9267 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9268 |
||
9269 |
characters |
|
9270 |
^ characters |
|
9271 |
! |
|
9272 |
||
9273 |
col1 |
|
9274 |
^ col1 |
|
9275 |
! |
|
9276 |
||
9277 |
col2 |
|
9278 |
^ col2 |
|
9279 |
! |
|
9280 |
||
9281 |
line |
|
9282 |
^ line |
|
9283 |
! |
|
9284 |
||
9285 |
line:lineArg col:colArg character:characterArg |
|
9286 |
line := lineArg. |
|
9287 |
col1 := col2 := colArg. |
|
9288 |
characters := characterArg asString. |
|
9289 |
! |
|
9290 |
||
9291 |
line:lineArg col:colArg characters:charactersArg |
|
9292 |
line := lineArg. |
|
9293 |
col1 := colArg. |
|
9294 |
characters := charactersArg asString. |
|
9295 |
col2 := col1 + charactersArg size - 1 |
|
9296 |
! ! |
|
9297 |
||
9298 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9299 |
||
9300 |
canCombineWithNext:anotherAction |
|
9301 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9302 |
! |
|
9303 |
||
9304 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9305 |
"I will combine only if we both are single character deletes, |
|
9306 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9307 |
(i.e. single-character typing)" |
|
9308 |
||
9309 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 9310 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9311 |
^ true |
|
9312 |
]. |
|
3235 | 9313 |
]. |
9314 |
||
9315 |
^ false |
|
9316 |
! |
|
9317 |
||
9318 |
combineWithNext:nextReplaceAction |
|
9319 |
self assert:(line == nextReplaceAction line). |
|
9320 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9321 |
||
9322 |
col2 := nextReplaceAction col2. |
|
9323 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9324 |
characters := characters , nextReplaceAction characters. |
|
9325 |
! ! |
|
9326 |
||
9327 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9328 |
||
9329 |
executeIn:editor |
|
9330 |
editor |
|
4823 | 9331 |
replaceString:characters |
9332 |
atLine:line |
|
9333 |
col:col1. |
|
3235 | 9334 |
editor cursorLine:line col:col1. |
9335 |
! ! |
|
9336 |
||
3131 | 9337 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9338 |
||
9339 |
text:something |
|
9340 |
text := something. |
|
9341 |
! ! |
|
9342 |
||
9343 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9344 |
||
3160 | 9345 |
executeIn:editor |
3131 | 9346 |
editor contents:text |
9347 |
! ! |
|
9348 |
||
3130 | 9349 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9350 |
||
3160 | 9351 |
line:lineArg string:stringArg |
3130 | 9352 |
line := lineArg. |
9353 |
text := stringArg. |
|
9354 |
! ! |
|
9355 |
||
9356 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9357 |
||
3160 | 9358 |
executeIn:editor |
3130 | 9359 |
editor list at:line put:text. |
9360 |
editor invalidateLine:line |
|
9361 |
! ! |
|
9362 |
||
3402 | 9363 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9364 |
||
9365 |
line:lineArg lines:lineCollectionArg |
|
9366 |
line := lineArg. |
|
9367 |
text := lineCollectionArg. |
|
9368 |
||
9369 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9370 |
! ! |
|
9371 |
||
9372 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9373 |
||
9374 |
executeIn:editor |
|
9375 |
|lnr| |
|
9376 |
||
9377 |
lnr := line. |
|
9378 |
text do:[:eachLine | |
|
4823 | 9379 |
editor list at:lnr put:eachLine. |
9380 |
editor invalidateLine:lnr. |
|
9381 |
lnr := lnr + 1. |
|
3402 | 9382 |
]. |
9383 |
||
9384 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9385 |
! ! |
|
9386 |
||
5689 | 9387 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9388 |
||
9389 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9390 |
cursorLine := cursorLineArg. |
|
9391 |
cursorCol := cursorColArg. |
|
9392 |
selectionStartLine := selectionStartLineArg. |
|
9393 |
selectionStartCol := selectionStartColArg. |
|
9394 |
selectionEndLine := selectionEndLineArg. |
|
9395 |
selectionEndCol := selectionEndColArg. |
|
9396 |
! |
|
9397 |
||
9398 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
|
9399 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
|
9400 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9401 |
info:info |
|
9402 |
||
9403 |
cursorLine := cursorLineArg. |
|
9404 |
cursorCol := cursorColArg. |
|
9405 |
selectionStartLine := selectionStartLineArg. |
|
9406 |
selectionStartCol := selectionStartColArg. |
|
9407 |
selectionEndLine := selectionEndLineArg. |
|
9408 |
selectionEndCol := selectionEndColArg. |
|
9409 |
userFriendlyInfo := info. |
|
9410 |
||
9411 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9412 |
! ! |
|
9413 |
||
9414 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9415 |
||
9416 |
executeIn:editor |
|
9417 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9418 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
9419 |
editor setCursorLine:cursorLine col:cursorCol. |
|
9420 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
9421 |
] ifFalse:[ |
|
9422 |
editor cursorLine:cursorLine col:cursorCol. |
|
9423 |
]. |
|
9424 |
||
9425 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9426 |
! ! |
|
9427 |
||
5710 | 9428 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9429 |
||
9430 |
isRestoreSelectionAndCursor |
|
9431 |
^ true |
|
9432 |
! ! |
|
9433 |
||
865 | 9434 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9435 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9436 |
version |
5361 | 9437 |
^ '$Header$' |
3945 | 9438 |
! |
9439 |
||
9440 |
version_CVS |
|
5361 | 9441 |
^ '$Header$' |
4843
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9442 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9443 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9444 |
version_HG |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9445 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9446 |
^ '$Changeset: <not expanded> $' |
0 | 9447 |
! ! |
4481 | 9448 |