author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sun, 09 Aug 2015 07:20:03 +0100 | |
branch | jv |
changeset 5395 | fc9336b15c5c |
parent 5389 | 940dcf5485be |
parent 5394 | bd2329beafbc |
child 5403 | 569378fb6c8e |
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 |
||
865 | 141 |
!EditTextView class methodsFor:'documentation'! |
0 | 142 |
|
33 | 143 |
copyright |
144 |
" |
|
145 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 146 |
All Rights Reserved |
33 | 147 |
|
148 |
This software is furnished under a license and may be used |
|
149 |
only in accordance with the terms of that license and with the |
|
150 |
inclusion of the above copyright notice. This software may not |
|
151 |
be provided or otherwise made available to, or used by, any |
|
152 |
other person. No title to or ownership of the software is |
|
153 |
hereby transferred. |
|
154 |
" |
|
155 |
! |
|
156 |
||
0 | 157 |
documentation |
158 |
" |
|
159 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 160 |
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
|
161 |
acceptAction to be performed for accept |
125 | 162 |
|
163 |
If used with a model, this is informed by sending it a changeMsg with |
|
164 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
165 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 166 |
|
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
|
167 |
Please read the historic notice in the ListView class. |
0 | 168 |
|
586 | 169 |
[Instance variables:] |
0 | 170 |
|
4010 | 171 |
cursorLine <Number> line where cursor sits (1..) |
172 |
||
173 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
174 |
||
175 |
cursorCol <Number> col where cursor sits (1..) |
|
176 |
||
177 |
cursorShown <Boolean> true, if cursor is currently shown |
|
178 |
||
179 |
readOnly <Boolean> true, if text may not be edited |
|
180 |
||
181 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
182 |
cleared on accept. |
|
183 |
||
184 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
185 |
||
186 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
187 |
||
188 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
189 |
if it returns true, the modification will be done anyway. |
|
190 |
if it returns anything else, the modification is not done. |
|
191 |
||
192 |
cursorFgColor <Color> color used for cursor drawing |
|
193 |
cursorBgColor <Color> color used for cursor drawing |
|
194 |
||
195 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 196 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 197 |
(vertical bar at insertion point) |
4721 | 198 |
and #caret (caret below insertion-point). |
199 |
see cursorType: for an up-to-date list. |
|
4010 | 200 |
|
201 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
202 |
nil means: hide the cursor. |
|
203 |
||
204 |
undoAction <Block> block which undoes last cut, paste or replace |
|
205 |
(not yet fully implemented) |
|
206 |
||
207 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
208 |
this affects the next keyPress: if #paste it does not |
|
209 |
replace; otherwise it replaces the selection. |
|
210 |
||
211 |
lastCut <String> last cut or replaced string |
|
212 |
||
4053 | 213 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
214 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
215 |
lastReplacement is the string to replace lastStringToReplace |
|
216 |
||
217 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
218 |
(cleared after a new selection) |
|
4010 | 219 |
|
220 |
replacing <Boolean> true if entered characters replace last selection |
|
221 |
||
222 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
223 |
when entering one; this is the default. |
|
224 |
||
225 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
226 |
||
227 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
228 |
argument |
|
229 |
||
230 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
231 |
focus to the next field. For editTextViews, this is false |
|
232 |
by default (i.e. tabs can be entered into the text). |
|
233 |
For some subclasses (inputFields), this may be true. |
|
234 |
||
235 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
236 |
removed when editing. |
|
237 |
Default is true. |
|
238 |
||
239 |
wordWrap <Boolean> Currently not used. |
|
240 |
||
241 |
lockUpdates <Boolean> internal, private |
|
242 |
||
243 |
prevCursorState <Boolean> temporary, private |
|
244 |
||
245 |
cursorMovementWhenUpdating |
|
246 |
<Symbol> defines where the cursor is to be positioned if the |
|
247 |
model changes its value by some outside activity |
|
248 |
(i.e. not by user input into the field). |
|
249 |
Can be one of: |
|
250 |
#keep / nil -> stay where it was |
|
251 |
#endOfText -> cursor to the end |
|
252 |
#endOfLine -> stay in the line, but move to end |
|
253 |
#beginOfText -> cursor to the beginning |
|
254 |
#beginOfLine -> stay in the line, but move to begin |
|
255 |
The default is #beginOfText |
|
256 |
||
257 |
||
258 |
||
259 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 260 |
|
261 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
262 |
userPreference values: |
4010 | 263 |
userPreferences.st80EditMode |
264 |
<Boolean> if true, cursor positioning is |
|
265 |
done as in vi or ST80; i.e. |
|
266 |
wysiwyg mode is somewhat relaxed, |
|
267 |
in that the cursor cannot be |
|
268 |
positioned behind a lines end. |
|
269 |
This is not yet completely implemented. |
|
33 | 270 |
used globals: |
271 |
||
4010 | 272 |
DeleteHistory <Text> last 1000 lines of deleted text |
273 |
(but only if this variable exists already) |
|
586 | 274 |
|
275 |
[styleSheet parameters:] |
|
121 | 276 |
|
4010 | 277 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
278 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
279 |
textCursorNoFocusForegroundColor |
|
280 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
281 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 282 |
|
283 |
[author:] |
|
4010 | 284 |
Claus Gittinger |
586 | 285 |
|
286 |
[see also:] |
|
4010 | 287 |
CodeView Workspace TextView ListView |
288 |
EditField |
|
0 | 289 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
290 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
291 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
292 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
293 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
294 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
295 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
296 |
basic setup: |
4823 | 297 |
[exBegin] |
298 |
|top textView| |
|
299 |
||
300 |
top := StandardSystemView new. |
|
301 |
top extent:300@200. |
|
302 |
||
303 |
textView := EditTextView new. |
|
304 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
305 |
top addSubView:textView. |
|
306 |
||
307 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
308 |
||
309 |
top open. |
|
310 |
[exEnd] |
|
594 | 311 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
312 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
313 |
with vertical scrollbar: |
4823 | 314 |
[exBegin] |
315 |
|top scrollView textView| |
|
316 |
||
317 |
top := StandardSystemView new. |
|
318 |
top extent:300@200. |
|
319 |
||
320 |
scrollView := ScrollableView for:EditTextView. |
|
321 |
textView := scrollView scrolledView. |
|
322 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
323 |
top addSubView:scrollView. |
|
324 |
||
325 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
326 |
||
327 |
top open. |
|
328 |
[exEnd] |
|
594 | 329 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
330 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
331 |
with horizontal & vertical scrollbars: |
4823 | 332 |
[exBegin] |
333 |
|top scrollView textView| |
|
334 |
||
335 |
top := StandardSystemView new. |
|
336 |
top extent:300@200. |
|
337 |
||
338 |
scrollView := HVScrollableView for:EditTextView. |
|
339 |
textView := scrollView scrolledView. |
|
340 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
341 |
top addSubView:scrollView. |
|
342 |
||
343 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
344 |
||
345 |
top open. |
|
346 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
347 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
348 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
349 |
set the action for accept: |
4823 | 350 |
[exBegin] |
351 |
|top textView| |
|
352 |
||
353 |
top := StandardSystemView new. |
|
354 |
top extent:300@200. |
|
355 |
||
356 |
textView := EditTextView new. |
|
357 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
358 |
top addSubView:textView. |
|
359 |
||
360 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
361 |
textView acceptAction:[:contents | |
|
362 |
Transcript showCR:'will not overwrite the file with:'. |
|
363 |
Transcript showCR:contents asString |
|
364 |
]. |
|
365 |
top open. |
|
366 |
[exEnd] |
|
594 | 367 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
368 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
369 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
370 |
non-string (text) items: |
4823 | 371 |
[exBegin] |
372 |
|top textView list| |
|
373 |
||
374 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
375 |
1 to:list size by:2 do:[:nr | |
|
376 |
list at:nr put:(Text string:(list at:nr) |
|
377 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
378 |
]. |
|
379 |
||
380 |
top := StandardSystemView new. |
|
381 |
top extent:300@200. |
|
382 |
||
383 |
textView := EditTextView new. |
|
384 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
385 |
top addSubView:textView. |
|
386 |
||
387 |
textView contents:list. |
|
388 |
top open. |
|
389 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
390 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
391 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
392 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
393 |
MVC operation: |
594 | 394 |
(the examples model here is a plug simulating a real model; |
395 |
real world applications would not use a plug ..) |
|
4823 | 396 |
[exBegin] |
397 |
|top textView model| |
|
398 |
||
399 |
model := Plug new. |
|
400 |
model respondTo:#accepted: |
|
401 |
with:[:newContents | |
|
402 |
Transcript showCR:'will not overwrite the file with:'. |
|
403 |
Transcript showCR:newContents asString |
|
404 |
]. |
|
405 |
model respondTo:#getList |
|
406 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
407 |
||
408 |
||
409 |
top := StandardSystemView new. |
|
410 |
top extent:300@200. |
|
411 |
||
412 |
textView := EditTextView new. |
|
413 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
414 |
top addSubView:textView. |
|
415 |
||
416 |
textView listMessage:#getList; |
|
417 |
model:model; |
|
418 |
changeMessage:#accepted:; |
|
419 |
aspect:#list. |
|
420 |
top open. |
|
421 |
[exEnd] |
|
594 | 422 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
423 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
424 |
two textViews on the same model: |
4823 | 425 |
[exBegin] |
426 |
|top1 textView1 top2 textView2 model currentContents| |
|
427 |
||
428 |
model := Plug new. |
|
429 |
model respondTo:#accepted: |
|
430 |
with:[:newContents | |
|
431 |
Transcript showCR:'accepted:'. |
|
432 |
Transcript showCR:newContents asString. |
|
433 |
currentContents := newContents. |
|
434 |
model changed:#contents |
|
435 |
]. |
|
436 |
model respondTo:#getList |
|
437 |
with:[Transcript showCR:'query'. |
|
438 |
currentContents]. |
|
439 |
||
440 |
||
441 |
top1 := StandardSystemView new. |
|
442 |
top1 extent:300@200. |
|
443 |
||
444 |
textView1 := EditTextView new. |
|
445 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
446 |
top1 addSubView:textView1. |
|
447 |
||
448 |
textView1 listMessage:#getList; |
|
449 |
model:model; |
|
450 |
aspect:#contents; |
|
451 |
changeMessage:#accepted:. |
|
452 |
top1 open. |
|
453 |
||
454 |
top2 := StandardSystemView new. |
|
455 |
top2 extent:300@200. |
|
456 |
||
457 |
textView2 := EditTextView new. |
|
458 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
459 |
top2 addSubView:textView2. |
|
460 |
||
461 |
textView2 listMessage:#getList; |
|
462 |
model:model; |
|
463 |
aspect:#contents; |
|
464 |
changeMessage:#accepted:. |
|
465 |
top2 open. |
|
466 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
467 |
" |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
468 |
! |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
469 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
470 |
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
|
471 |
" |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
472 |
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
|
473 |
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
|
474 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
475 |
* 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
|
476 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
477 |
* 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
|
478 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
479 |
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
|
480 |
2. Stop dragging |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
481 |
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
|
482 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
483 |
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
|
484 |
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
|
485 |
(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
|
486 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
487 |
* 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
|
488 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
489 |
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
|
490 |
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
|
491 |
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
|
492 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
493 |
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
|
494 |
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
|
495 |
(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
|
496 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
497 |
* 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
|
498 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
499 |
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
|
500 |
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
|
501 |
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
|
502 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
(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
|
506 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
507 |
Scenario B: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
512 |
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
|
513 |
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
|
514 |
(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
|
515 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
516 |
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
|
517 |
UserPreferences current selectionExtensionMode |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
518 |
|
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 |
* 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
|
521 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
522 |
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
|
523 |
2. Select word |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
524 |
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
|
525 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
526 |
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
|
527 |
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
|
528 |
(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
|
529 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
530 |
" |
0 | 531 |
! ! |
532 |
||
865 | 533 |
!EditTextView class methodsFor:'defaults'! |
59 | 534 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
535 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
536 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
537 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
538 |
"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
|
539 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
540 |
|
1419 | 541 |
st80Mode |
542 |
"return true, if the st80 editing mode is turned on. |
|
543 |
This setting affects the behavior of the cursor, when positioned |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
544 |
beyond the end of a line or the end of the text." |
1419 | 545 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
546 |
^ UserPreferences current st80EditMode |
1419 | 547 |
|
548 |
" |
|
549 |
EditTextView st80Mode:true |
|
550 |
EditTextView st80Mode:false |
|
551 |
" |
|
552 |
||
553 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
554 |
! |
|
555 |
||
556 |
st80Mode:aBoolean |
|
557 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 558 |
beyond the end of a line or the last line" |
1419 | 559 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
560 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 561 |
|
562 |
" |
|
563 |
EditTextView st80Mode:true |
|
564 |
EditTextView st80Mode:false |
|
565 |
" |
|
566 |
||
567 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
568 |
! |
|
569 |
||
59 | 570 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
571 |
"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
|
572 |
|
1390 | 573 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 574 |
#'textCursor.noFocusForegroundColor' |
575 |
#'textCursor.type' |
|
576 |
#'textCursor.typeNoFocus' |
|
577 |
#'editText.st80Mode')> |
|
1355 | 578 |
|
579 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
580 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
581 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
582 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
583 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
584 |
|
1419 | 585 |
" |
586 |
self updateStyleCache |
|
587 |
" |
|
588 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
589 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 590 |
! ! |
591 |
||
3431 | 592 |
!EditTextView class methodsFor:'specs'! |
593 |
||
594 |
searchReplaceDialogSpec |
|
595 |
"This resource specification was automatically generated |
|
596 |
by the UIPainter of ST/X." |
|
597 |
||
598 |
"Do not manually edit this!! If it is corrupted, |
|
599 |
the UIPainter may not be able to read the specification." |
|
600 |
||
601 |
" |
|
602 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
603 |
" |
|
604 |
||
605 |
<resource: #canvas> |
|
606 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
607 |
^ |
3431 | 608 |
#(FullSpec |
4823 | 609 |
name: searchReplaceDialogSpec |
610 |
window: |
|
3431 | 611 |
(WindowSpec |
4823 | 612 |
label: 'String Search and Replace' |
613 |
name: 'String Search and Replace' |
|
614 |
min: (Point 283 196) |
|
615 |
max: (Point 283 196) |
|
616 |
bounds: (Rectangle 0 0 279 192) |
|
617 |
) |
|
618 |
component: |
|
3431 | 619 |
(SpecCollection |
4823 | 620 |
collection: ( |
621 |
(LabelSpec |
|
622 |
label: 'Search Pattern:' |
|
623 |
name: 'label' |
|
624 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
625 |
level: 0 |
|
626 |
translateLabel: true |
|
627 |
adjust: left |
|
628 |
) |
|
629 |
(ComboBoxSpec |
|
630 |
name: 'patternComboBox' |
|
631 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
632 |
tabable: true |
|
633 |
model: searchPattern |
|
634 |
immediateAccept: false |
|
635 |
acceptOnLeave: true |
|
636 |
acceptOnReturn: true |
|
637 |
acceptOnTab: true |
|
638 |
acceptOnLostFocus: true |
|
639 |
acceptOnPointerLeave: false |
|
640 |
autoSelectInitialText: true |
|
641 |
comboList: patternList |
|
642 |
) |
|
643 |
(ComboBoxSpec |
|
644 |
name: 'replaceComboBox' |
|
645 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
646 |
tabable: true |
|
647 |
model: replacePattern |
|
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 |
(CheckBoxSpec |
|
658 |
label: 'Ignore Case' |
|
659 |
name: 'ignoreCaseCheckBox' |
|
660 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
661 |
level: 0 |
|
662 |
tabable: true |
|
663 |
model: ignoreCase |
|
664 |
translateLabel: true |
|
665 |
) |
|
666 |
(VariableVerticalPanelSpec |
|
667 |
name: 'VariableVerticalPanel1' |
|
668 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
669 |
component: |
|
670 |
(SpecCollection |
|
671 |
collection: ( |
|
672 |
(HorizontalPanelViewSpec |
|
673 |
name: 'HorizontalPanel1' |
|
674 |
level: 0 |
|
675 |
horizontalLayout: fitSpace |
|
676 |
verticalLayout: center |
|
677 |
horizontalSpace: 3 |
|
678 |
verticalSpace: 3 |
|
679 |
ignoreInvisibleComponents: true |
|
680 |
reverseOrderIfOKAtLeft: true |
|
681 |
component: |
|
682 |
(SpecCollection |
|
683 |
collection: ( |
|
684 |
(ActionButtonSpec |
|
685 |
label: 'Replace' |
|
686 |
name: 'replaceButton' |
|
687 |
level: 2 |
|
688 |
translateLabel: true |
|
689 |
tabable: true |
|
690 |
model: replaceAction |
|
691 |
extent: (Point 134 21) |
|
692 |
) |
|
693 |
(ActionButtonSpec |
|
694 |
label: 'Replace All' |
|
695 |
name: 'replaceAllButton' |
|
696 |
level: 2 |
|
697 |
borderWidth: 1 |
|
698 |
translateLabel: true |
|
699 |
tabable: true |
|
700 |
model: replaceAllAction |
|
701 |
extent: (Point 134 21) |
|
702 |
) |
|
703 |
) |
|
704 |
||
705 |
) |
|
706 |
) |
|
707 |
(HorizontalPanelViewSpec |
|
708 |
name: 'horizontalPanelView' |
|
709 |
level: 0 |
|
710 |
horizontalLayout: fitSpace |
|
711 |
verticalLayout: center |
|
712 |
horizontalSpace: 3 |
|
713 |
verticalSpace: 3 |
|
714 |
ignoreInvisibleComponents: true |
|
715 |
reverseOrderIfOKAtLeft: true |
|
716 |
component: |
|
717 |
(SpecCollection |
|
718 |
collection: ( |
|
719 |
(ActionButtonSpec |
|
720 |
label: 'Cancel' |
|
721 |
name: 'cancelButton' |
|
722 |
level: 2 |
|
723 |
translateLabel: true |
|
724 |
tabable: true |
|
725 |
model: cancel |
|
726 |
extent: (Point 88 21) |
|
727 |
) |
|
728 |
(ActionButtonSpec |
|
729 |
label: 'Prev' |
|
730 |
name: 'prevButton' |
|
731 |
level: 2 |
|
732 |
translateLabel: true |
|
733 |
tabable: true |
|
734 |
model: prevAction |
|
735 |
extent: (Point 89 21) |
|
736 |
) |
|
737 |
(ActionButtonSpec |
|
738 |
label: 'Next' |
|
739 |
name: 'nextButton' |
|
740 |
level: 2 |
|
741 |
borderWidth: 1 |
|
742 |
translateLabel: true |
|
743 |
tabable: true |
|
744 |
model: nextAction |
|
745 |
isDefault: true |
|
746 |
extent: (Point 88 21) |
|
747 |
) |
|
748 |
) |
|
749 |
||
750 |
) |
|
751 |
) |
|
752 |
) |
|
753 |
||
754 |
) |
|
755 |
handles: (Any 0.5 1.0) |
|
756 |
) |
|
757 |
(LabelSpec |
|
758 |
label: 'Replace By:' |
|
759 |
name: 'ReplaceLabel' |
|
760 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
761 |
level: 0 |
|
762 |
translateLabel: true |
|
763 |
adjust: left |
|
764 |
) |
|
765 |
) |
|
766 |
||
767 |
) |
|
3431 | 768 |
) |
769 |
||
770 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
771 |
! ! |
|
772 |
||
2744 | 773 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
774 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
775 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
776 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
777 |
|
2019 | 778 |
"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
|
779 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
780 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
781 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
782 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
783 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
784 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
785 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
786 |
|
1390 | 787 |
cutSelection |
788 |
self cut |
|
789 |
||
790 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
791 |
! |
|
792 |
||
1590 | 793 |
deselect |
794 |
"remove the selection" |
|
795 |
||
796 |
^ self unselect |
|
797 |
||
798 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
799 |
! |
|
800 |
||
2101 | 801 |
enabled:aBoolean |
802 |
||
803 |
self readOnly:aBoolean not |
|
804 |
||
805 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
806 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
807 |
! |
|
808 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
809 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
810 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
811 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
812 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
813 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
814 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
815 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
816 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
817 |
"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
|
818 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
819 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
820 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
821 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
822 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
823 |
col < 1 ifTrue:[ |
4823 | 824 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
825 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
826 |
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
|
827 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
828 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
829 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
830 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
831 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
832 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
833 |
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
|
834 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
835 |
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
|
836 |
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
|
837 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
838 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
839 |
"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
|
840 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
841 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
842 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
843 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
844 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
845 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
846 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
847 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 848 |
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
|
849 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
850 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 851 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
852 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
853 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
854 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
855 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
856 |
v insertAndSelect:'<- hello there' at:5. |
125 | 857 |
" |
1390 | 858 |
! |
859 |
||
860 |
pasteSelection |
|
861 |
self paste |
|
862 |
||
863 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 864 |
! |
865 |
||
866 |
replaceSelectionWith:aString |
|
867 |
^ self replaceSelectionBy:aString |
|
868 |
||
869 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
870 |
! |
|
871 |
||
872 |
selectAt:pos |
|
873 |
"move the cursor before cursorPosition." |
|
874 |
||
875 |
self cursorToCharacterPosition:pos |
|
876 |
||
877 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
878 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
879 |
! |
|
880 |
||
2101 | 881 |
textHasChanged |
882 |
^ self modified |
|
883 |
||
884 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
885 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
886 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
887 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
888 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
889 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
890 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
891 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
892 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
893 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
894 |
|
4585 | 895 |
!EditTextView methodsFor:'accessing'! |
896 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
897 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
898 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
899 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
900 |
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
|
901 |
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
|
902 |
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
|
903 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
904 |
"/ 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
|
905 |
"/ 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
|
906 |
^((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
|
907 |
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
|
908 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
909 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
910 |
"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
|
911 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
912 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
913 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
914 |
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
|
915 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
916 |
"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
|
917 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
918 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
919 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
920 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
921 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
922 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
923 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
924 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
925 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
926 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
927 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
928 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
929 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
930 |
"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
|
931 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
932 |
|
4609 | 933 |
editedClass |
934 |
|cm| |
|
935 |
||
936 |
cm := self editedMethodOrClass. |
|
937 |
cm isBehavior ifTrue:[^ cm]. |
|
938 |
cm isMethod ifTrue:[^ cm mclass]. |
|
939 |
^ nil |
|
940 |
! |
|
941 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
942 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
943 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
944 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
945 |
"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
|
946 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
947 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
948 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
949 |
"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
|
950 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
951 |
"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
|
952 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
953 |
|
4609 | 954 |
editedMethod |
955 |
|cm| |
|
956 |
||
957 |
cm := self editedMethodOrClass. |
|
958 |
cm isMethod ifTrue:[^ cm]. |
|
959 |
cm isBehavior ifTrue:[^ nil]. |
|
960 |
^ nil |
|
961 |
! |
|
962 |
||
963 |
editedMethodOrClass |
|
964 |
^ nil |
|
965 |
! |
|
966 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
967 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
968 |
"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
|
969 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
970 |
"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
|
971 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
972 |
|
4585 | 973 |
hasSelectionOrTextInCursorLine |
974 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
975 |
! |
|
976 |
||
4589 | 977 |
selectionOrTextOfCursorLine |
978 |
^ self selectionOrTextOfCursorLine:true |
|
979 |
! |
|
980 |
||
4585 | 981 |
selectionOrTextOfCursorLine:doSelect |
982 |
|sel lNr line| |
|
983 |
||
984 |
sel := self selectionAsString. |
|
985 |
sel notNil ifTrue:[^ sel]. |
|
986 |
||
987 |
lNr := self cursorLine. |
|
988 |
line := self listAt:lNr. |
|
989 |
line notEmptyOrNil ifTrue:[ |
|
990 |
doSelect ifTrue:[ |
|
991 |
self selectLine:lNr. |
|
992 |
]. |
|
993 |
^ line |
|
994 |
]. |
|
995 |
||
996 |
^ nil |
|
997 |
! ! |
|
998 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
999 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1000 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1001 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1002 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1003 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1004 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1005 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1006 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1007 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1008 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1009 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1010 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1011 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1012 |
|
2792 | 1013 |
acceptChannel |
1014 |
"return the valueHolder holding true if text was accepted. |
|
1015 |
By placing a true into this channel, an accept can also be forced." |
|
1016 |
||
1017 |
^ acceptChannel |
|
1018 |
||
1019 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
1020 |
! |
|
1021 |
||
1022 |
acceptChannel:aValueHolder |
|
1023 |
"set the valueHolder holding true if text was accepted. |
|
1024 |
By placing a true into this channel, an accept can also be forced." |
|
1025 |
||
1026 |
|prev| |
|
1027 |
||
1028 |
prev := acceptChannel. |
|
1029 |
acceptChannel := aValueHolder. |
|
1030 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1031 |
||
1032 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
1033 |
! |
|
1034 |
||
1108 | 1035 |
acceptEnabled:aBoolean |
1036 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
1037 |
||
1038 |
acceptEnabled := aBoolean |
|
1039 |
||
1040 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
1041 |
! |
|
1042 |
||
2792 | 1043 |
accepted |
1044 |
"return true if text was accepted" |
|
1045 |
||
1046 |
^ acceptChannel value |
|
1047 |
||
1048 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1049 |
! |
|
1050 |
||
1051 |
accepted:aBoolean |
|
1052 |
"set/clear the accepted flag. |
|
1053 |
This may force my current contents to be placed into my model." |
|
1054 |
||
1055 |
acceptChannel value:aBoolean. |
|
1056 |
||
1057 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1058 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1059 |
! |
|
1060 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1061 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1062 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1063 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1064 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1065 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1066 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1067 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1068 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1069 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1070 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1071 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1072 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1073 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1074 |
|
2774 | 1075 |
cursorMovementWhenUpdating |
3160 | 1076 |
"return what is be done with the cursor, |
2774 | 1077 |
when I get a new text (via the model or the #contents/#list) |
1078 |
Allowed arguments are: |
|
4823 | 1079 |
#keep / nil -> stay where it was |
1080 |
#endOfText -> position cursor to the end |
|
1081 |
#beginOfText -> position cursor to the beginning |
|
1082 |
#endOfLine -> position cursor to the current lines end |
|
1083 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1084 |
The default is #beginOfText. |
1085 |
This may be useful for fields which get new values assigned from |
|
1086 |
the program (i.e. not from the user)" |
|
1087 |
||
1088 |
^ cursorMovementWhenUpdating |
|
1089 |
||
1090 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1091 |
! |
|
1092 |
||
2133 | 1093 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1094 |
"define what should be done with the cursor, |
2133 | 1095 |
when I get a new text (via the model or the #contents/#list) |
1096 |
Allowed arguments are: |
|
4823 | 1097 |
#keep / nil -> stay where it was |
1098 |
#endOfText -> position cursor to the end |
|
1099 |
#beginOfText -> position cursor to the beginning |
|
1100 |
#endOfLine -> position cursor to the current lines end |
|
1101 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1102 |
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
|
1103 |
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
|
1104 |
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
|
1105 |
|
2133 | 1106 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1107 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1108 |
"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
|
1109 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1110 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1111 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1112 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1113 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1114 |
|
2438 | 1115 |
dontReplaceSelectionOnInput |
4742 | 1116 |
"remember that the current selection was created by a paste operation |
1117 |
(as opposed to an explicit selection by the user). |
|
1118 |
This selection will not be replaced by followup user input, |
|
1119 |
so multiple pastes will be possible." |
|
1120 |
||
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
|
1121 |
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
|
1122 |
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
|
1123 |
]. |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1124 |
|
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1125 |
"Modified: / 02-05-2015 / 21:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2438 | 1126 |
! |
1127 |
||
3235 | 1128 |
editModeHolder |
1129 |
^ editMode. |
|
1130 |
! |
|
1131 |
||
1132 |
editModeInsert |
|
1133 |
editMode value:EditMode insertMode |
|
1134 |
! |
|
1135 |
||
1136 |
editModeInsertAndSelect |
|
1137 |
editMode value:EditMode insertAndSelectMode |
|
1138 |
! |
|
1139 |
||
1140 |
editModeOverwrite |
|
1141 |
editMode value:EditMode overwriteMode |
|
1142 |
! |
|
1143 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1144 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1145 |
"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
|
1146 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1147 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1148 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1149 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1150 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1151 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1152 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1153 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1154 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1155 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1156 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1157 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1158 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1159 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1160 |
readOnly == true ifFalse:[ |
4823 | 1161 |
readOnly := true. |
1162 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1163 |
menu disableAll:#(cut paste replace indent) |
|
1164 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1165 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1166 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1167 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
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 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1170 |
insertMode:aBoolean |
3235 | 1171 |
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
|
1172 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1173 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1174 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1175 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1176 |
insertModeHolder |
3235 | 1177 |
^ BlockValue |
4823 | 1178 |
with:[:m | m isInsertMode] |
1179 |
argument:(editMode). |
|
3465 | 1180 |
|
1181 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1182 |
! |
1183 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1184 |
isInInsertMode |
3235 | 1185 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1186 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1187 |
|
5216 | 1188 |
isNotReadOnly |
1189 |
"return true, if the text is not readonly." |
|
1190 |
||
1191 |
^ self isReadOnly not |
|
1192 |
! |
|
1193 |
||
2792 | 1194 |
isReadOnly |
1195 |
"return true, if the text is readonly." |
|
1196 |
||
1197 |
^ readOnly value |
|
1198 |
||
1199 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1200 |
! |
|
1201 |
||
2796 | 1202 |
modeLabelHolder |
1203 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1204 |
||
3160 | 1205 |
^ BlockValue |
4041 | 1206 |
with:[:e :l | |
1207 |
self isReadOnly ifTrue:[ |
|
1208 |
'' |
|
1209 |
] ifFalse:[ |
|
1210 |
l ifTrue:[ 'L' allBold colorizeAllWith:Color red] |
|
1211 |
ifFalse:[ e infoPrintString]]] |
|
1212 |
argument:(self editModeHolder) |
|
1213 |
argument:(self learnModeHolder). |
|
3465 | 1214 |
|
1215 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1216 |
! |
1217 |
||
2792 | 1218 |
modified |
1219 |
"return true if text was modified" |
|
1220 |
||
1221 |
^ modifiedChannel value |
|
1222 |
! |
|
1223 |
||
1224 |
modified:aBoolean |
|
1225 |
"set/clear the modified flag" |
|
1226 |
||
1227 |
modifiedChannel value:aBoolean |
|
1228 |
||
1229 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1230 |
! |
|
1231 |
||
1232 |
modifiedChannel |
|
1233 |
"return the valueHolder holding true if text was modified" |
|
1234 |
||
1235 |
^ modifiedChannel |
|
1236 |
! |
|
1237 |
||
1238 |
modifiedChannel:aValueHolder |
|
1239 |
"set the valueHolder holding true if text was modified" |
|
1240 |
||
1241 |
|prev| |
|
1242 |
||
1243 |
prev := modifiedChannel. |
|
1244 |
modifiedChannel := aValueHolder. |
|
1245 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1246 |
||
1247 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1248 |
! |
|
1249 |
||
1250 |
readOnly |
|
1251 |
"make the text readonly. |
|
4664 | 1252 |
Obsolete because it is obfuscating (looks like a getter) |
1253 |
- use #readOnly:" |
|
2792 | 1254 |
|
1255 |
<resource:#obsolete> |
|
1256 |
||
1257 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1258 |
self readOnly:true. |
2792 | 1259 |
|
4664 | 1260 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1261 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1262 |
! |
1263 |
||
1264 |
readOnly:aBoolean |
|
1265 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1266 |
The argument may also be a valueHolder." |
|
1267 |
||
1268 |
readOnly := aBoolean |
|
1269 |
||
1270 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1271 |
! |
|
1272 |
||
4782 | 1273 |
reallyModifiedChannel |
1274 |
"return the valueHolder holding true if text was really modified. |
|
1275 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1276 |
||
1277 |
^ self modifiedChannel |
|
1278 |
! |
|
1279 |
||
5255 | 1280 |
st80Mode:aBooleanOrNil |
4192 | 1281 |
"set/clear the st80Mode flag. |
1282 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1283 |
if off, we have the Rand-editor behavior (random access) |
1284 |
if nil, the setting follows the current userPref setting." |
|
1285 |
||
1286 |
st80Mode := aBooleanOrNil |
|
4192 | 1287 |
|
1288 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1289 |
! |
|
1290 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1291 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1292 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1293 |
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
|
1294 |
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
|
1295 |
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
|
1296 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1297 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1298 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1299 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1300 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1301 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1302 |
"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
|
1303 |
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
|
1304 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1305 |
|
3160 | 1306 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1307 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1308 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1309 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1310 |
"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
|
1311 |
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
|
1312 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1313 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1314 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1315 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1316 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1317 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1318 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1319 |
at:lineNr basicPut:aLine |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1320 |
"change a line without change notification" |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1321 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1322 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1323 |
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
|
1324 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1325 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1326 |
|
522 | 1327 |
at:lineNr put:aLine |
5393 | 1328 |
|oldLine| |
1329 |
||
1330 |
oldLine := (self at:lineNr) ? ''. |
|
1331 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
4823 | 1332 |
super at:lineNr put:aLine. |
1333 |
self textChanged |
|
522 | 1334 |
]. |
1335 |
! |
|
1336 |
||
4700 | 1337 |
characterAfterCursor |
1338 |
"return the character one after the cursor - space if beyond line." |
|
1339 |
||
1340 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1341 |
! |
|
1342 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1343 |
characterBeforeCursor |
4700 | 1344 |
"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
|
1345 |
|
5142 | 1346 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1347 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1348 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1349 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1350 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1351 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1352 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1353 |
characterUnderCursor |
2707 | 1354 |
"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
|
1355 |
For non-block cursors, this is the character immediately to the right |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1356 |
of the insertion-bar or caret." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1357 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1358 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1359 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1360 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1361 |
contents |
2213 | 1362 |
"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
|
1363 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1364 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1365 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1366 |
^ super contents. |
3313 | 1367 |
|
1368 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1369 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1370 |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1371 |
contents:something |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1372 |
self contents:something keepUndoHistory:false. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1373 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1374 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1375 |
contents:something keepUndoHistory:keepUndoHistory |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1376 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1377 |
keepUndoHistory ifFalse:[ |
4823 | 1378 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1379 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1380 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1381 |
|
2213 | 1382 |
contentsAsString |
1383 |
"return the contents as a String (i.e. without emphasis)" |
|
1384 |
||
1385 |
list isNil ifTrue:[^ '']. |
|
1386 |
self removeTrailingBlankLines. |
|
1387 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1388 |
ifFalse:[each string] |
1389 |
]) asStringWithCRs |
|
2213 | 1390 |
! |
1391 |
||
5067 | 1392 |
contentsAsStringWithTabs |
1393 |
"return the contents as a String (i.e. without emphasis) |
|
1394 |
and with leading spaces replaced by tab characters |
|
1395 |
(i.e. as would be written to a file)" |
|
1396 |
||
1397 |
list isNil ifTrue:[^ '']. |
|
1398 |
self removeTrailingBlankLines. |
|
1399 |
^ (list collect:[:each | |
|
1400 |
each isNil |
|
1401 |
ifTrue:[''] |
|
1402 |
ifFalse:[each string withTabs] |
|
1403 |
]) asStringWithCRs |
|
1404 |
! |
|
1405 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1406 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1407 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1408 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1409 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1410 |
^ cursorCol |
125 | 1411 |
! |
1412 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1413 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1414 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1415 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1416 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1417 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1418 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1419 |
cursorLine |
3160 | 1420 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1421 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1422 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1423 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1424 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1425 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1426 |
cursorLineHolder |
3160 | 1427 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1428 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1429 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1430 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1431 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1432 |
|
4713 | 1433 |
lineStringBeforeCursor |
1434 |
"return the line's string before the cursor. |
|
1435 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1436 |
||
1437 |
|line| |
|
1438 |
||
1439 |
line := ((self at:cursorLine) ? '') string. |
|
1440 |
line size < (cursorCol-1) ifTrue:[ |
|
1441 |
^ line paddedTo:(cursorCol-1) |
|
1442 |
]. |
|
1443 |
^ line copyTo:(cursorCol-1) |
|
1444 |
! |
|
1445 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1446 |
list:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1447 |
"position cursor home when setting contents" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1448 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1449 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1450 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1451 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1452 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1453 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1454 |
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
|
1455 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1456 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1457 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1458 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1459 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1460 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1461 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1462 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1463 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1464 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1465 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1466 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1467 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1468 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1469 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1470 |
^ 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
|
1471 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1472 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1473 |
"/ 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
|
1474 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1475 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1476 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1477 |
setContents:something |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1478 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1479 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1480 |
undoSupport resetHistories. |
2955 | 1481 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1482 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1483 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1484 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1485 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1486 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1487 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1488 |
|
4609 | 1489 |
!EditTextView methodsFor:'accessing-dimensions'! |
1490 |
||
1491 |
xOfCursor |
|
4728 | 1492 |
|point| |
1493 |
||
1494 |
cursorVisibleLine isNil ifTrue:[ |
|
1495 |
"/ take the end of the selection, if any |
|
1496 |
(selectionStartLine notNil |
|
1497 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1498 |
ifTrue:[ |
|
1499 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1500 |
]. |
|
1501 |
||
1502 |
"/ point := device |
|
1503 |
"/ translatePoint:(device pointerPosition) |
|
1504 |
"/ fromView:nil |
|
1505 |
"/ toView:self. |
|
1506 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1507 |
"/ ^ point x |
|
1508 |
"/ ]. |
|
1509 |
"/ ^ 0 |
|
1510 |
^ nil |
|
1511 |
]. |
|
4609 | 1512 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1513 |
||
1514 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1515 |
! ! |
|
4590 | 1516 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1517 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1518 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1519 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1520 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1521 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1522 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1523 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1524 |
wasOn := self hideCursor. |
4940 | 1525 |
cursorFgColor := color1 onDevice:self graphicsDevice. |
1526 |
cursorBgColor := color2 onDevice:self graphicsDevice. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1527 |
wasOn ifTrue:[self showCursor] |
1333 | 1528 |
! |
1529 |
||
1899 | 1530 |
cursorType |
1531 |
"return the style of the text cursor. |
|
4721 | 1532 |
Currently, supported are: #none |
1533 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1534 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1535 |
|
1536 |
^ cursorType |
|
1537 |
||
1538 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1539 |
! |
|
1540 |
||
1333 | 1541 |
cursorType:aCursorTypeSymbol |
1542 |
"set the style of the text cursor. |
|
4721 | 1543 |
Currently, supported are: #none |
1544 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1545 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1546 |
|
1334 | 1547 |
cursorType := aCursorTypeSymbol. |
1333 | 1548 |
|
1549 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1550 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1551 |
! |
1552 |
||
1899 | 1553 |
cursorTypeNoFocus |
1554 |
"return the style of the text cursor when the view has no focus. |
|
1555 |
If left unspecified, this is the same as the regular cursorType." |
|
1556 |
||
1557 |
^ cursorTypeNoFocus |
|
1558 |
||
1559 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1560 |
! |
|
1561 |
||
1334 | 1562 |
cursorTypeNoFocus:aCursorTypeSymbol |
1563 |
"set the style of the text cursor when the view has no focus. |
|
1564 |
If left unspecified, this is the same as the regular cursorType." |
|
1565 |
||
1566 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1567 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1568 |
|
4048 | 1569 |
!EditTextView methodsFor:'accessing-replace'! |
1570 |
||
4746 | 1571 |
lastReplacementInfo |
1572 |
^ lastReplacementInfo |
|
1573 |
! |
|
1574 |
||
4048 | 1575 |
lastStringToReplace: aString |
4818 | 1576 |
! |
1577 |
||
1578 |
previousReplacements |
|
1579 |
"accessor for the code completion" |
|
1580 |
||
1581 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1582 |
! ! |
1583 |
||
2119 | 1584 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1585 |
|
125 | 1586 |
accept |
1587 |
"accept the current contents by executing the accept-action and/or |
|
1588 |
changeMessage." |
|
1589 |
||
1108 | 1590 |
acceptEnabled == false ifTrue:[ |
3945 | 1591 |
self beep. |
1592 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1593 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1594 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1595 |
^ self |
1108 | 1596 |
]. |
1597 |
||
125 | 1598 |
lockUpdates := true. |
1013 | 1599 |
|
1600 |
"/ |
|
1601 |
"/ ST-80 way of doing it |
|
1602 |
"/ |
|
1603 |
model notNil ifTrue:[ |
|
4142 | 1604 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
3945 | 1605 |
acceptChannel value:true withoutNotifying:self. |
2999 | 1606 |
]. |
1607 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1608 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1609 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1610 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1611 |
"/ 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
|
1612 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1613 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1614 |
acceptAction notNil ifTrue:[ |
3945 | 1615 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1616 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1617 |
|
125 | 1618 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1619 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1620 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1621 |
! |
1622 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1623 |
argForChangeMessage |
597 | 1624 |
"return the argument to be passed with the change notification. |
1625 |
Defined as separate method for easier subclassability." |
|
1626 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1627 |
^ self contents |
597 | 1628 |
|
1629 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1630 |
! |
1631 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1632 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1633 |
"get my contents from the model. |
597 | 1634 |
Redefined to ignore updates resulting from my own changes |
1635 |
(i.e. if lockUpdates is true)." |
|
121 | 1636 |
|
1637 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1638 |
ignore updates from my own change |
121 | 1639 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1640 |
lockUpdates ifTrue:[ |
4823 | 1641 |
lockUpdates := false. |
1642 |
^ self |
|
121 | 1643 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1644 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1645 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1646 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1647 |
"/ validate the cursorLine |
3160 | 1648 |
(cursorLine notNil |
2310 | 1649 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1650 |
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
|
1651 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1652 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1653 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1654 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1655 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1656 |
acceptChannel value == true ifTrue:[ |
1657 |
self accept. |
|
1658 |
]. |
|
1659 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1660 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1661 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1662 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1663 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1664 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1665 |
! ! |
1666 |
||
1667 |
!EditTextView methodsFor:'cursor handling'! |
|
1668 |
||
4820 | 1669 |
basicCursorReturn |
1670 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1671 |
||
1672 |
|wasOn| |
|
1673 |
||
1674 |
self checkForExistingLine:(cursorLine + 1). |
|
1675 |
cursorVisibleLine notNil ifTrue:[ |
|
1676 |
nFullLinesShown notNil ifTrue:[ |
|
1677 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1678 |
] |
|
1679 |
]. |
|
1680 |
||
1681 |
wasOn := self hideCursor. |
|
1682 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1683 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1684 |
||
1685 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1686 |
! |
|
1687 |
||
2406 | 1688 |
characterPositionOfCursor |
1689 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1690 |
! |
|
1691 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1692 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1693 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1694 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1695 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1696 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1697 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1698 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1699 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1700 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1701 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1702 |
|
2822 | 1703 |
(cursorCol == newCol) ifTrue:[^ self]. |
1704 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1705 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1706 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1707 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1708 |
|
1709 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1710 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1711 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1712 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1713 |
"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
|
1714 |
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
|
1715 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1716 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1717 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1718 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1719 |
|
2707 | 1720 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1721 |
cursorLine > list size ifTrue:[ |
4595 | 1722 |
wasOn := self hideCursor. |
1723 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1724 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1725 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1726 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1727 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1728 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1729 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1730 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1731 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1732 |
"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
|
1733 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1734 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1735 |
|
4595 | 1736 |
(nL := cursorLine) isNil ifTrue:[ |
1737 |
nL := firstLineShown |
|
1738 |
]. |
|
1739 |
||
1740 |
self st80EditMode ifTrue:[ |
|
1741 |
nL == list size ifTrue:[ |
|
1742 |
wasOn := self hideCursor. |
|
1743 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1744 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1745 |
self beep. |
|
1746 |
^ self. |
|
1747 |
] |
|
1748 |
]. |
|
1749 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1750 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1751 |
wasOn := self hideCursor. |
1752 |
nv := cursorVisibleLine + n - 1. |
|
1753 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1754 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1755 |
]. |
|
1756 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1757 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1758 |
] ifFalse:[ |
4595 | 1759 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1760 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1761 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1762 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1763 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1764 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1765 |
|
121 | 1766 |
cursorHome |
597 | 1767 |
"scroll to top AND move cursor to first line of text." |
121 | 1768 |
|
674 | 1769 |
self cursorLine:1 col:1 |
1770 |
||
1771 |
"/ |wasOn| |
|
1772 |
"/ |
|
1773 |
"/ wasOn := self hideCursor. |
|
1774 |
"/ self scrollToTop. |
|
1775 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1776 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1777 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1778 |
||
1779 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1780 |
! |
1781 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1782 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1783 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1784 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1785 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1786 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1787 |
] ifFalse:[ |
4823 | 1788 |
cursorLine ~~ 1 ifTrue:[ |
1789 |
self st80EditMode ifTrue:[ |
|
1790 |
self cursorUp. |
|
1791 |
self cursorToEndOfLine. |
|
1792 |
] |
|
1793 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1794 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1795 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1796 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1797 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1798 |
|
4126 | 1799 |
cursorLeft:n |
1800 |
"move cursor to left" |
|
1801 |
||
1802 |
n timesRepeat:[ |
|
1803 |
self cursorLeft |
|
1804 |
]. |
|
1805 |
! |
|
1806 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1807 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1808 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1809 |
|
5056 | 1810 |
self cursorLine:line col:col makeVisible:true |
1811 |
! |
|
1812 |
||
1813 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
1814 |
"this positions onto physical - not visible - line" |
|
1815 |
||
676 | 1816 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1817 |
|
2822 | 1818 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1819 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1820 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1821 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1822 |
|
672 | 1823 |
(col < 1) ifTrue:[ |
4823 | 1824 |
newCol := 1 |
672 | 1825 |
] ifFalse:[ |
4823 | 1826 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1827 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1828 |
self st80EditMode ifTrue:[ |
4823 | 1829 |
(cursorLine == list size |
1830 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1831 |
newCol := (self listAt:(list size)) size + 1. |
|
1832 |
] |
|
1419 | 1833 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1834 |
self setValidatedCursorCol:newCol. |
5056 | 1835 |
makeVisibleBoolean ifTrue:[ |
1836 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1837 |
] ifFalse:[ |
|
1838 |
wasOn ifTrue:[self showCursor] |
|
1839 |
]. |
|
672 | 1840 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1841 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1842 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1843 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1844 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1845 |
"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
|
1846 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1847 |
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
|
1848 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1849 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1850 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1851 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1852 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1853 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1854 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1855 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1856 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1857 |
"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
|
1858 |
|
4820 | 1859 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1860 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1861 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1862 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1863 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1864 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1865 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1866 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1867 |
self st80EditMode ifTrue:[ |
4823 | 1868 |
l := (self listAt:cursorLine). |
1869 |
cursorCol >= (l size + 1) ifTrue:[ |
|
1870 |
cursorLine < list size ifTrue:[ |
|
1871 |
self cursorReturn. |
|
1872 |
]. |
|
1873 |
^ self |
|
1874 |
] |
|
3160 | 1875 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1876 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1877 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1878 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1879 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1880 |
|
4126 | 1881 |
cursorRight:n |
1882 |
"move cursor to right" |
|
1883 |
||
1884 |
n timesRepeat:[ |
|
1885 |
self cursorRight |
|
1886 |
]. |
|
1887 |
! |
|
1888 |
||
1833 | 1889 |
cursorShown:aBoolean |
1890 |
"change cursor visibility |
|
1891 |
return true if cursor was visible before." |
|
1892 |
||
1893 |
|oldState| |
|
1894 |
||
4494 | 1895 |
aBoolean == cursorShown ifTrue:[ |
1896 |
^ cursorShown |
|
1897 |
]. |
|
1833 | 1898 |
oldState := cursorShown. |
1899 |
||
1900 |
aBoolean ifTrue:[ |
|
4494 | 1901 |
self drawCursor. |
1833 | 1902 |
] ifFalse:[ |
4494 | 1903 |
(cursorShown and:[shown]) ifTrue: [ |
1904 |
self undrawCursor. |
|
1905 |
]. |
|
1833 | 1906 |
]. |
1907 |
cursorShown := aBoolean. |
|
1908 |
||
1909 |
^ oldState |
|
1910 |
||
1911 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1912 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1913 |
! |
|
1914 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1915 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1916 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1917 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1918 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1919 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1920 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1921 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1922 |
"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
|
1923 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1924 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1925 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1926 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1927 |
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
|
1928 |
cursorCol > textStart ifTrue:[ |
4823 | 1929 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1930 |
] ifFalse:[ |
4823 | 1931 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1932 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1933 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1934 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1935 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1936 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1937 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1938 |
"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
|
1939 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1940 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1941 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1942 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1943 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1944 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1945 |
(newTop < 1) ifTrue:[ |
4823 | 1946 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1947 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1948 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1949 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1950 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1952 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1953 |
|
674 | 1954 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1955 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1956 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1957 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1958 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1959 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1960 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1961 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1962 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1963 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1964 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1965 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1966 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1967 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1968 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1969 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1970 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1971 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1972 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1973 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1974 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1975 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1976 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1977 |
cursorLine >= lineNr ifTrue:[ |
4823 | 1978 |
line := self listAt:cursorLine. |
1979 |
(line isEmptyOrNil) ifTrue:[ |
|
1980 |
^ self |
|
1981 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1982 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1984 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1985 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1986 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1987 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1988 |
(newTop < 1) ifTrue:[ |
4823 | 1989 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1990 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1991 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1992 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1993 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1994 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1995 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1996 |
|
674 | 1997 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1998 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1999 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2000 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2001 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2002 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2003 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2004 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2005 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2006 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2007 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2008 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2009 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2010 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2011 |
cursorToEndOfText |
4288 | 2012 |
"move cursor to the end of the text (behind the last character in last line)" |
2013 |
||
2014 |
|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
|
2015 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2016 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2017 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2018 |
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
|
2019 |
(newTop < 1) ifTrue:[ |
4288 | 2020 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2021 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2022 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2023 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2024 |
self setValidatedCursorLine:list size. |
4288 | 2025 |
lastLineLength := (self listAt:cursorLine) size. |
2026 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2027 |
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
|
2028 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2029 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2030 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2031 |
"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
|
2032 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2033 |
|
3310 | 2034 |
cursorToEndOfWord |
2035 |
"move the cursor to the end of the word" |
|
2036 |
||
2037 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2038 |
||
2039 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2040 |
:beginLine :beginCol :endLine :endCol :style | |
2041 |
||
2042 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2043 |
] |
2044 |
||
2045 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2046 |
! |
|
2047 |
||
131 | 2048 |
cursorToFirstVisibleLine |
2049 |
"place cursor into the first visible line; do not scroll." |
|
2050 |
||
2051 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2052 |
! |
|
2053 |
||
2054 |
cursorToLastVisibleLine |
|
2055 |
"place cursor into the first visible line; do not scroll." |
|
2056 |
||
2057 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2058 |
! |
|
2059 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2060 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2061 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2062 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2063 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2064 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2065 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2066 |
|
3890 | 2067 |
self |
4707 | 2068 |
wordAtLine:cursorLine col:cursorCol |
2069 |
do:[ |
|
3890 | 2070 |
:beginLine :beginCol :endLine :endCol :style | |
2071 |
||
2072 |
line := endLine. |
|
2073 |
col := endCol + 1. |
|
2074 |
searching := true. |
|
4707 | 2075 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2076 |
self wordAtLine:line col:col do:[ |
2077 |
:beginLine :beginCol :endLine :endCol :style | |
|
2078 |
||
2079 |
(line > list size) ifTrue:[ |
|
2080 |
"break out" |
|
2081 |
searching := false |
|
2082 |
] ifFalse:[ |
|
2083 |
line := endLine. |
|
2084 |
col := endCol + 1. |
|
2085 |
] |
|
2086 |
] |
|
2087 |
]. |
|
2088 |
self cursorLine:line col:col |
|
4707 | 2089 |
] |
121 | 2090 |
! |
2091 |
||
499 | 2092 |
cursorToPreviousWord |
2093 |
"move the cursor to the beginning of this or the previous word" |
|
2094 |
||
2095 |
|col line searching l| |
|
2096 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2097 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2098 |
|
2099 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2100 |
:beginLine :beginCol :endLine :endCol :style | |
2101 |
||
2102 |
line := beginLine. |
|
2103 |
col := beginCol. |
|
2104 |
style == #wordLeft ifTrue:[ |
|
2105 |
col := col + 1 |
|
2106 |
]. |
|
2107 |
||
2108 |
(cursorLine == line |
|
2109 |
and:[cursorCol == col]) ifTrue:[ |
|
2110 |
searching := true. |
|
2111 |
||
2112 |
col > 1 ifTrue:[ |
|
2113 |
col := col - 1. |
|
2114 |
]. |
|
2115 |
||
2116 |
[searching] whileTrue:[ |
|
2117 |
(col == 1) ifTrue:[ |
|
2118 |
line == 1 ifTrue:[ |
|
2119 |
searching := false |
|
2120 |
] ifFalse:[ |
|
2121 |
line := line - 1. |
|
2122 |
l := list at:line. |
|
2123 |
col := l size + 1. |
|
2124 |
] |
|
2125 |
] ifFalse:[ |
|
2126 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2127 |
self wordAtLine:line col:col do:[ |
|
2128 |
:beginLine :beginCol :endLine :endCol :style | |
|
2129 |
||
2130 |
line := beginLine. |
|
2131 |
col := beginCol. |
|
2132 |
style == #wordLeft ifTrue:[ |
|
2133 |
col := col + 1 |
|
2134 |
]. |
|
2135 |
searching := false. |
|
2136 |
] |
|
2137 |
] ifTrue:[ |
|
2138 |
col := col - 1 |
|
2139 |
] |
|
2140 |
] |
|
2141 |
] |
|
2142 |
]. |
|
2143 |
self cursorLine:line col:col |
|
499 | 2144 |
] |
2145 |
||
2146 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2147 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2148 |
! |
|
2149 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2150 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2151 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2152 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2153 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2154 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2155 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2156 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2157 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2158 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2159 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2160 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2161 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2162 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2163 |
"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
|
2164 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2165 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2166 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2167 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2168 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2169 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2170 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2171 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2172 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2173 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2174 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2175 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2176 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2177 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2178 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2179 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2180 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2181 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2182 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2183 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2184 |
] |
672 | 2185 |
|
674 | 2186 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2187 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2188 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2189 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2190 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2191 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2192 |
|wasOn newCol listLine| |
259
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 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2195 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2196 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2197 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2198 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2199 |
|
676 | 2200 |
newCol := colNr. |
2201 |
(newCol < 1) ifTrue:[ |
|
4823 | 2202 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2203 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2204 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2205 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2206 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2207 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2208 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2209 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2210 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2211 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2212 |
"put cursor to position next to x/y coordinate in view" |
121 | 2213 |
|
2214 |
|line col| |
|
2215 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2216 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2217 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2218 |
self cursorVisibleLine:line col:col. |
121 | 2219 |
! |
2220 |
||
2221 |
drawCursor |
|
2222 |
"draw the cursor if shown and cursor is visible. |
|
2223 |
(but not, if there is a selection - to avoid confusion)" |
|
2224 |
||
2225 |
shown ifTrue:[ |
|
4823 | 2226 |
cursorVisibleLine notNil ifTrue:[ |
2227 |
self hasSelection ifFalse:[ |
|
2228 |
self drawCursorCharacter |
|
2229 |
] |
|
2230 |
] |
|
121 | 2231 |
] |
2232 |
! |
|
2233 |
||
2234 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2235 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2236 |
of cursor should be drawn. |
4721 | 2237 |
Currently, supported are: #none, |
2238 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2239 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2240 |
|
2570 | 2241 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2242 |
|
2243 |
self hasSelection ifTrue:[ |
|
4580 | 2244 |
" |
2245 |
hide cursor, if there is a selection |
|
2246 |
" |
|
2247 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2248 |
]. |
2249 |
||
1334 | 2250 |
cursorType == #none ifTrue:[ |
4580 | 2251 |
^ self |
1334 | 2252 |
]. |
2253 |
||
121 | 2254 |
cursorType == #block ifTrue:[ |
4829 | 2255 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2256 |
^ self |
121 | 2257 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2258 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2259 |
y := self yOfVisibleLine:cursorVisibleLine. |
2260 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2261 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2262 |
cursorType == #frame ifTrue:[ |
4580 | 2263 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2264 |
||
2265 |
char := self characterUnderCursor asString. |
|
4829 | 2266 |
self paint:bgColor. |
4889 | 2267 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2268 |
] ifFalse:[ |
4580 | 2269 |
self paint:bgColor. |
2270 |
cursorType == #ibeam ifTrue:[ |
|
2271 |
x1 := x - 1. |
|
2272 |
y2 := y + fontHeight - lineSpacing. |
|
2273 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2274 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2275 |
^ self |
|
2276 |
]. |
|
2277 |
||
2278 |
cursorType == #Ibeam ifTrue:[ |
|
2279 |
x1 := x - 1. |
|
2280 |
y := y + 1. |
|
2281 |
y2 := y + fontHeight - lineSpacing. |
|
2282 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
|
2283 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2284 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2285 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2286 |
^ self |
|
2287 |
]. |
|
2288 |
||
2289 |
y := y + fontHeight - 3. |
|
2290 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2291 |
w := (fontWidth * 2 // 3) max:4. |
|
2292 |
y2 := y + w + (w//2). |
|
2293 |
] ifFalse:[ |
|
2294 |
w := (fontWidth // 2) max:4. |
|
2295 |
y2 := y + w. |
|
2296 |
]. |
|
2297 |
x1 := x - w. |
|
2298 |
x2 := x + w. |
|
2299 |
||
2300 |
oldClip := self clippingRectangleOrNil. |
|
2301 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2302 |
||
2303 |
cursorType == #caret ifTrue:[ |
|
2304 |
self lineWidth:2. |
|
2305 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2306 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2307 |
] ifFalse:[ |
|
2308 |
"anything else: solidCaret" |
|
2309 |
||
2310 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2311 |
with:(x @ y) |
|
2312 |
with:(x2 @ y2)) |
|
2313 |
]. |
|
2314 |
||
2315 |
self clippingRectangle:oldClip |
|
121 | 2316 |
]. |
133 | 2317 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2318 |
|
2088 | 2319 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2320 |
! |
2321 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2322 |
drawCursorCharacter |
3160 | 2323 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2324 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2325 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2326 |
|
3160 | 2327 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2328 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2329 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2330 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2331 |
] ifFalse:[ |
4823 | 2332 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2333 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2334 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2335 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2336 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2337 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2338 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2339 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2340 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2341 |
self hasSelection ifTrue:[ |
5260 | 2342 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2343 |
]. |
2344 |
cursorType == #none ifTrue:[ |
|
4823 | 2345 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2346 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2347 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2348 |
|
2349 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2350 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2351 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2352 |
drawNoFocusCursor |
3160 | 2353 |
"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
|
2354 |
|
1334 | 2355 |
|cType| |
2356 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2357 |
self hasSelection ifTrue:[ |
4823 | 2358 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2359 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2360 |
|
1334 | 2361 |
cType := cursorTypeNoFocus ? cursorType. |
2362 |
cType == #none ifTrue:[ |
|
4823 | 2363 |
^ self undrawCursor |
1334 | 2364 |
]. |
2365 |
||
2366 |
cType == #block ifTrue:[ |
|
4823 | 2367 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2368 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2369 |
|
1334 | 2370 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2371 |
||
2372 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2373 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2374 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2375 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2376 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2377 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2378 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2379 |
self makeLineVisible:aLineNumber. |
2951 | 2380 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2381 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2382 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2383 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2384 |
hideCursor |
1833 | 2385 |
"make cursor invisible if currently invisible" |
2386 |
||
2387 |
^ self cursorShown:false |
|
2388 |
||
2389 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2390 |
! |
2391 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2392 |
makeCursorVisible |
3160 | 2393 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2394 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2395 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2396 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2397 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2398 |
cursorLine notNil ifTrue:[ |
4823 | 2399 |
line := cursorLine. |
2400 |
col := cursorCol. |
|
2401 |
" |
|
2402 |
if there is a selection, its better to |
|
2403 |
have its start being visible, instead of the end |
|
2404 |
" |
|
2405 |
(selectionStartLine notNil |
|
2406 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2407 |
expandingTop ~~ false ifTrue:[ |
|
2408 |
line := selectionStartLine. |
|
2409 |
col := selectionStartCol. |
|
2410 |
] ifFalse:[ |
|
2411 |
line := selectionEndLine. |
|
2412 |
col := selectionEndCol |
|
2413 |
] |
|
2414 |
]. |
|
2415 |
self makeLineVisible:line. |
|
2416 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2417 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2418 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2419 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2420 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2421 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2422 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2423 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2424 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2425 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2426 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2427 |
flag ifTrue:[self showCursor] |
121 | 2428 |
! |
2429 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2430 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2431 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2432 |
|
2815 | 2433 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2434 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2435 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2436 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2437 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2438 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2439 |
|
3303 | 2440 |
"/ self assert:(lineNr notNil). |
2441 |
||
2442 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2443 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2444 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2445 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2446 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2447 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2448 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2449 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2450 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2451 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2452 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2453 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2454 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2455 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2456 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2457 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2458 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2459 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2460 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2461 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2462 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2463 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2464 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2465 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2466 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2467 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2468 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2469 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2470 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2471 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2472 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2473 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2474 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2475 |
|
1833 | 2476 |
^ self cursorShown:true |
2477 |
||
2478 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2481 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2482 |
"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
|
2483 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2484 |
|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
|
2485 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2486 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2487 |
prevCol := cursorCol - 1. |
2488 |
||
2489 |
"/ if there is any italic stuff in the cursor line, |
|
2490 |
"/ redraw it completely (because characters overlap). |
|
2491 |
cursorCol > 1 ifTrue:[ |
|
2492 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2493 |
line hasChangeOfEmphasis ifTrue:[ |
|
2494 |
line size >= (cursorCol-1) ifTrue:[ |
|
2495 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2496 |
line size >= (cursorCol) ifTrue:[ |
|
2497 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2498 |
line size >= (cursorCol+1) ifTrue:[ |
|
2499 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2500 |
]. |
|
2501 |
]. |
|
2502 |
]. |
|
2503 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2504 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2505 |
] |
|
2506 |
] |
|
2507 |
] |
|
2508 |
]. |
|
2509 |
||
2510 |
((cursorType == #caret) |
|
2511 |
or:[cursorType == #solidCaret |
|
2512 |
or:[cursorType == #bigSolidCaret |
|
2513 |
or:[cursorType == #bigCaret |
|
2514 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2515 |
"caret-cursor touches 4 characters" |
|
2516 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2517 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2518 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2519 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2520 |
] ifFalse:[ |
|
2521 |
"care for left margin" |
|
2522 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2523 |
]. |
|
2524 |
^ self |
|
2525 |
]. |
|
2526 |
||
2527 |
cursorType == #ibeam ifTrue:[ |
|
2528 |
"ibeam-cursor touches 2 characters" |
|
2529 |
cursorCol > 1 ifTrue:[ |
|
2530 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2531 |
] ifFalse:[ |
|
2532 |
"care for left margin" |
|
2533 |
super redrawVisibleLine:cursorVisibleLine. |
|
2534 |
]. |
|
2535 |
^ self |
|
2536 |
]. |
|
2537 |
||
2538 |
"block cursor is simple - just one character under cursor" |
|
2539 |
||
2540 |
"/ however, if italic characters are involved, we must care |
|
2541 |
"/ for the chars before/after the cursor. |
|
2542 |
"/ We redraw the part of the previous character which got |
|
2543 |
"/ detroyed by the block cursor. |
|
2544 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2545 |
||
2546 |
line := self visibleAt:cursorVisibleLine. |
|
2547 |
(line notNil and:[line isText]) ifTrue:[ |
|
2548 |
cursorCol > 1 ifTrue:[ |
|
2549 |
oldClip := self clippingRectangleOrNil. |
|
2550 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2551 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2552 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2553 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2554 |
self clippingRectangle:oldClip. |
|
2555 |
^ self. |
|
2556 |
]. |
|
2557 |
]. |
|
2558 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2559 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2560 |
|
2088 | 2561 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2562 |
! |
2563 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2564 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2565 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2566 |
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
|
2567 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2568 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2569 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2570 |
|
672 | 2571 |
validateCursorCol:col inLine:line |
674 | 2572 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2573 |
Here, no limits are enforced (and col is returned), |
2574 |
but it may be redefined in EditFields or views which dont like the |
|
674 | 2575 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2576 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2577 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2578 |
|
1419 | 2579 |
"/ in ST80 mode, |
2707 | 2580 |
"/ the cursor may not be positioned beyond the |
2581 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2582 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2583 |
self st80EditMode ifTrue:[ |
4823 | 2584 |
l := (self listAt:line). |
2585 |
max := l size + 1. |
|
2586 |
col > max ifTrue:[ |
|
2587 |
^ max |
|
2588 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2589 |
]. |
672 | 2590 |
^ col |
2591 |
||
1419 | 2592 |
"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
|
2593 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2594 |
! |
2595 |
||
2596 |
validateCursorLine:line |
|
2597 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2598 |
Here, no limits are enforced (and line is returned), but it may be |
674 | 2599 |
redefined in views which dont like the cursor to be positioned |
2600 |
behind the end of the text (vi/st-80 behavior), or want to |
|
2601 |
skip reserved regions" |
|
2602 |
||
1419 | 2603 |
"/ |
2604 |
"/ in st80Mode, the cursor may not be positioned |
|
5367 | 2605 |
"/ beyond the last line |
2606 |
"/ (but it must be posible to place it on one line below the last one |
|
2607 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
|
1419 | 2608 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2609 |
self st80EditMode ifTrue:[ |
5367 | 2610 |
^ (line min:(list size + 1)) max:1 |
1419 | 2611 |
]. |
674 | 2612 |
^ line |
2613 |
||
1419 | 2614 |
"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
|
2615 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2616 |
! |
2617 |
||
121 | 2618 |
withCursorOffDo:aBlock |
2619 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2620 |
||
2621 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2622 |
^ aBlock value |
121 | 2623 |
]. |
2624 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2625 |
aBlock ensure:[ |
4823 | 2626 |
self showCursor |
121 | 2627 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2628 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2629 |
|
2589 | 2630 |
!EditTextView methodsFor:'drag & drop'! |
2631 |
||
2632 |
allowDrop:aBoolean |
|
3236 | 2633 |
"enable/disable drop support" |
2634 |
||
2589 | 2635 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2636 |
dropTarget := nil. |
2589 | 2637 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2638 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2639 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2640 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2641 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2642 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2643 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2644 |
] |
3236 | 2645 |
]. |
2646 |
! |
|
2647 |
||
3412 | 2648 |
canDrop:aDropContext |
2649 |
"public from d&d. |
|
2650 |
I accept textObjects and fileObjects only." |
|
2651 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2652 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2653 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2654 |
^ self canDropObjects:aDropContext dropObjects |
|
2655 |
||
2656 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2657 |
! |
|
2658 |
||
2659 |
canDropObjects:aCollectionOfDropObjects |
|
2660 |
"public from d&d. |
|
2661 |
I accept textObjects and fileObjects only." |
|
2589 | 2662 |
|
2663 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2664 |
||
3412 | 2665 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2666 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2667 |
||
2668 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2669 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2670 |
! |
|
2671 |
||
2672 |
drop:aDropContext |
|
2673 |
"public from d&d. |
|
2674 |
drop objects (new API)" |
|
2675 |
||
2676 |
self dropObjects:(aDropContext dropObjects) |
|
2677 |
||
2678 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2679 |
! |
|
2680 |
||
2681 |
dropFileObject:aDropObject |
|
2589 | 2682 |
"drop objects |
3236 | 2683 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2684 |
||
4136 | 2685 |
|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
|
2686 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2687 |
pasteWhat := #name. |
3412 | 2688 |
|
2689 |
fn := aDropObject asFilename. |
|
2690 |
(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
|
2691 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2692 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2693 |
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
|
2694 |
pasteWhat := enforcedDropMode. |
3886 | 2695 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2696 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2697 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2698 |
pasteWhat := #name. |
3886 | 2699 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2700 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2701 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2702 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2703 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2704 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2705 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2706 |
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
|
2707 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2708 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2709 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2710 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2711 |
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
|
2712 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2713 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2714 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2715 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2716 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2717 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2718 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2719 |
] |
3886 | 2720 |
] |
2721 |
]. |
|
2722 |
]. |
|
2723 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2724 |
pasteWhat == #name ifTrue:[ |
3886 | 2725 |
text := fn pathName |
2726 |
] ifFalse:[ |
|
2727 |
self withWaitCursorDo:[ |
|
5063 | 2728 |
text := fn contentsAsString |
4136 | 2729 |
]. |
2730 |
(app := self application) notNil ifTrue:[ |
|
2731 |
app droppedFile:fn in:self |
|
2732 |
]. |
|
3886 | 2733 |
]. |
2734 |
||
3799 | 2735 |
self |
2736 |
undoablePaste:text |
|
2737 |
info:'Drop File'. |
|
3412 | 2738 |
|
2739 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2740 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2741 |
! |
2742 |
||
2743 |
dropObject:aDropObject |
|
2744 |
"drop objects |
|
2745 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2746 |
||
3415 | 2747 |
|text| |
2748 |
||
3412 | 2749 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2750 |
self dropFileObject:aDropObject |
3412 | 2751 |
] ifFalse:[ |
3799 | 2752 |
aDropObject isTextObject ifTrue:[ |
2753 |
text := aDropObject theObject. |
|
2754 |
text isStringCollection ifTrue:[ |
|
2755 |
text := text asStringWithoutFinalCR |
|
2756 |
]. |
|
2757 |
] ifFalse:[ |
|
2758 |
text := aDropObject theObject asString |
|
2759 |
]. |
|
2760 |
self |
|
2761 |
undoablePaste:text |
|
2762 |
info:'Drop'. |
|
3412 | 2763 |
]. |
2764 |
||
2765 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2766 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2767 |
! |
2768 |
||
2769 |
dropObjects:aCollectionOfDropObjects |
|
2770 |
"public from d&d. |
|
2771 |
drop objects (old API)" |
|
2772 |
||
3868 | 2773 |
aCollectionOfDropObjects do:[:el | |
2774 |
self dropObject:el |
|
3412 | 2775 |
]. |
2776 |
||
2777 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2778 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2779 |
! ! |
2780 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2781 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2782 |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2783 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2784 |
"toLower/toUppercaseFirst/toUpper selected text" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2785 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2786 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2787 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2788 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2789 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2790 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2791 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2792 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2793 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2794 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2795 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2796 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2797 |
line1 to:line2 do:[:lineNr | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2798 |
|line col1 col2 isAllLower isLowerFirst isAllUpper isUpperFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2799 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2800 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2801 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2802 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2803 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2804 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2805 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2806 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2807 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2808 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2809 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2810 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2811 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2812 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2813 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2814 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2815 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2816 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2817 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2818 |
ch isUppercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2819 |
isAllLower := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2820 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2821 |
isLowerFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2822 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2823 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2824 |
ch isLowercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2825 |
isAllUpper := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2826 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2827 |
isUpperFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2828 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2829 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2830 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2831 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2832 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2833 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2834 |
isLowerFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2835 |
makeUppercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2836 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2837 |
"/ must remember where we come from - otherwise, we end up |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2838 |
"/ in upperFirst - lowerFirst cycle. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2839 |
"/ think about a good place to store this state |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2840 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2841 |
makeLowercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2842 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2843 |
isAllUpper ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2844 |
makeLowercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2845 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2846 |
makeUppercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2847 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2848 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2849 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2850 |
makeUppercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2851 |
line at:col1 put:(line at:col1) asUppercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2852 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2853 |
makeLowercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2854 |
line at:col1 put:(line at:col1) asLowercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2855 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2856 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2857 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2858 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2859 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2860 |
ch := makeLowercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2861 |
ifTrue:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2862 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2863 |
makeUppercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2864 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2865 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2866 |
col == col1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2867 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2868 |
ifFalse:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2869 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2870 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2871 |
line at:col put:ch. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2872 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2873 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2874 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2875 |
self withoutRedrawAt:lineNr put:line. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2876 |
self invalidateLine:lineNr. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2877 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2878 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2879 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2880 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2881 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2882 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2883 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2884 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2885 |
"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
|
2886 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2887 |
selectionStartLine notNil ifTrue:[ |
4823 | 2888 |
self setClipboardText:(self selection). |
2889 |
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
|
2890 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2891 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2892 |
"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
|
2893 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2894 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2895 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2896 |
"delete single character under cursor; does not merge lines" |
121 | 2897 |
|
2898 |
|wasOn| |
|
2899 |
||
2900 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2901 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2902 |
wasOn ifTrue:[self showCursor] |
2903 |
! |
|
2904 |
||
827 | 2905 |
deleteCharAtLine:lineNr col:colNr |
2906 |
"delete a single character at colNr in line lineNr" |
|
2907 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2908 |
self st80EditMode ifTrue:[ |
4823 | 2909 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2910 |
| wasOn | |
|
2911 |
wasOn := self hideCursor. |
|
2912 |
self |
|
2913 |
cursorReturn; |
|
2914 |
cursorCol:1; |
|
2915 |
deleteCharBeforeCursor. |
|
2916 |
wasOn ifTrue:[ self showCursor]. |
|
2917 |
^ self. |
|
2918 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2919 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2920 |
|
827 | 2921 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2922 |
! |
|
2923 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2924 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2925 |
"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
|
2926 |
|
4592 | 2927 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 2928 |
|
2929 |
wasOn := self hideCursor. |
|
4814 | 2930 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 2931 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
4966 | 2932 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
4592 | 2933 |
ln size < prevTab ifTrue:[ |
2934 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2935 |
]. |
|
2936 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2937 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2938 |
cursorCol > prevTab ifTrue:[ |
|
2939 |
self st80EditMode ifTrue:[ |
|
2940 |
"/ ensure that there is no conflict here: st80EditMode will |
|
2941 |
"/ not allow a cursor position beyond the end of line, |
|
2942 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
|
2943 |
originalLine size < prevTab ifTrue:[ |
|
4771 | 2944 |
self basicListAt:cursorLine put:ln |
4592 | 2945 |
] |
2946 |
]. |
|
2947 |
self cursorLine:cursorLine col:prevTab. |
|
2948 |
wasOn ifTrue:[ self showCursor ]. |
|
2949 |
^ self |
|
2950 |
]. |
|
2951 |
] ifFalse:[ |
|
2952 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2953 |
self cursorLine:cursorLine col:prevTab. |
|
2954 |
wasOn ifTrue:[ self showCursor ]. |
|
2955 |
^ self. |
|
2956 |
] |
|
2957 |
]. |
|
827 | 2958 |
]. |
2959 |
||
2491 | 2960 |
"/ (autoIndent |
2961 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2962 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2963 |
"/ ifTrue:[ |
2964 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2965 |
"/ |
|
2966 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2967 |
"/ ln := list at:cursorLine. |
|
2968 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2969 |
"/ soCol := 1 |
|
2970 |
"/ ] |
|
2971 |
"/ ] |
|
2972 |
"/ ] ifFalse:[ |
|
4592 | 2973 |
soCol := 1. |
2491 | 2974 |
"/ ]. |
2975 |
||
1419 | 2976 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 2977 |
" |
2978 |
somewhere in the middle of a line |
|
2979 |
" |
|
2980 |
self cursorLeft. |
|
2981 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2982 |
] ifFalse:[ |
4592 | 2983 |
" |
2984 |
at begin of line - merge with previous line; |
|
2985 |
except for the very first line. |
|
2986 |
" |
|
2987 |
(cursorLine == 1) ifFalse:[ |
|
2988 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2989 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2990 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2991 |
"/ we are beyond the end of the text. |
|
2992 |
"/ move the cursor to the previous line. |
|
2993 |
self cursorLine:lineNrAboveCursor col:1. |
|
2994 |
] ifFalse:[ |
|
2995 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2996 |
] |
|
2997 |
] |
|
2998 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2999 |
]. |
827 | 3000 |
wasOn ifTrue:[ self showCursor ] |
3001 |
||
1419 | 3002 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 3003 |
! |
3004 |
||
3005 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3006 |
"delete characters from colNr up to the end in line lineNr" |
|
3007 |
||
3008 |
|line| |
|
3009 |
||
3010 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 3011 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3012 |
] |
3013 |
||
3014 |
! |
|
3015 |
||
4458 | 3016 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3017 |
"delete characters from startCol to endCol in line lineNr" |
|
3018 |
||
3019 |
|deleted| |
|
3020 |
||
3021 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3022 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3023 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3024 |
! |
|
3025 |
||
827 | 3026 |
deleteCharsAtLine:lineNr toCol:colNr |
3027 |
"delete characters from start up to colNr in line lineNr" |
|
3028 |
||
3029 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3030 |
||
3031 |
||
121 | 3032 |
! |
3033 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3034 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3035 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3036 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3037 |
self deleteLine:cursorLine |
121 | 3038 |
! |
3039 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3040 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3041 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3042 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3043 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3044 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3045 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3046 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3047 |
col1 == 0 ifTrue:[ |
4823 | 3048 |
line1 := line1 - 1. |
3049 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3050 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3051 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3052 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3053 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3054 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3055 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3056 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3057 |
|
2954 | 3058 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3059 |
"delete all text from startLine/startCol to endLine/endCol - |
|
3060 |
joining lines if nescessary" |
|
3061 |
||
3062 |
|line newLine lineSize nMore| |
|
3063 |
||
3064 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3065 |
list isNil ifTrue:[^ self]. |
|
3066 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3067 |
||
3068 |
(startLine == endLine) ifTrue:[ |
|
4225 | 3069 |
"/ delete chars within a line |
3070 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3071 |
^ self |
|
2954 | 3072 |
]. |
3073 |
||
3074 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3075 |
"/ delete full lines only |
3076 |
endLine > startLine ifTrue:[ |
|
3077 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3078 |
]. |
|
3079 |
^ self |
|
2954 | 3080 |
]. |
3081 |
||
3082 |
"/ delete right rest of 1st line |
|
4786 | 3083 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3084 |
|
3085 |
"/ delete the inner lines ... |
|
3086 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3087 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3088 |
]. |
3089 |
||
3090 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3091 |
"/ delete the left rest of the last line |
3092 |
||
3093 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3094 |
||
3095 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3096 |
startLine <= list size ifTrue:[ |
|
3097 |
line := list at:startLine. |
|
3098 |
lineSize := line size. |
|
3099 |
(startCol > lineSize) ifTrue:[ |
|
3100 |
newLine := line. |
|
3101 |
line isNil ifTrue:[ |
|
3102 |
newLine := String new:(startCol - 1) |
|
3103 |
] ifFalse:[ |
|
3104 |
nMore := startCol - 1 - lineSize. |
|
3105 |
nMore > 0 ifTrue:[ |
|
3106 |
newLine := line , (line species new:nMore) |
|
3107 |
] |
|
3108 |
]. |
|
3109 |
newLine ~~ line ifTrue:[ |
|
4771 | 3110 |
self basicListAt:startLine put:newLine. |
4225 | 3111 |
]. |
3112 |
"/ TODO: remember old maxwidth of linerange, |
|
3113 |
"/ only clear widthOfWidestLine, if this max |
|
3114 |
"/ length was (one of) the longest. |
|
3115 |
"/ avoids slow delete with huge texts. |
|
3116 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3117 |
self textChanged. |
|
3118 |
] |
|
3119 |
] |
|
2954 | 3120 |
]. |
3121 |
||
3122 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3123 |
self mergeLine:startLine removeBlanks:false |
|
3124 |
||
4225 | 3125 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3126 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3127 |
! |
3128 |
||
4458 | 3129 |
deleteFromLine:startLineNr toLine:endLineNr |
3130 |
"delete some lines" |
|
3131 |
||
3132 |
|deleted| |
|
3133 |
||
3134 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3135 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3136 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3137 |
! |
|
3138 |
||
827 | 3139 |
deleteLine:lineNr |
3140 |
"delete line" |
|
3141 |
||
3142 |
self deleteFromLine:lineNr toLine:lineNr |
|
3143 |
||
3144 |
||
3145 |
! |
|
3146 |
||
4458 | 3147 |
deleteLineWithoutRedraw:lineNr |
3148 |
"delete line - no redraw; |
|
3149 |
return true, if something was really deleted" |
|
3150 |
||
3151 |
|deleted ret| |
|
3152 |
||
3153 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3154 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3155 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3156 |
^ ret. |
|
3157 |
! |
|
3158 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3159 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3160 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3161 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3162 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3163 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3164 |
|
4771 | 3165 |
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
|
3166 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3167 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3168 |
(endLine > list size) ifTrue:[ |
4771 | 3169 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3170 |
] ifFalse:[ |
4771 | 3171 |
lastLine := endLine |
3172 |
]. |
|
3173 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3174 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3175 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3176 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3177 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3178 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3179 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3180 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3181 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3182 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3183 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3184 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3185 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3186 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3187 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3188 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3189 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3190 |
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
|
3191 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3192 |
selectionStartLine notNil ifTrue:[ |
4823 | 3193 |
wasOn := self hideCursor. |
3194 |
||
3195 |
startLine := selectionStartLine. |
|
3196 |
startCol := selectionStartCol. |
|
3197 |
endLine := selectionEndLine. |
|
3198 |
endCol := selectionEndCol. |
|
3199 |
self unselectWithoutRedraw. |
|
3200 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3201 |
self setCursorLine:startLine col:startCol. |
|
3202 |
||
3203 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3204 |
] |
121 | 3205 |
! |
3206 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3207 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3208 |
"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
|
3209 |
|
2952 | 3210 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3211 |
|
3799 | 3212 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3213 |
cursorCol <= 1 ifTrue:[ |
3214 |
self deleteCharBeforeCursor. |
|
3215 |
^ self |
|
3216 |
]. |
|
3799 | 3217 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3218 |
wasOn := self hideCursor. |
3799 | 3219 |
self |
3220 |
undoableDo:[ |
|
3221 |
endCol := cursorCol-1. |
|
3222 |
endLine := cursorLine. |
|
3223 |
self cursorToPreviousWord. |
|
3224 |
beginCol := cursorCol. |
|
3225 |
beginLine := cursorLine. |
|
3226 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5361 | 3227 |
self cursorLine:cursorLine col:beginCol. |
3799 | 3228 |
] |
3229 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3230 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3231 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3232 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3233 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3234 |
|
4458 | 3235 |
insert:aCharacter atLine:lineNr col:colNr |
3236 |
"insert a single character at lineNr/colNr; |
|
3237 |
set emphasis to character at current position" |
|
3238 |
||
3239 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3240 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3241 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3242 |
] |
3243 |
! |
|
3244 |
||
121 | 3245 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3246 |
"insert a single character at cursor-position - advance cursor." |
121 | 3247 |
|
3248 |
|wasOn| |
|
3249 |
||
3250 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3251 |
aCharacter == Character tab ifTrue:[ |
4820 | 3252 |
"/ needs special care to advance cursor correctly |
3253 |
self insertTabAtCursor |
|
121 | 3254 |
] ifFalse:[ |
4820 | 3255 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3256 |
aCharacter == (Character cr) ifTrue:[ |
|
3257 |
self basicCursorReturn |
|
3258 |
] ifFalse:[ |
|
3259 |
self cursorRight. |
|
3260 |
]. |
|
121 | 3261 |
]. |
3262 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3263 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3264 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3265 |
! |
3266 |
||
641 | 3267 |
insertLine:aString before:lineNr |
3268 |
"insert the line aString before line lineNr" |
|
3269 |
||
3270 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3271 |
||
3272 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3273 |
! |
|
3274 |
||
155 | 3275 |
insertLines:aStringCollection before:lineNr |
3276 |
"insert a bunch before line lineNr" |
|
3277 |
||
3278 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3279 |
||
3280 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3281 |
! |
|
3282 |
||
4771 | 3283 |
insertLines:someText from:start to:end before:lineNr |
3284 |
"insert a bunch of lines before line lineNr. |
|
3285 |
The cursor position is left unchanged." |
|
3286 |
||
3287 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3288 |
srcY "{ Class: SmallInteger }" |
|
3289 |
dstY "{ Class: SmallInteger }" | |
|
3290 |
||
5357 | 3291 |
"wrong when pasting multiple lines" |
3292 |
false "autoIndent" ifTrue:[ |
|
4771 | 3293 |
indent := self leftIndentForLine:lineNr. |
3294 |
||
4812 | 3295 |
text := someText |
3296 |
collect:[:ln||line| |
|
3297 |
ln notNil ifTrue:[ |
|
3298 |
line := ln withoutLeadingSeparators. |
|
3299 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3300 |
line := (String new:indent), line |
|
3301 |
]. |
|
3302 |
line |
|
3303 |
] ifFalse:[ |
|
3304 |
nil |
|
3305 |
] |
|
3306 |
]. |
|
4771 | 3307 |
] ifFalse:[ |
3308 |
text := someText |
|
3309 |
]. |
|
3310 |
||
3311 |
visLine := self listLineToVisibleLine:lineNr. |
|
3312 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3313 |
self withoutRedrawInsertLines:text |
|
3314 |
from:start to:end |
|
3315 |
before:lineNr. |
|
3316 |
] ifFalse:[ |
|
3317 |
nLines := end - start + 1. |
|
3318 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3319 |
self withoutRedrawInsertLines:text |
|
3320 |
from:start to:end |
|
3321 |
before:lineNr. |
|
3322 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3323 |
] ifFalse:[ |
|
3324 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3325 |
and:(firstLineShown + nLines + nLinesShown). |
|
3326 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3327 |
dstY := srcY + (nLines * fontHeight). |
|
3328 |
||
3329 |
"/ |
|
3330 |
"/ scroll ... |
|
3331 |
"/ |
|
3332 |
" |
|
3333 |
stupid: must catchExpose before inserting new |
|
3334 |
stuff - since catchExpose may perform redraws |
|
3335 |
" |
|
3336 |
self catchExpose. |
|
3337 |
self withoutRedrawInsertLines:text |
|
3338 |
from:start to:end |
|
3339 |
before:lineNr. |
|
3340 |
self |
|
3341 |
copyFrom:self |
|
3342 |
x:textStartLeft y:srcY |
|
3343 |
toX:textStartLeft y:dstY |
|
3344 |
width:w |
|
3345 |
height:(height - dstY) |
|
3346 |
async:true. |
|
3347 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3348 |
self waitForExpose |
|
3349 |
]. |
|
3350 |
]. |
|
3351 |
widthOfWidestLine notNil ifTrue:[ |
|
3352 |
text do:[:line | |
|
3353 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3354 |
] |
|
3355 |
]. |
|
3356 |
self textChanged. |
|
3357 |
||
3358 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3359 |
! |
|
3360 |
||
654 | 3361 |
insertLines:lines withCR:withCr |
3160 | 3362 |
"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
|
3363 |
Cursor is moved behind insertion. |
641 | 3364 |
If withCr is true, append cr after last line" |
3365 |
||
3366 |
|start end nLines wasOn| |
|
3367 |
||
3368 |
lines notNil ifTrue:[ |
|
4649 | 3369 |
nLines := lines size. |
3370 |
(nLines == 1) ifTrue:[ |
|
3371 |
self insertStringAtCursor:(lines at:1). |
|
3372 |
withCr ifTrue:[ |
|
3373 |
self insertCharAtCursor:(Character cr) |
|
3374 |
] |
|
3375 |
] ifFalse:[ |
|
3376 |
(cursorCol ~~ 1) ifTrue:[ |
|
3377 |
self insertStringAtCursor:(lines at:1). |
|
3378 |
self insertCharAtCursor:(Character cr). |
|
3379 |
start := 2 |
|
3380 |
] ifFalse:[ |
|
3381 |
start := 1 |
|
3382 |
]. |
|
3383 |
withCr ifTrue:[ |
|
3384 |
end := nLines |
|
3385 |
] ifFalse:[ |
|
3386 |
end := nLines - 1 |
|
3387 |
]. |
|
3388 |
(start <= nLines) ifTrue:[ |
|
3389 |
(end >= start) ifTrue:[ |
|
3390 |
wasOn := self hideCursor. |
|
3391 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3392 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3393 |
wasOn ifTrue:[self showCursor]. |
|
3394 |
] |
|
3395 |
]. |
|
3396 |
withCr ifFalse:[ |
|
3397 |
"last line without cr" |
|
3398 |
self insertStringAtCursor:(lines at:nLines) |
|
3399 |
] |
|
3400 |
] |
|
641 | 3401 |
] |
654 | 3402 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3403 |
"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
|
3404 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3405 |
! |
3406 |
||
3407 |
insertLines:lines withCr:withCr |
|
3408 |
"insert a bunch of lines at cursor position. Cursor |
|
3409 |
is moved behind insertion. |
|
3410 |
If withCr is true, append cr after last line" |
|
3411 |
||
2363 | 3412 |
<resource:#obsolete> |
3413 |
||
1292 | 3414 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3415 |
self insertLines:lines withCR:withCr. |
|
3416 |
||
3417 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3418 |
! |
3419 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3420 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3421 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3422 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3423 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3424 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3425 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3426 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3427 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3428 |
self selectFromLine:startLine col:startCol |
4823 | 3429 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3430 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3431 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3432 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3433 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3434 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3435 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3436 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3437 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3438 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3439 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3440 |
col == 0 ifTrue:[ |
3441 |
line > 1 ifTrue:[ |
|
3442 |
line := line - 1. |
|
5216 | 3443 |
col := (self listAt:line) size + 1. |
5060 | 3444 |
] ifFalse:[ |
3445 |
col := 1. |
|
3446 |
] |
|
3447 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3448 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3449 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3450 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3451 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3452 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3453 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3454 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3455 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3456 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3457 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3458 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3459 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3460 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3461 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3462 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3463 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3464 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3465 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3466 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3467 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3468 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3469 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3470 |
[start <= end] whileTrue:[ |
4823 | 3471 |
stop := aString indexOf:(Character cr) startingAt:start. |
3472 |
stop == 0 ifTrue:[ |
|
3473 |
stop := end + 1 |
|
3474 |
]. |
|
3475 |
subString := aString copyFrom:start to:(stop - 1). |
|
3476 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3477 |
(stop <= end) ifTrue:[ |
|
3478 |
c := c + subString size. |
|
3479 |
self insert:(Character cr) atLine:l col:c. |
|
3480 |
l := l + 1. |
|
3481 |
c := 1 |
|
3482 |
]. |
|
3483 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3484 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3485 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3486 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3487 |
! |
3488 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3489 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3490 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3491 |
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
|
3492 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3493 |
aString isNil ifTrue:[ |
4823 | 3494 |
"new:" |
3495 |
self insertCharAtCursor:(Character cr). |
|
3496 |
^ self |
|
105 | 3497 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3498 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3499 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3500 |
]. |
3501 |
||
654 | 3502 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3503 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3504 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3505 |
! |
3506 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3507 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3508 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3509 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3510 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3511 |
shown ifTrue:[ |
4889 | 3512 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3513 |
self invalidateLine:lineNr. |
3514 |
] ifFalse:[ |
|
3515 |
self redrawLine:lineNr from:colNr |
|
3516 |
] |
|
3517 |
] |
|
3518 |
||
4191 | 3519 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3520 |
! |
3521 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3522 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3523 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3524 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3525 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3526 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3527 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3528 |
aString size > 0 ifTrue:[ |
4823 | 3529 |
wasOn := self hideCursor. |
3530 |
(aString includes:Character tab) ifTrue:[ |
|
3531 |
self checkForExistingLine:cursorLine. |
|
3532 |
oldLen := (list at:cursorLine) size. |
|
3533 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3534 |
newLen := (list at:cursorLine) size. |
|
3535 |
deltaLen := newLen - oldLen. |
|
3536 |
] ifFalse:[ |
|
3537 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3538 |
deltaLen := aString size. |
|
3539 |
]. |
|
3540 |
self setCursorCol:(cursorCol + deltaLen). |
|
3541 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3542 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3543 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3544 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3545 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3546 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3547 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3548 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3549 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3550 |
|wasOn nextTab| |
105 | 3551 |
|
121 | 3552 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3553 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3554 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3555 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3556 |
! |
3557 |
||
3542 | 3558 |
joinLines |
3890 | 3559 |
"join lines (remove line-break)" |
3560 |
||
3583 | 3561 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3562 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3563 |
self |
3890 | 3564 |
undoableDo:[ |
3565 |
|line col lineLen| |
|
3566 |
||
3567 |
line := cursorLine. |
|
3568 |
col := cursorCol. |
|
3569 |
lineLen := (list at:line) size. |
|
3570 |
col > lineLen ifTrue:[ |
|
3571 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3572 |
] ifFalse:[ |
|
3573 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3574 |
]. |
|
3575 |
self mergeLine:line removeBlanks:true. |
|
3576 |
self cursorLine:line col:col. |
|
3577 |
] |
|
3578 |
info:'Join' |
|
3542 | 3579 |
! |
3580 |
||
2952 | 3581 |
mergeLine:lineNr |
3582 |
"merge line lineNr with line lineNr+1" |
|
3583 |
||
3584 |
self mergeLine:lineNr removeBlanks:true |
|
3585 |
||
3586 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3587 |
! |
|
3588 |
||
4458 | 3589 |
mergeLine:lineNr removeBlanks:removeBlanks |
3590 |
"merge line lineNr with line lineNr+1" |
|
3591 |
||
3592 |
|len| |
|
3593 |
||
3594 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3595 |
||
3596 |
len := (self listAt:lineNr) size. |
|
3597 |
self nonUndoableDo:[ |
|
4823 | 3598 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3599 |
]. |
3600 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3601 |
! |
|
3602 |
||
2506 | 3603 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3604 |
|newSelectionEnd| |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3605 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3606 |
self hasSelection ifFalse:[^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3607 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3608 |
newSelectionEnd := selectionEndCol. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3609 |
|
2506 | 3610 |
(self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[ |
4823 | 3611 |
(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[ |
3612 |
self deleteCharAtLine:selectionEndLine col:selectionEndCol. |
|
3613 |
newSelectionEnd := newSelectionEnd-1. |
|
3614 |
]. |
|
3615 |
self deleteCharAtLine:selectionStartLine col:selectionStartCol. |
|
3616 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3617 |
newSelectionEnd := newSelectionEnd-1. |
|
3618 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3619 |
] ifFalse:[ |
4823 | 3620 |
self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1. |
3621 |
newSelectionEnd := newSelectionEnd+1. |
|
3622 |
self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol. |
|
3623 |
selectionStartLine == selectionEndLine ifTrue:[ |
|
3624 |
newSelectionEnd := newSelectionEnd+1. |
|
3625 |
] |
|
3160 | 3626 |
]. |
3627 |
self |
|
4823 | 3628 |
selectFromLine:selectionStartLine col:selectionStartCol |
3629 |
toLine:selectionEndLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3630 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3631 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3632 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3633 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3634 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3635 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3636 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3637 |
|
5114 | 3638 |
NoModificationError handle:[:ex | |
3639 |
^ self |
|
3640 |
] do:[ |
|
3641 |
lastLine := list size. |
|
3642 |
finished := false. |
|
3643 |
[finished] whileFalse:[ |
|
3644 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 3645 |
finished := true |
3646 |
] ifFalse:[ |
|
5114 | 3647 |
line := list at:lastLine. |
3648 |
line notNil ifTrue:[ |
|
3649 |
line isBlank ifTrue:[ |
|
3650 |
self basicListAt:lastLine put:nil. |
|
3651 |
line := nil |
|
3652 |
] |
|
3653 |
]. |
|
3654 |
line notNil ifTrue:[ |
|
3655 |
finished := true |
|
3656 |
] ifFalse:[ |
|
3657 |
lastLine := lastLine - 1 |
|
3658 |
] |
|
4771 | 3659 |
] |
5114 | 3660 |
]. |
3661 |
(lastLine ~~ list size) ifTrue:[ |
|
3662 |
list grow:lastLine. |
|
3663 |
"/ self textChanged |
|
4771 | 3664 |
] |
118 | 3665 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3666 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3667 |
|
4458 | 3668 |
replace:aCharacter atLine:lineNr col:colNr |
3669 |
"replace a single character at lineNr/colNr" |
|
3670 |
||
3671 |
|originalChar| |
|
3672 |
||
3673 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3674 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3675 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3676 |
! |
|
3677 |
||
4713 | 3678 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3679 |
|pattern replacePattern| |
3680 |
||
3681 |
pattern := patternArg string. |
|
3682 |
replacePattern := replacePatternArg string. |
|
4630 | 3683 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3684 |
self rememberSearchPattern:pattern. |
|
3685 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3686 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3687 |
self |
3688 |
undoableDo:[ |
|
3689 |
all ifTrue:[ |
|
3690 |
self |
|
3691 |
replaceString:pattern |
|
3692 |
to:replacePattern |
|
4713 | 3693 |
ignoreCase:ignoreCase |
4630 | 3694 |
] ifFalse:[ |
3695 |
(self selectionAsString notNil |
|
4713 | 3696 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3697 |
ifTrue:[ |
4742 | 3698 |
self replaceSelectionBy:replacePattern. |
4630 | 3699 |
self |
3700 |
search:pattern |
|
4713 | 3701 |
ignoreCase:ignoreCase |
4630 | 3702 |
forward:(lastSearchDirection = #forward). |
3703 |
]. |
|
3704 |
] |
|
3705 |
] |
|
3706 |
info:'Replace' |
|
3430 | 3707 |
] |
3708 |
||
3709 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3710 |
! |
|
3711 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3712 |
replaceCharAtCursor:aCharacter |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3713 |
"replace a single character at cursor-position - advance cursor" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3714 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3715 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3716 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3717 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3718 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3719 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3720 |
] ifFalse:[ |
4823 | 3721 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3722 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3723 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3724 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3725 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3726 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3727 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3728 |
|
4458 | 3729 |
replaceContentsWith:newContents |
3730 |
"replace everything" |
|
3731 |
||
3732 |
|originalContents| |
|
3733 |
||
3734 |
originalContents := self contents. |
|
3735 |
self contents:newContents keepUndoHistory:true. |
|
3736 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3737 |
! |
|
3738 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3739 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3740 |
"replace a substring at a character position" |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3741 |
|
5216 | 3742 |
"/ 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
|
3743 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3744 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3745 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3746 |
|
4458 | 3747 |
replaceLine:lineNr with:newText |
3748 |
"replace a line at lineNr" |
|
3749 |
||
3750 |
|originalLine| |
|
3751 |
||
3752 |
originalLine := self listAt:lineNr. |
|
3753 |
originalLine isNil ifTrue:[ |
|
4823 | 3754 |
self checkForExistingLine:lineNr |
4458 | 3755 |
]. |
3756 |
self list at:lineNr put:newText. |
|
3757 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3758 |
self invalidateLine:lineNr. |
|
3759 |
||
3760 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3761 |
! |
|
3762 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3763 |
replaceLines:lines withCR:withCr |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3764 |
"replace a bunch of lines at cursor position. Cursor |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3765 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3766 |
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
|
3767 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3768 |
|
1809 | 3769 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3770 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3771 |
lines notNil ifTrue:[ |
4661 | 3772 |
wasOn := self hideCursor. |
3773 |
nLines := lines size. |
|
3774 |
line := cursorLine. |
|
3775 |
col := cursorCol. |
|
3776 |
lines keysAndValuesDo:[:i :l | |
|
3777 |
self replaceString:(l ? '') atLine:line col:col. |
|
3778 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3779 |
line := line + 1. |
|
3780 |
col := 1. |
|
3781 |
] ifFalse:[ |
|
3782 |
col := col + (l size). |
|
3783 |
] |
|
3784 |
]. |
|
3785 |
self cursorLine:line col:col. |
|
3786 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3787 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3788 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3789 |
|
4661 | 3790 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3791 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3792 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3793 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3794 |
replaceSelectionBy:something |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3795 |
"delete the selection (if any) and insert something, a character or string; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3796 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3797 |
|
4666 | 3798 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3799 |
! |
3800 |
||
3801 |
replaceSelectionBy:something keepCursor:keep |
|
3802 |
"delete the selection (if any) and insert something, a character or string; |
|
3803 |
leave cursor after insertion or leave it, depending on keep" |
|
3804 |
||
4666 | 3805 |
self replaceSelectionBy:something keepCursor:keep select:false |
3806 |
||
3807 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3808 |
! |
|
3809 |
||
3810 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
3811 |
"delete the selection (if any) and insert something, a character or string; |
|
3812 |
leave cursor after insertion or leave it, depending on keep. |
|
3813 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3814 |
||
3815 |
|sel l c selStartLine selStartCol| |
|
105 | 3816 |
|
3817 |
l := cursorLine. |
|
3818 |
c := cursorCol. |
|
3819 |
||
4818 | 3820 |
sel := self selectionAsString. |
4666 | 3821 |
sel isNil ifTrue:[ |
3822 |
selStartLine := l. |
|
3823 |
selStartCol := c. |
|
3824 |
] ifFalse:[ |
|
3825 |
selStartLine := selectionStartLine. |
|
3826 |
selStartCol := selectionStartCol. |
|
3827 |
||
4053 | 3828 |
self setLastStringToReplace: sel. |
3829 |
||
4010 | 3830 |
self deleteSelection. |
3831 |
replacing := true. |
|
4818 | 3832 |
lastReplacementInfo rememberReplacement. |
4048 | 3833 |
lastReplacementInfo lastReplacement: ''. |
4818 | 3834 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 3835 |
undoSupport actionInfo:'replace'. |
3161 | 3836 |
]. |
3837 |
||
3838 |
something isCharacter ifTrue:[ |
|
4051 | 3839 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 3840 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 3841 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 3842 |
]. |
4010 | 3843 |
]. |
3844 |
self isInInsertMode ifTrue:[ |
|
3845 |
self insertCharAtCursor:something |
|
3846 |
] ifFalse:[ |
|
3847 |
self replaceCharAtCursor:something |
|
3848 |
] |
|
105 | 3849 |
] ifFalse:[ |
4010 | 3850 |
something isString ifTrue:[ |
4048 | 3851 |
lastReplacementInfo lastReplacement: something. |
4010 | 3852 |
self isInInsertMode ifTrue:[ |
3853 |
self insertStringAtCursor:something |
|
3854 |
] ifFalse:[ |
|
3855 |
self replaceStringAtCursor:something |
|
3856 |
] |
|
3857 |
] ifFalse:[ |
|
3858 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3859 |
]. |
|
105 | 3860 |
]. |
3861 |
keep ifTrue:[ |
|
4010 | 3862 |
self cursorLine:l col:c |
4666 | 3863 |
]. |
3864 |
selectNewText ifTrue:[ |
|
3865 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 3866 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3867 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3868 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3869 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3870 |
|
4458 | 3871 |
replaceString:aString atLine:lineNr col:colNr |
3872 |
"replace multiple characters starting at lineNr/colNr. |
|
3873 |
This is not prepared to encounter special chars (except TAB) in the string." |
|
3874 |
||
3875 |
|originalString| |
|
3876 |
||
3877 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3878 |
||
3879 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
3880 |
||
3881 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3882 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
3883 |
! |
|
3884 |
||
4713 | 3885 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 3886 |
|continue count| |
3887 |
||
3888 |
self cursorToTop. |
|
3889 |
self selectFromBeginning. |
|
3890 |
count := 0. |
|
3891 |
continue := true. |
|
3892 |
[ continue ] whileTrue:[ |
|
4713 | 3893 |
(self selectionAsString notNil |
3894 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
3895 |
ifTrue:[ |
|
4742 | 3896 |
self replaceSelectionBy:aNewString. |
4713 | 3897 |
count := count + 1. |
3898 |
]. |
|
3899 |
self |
|
3900 |
searchFwd:aString |
|
3901 |
ignoreCase:ignoreCase |
|
3902 |
ifAbsent:[ |
|
3903 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
3904 |
bindWith:aString with:aNewString with:count). |
|
3905 |
continue := false. |
|
3906 |
]. |
|
3549 | 3907 |
]. |
3430 | 3908 |
|
3909 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3910 |
! |
|
3911 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3912 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3913 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3914 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3915 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3916 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3917 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3918 |
(aString includes:Character tab) ifTrue:[ |
4823 | 3919 |
"/ need special care for TAB (to move cursor correctly) |
3920 |
i1 := 1. |
|
3921 |
[i1 ~~ 0] whileTrue:[ |
|
3922 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3923 |
i2 ~~ 0 ifTrue:[ |
|
3924 |
i1 ~~ i2 ifTrue:[ |
|
3925 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3926 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3927 |
]. |
|
3928 |
self replaceTABAtCursor. |
|
3929 |
i2 := i2 + 1. |
|
3930 |
] ifFalse:[ |
|
3931 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3932 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3933 |
]. |
|
3934 |
i1 := i2. |
|
3935 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3936 |
] ifFalse:[ |
4823 | 3937 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
5325 | 3938 |
self setValidatedCursorCol:(cursorCol + aString size). |
3939 |
"/ self cursorCol:(cursorCol + aString size). |
|
3940 |
]. |
|
3941 |
wasOn ifTrue:[ |
|
3942 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
|
3943 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
3944 |
]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3945 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3946 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3947 |
"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
|
3948 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3949 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3950 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3951 |
"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
|
3952 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3953 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3954 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3955 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3956 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3957 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3958 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3959 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3960 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 3961 |
! |
3962 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3963 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3964 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3965 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3966 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3967 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3968 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3969 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3970 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3971 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3972 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3973 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3974 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3975 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3976 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3977 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3978 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3979 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3980 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3981 |
|
4458 | 3982 |
splitLine:lineNr before:colNr |
3983 |
"split the line linNr before colNr; the right part (from colNr) |
|
3984 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3985 |
||
3986 |
self basicSplitLine:lineNr before:colNr. |
|
3987 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
3988 |
! |
|
3989 |
||
5146 | 3990 |
withAutoIndent:aBoolean do:aBlock |
3991 |
|sav| |
|
3992 |
||
3993 |
sav := autoIndent. |
|
3994 |
autoIndent := aBoolean. |
|
3995 |
aBlock ensure:[ autoIndent := sav ]. |
|
3996 |
! |
|
3997 |
||
4458 | 3998 |
withoutRedrawAt:lineNr put:aString |
3999 |
"replace a line at lineNr" |
|
4000 |
||
4001 |
|originalLine| |
|
4002 |
||
4003 |
originalLine := self listAt:lineNr. |
|
4004 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4005 |
super withoutRedrawAt:lineNr put:aString. |
|
4006 |
! |
|
4007 |
||
4008 |
withoutRedrawInsertLine:aString before:lineNr |
|
4009 |
"insert the argument, aString before line lineNr; the string |
|
4010 |
becomes line lineNr; everything else is moved down; the view |
|
4011 |
is not redrawn" |
|
4012 |
||
4771 | 4013 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4014 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4015 |
! |
|
4016 |
||
4017 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4018 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4019 |
||
4020 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4021 |
self isReadOnly ifFalse:[ |
|
4823 | 4022 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4023 |
]. |
4024 |
! |
|
4025 |
||
4026 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4027 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4028 |
||
4029 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4030 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4031 |
! |
|
4032 |
||
3890 | 4033 |
wrapLines |
4034 |
"wrap lines (insert line-break)" |
|
4035 |
||
4036 |
|lineLength answerString string| |
|
4037 |
||
4038 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4039 |
||
4040 |
self hasSelection ifFalse:[ |
|
4041 |
self selectLine:cursorLine. |
|
4042 |
]. |
|
4043 |
string := self selectionAsString. |
|
4044 |
string isEmptyOrNil ifTrue:[ |
|
4045 |
Dialog information:(resources string:'Nothing selected.'). |
|
4046 |
^ self. |
|
4047 |
]. |
|
4048 |
||
4049 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4050 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4051 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4052 |
lineLength < 1 ifTrue:[ |
4053 |
lineLength := 1. |
|
4054 |
]. |
|
4055 |
||
4056 |
self |
|
4057 |
undoableDo:[ |
|
4058 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4059 |
||
4060 |
line := selectionStartLine. |
|
4061 |
col := selectionStartCol. |
|
4062 |
||
4063 |
self cutSelection. |
|
4064 |
self cursorLine:line col:col. |
|
4065 |
||
4066 |
lastGoodCol := col. |
|
4067 |
||
4068 |
inStream := string readStream. |
|
4069 |
[ inStream atEnd ] whileFalse:[ |
|
4070 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4071 |
word := WriteStream on:(String new:10). |
|
4072 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4073 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4074 |
self insertCharAtCursor:(Character cr). |
|
4075 |
col := 1. |
|
4076 |
] ifFalse:[ |
|
4077 |
col ~~ 1 ifTrue:[ |
|
4078 |
self insertStringAtCursor:' '. |
|
4079 |
col := col + 1. |
|
4080 |
] |
|
4081 |
]. |
|
4082 |
self insertStringAtCursor:word contents. |
|
4083 |
col := col + word size. |
|
4084 |
]. |
|
4085 |
] |
|
4086 |
info:'Wrap' |
|
4388 | 4087 |
|
4088 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4089 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4090 |
|
2752 | 4091 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4092 |
|
2952 | 4093 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4094 |
"delete characters from startCol to endCol in line lineNr" |
4095 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4096 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4097 |
|
4673 | 4098 |
self unselect. |
4099 |
||
4100 |
cursorLine == lineNr ifTrue:[ |
|
4101 |
cursorCol >= startCol ifTrue:[ |
|
4102 |
cursorCol >= endCol ifTrue:[ |
|
4103 |
cursorCol := startCol. |
|
4104 |
] ifFalse:[ |
|
4105 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
4106 |
] |
|
4107 |
]. |
|
4108 |
]. |
|
4109 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4110 |
line := self listAt:lineNr. |
827 | 4111 |
|
4673 | 4112 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4113 |
||
4114 |
lineSize := line size. |
|
4115 |
||
4116 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4117 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4118 |
||
4119 |
stop >= start ifTrue:[ |
|
4120 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
4121 |
ifFalse:[ newLine := '' ]. |
|
4122 |
||
4123 |
stop == lineSize ifFalse:[ |
|
4124 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4125 |
newLine := line string species fromString:newLine. |
|
4190 | 4126 |
]. |
4673 | 4127 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
4128 |
]. |
|
4129 |
||
4130 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4131 |
newLine := nil |
|
4132 |
]. |
|
4133 |
||
4134 |
prevWidth := self widthOfLine:lineNr. |
|
4135 |
||
4771 | 4136 |
self basicListAt:lineNr put:newLine. |
4673 | 4137 |
|
4138 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4139 |
"/ remember old width of this line, |
|
4140 |
"/ only clear widthOfWidestLine, if this lines |
|
4141 |
"/ length was (one of) the longest. |
|
4142 |
"/ avoids slow delete with huge texts. |
|
4143 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4144 |
||
4145 |
"/ scroll left if reqiured |
|
4146 |
viewOrigin x > 0 ifTrue:[ |
|
4147 |
newWidth := self widthOfLine:lineNr. |
|
4148 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4149 |
self scrollHorizontalTo:(newWidth |
|
4150 |
- width |
|
4151 |
+ margin + margin |
|
4889 | 4152 |
+ (gc font widthOf:' ')) |
4673 | 4153 |
] |
4190 | 4154 |
]. |
4673 | 4155 |
self textChanged. |
4156 |
] ifFalse:[ |
|
4157 |
self textChanged "/ textChangedButNoSizeChange |
|
4158 |
]. |
|
4889 | 4159 |
gc font hasOverlappingCharacters ifTrue:[ |
4673 | 4160 |
self invalidateLine:lineNr. |
4161 |
] ifFalse:[ |
|
4162 |
self redrawLine:lineNr from:start. |
|
4163 |
]. |
|
4164 |
]. |
|
827 | 4165 |
|
4191 | 4166 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4167 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4168 |
|
2952 | 4169 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4170 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4171 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4172 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4173 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4174 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4175 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4176 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4177 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4178 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4179 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4180 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4181 |
startLineNr <= list size ifTrue:[ |
4771 | 4182 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4183 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4184 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4185 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4186 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4187 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4188 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4189 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4190 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4191 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4192 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4193 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4194 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4195 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4196 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4197 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4198 |
|
4226 | 4199 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4200 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4201 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4202 |
|
2952 | 4203 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4204 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4205 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4206 |
|
2952 | 4207 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4208 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4209 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4210 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4211 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4212 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4213 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4214 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4215 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4216 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4217 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4218 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4219 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4220 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4221 |
|
2952 | 4222 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4223 |
"insert a single character at lineNr/colNr; |
827 | 4224 |
set emphasis to character at current position" |
4225 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4226 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4227 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4228 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4229 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4230 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4231 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4232 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4233 |
]. |
827 | 4234 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4235 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4236 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4237 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4238 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4239 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4240 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4241 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4242 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4243 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4244 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4245 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4246 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4247 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4248 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4249 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4250 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4251 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4252 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4253 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4254 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4255 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4256 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4257 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4258 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4259 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4260 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4261 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4262 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4263 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4264 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4265 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4266 |
]. |
827 | 4267 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4268 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4269 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4270 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4271 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4272 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4273 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4274 |
newLine at:colNr put:aCharacter. |
827 | 4275 |
|
4276 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4277 |
newLine emphasisAt:colNr put:attribute. |
827 | 4278 |
]. |
4279 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4280 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4281 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4282 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4283 |
]. |
827 | 4284 |
|
4771 | 4285 |
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
|
4286 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4287 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4288 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4289 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4290 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4291 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4292 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4293 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4294 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4295 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4296 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4297 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4298 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4299 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4300 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 4301 |
|
4889 | 4302 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4303 |
self invalidateLine:lineNr. |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4304 |
] ifFalse:[ |
4190 | 4305 |
drawCharacterOnly ifTrue:[ |
4889 | 4306 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4190 | 4307 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4308 |
] ifFalse:[ |
|
4309 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4310 |
self redrawLine:lineNr from:colNr-1 |
|
4311 |
]. |
|
4312 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4313 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4314 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4315 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4316 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4317 |
]. |
4889 | 4318 |
gc font hasOverlappingCharacters ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4319 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4320 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4321 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4322 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4323 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4324 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4325 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4326 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4327 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4328 |
|
4191 | 4329 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4330 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4331 |
|
4771 | 4332 |
basicListAt:lineNr put:newLine |
4333 |
"redefinable for special subclasses (with virtual list)" |
|
4334 |
||
4335 |
list at:lineNr put:newLine. |
|
4336 |
! |
|
4337 |
||
4338 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4339 |
"redefinable for special subclasses (with virtual list)" |
|
4340 |
||
4341 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4342 |
! |
|
4343 |
||
2952 | 4344 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4345 |
"merge line lineNr with line lineNr+1" |
4346 |
||
827 | 4347 |
|leftPart rightPart bothParts nextLineNr i| |
4348 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4349 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
4771 | 4350 |
"/ empty list or beyond end of text |
4351 |
^ self |
|
827 | 4352 |
]. |
4353 |
leftPart := self listAt:lineNr. |
|
4354 |
||
4355 |
leftPart isNil ifTrue:[ |
|
4771 | 4356 |
leftPart := ''. |
4357 |
autoIndent ifTrue:[ |
|
4358 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4359 |
leftPart := String new:i |
|
4360 |
] |
|
4361 |
] |
|
827 | 4362 |
]. |
4363 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4364 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4365 |
||
4366 |
nextLineNr > (list size) ifFalse:[ |
|
4771 | 4367 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4368 |
rightPart := '' |
|
4369 |
] ifFalse:[ |
|
4370 |
removeBlanks ifTrue:[ |
|
4371 |
rightPart := rightPart withoutLeadingSeparators. |
|
4372 |
] |
|
4373 |
]. |
|
4374 |
||
4375 |
bothParts := leftPart , rightPart. |
|
4376 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4377 |
self basicListAt:lineNr put:bothParts. |
|
4378 |
self redrawLine:lineNr. |
|
4379 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4380 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4381 |
|
1319 | 4382 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4383 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4384 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4385 |
|
2952 | 4386 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4387 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4388 |
|
5045 | 4389 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4390 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4391 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4392 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4393 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4394 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4395 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4396 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4397 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4398 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4399 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4400 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4401 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4402 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4403 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4404 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4405 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4406 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4407 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4408 |
(lineSize == 0) ifTrue:[ |
4190 | 4409 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4410 |
] ifFalse: [ |
5045 | 4411 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4412 |
newLineSpecies := aCharacter stringSpecies |
|
4413 |
] ifFalse:[ |
|
4414 |
newLineSpecies := line species |
|
4415 |
]. |
|
4416 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4417 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4418 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4419 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4420 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4421 |
newLine := self withTabsExpanded:newLine. |
4422 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4423 |
]. |
4771 | 4424 |
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
|
4425 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4426 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4427 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4428 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4429 |
shown ifTrue:[ |
4889 | 4430 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4431 |
self invalidateLine:lineNr. |
4432 |
] ifFalse:[ |
|
4433 |
drawCharacterOnly ifTrue:[ |
|
4434 |
self redrawLine:lineNr col:colNr |
|
4435 |
] ifFalse:[ |
|
4436 |
self redrawLine:lineNr from:colNr |
|
4437 |
] |
|
4438 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4439 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4440 |
|
4190 | 4441 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4442 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4443 |
! |
4444 |
||
3235 | 4445 |
basicReplaceString:aString atLine:lineNr col:colNr |
4446 |
"replace multiple characters starting at lineNr/colNr. |
|
4447 |
This is not prepared to encounter special chars (except TAB) |
|
4448 |
in the string." |
|
4449 |
||
5023
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4450 |
|line lineSize newLine endCol| |
3235 | 4451 |
|
4452 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4453 |
||
4454 |
self checkForExistingLine:lineNr. |
|
4455 |
line := list at:lineNr. |
|
4456 |
lineSize := line size. |
|
4457 |
||
4458 |
endCol := colNr + aString size - 1. |
|
4459 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4460 |
newLine := aString species new:endCol. |
3235 | 4461 |
] ifFalse: [ |
5023
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4462 |
(endCol > lineSize) ifTrue: [ |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4463 |
aString isText ifTrue:[ |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4464 |
newLine := aString species new:endCol. |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4465 |
] ifFalse:[ |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4466 |
newLine := line species new:endCol. |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4467 |
]. |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4468 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4469 |
] ifFalse: [ |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4470 |
aString isText ifTrue:[ |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4471 |
newLine := aString species new:line size. |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4472 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4473 |
] ifFalse:[ |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4474 |
newLine := line copy. |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4475 |
] |
a18a03c5c572
GC is delegated instead of inherited
Stefan Vogel <sv@exept.de>
parents:
diff
changeset
|
4476 |
] |
3235 | 4477 |
]. |
4478 |
newLine replaceFrom:colNr with:aString. |
|
4479 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4480 |
newLine := self withTabsExpanded:newLine. |
3235 | 4481 |
]. |
4771 | 4482 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4483 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4484 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4485 |
]. |
4486 |
self textChanged. |
|
4487 |
shown ifTrue:[ |
|
4889 | 4488 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4489 |
self invalidateLine:lineNr. |
4490 |
] ifFalse:[ |
|
4491 |
self redrawLine:lineNr from:colNr |
|
4492 |
] |
|
3235 | 4493 |
] |
4494 |
||
4190 | 4495 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4496 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4497 |
! |
4498 |
||
2952 | 4499 |
basicSplitLine:lineNr before:colNr |
4500 |
"split the line linNr before colNr; the right part (from colNr) |
|
4501 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4502 |
||
3160 | 4503 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4504 |
srcY "{ Class: SmallInteger }" | |
4505 |
||
3027 | 4506 |
list isNil ifTrue:[ ^ self ]. |
4507 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4508 |
||
4509 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4510 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4511 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4512 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4513 |
^ self |
3027 | 4514 |
]. |
4515 |
||
4516 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4517 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4518 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4519 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4520 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4521 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4522 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4523 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4524 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4525 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4526 |
] |
3027 | 4527 |
]. |
4528 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4529 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4530 |
]. |
4771 | 4531 |
self basicListAt:lineNr put:leftRest. |
3027 | 4532 |
self nonUndoableDo:[ |
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4533 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4534 |
]. |
4535 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4536 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4537 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4538 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4539 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4540 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4541 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4542 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4543 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4544 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4545 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4546 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4547 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4548 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4549 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4550 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4551 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4552 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4553 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4554 |
]. |
4555 |
widthOfWidestLine := nil. "/ unknown |
|
4556 |
self textChanged. |
|
2952 | 4557 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4558 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4559 |
! |
4560 |
||
2954 | 4561 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4562 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4563 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4564 |
because the text might have been pasted from an alien view." |
|
2954 | 4565 |
|
4566 |
|newLine newLines nLines| |
|
4567 |
||
4568 |
nLines := end - start + 1. |
|
4569 |
newLines := Array new:(lines size). |
|
4570 |
start to:end do:[:index | |
|
4328 | 4571 |
newLine := lines at:index. |
4572 |
newLine notNil ifTrue:[ |
|
4573 |
newLine isString ifTrue:[ |
|
4574 |
newLine isBlank ifTrue:[ |
|
4575 |
newLine := nil |
|
4576 |
] ifFalse:[ |
|
4577 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4578 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4579 |
] |
|
4580 |
] |
|
4581 |
] |
|
4582 |
]. |
|
4583 |
newLines at:index put:newLine |
|
2954 | 4584 |
]. |
4585 |
list isNil ifTrue: [ |
|
4328 | 4586 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4587 |
] ifFalse: [ |
4328 | 4588 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4589 |
]. |
4590 |
||
4591 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4592 |
overlapping copy - if it didn't, we had to use:" |
4593 |
" |
|
4594 |
index := list size. |
|
4595 |
[index > lineNr] whileTrue: [ |
|
4328 | 4596 |
pIndex := index - 1. |
4597 |
list at:index put:(list at:pIndex). |
|
4598 |
index := pIndex |
|
2954 | 4599 |
]. |
4600 |
" |
|
4601 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4602 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4603 |
self contentsChanged |
|
4604 |
||
4328 | 4605 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4606 |
! |
4607 |
||
4608 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4609 |
"insert aString (which has no crs) at lineNr/colNr. |
4610 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4611 |
because the text might have been pasted from an alien view." |
|
2954 | 4612 |
|
4360 | 4613 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4614 |
|
4623 | 4615 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4616 |
|
4617 |
strLen := aString size. |
|
4618 |
self checkForExistingLine:lineNr. |
|
4619 |
||
4620 |
stringType := aString string species. |
|
4621 |
isText := aString isText. |
|
4622 |
line := list at:lineNr. |
|
4623 |
||
4624 |
line notNil ifTrue:[ |
|
4328 | 4625 |
lineSize := line size. |
4626 |
line isString ifFalse:[ |
|
4627 |
stringType := line species |
|
4628 |
] ifTrue:[ |
|
4360 | 4629 |
lineCharWidth := line bitsPerCharacter. |
4630 |
stringCharWidth := aString bitsPerCharacter. |
|
4631 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4632 |
stringType := line string species |
4360 | 4633 |
] ifFalse:[ |
4634 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4635 |
stringType := aString string species |
|
4636 |
] |
|
4328 | 4637 |
]. |
4638 |
line isText ifTrue:[ isText := true ] |
|
4639 |
]. |
|
2954 | 4640 |
] ifFalse:[ |
4328 | 4641 |
lineSize := 0 |
2954 | 4642 |
]. |
4643 |
||
4644 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4645 |
newLine := aString |
2954 | 4646 |
] ifFalse:[ |
4328 | 4647 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4648 |
sz := colNr + strLen - 1 |
|
4649 |
] ifFalse:[ |
|
4650 |
sz := lineSize + strLen |
|
4651 |
]. |
|
4652 |
||
4360 | 4653 |
newLine := stringType new:sz. |
4654 |
isText ifTrue:[ |
|
4655 |
newLine := Text string:newLine |
|
4328 | 4656 |
]. |
4657 |
||
4658 |
(lineSize ~~ 0) ifTrue: [ |
|
4659 |
(colNr > lineSize) ifTrue: [ |
|
4660 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4661 |
] ifFalse: [ |
|
4662 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4663 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4664 |
] |
|
4665 |
]. |
|
4666 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4667 |
]. |
4668 |
||
4669 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4670 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4671 |
]. |
4672 |
||
4771 | 4673 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4674 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4675 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4676 |
]. |
4677 |
self textChanged. |
|
4678 |
||
4360 | 4679 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4680 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4681 |
|
2752 | 4682 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4683 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4684 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4685 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4686 |
|
5216 | 4687 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 4688 |
dragIsActive := false. |
4689 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4690 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4691 |
"/ 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
|
4692 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4693 |
]. |
4609 | 4694 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4695 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4696 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4697 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4698 |
|
4420 | 4699 |
"On X11, be nice and paste PRIMARY when middle click. |
4700 |
Note, that middle button on X11 is translated to button |
|
4701 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
4940 | 4702 |
(button == #paste and:[self graphicsDevice platformName == #X11]) ifTrue:[ |
4420 | 4703 |
self undoableDo:[ |
4704 |
self paste: (self getClipboardText:#selection). |
|
4705 |
]. |
|
4706 |
^self. |
|
4707 |
]. |
|
4708 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4709 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4710 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4711 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4712 |
"/ 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
|
4713 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4714 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4715 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4716 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4717 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4718 |
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
|
4719 |
|
4420 | 4720 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4721 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4722 |
! |
4723 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4724 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4725 |
"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
|
4726 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4727 |
|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
|
4728 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4729 |
(button == 1) ifTrue:[ |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4730 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4731 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4732 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4733 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4734 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4735 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4736 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4737 |
self cursorMovementAllowed ifTrue:[ |
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4738 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4739 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4740 |
cursorType ~~ #block ifTrue:[ |
3790 | 4741 |
clickPos notNil ifTrue:[ |
4742 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4743 |
"/ (i.e. if its an ibeam). |
|
4744 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4745 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4746 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4747 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4748 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4749 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4750 |
]. |
5056 | 4751 |
"/ the following fixes the ugly select behavior when double clicking on |
4752 |
"/ a partially visible last line (where the first click used to |
|
4753 |
"/ scroll the text so that the second click was handled on another |
|
4754 |
"/ line. An alternative (possibly better) solution would be to |
|
4755 |
"/ remember the last click posision and adjust in the double click |
|
4756 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
4757 |
"/ Time will show, if this hack works. |
|
5057 | 4758 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
4759 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
4760 |
Processor |
|
4761 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
4762 |
afterSeconds:0.3. |
|
4763 |
] ifFalse:[ |
|
4764 |
self cursorLine:clickLine col:newCursorCol. |
|
4765 |
]. |
|
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4766 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4767 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4768 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4769 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4770 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4771 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4772 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4773 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4774 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4775 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4776 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4777 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4778 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4779 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4780 |
] ifFalse:[ |
4048 | 4781 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4782 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4783 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4784 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4785 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4786 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4787 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4788 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4789 |
|
2580 | 4790 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4791 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4792 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4793 |
| n oldTypeOfSelection | |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4794 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4795 |
oldTypeOfSelection := typeOfSelection. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4796 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4797 |
self changeTypeOfSelectionTo:nil. |
2580 | 4798 |
|
4799 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4800 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4801 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4802 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4803 |
cursorCol := cursorCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4804 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4805 |
self validateNewSelection. |
4420 | 4806 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4807 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4808 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4809 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4810 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4811 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4812 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4813 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4814 |
self addToSelectionAfter:[ self cursorRight ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4815 |
] ifFalse:[ |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4816 |
"/ 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
|
4817 |
"/ 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
|
4818 |
"/ 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
|
4819 |
"/ (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
|
4820 |
"/ 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
|
4821 |
oldTypeOfSelection == #paste ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4822 |
cursorLine := selectionEndLine. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4823 |
cursorCol := selectionEndCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4824 |
]. |
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
|
4825 |
|
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
|
4826 |
"/ 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
|
4827 |
"/ 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
|
4828 |
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
|
4829 |
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
|
4830 |
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
|
4831 |
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
|
4832 |
^ self. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4833 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4834 |
self unselect; makeCursorVisible. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4835 |
self cursorRight. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4836 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4837 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4838 |
^ self |
2580 | 4839 |
]. |
4840 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4841 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4842 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4843 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4844 |
selectionEndCol := cursorCol - 1. |
4970 | 4845 |
"/ selectionEndCol == 1 ifTrue:[ |
4846 |
"/ selectionEndCol := 0. |
|
4847 |
"/ ]. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4848 |
self setCursorLine: cursorLine + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4849 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4850 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4851 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4852 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4853 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4854 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4855 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4856 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4857 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4858 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4859 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4860 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4861 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4862 |
"/ self setCursorLine:(selectionEndLine ? selectionStartLine). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4863 |
"/ self setCursorCol:selectionStartCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4864 |
"/ (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4865 |
"/ self setCursorCol:1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4866 |
"/ self setCursorLine:(cursorLine - 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4867 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4868 |
"/ self makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4869 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4870 |
"/ shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4871 |
"/ clickLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4872 |
"/ clickCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4873 |
"/ self setCursorLine: cursorLine + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4874 |
"/ self expandSelectionDown. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4875 |
"/ ^ self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4876 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4877 |
"/ self unselect. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4878 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4879 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4880 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4881 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4882 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4883 |
self addToSelectionAfter:[ self cursorDown:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4884 |
] 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
|
4885 |
"/ 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
|
4886 |
"/ 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
|
4887 |
"/ selectionStartCol column. This behavior is |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
4888 |
"/ 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
|
4889 |
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
|
4890 |
self setCursorLine: selectionEndLine. |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
4891 |
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
|
4892 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4893 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4894 |
self cursorDown:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4895 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4896 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4897 |
"/ flush keyboard to avoid runaway cursor |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4898 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4899 |
self sensor flushKeyboardFor:self. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4900 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4901 |
^ self |
2580 | 4902 |
]. |
4903 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4904 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4905 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4906 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4907 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4908 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4909 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4910 |
selectionStartCol := cursorCol-1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4911 |
self setCursorCol: cursorCol-1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4912 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4913 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4914 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4915 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4916 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4917 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4918 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4919 |
selectionEndLine := clickStartLine := cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4920 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4921 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4922 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4923 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4924 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4925 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4926 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4927 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4928 |
self redrawFromLine:selectionStartLine to:cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4929 |
self setCursorLine: cursorLine - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4930 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4931 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4932 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4933 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4934 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4935 |
self hasSelection ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4936 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4937 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4938 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4939 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4940 |
"/ self setCursorLine:selectionStartLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4941 |
"/ 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
|
4942 |
"/ 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
|
4943 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4944 |
"/ shifted ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4945 |
"/ self unselect. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4946 |
"/ ] |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4947 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4948 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4949 |
(key == #CursorLeft) ifTrue:[ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4950 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4951 |
self addToSelectionAfter:[self cursorLeft]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4952 |
] 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
|
4953 |
"/ 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
|
4954 |
"/ 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
|
4955 |
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
|
4956 |
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
|
4957 |
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
|
4958 |
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
|
4959 |
^ 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
|
4960 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4961 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4962 |
self cursorLeft. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4963 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4964 |
^self |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4965 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4966 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4967 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4968 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4969 |
self addToSelectionAfter: [ self cursorUp:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4970 |
] 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
|
4971 |
"/ 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
|
4972 |
"/ 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
|
4973 |
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
|
4974 |
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
|
4975 |
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
|
4976 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4977 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4978 |
self cursorUp:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4979 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4980 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4981 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4982 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4983 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4984 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4985 |
]. |
2580 | 4986 |
]. |
4420 | 4987 |
|
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
4988 |
"Modified: / 28-03-2014 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2580 | 4989 |
! |
4990 |
||
2952 | 4991 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4992 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4993 |
|
4521 | 4994 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 4995 |
#Replace #Undo #Redo #Accept |
3780 | 4996 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 4997 |
#DeleteSpaces #Join |
3780 | 4998 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 4999 |
#SelectWord #ExpandSelectionByWord |
3780 | 5000 |
#SelectToEnd #SelectFromBeginning |
4707 | 5001 |
#SelectLine #ExpandSelectionByLine |
3780 | 5002 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
5003 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5004 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5005 |
#GotoLine #BeginOfText #EndOfText |
|
5006 |
#InsertLine #DeleteLine |
|
5007 |
#SelectLineFromBeginning |
|
5008 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 5009 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 5010 |
#'F*' #'f*')> |
2017 | 5011 |
|
4730 | 5012 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5013 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5014 |
|
5015 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5016 |
|
4701 | 5017 |
"/ experimental |
4818 | 5018 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 5019 |
(immediateCompletion |
4818 | 5020 |
or:[currentUserPrefs codeCompletionOnControlKey |
5021 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5022 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5023 |
self initializeCompletionSupport. |
4609 | 5024 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5025 |
]. |
5394 | 5026 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5027 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5028 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5029 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5030 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5031 |
completionSupport notNil ifTrue:[ |
5394 | 5032 |
completionSupport stopCompletionProcess. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5033 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5034 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5035 |
|
4818 | 5036 |
key isSymbol ifTrue:[ |
4940 | 5037 |
(self graphicsDevice modifierKeys includes:key) ifFalse:[ |
4818 | 5038 |
lastReplacementInfo stillCollectingInput:false. |
5039 |
] |
|
5040 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5041 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 5042 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5043 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5044 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5045 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5046 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 5047 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5048 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5049 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5050 |
]. |
3799 | 5051 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5052 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5053 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5054 |
self learnMode ifTrue:[ |
4482 | 5055 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5056 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5057 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5058 |
|
4238 | 5059 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
5060 |
"the macro named key exists" |
|
3780 | 5061 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5062 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5063 |
|
4482 | 5064 |
key isSymbol ifFalse:[ |
5065 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
5066 |
self handleNonCommandKey:key. |
|
5067 |
^ self |
|
5068 |
]. |
|
5069 |
||
5070 |
event isNil ifTrue:[ |
|
5071 |
event := WindowGroup lastEventQuerySignal query. |
|
5072 |
]. |
|
5073 |
shiftPressed := event hasShift. |
|
5074 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5075 |
rawKey := event rawKey. |
4482 | 5076 |
|
5133 | 5077 |
key == #InsertUUID ifTrue:[ |
5078 |
self insertUUID. |
|
5079 |
^ self. |
|
5080 |
]. |
|
5081 |
||
4253 | 5082 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
5083 |
self deleteWordBeforeCursor. |
|
5084 |
^ self. |
|
5085 |
]. |
|
5086 |
||
5119 | 5087 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 5088 |
selectionStartLine notNil ifTrue:[ |
5089 |
((key == #BasicBackspace) |
|
4818 | 5090 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 5091 |
ifTrue:[ |
5092 |
self deleteSelection. |
|
5093 |
] ifFalse: [ |
|
5094 |
self copyAndDeleteSelection. |
|
5095 |
]. |
|
4609 | 5096 |
] ifFalse:[ |
5097 |
self makeCursorVisible. |
|
5098 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
5099 |
"/ self deleteWordBeforeCursor. |
|
5100 |
"/ ] ifFalse:[ |
|
5101 |
self deleteCharBeforeCursor. |
|
5102 |
"/ ]. |
|
3780 | 5103 |
]. |
4738 | 5104 |
true "immediateCompletion" ifTrue:[ |
5394 | 5105 |
completionSupport notNil ifTrue:[ |
5106 |
completionSupport postKeyPress:key |
|
5107 |
]. |
|
4731 | 5108 |
]. |
3780 | 5109 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5110 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5111 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5112 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5113 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5114 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5115 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5116 |
|
3235 | 5117 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5118 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 5119 |
^ self. |
3160 | 5120 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5121 |
|
4162 | 5122 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
5123 |
CharacterSetView notNil ifTrue:[ |
|
5124 |
self specialCharacters. |
|
5125 |
^ self. |
|
5126 |
] |
|
5127 |
]. |
|
5128 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5129 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5130 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5131 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5132 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 5133 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5134 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5135 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5136 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5137 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5138 |
(('[fF][0-9]' match:key) |
5139 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5140 |
shiftPressed ifFalse:[ |
|
4818 | 5141 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5142 |
fKeyMacros notNil ifTrue:[ |
5143 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5144 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5145 |
^ self |
|
5146 |
] |
|
5147 |
] |
|
5148 |
] |
|
5149 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5150 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5151 |
|
2506 | 5152 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5153 |
self parenthizeSelectionWith:$( and:$). |
5154 |
^ self. |
|
2506 | 5155 |
]. |
5156 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5157 |
self parenthizeSelectionWith:$" and:$". |
5158 |
^ self. |
|
2506 | 5159 |
]. |
5160 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5161 |
self parenthizeSelectionWith:$' and:$'. |
5162 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5163 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5164 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5165 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5166 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5167 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5168 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5169 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5170 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5171 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5172 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5173 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5174 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5175 |
|
3542 | 5176 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5177 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5178 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5179 |
self makeCursorVisible. |
|
5180 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5181 |
^ self |
|
5182 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5183 |
(key == #SelectWord) ifTrue:[ |
3780 | 5184 |
self makeCursorVisible. |
5185 |
self selectWordUnderCursor. |
|
5186 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5187 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5188 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5189 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5190 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5191 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5192 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5193 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5194 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5195 |
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
|
5196 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5197 |
(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
|
5198 |
(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
|
5199 |
(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
|
5200 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5201 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5202 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5203 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5204 |
shiftPressed ifTrue: [ |
5205 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5206 |
"/ self unselect. |
|
5207 |
"/ self cursorHome. |
|
5208 |
"Jan's modification" |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5209 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
4257 | 5210 |
"/ 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
|
5211 |
"/ 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
|
5212 |
"/ self selectFromBeginOfLine. |
3780 | 5213 |
] ifFalse: [ |
5214 |
self unselect. |
|
5215 |
ctrlPressed ifTrue:[ |
|
5216 |
self cursorHome. |
|
5217 |
] ifFalse:[ |
|
5218 |
self cursorToBeginOfLine. |
|
5219 |
] |
|
5220 |
]. |
|
5221 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5222 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5223 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5224 |
shiftPressed ifTrue:[ |
5225 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5226 |
"/ self unselect. |
|
5227 |
"/ self cursorToBottom |
|
4257 | 5228 |
" Jan's modification" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5229 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
4257 | 5230 |
"/ 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
|
5231 |
"/ 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
|
5232 |
"/ self selectToEndOfLine. |
3780 | 5233 |
] ifFalse:[ |
5234 |
self unselect. |
|
5235 |
ctrlPressed ifTrue:[ |
|
5236 |
self cursorToBottom |
|
5237 |
] ifFalse:[ |
|
5238 |
self cursorToEndOfLine. |
|
5239 |
] |
|
5240 |
]. |
|
5241 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5242 |
]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5243 |
(key == #NextWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5244 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5245 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5246 |
self cursorToNextWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5247 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5248 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5249 |
self cursorToNextWord |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5250 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5251 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5252 |
]. |
3310 | 5253 |
(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
|
5254 |
(key == #PreviousWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5255 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5256 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5257 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5258 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5259 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5260 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5261 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5262 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5263 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5264 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5265 |
|
5119 | 5266 |
(rawKey == #CursorRight |
5267 |
or:[rawKey == #CursorDown |
|
5268 |
or:[rawKey == #CursorLeft |
|
5269 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5270 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5271 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5272 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5273 |
|
5119 | 5274 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5275 |
self unselect. self cursorReturn. |
5276 |
^ self |
|
3257 | 5277 |
]. |
5278 |
||
5279 |
(key == #Return) ifTrue:[ |
|
3780 | 5280 |
shiftPressed ifTrue:[ |
5281 |
self unselect. self cursorReturn. |
|
5282 |
^ self |
|
5283 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5284 |
|
3780 | 5285 |
self isReadOnly ifTrue:[ |
5286 |
self unselect; makeCursorVisible. |
|
5287 |
self cursorReturn |
|
5288 |
] ifFalse:[ |
|
5289 |
self isInInsertMode ifFalse:[ |
|
5290 |
self cursorReturn. |
|
5291 |
autoIndent == true ifTrue:[ |
|
5292 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5293 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5294 |
self cursorCol:(i+1 max:1) |
5295 |
] |
|
3780 | 5296 |
] |
5297 |
] ifTrue:[ |
|
4826 | 5298 |
|left right oldIndent| |
4812 | 5299 |
|
3780 | 5300 |
"/ old version just unselected ... |
5301 |
"/ self unselect; makeCursorVisible. |
|
5302 |
||
5303 |
"/ new version deletes ... |
|
5304 |
typeOfSelection == #paste ifTrue:[ |
|
5305 |
self unselect; makeCursorVisible. |
|
5306 |
] ifFalse:[ |
|
5307 |
self copyAndDeleteSelection. |
|
5308 |
]. |
|
4816 | 5309 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5310 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5311 |
self insertCharAtCursor:(Character cr). |
5112 | 5312 |
|
3780 | 5313 |
autoIndent == true ifTrue:[ |
4816 | 5314 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5315 |
"/ nothing to do. |
|
4812 | 5316 |
] ifFalse:[ |
5317 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5318 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5319 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5320 |
left := left withoutSeparators. |
5321 |
right := right withoutSeparators. |
|
5322 |
(left endsWith:'[') ifTrue:[ |
|
5323 |
"/ i := i + 4. |
|
4816 | 5324 |
] ifFalse:[ |
4823 | 5325 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5326 |
i := i - 4. |
5327 |
]. |
|
4812 | 5328 |
]. |
4826 | 5329 |
oldIndent := self leftIndentOfLine:cursorLine. |
5330 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5331 |
self st80EditMode ifTrue:[ |
|
5332 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5333 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5334 |
]. |
|
5335 |
]. |
|
4812 | 5336 |
self cursorCol:(i+1 max:1) |
5337 |
]. |
|
5338 |
] |
|
3780 | 5339 |
]. |
5340 |
]. |
|
5341 |
]. |
|
5342 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5343 |
]. |
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
|
5344 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5345 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5346 |
self unselect. self cursorTab. |
5347 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5348 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5349 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5350 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5351 |
||
5352 |
self hasSelection ifTrue:[ |
|
5353 |
selectStyle == #line ifTrue:[ |
|
4238 | 5354 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5355 |
macroName := #IndentBy4. |
|
5356 |
] ifFalse:[ |
|
5357 |
macroName := #UndentBy4. |
|
5358 |
]. |
|
5359 |
macroName notNil ifTrue:[ |
|
5360 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5361 |
]. |
5362 |
] |
|
5363 |
]. |
|
5364 |
||
5365 |
self unselect. |
|
5366 |
(key == #Tab) ifTrue:[ |
|
5367 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5368 |
self cursorTab. |
|
5369 |
^ self |
|
5370 |
]. |
|
5371 |
self insertTabAtCursor. |
|
5372 |
^ self |
|
5373 |
]. |
|
5374 |
self cursorBacktab. |
|
5375 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5376 |
]. |
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
|
5377 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5378 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5379 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5380 |
shiftPressed ifTrue:[ |
5381 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5382 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5383 |
self makeCursorVisible. |
|
5384 |
self deleteCharAtCursor. |
|
5385 |
]. |
|
5386 |
^ self |
|
5387 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5388 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5389 |
|
5119 | 5390 |
(rawKey == #Delete |
870 | 5391 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5392 |
selectionStartLine notNil ifTrue:[ |
4130 | 5393 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5394 |
"/ To remove text repetetively, use Cut instead. |
|
5395 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5396 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5397 |
((key == #BasicDelete) |
4818 | 5398 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5399 |
self deleteSelection. |
5400 |
] ifFalse:[ |
|
5401 |
self copyAndDeleteSelection. |
|
5402 |
]. |
|
5403 |
^ self |
|
5404 |
]. |
|
5405 |
self makeCursorVisible. |
|
5406 |
self deleteCharAtCursor. |
|
5407 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5408 |
]. |
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
|
5409 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5410 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5411 |
self unselect. |
5412 |
cursorVisibleLine == 1 ifTrue:[ |
|
5413 |
self cursorHome. |
|
5414 |
] ifFalse:[ |
|
5415 |
self cursorToFirstVisibleLine |
|
5416 |
]. |
|
5417 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5418 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5419 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5420 |
self unselect. |
5421 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5422 |
self cursorToBottom. |
|
5423 |
] ifFalse:[ |
|
5424 |
self cursorToLastVisibleLine |
|
5425 |
]. |
|
5426 |
^ self |
|
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 |
((key == #Escape) |
3257 | 5429 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5430 |
self makeCursorVisible. |
5431 |
self unselect. self selectCursorLineFromBeginning. |
|
5432 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5433 |
]. |
3257 | 5434 |
(key == #SelectLine) ifTrue:[ |
3780 | 5435 |
self makeCursorVisible. |
5436 |
self unselect. self selectCursorLine. |
|
5437 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5438 |
]. |
3257 | 5439 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5440 |
"/ self makeCursorVisible. |
3780 | 5441 |
self selectExpandCursorLine. |
5442 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5443 |
]. |
3257 | 5444 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5445 |
self makeCursorVisible. |
5446 |
self unselect. self deleteCursorLine. |
|
5447 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5448 |
]. |
3257 | 5449 |
(key == #InsertLine) ifTrue:[ |
3780 | 5450 |
self makeCursorVisible. |
5451 |
self unselect. self insertLine:nil before:cursorLine. |
|
5452 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5453 |
]. |
3781 | 5454 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5455 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5456 |
|
3310 | 5457 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5458 |
"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
|
5459 |
"Modified: / 31-03-2014 / 16:27:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5460 |
! |
5461 |
||
2952 | 5462 |
executeKeyboardMacro:cmdMacro |
5463 |
Error handle:[:ex | |
|
4823 | 5464 |
self warn:'Error in keyboard macro: ' , ex description. |
5465 |
ex return. |
|
2952 | 5466 |
] do:[ |
4823 | 5467 |
AbortOperationRequest handle:[:ex | |
5468 |
self warn:'Keyboard macro aborted'. |
|
5469 |
ex return. |
|
5470 |
] do:[ |
|
5471 |
Parser |
|
5472 |
evaluate:cmdMacro asString |
|
5473 |
receiver:self |
|
5474 |
notifying:nil |
|
5475 |
compile:false. |
|
5476 |
]. |
|
2952 | 5477 |
]. |
5478 |
! |
|
5479 |
||
5340
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5480 |
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
|
5481 |
| 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
|
5482 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5483 |
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
|
5484 |
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
|
5485 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5486 |
(x < leftMargin) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5487 |
movedCol := 0 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5488 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5489 |
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
|
5490 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5491 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5492 |
"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
|
5493 |
movedUp := false. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5494 |
(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
|
5495 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5496 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5497 |
(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
|
5498 |
(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
|
5499 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5500 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5501 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5502 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5503 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5504 |
self hasSelection ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5505 |
movedUp ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5506 |
"/ 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
|
5507 |
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
|
5508 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5509 |
"/ 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
|
5510 |
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
|
5511 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5512 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5513 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5514 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5515 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5516 |
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
|
5517 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5518 |
"Created: / 02-05-2015 / 07:33:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5519 |
! |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5520 |
|
2952 | 5521 |
handleNonCommandKey:keyArg |
4700 | 5522 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5523 |
|
5524 |
self isReadOnly ifTrue:[ |
|
4988 | 5525 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5526 |
^ self. |
2952 | 5527 |
]. |
5528 |
||
5529 |
key := keyArg. |
|
5530 |
||
5531 |
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
|
5532 |
"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
|
5533 |
|
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
|
5534 |
"/ 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
|
5535 |
"/ 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
|
5536 |
"/ 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
|
5537 |
"/ 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
|
5538 |
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
|
5539 |
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
|
5540 |
|
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
|
5541 |
"/ 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
|
5542 |
self unselect. |
2952 | 5543 |
]. |
5544 |
||
4700 | 5545 |
selStartLineBefore := selectionStartLine. |
5546 |
selStartColBefore := self selectionStartCol. |
|
5547 |
selEndLineBefore := selectionEndLine. |
|
5548 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5549 |
|
4940 | 5550 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 5551 |
key isCharacter ifTrue:[ |
4940 | 5552 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5553 |
] ifFalse:[ |
4940 | 5554 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5555 |
]. |
2952 | 5556 |
]. |
5557 |
||
5558 |
"replace selection by what is typed in - |
|
3235 | 5559 |
if word was selected with a space, keep it. |
4700 | 5560 |
if there was no selection, the key's character is inserted" |
3235 | 5561 |
|
5562 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5563 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5564 |
]. |
2952 | 5565 |
|
5566 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5567 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5568 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5569 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5570 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5571 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5572 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5573 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5574 |
] |
3160 | 5575 |
]. |
2952 | 5576 |
selectStyle := nil. |
5577 |
||
3235 | 5578 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5579 |
selectionStartLine := selStartLineBefore. |
5580 |
selectionStartCol := selStartColBefore. |
|
5581 |
selectionEndLine := selEndLineBefore. |
|
5582 |
selectionEndCol := selEndColBefore. |
|
3235 | 5583 |
]. |
5584 |
||
2952 | 5585 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5586 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5587 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5588 |
"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
|
5589 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5590 |
" |
2952 | 5591 |
" |
4481 | 5592 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5593 |
" |
4481 | 5594 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5595 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5596 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5597 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5598 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5599 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5600 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5601 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5602 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5603 |
self cursorLine:line col:col. |
4940 | 5604 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5605 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5606 |
"/ 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
|
5607 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5608 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5609 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5610 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5611 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5612 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5613 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5614 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5615 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5616 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5617 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5618 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5619 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5620 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5621 |
] |
2952 | 5622 |
]. |
5623 |
||
5624 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5625 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5626 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5627 |
"/ |
|
5628 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5629 |
"/ self selection. |
|
5630 |
"/ typeOfSelection := #paste. |
|
3160 | 5631 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5632 |
"/ ]. |
3235 | 5633 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5634 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5635 |
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
|
5636 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5637 |
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
|
5638 |
]. |
3235 | 5639 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5640 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5641 |
|
5642 |
"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
|
5643 |
"Modified: / 30-08-2013 / 20:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 5644 |
! |
5645 |
||
5646 |
keyPress:key x:x y:y |
|
5647 |
"handle keyboard input" |
|
5648 |
||
4771 | 5649 |
|wasOn| |
5650 |
||
5651 |
wasOn := cursorShown. |
|
5652 |
||
5653 |
NoModificationError handle:[:ex | |
|
4988 | 5654 |
self flashReadOnly. |
4771 | 5655 |
(cursorShown not and:[wasOn]) ifTrue:[ |
5656 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5657 |
]. |
|
5658 |
] do:[ |
|
5659 |
self undoableDo:[ |
|
5660 |
self doKeyPress:key x:x y:y |
|
5661 |
]. |
|
4242 | 5662 |
]. |
5663 |
self repairDamage |
|
5664 |
||
5665 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
2952 | 5666 |
! |
5667 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5668 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5669 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5670 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5671 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5672 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5673 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5674 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5675 |
requestAutoAccept |
5068 | 5676 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
5677 |
This forces my value to be accepted into my model. |
|
5678 |
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
|
5679 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5680 |
acceptEnabled == false ifTrue:[ |
4823 | 5681 |
"/ nope - |
5682 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5683 |
]. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5684 |
self accept. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5685 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5686 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5687 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5688 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5689 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5690 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5691 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5692 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5693 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5694 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5695 |
cv notNil ifTrue:[ |
4823 | 5696 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5697 |
] |
4967 | 5698 |
! |
5699 |
||
5700 |
unmapped |
|
5701 |
super unmapped. |
|
5702 |
||
5703 |
completionSupport notNil ifTrue:[ |
|
5704 |
completionSupport release. |
|
5705 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5706 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5707 |
|
1807 | 5708 |
!EditTextView methodsFor:'focus handling'! |
5709 |
||
4818 | 5710 |
focusOut |
5711 |
super focusOut. |
|
5712 |
||
5713 |
completionSupport notNil ifTrue:[ |
|
5714 |
completionSupport release. |
|
5715 |
]. |
|
5716 |
! |
|
5717 |
||
1807 | 5718 |
hasKeyboardFocus:aBoolean |
5719 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5720 |
(otherwise, I would not know about this)" |
|
5721 |
||
5722 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5723 |
|
3160 | 5724 |
(cursorShown |
5725 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5726 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5727 |
self drawCursor |
5728 |
]. |
|
5729 |
||
5730 |
hasKeyboardFocus ifFalse:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5731 |
completionSupport notNil ifTrue:[ |
4821 | 5732 |
"/ this is a hack for Windows: |
5733 |
"/ on windows, an activate:false event is first sent to my textView, |
|
5734 |
"/ then an activate is sent to the completion popup. |
|
5735 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
5736 |
"/ therefore, allow for the activate of the completionMenu and it's button event to be processed. |
|
5737 |
"/ before forcing it to be closed... |
|
5216 | 5738 |
Processor addTimedBlock:[completionSupport editViewLostFocus] afterMilliseconds:200. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5739 |
]. |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5740 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5741 |
|
4821 | 5742 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 5743 |
! |
5744 |
||
5745 |
showFocus:explicit |
|
5746 |
"in addition to however my superclass thinks how a focusView is to be |
|
5747 |
displayed, show the cursor when I got the focus" |
|
5748 |
||
5239 | 5749 |
self hasKeyboardFocus:true. |
1807 | 5750 |
self showCursor. |
5751 |
super showFocus:explicit |
|
5752 |
||
5753 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5754 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5755 |
|
4967 | 5756 |
showNoFocus:explicit |
5757 |
"the view lost the keyboard focus |
|
5758 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
5759 |
- change any display attributes as req'd." |
|
5760 |
||
5761 |
super showNoFocus:explicit. |
|
5149 | 5762 |
|
5763 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
5764 |
"/ not when the focus is lost normally (because this also happens when |
|
5765 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
5766 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
5767 |
explicit ifTrue:[ |
|
5768 |
completionSupport notNil ifTrue:[ |
|
5769 |
completionSupport release. |
|
5770 |
]. |
|
4818 | 5771 |
]. |
5772 |
! |
|
5773 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5774 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5775 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5776 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5777 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5778 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5779 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5780 |
and:[self enabled |
4781 | 5781 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5782 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5783 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5784 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5785 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5786 |
^ false |
1807 | 5787 |
! ! |
5788 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5789 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5790 |
|
4237 | 5791 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5792 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5793 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5794 |
|
4482 | 5795 |
|cmdMacro| |
5796 |
||
5797 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5798 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5799 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5800 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5801 |
^ true |
4238 | 5802 |
|
5803 |
" |
|
4483 | 5804 |
EditTextView open |
4238 | 5805 |
contents:'bla'; |
5806 |
selectAll; |
|
5807 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 5808 |
EditTextView open |
4238 | 5809 |
contents:'bla'; |
5810 |
selectAll; |
|
5811 |
executekeyboardMacroNamed:#blabla. |
|
5812 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5813 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5814 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 5815 |
! |
5816 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5817 |
indent |
3221 | 5818 |
"indent a line-range - this is done by searching for the |
5819 |
last non-empty line before the selection, and changing the indent |
|
4742 | 5820 |
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
|
5821 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5822 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5823 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5824 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 5825 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5826 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5827 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5828 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 5829 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5830 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5831 |
self unselect. |
3160 | 5832 |
self |
3786 | 5833 |
undoableDo:[self indentFromLine:start toLine:end] |
5834 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5835 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5836 |
|
4237 | 5837 |
indentBy4 |
5050 | 5838 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
5839 |
||
5840 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5841 |
! |
|
5842 |
||
5843 |
indentBy8 |
|
5844 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 5845 |
|
5846 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5847 |
! |
|
5848 |
||
5050 | 5849 |
indentBy:n |
5850 |
|line1 line2| |
|
5851 |
||
5852 |
line1 := self selectionStartLine. |
|
5853 |
line2 := self selectionEndLine. |
|
5854 |
line1 isNil ifTrue:[ |
|
5855 |
line1 := self cursorLine. |
|
5856 |
line1 notNil ifTrue:[ |
|
5857 |
line2 := line1+1 |
|
5858 |
] |
|
5859 |
]. |
|
5860 |
line1 notNil ifTrue:[ |
|
5861 |
self indentFromLine:line1 toLine:line2 by:n. |
|
5862 |
] |
|
5863 |
! |
|
5864 |
||
5865 |
indentByTab |
|
5866 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
5867 |
! |
|
5868 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5869 |
indentFromLine:start toLine:end |
3221 | 5870 |
"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
|
5871 |
last non-empty line before start, and change the indent |
4742 | 5872 |
of the selected line-range based on that line's indent." |
5873 |
||
4811 | 5874 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5875 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5876 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5877 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5878 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5879 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5880 |
(delta == 0) ifTrue:[^ self]. |
4811 | 5881 |
self indentFromLine:start toLine:end by:delta |
5882 |
! |
|
5883 |
||
5884 |
indentFromLine:start toLine:end by:delta |
|
5885 |
"indent a line-range - this is done by searching for the |
|
5886 |
last non-empty line before start, and change the indent |
|
5887 |
of the selected line-range based on that line's indent." |
|
5888 |
||
5889 |
|d line spaces anyChange| |
|
5890 |
||
5891 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5892 |
(delta > 0) ifTrue:[ |
4742 | 5893 |
spaces := String new:delta |
5894 |
]. |
|
5895 |
||
5896 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5897 |
start to:end do:[:lineNr | |
4742 | 5898 |
line := self listAt:lineNr. |
5899 |
line notNil ifTrue:[ |
|
5900 |
line isBlank ifTrue:[ |
|
4771 | 5901 |
self basicListAt:lineNr put:nil |
4742 | 5902 |
] ifFalse:[ |
5903 |
(delta > 0) ifTrue:[ |
|
5904 |
line := spaces , line. |
|
5905 |
widthOfWidestLine notNil ifTrue:[ |
|
5906 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
5907 |
] |
|
5908 |
] ifFalse:[ |
|
5909 |
"check if deletion is ok" |
|
5910 |
d := delta negated + 1. |
|
5911 |
||
5912 |
line size > d ifTrue:[ |
|
5913 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
5914 |
line := line copyFrom:d |
|
5915 |
] |
|
5916 |
]. |
|
5917 |
widthOfWidestLine := nil |
|
5918 |
]. |
|
5919 |
self replaceLine:lineNr with:line. |
|
5920 |
anyChange := true. |
|
5921 |
] |
|
5922 |
] |
|
5923 |
]. |
|
5924 |
||
5925 |
anyChange ifTrue:[ self textChanged ]. |
|
5926 |
||
3221 | 5927 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5928 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5929 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5930 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5931 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5932 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5933 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5934 |
this is done by searching for the last non-empty line before it |
4823 | 5935 |
and returning its indent. |
5936 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5937 |
|
827 | 5938 |
"SHOULD GO TO ListView" |
5939 |
||
5940 |
|line lnr indent| |
|
5941 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5942 |
lnr := lineNr. |
827 | 5943 |
|
4823 | 5944 |
"/ [lnr ~~ 1] whileTrue:[ |
5945 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 5946 |
lnr := lnr - 1. |
5947 |
line := self listAt:lnr. |
|
5948 |
||
5949 |
line notNil ifTrue:[ |
|
5950 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
5951 |
indent ~~ 0 ifTrue:[ |
|
5952 |
(line endsWith:$[) ifTrue:[ |
|
5953 |
^ indent + 4 - 1 |
|
5954 |
]. |
|
5955 |
^ indent - 1 |
|
5956 |
] |
|
5957 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5958 |
]. |
827 | 5959 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5960 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5961 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 5962 |
! |
5963 |
||
5964 |
undentBy4 |
|
5050 | 5965 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
5966 |
||
5967 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5968 |
! |
|
5969 |
||
5970 |
undentBy8 |
|
5971 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 5972 |
|
5973 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 5974 |
! |
5975 |
||
5976 |
undentBy:n |
|
5977 |
self indentBy:(n negated) |
|
5978 |
! |
|
5979 |
||
5980 |
undentByTab |
|
5981 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 5982 |
! ! |
5983 |
||
0 | 5984 |
!EditTextView methodsFor:'initialization'! |
5985 |
||
941 | 5986 |
fetchDeviceResources |
5987 |
"fetch device colors, to avoid reallocation at redraw time" |
|
5988 |
||
5989 |
super fetchDeviceResources. |
|
5990 |
||
4940 | 5991 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:self graphicsDevice]. |
5992 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:self graphicsDevice]. |
|
5993 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:self graphicsDevice]. |
|
941 | 5994 |
|
5995 |
"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
|
5996 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 5997 |
! |
5998 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5999 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6000 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6001 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6002 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6003 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6004 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6005 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6006 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6007 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6008 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6009 |
super initStyle. |
4576 | 6010 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6011 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6012 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6013 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6014 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6015 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6016 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6017 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6018 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6019 |
cursorTypeNoFocus := cursorType. |
|
6020 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6021 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6022 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6023 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6024 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6025 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 6026 |
cursorType ~~ #block ifTrue:[ |
6027 |
cursorNoFocusFgColor := cursorBgColor |
|
6028 |
] ifFalse:[ |
|
6029 |
cursorNoFocusFgColor := cursorFgColor |
|
6030 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6031 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6032 |
|
2088 | 6033 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6034 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6035 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6036 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6037 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6038 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6039 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6040 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6041 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6042 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6043 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6044 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6045 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6046 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6047 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6048 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6049 |
cursorCol := 1. |
5251 | 6050 |
cursorLineHolder := ValueHolder with:1. |
6051 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6052 |
modifiedChannel := ValueHolder with:false. |
6053 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6054 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6055 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6056 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6057 |
tabMeansNextField := false. |
5106 | 6058 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6059 |
autoIndent := false. |
|
5251 | 6060 |
editMode := ValueHolder with:EditMode insertMode. |
6061 |
learnMode := ValueHolder with:false. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6062 |
trimBlankLines := self st80EditMode not. |
2131 | 6063 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6064 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6065 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6066 |
"/ enable drop by default |
2589 | 6067 |
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
|
6068 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6069 |
undoSupport := UndoSupport for:self. |
5251 | 6070 |
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
|
6071 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6072 |
"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
|
6073 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6074 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6075 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6076 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6077 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6078 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6079 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6080 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6081 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6082 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6083 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6084 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6085 |
! |
6086 |
||
6087 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6088 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6089 |
completionSupport release |
4771 | 6090 |
]. |
6091 |
super release |
|
0 | 6092 |
! ! |
6093 |
||
2580 | 6094 |
!EditTextView methodsFor:'macros'! |
6095 |
||
6096 |
executeLearnedKeyboardMacro |
|
4673 | 6097 |
"replay the characters as learned previously" |
6098 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6099 |
(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
|
6100 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6101 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6102 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6103 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6104 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6105 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6106 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6107 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6108 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6109 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6110 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6111 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6112 |
]. |
2580 | 6113 |
] ifFalse:[ |
5153 | 6114 |
self flash:'no macro'. |
2580 | 6115 |
]. |
6116 |
! |
|
6117 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6118 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6119 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6120 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6121 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6122 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6123 |
|
2580 | 6124 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6125 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6126 |
|
2580 | 6127 |
|fg bg| |
6128 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6129 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6130 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6131 |
aBoolean ifTrue:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6132 |
learnedMacro := OrderedCollection new. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6133 |
fg := Color white. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6134 |
bg := Color black. |
2580 | 6135 |
] ifFalse:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6136 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6137 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
2580 | 6138 |
]. |
6139 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6140 |
! |
|
6141 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6142 |
learnModeHolder |
4673 | 6143 |
"a holder returning true, if in learn mode" |
6144 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6145 |
learnMode isNil ifTrue:[ |
5251 | 6146 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6147 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6148 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6149 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6150 |
|
4673 | 6151 |
rememberLearnedMacroAs: nameString |
6152 |
Macros isNil ifTrue:[ |
|
6153 |
Macros := Dictionary new. |
|
6154 |
]. |
|
6155 |
Macros at:nameString put:learnedMacro |
|
6156 |
! |
|
6157 |
||
2580 | 6158 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6159 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6160 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6161 |
self learnMode:(self learnMode not). |
2580 | 6162 |
! ! |
6163 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6164 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6165 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6166 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6167 |
"translate the selected text and paste it after the selection" |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6168 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6169 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6170 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6171 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6172 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6173 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6174 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
6175 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 6176 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
6177 |
] do:[ |
|
6178 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
6179 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6180 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6181 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6182 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6183 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6184 |
self unselect. |
3799 | 6185 |
self |
6186 |
undoablePaste:translated |
|
6187 |
info:'Translate' |
|
3495 | 6188 |
|
6189 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6190 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6191 |
|
3517 | 6192 |
compareWithClipboard |
6193 |
"compare the selection against the clipboard contents" |
|
6194 |
||
6195 |
|t1 t2| |
|
6196 |
||
6197 |
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
|
6198 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6199 |
Dialog information:'Clipboard is empty.'. |
6200 |
^ self. |
|
3517 | 6201 |
]. |
6202 |
||
6203 |
self hasSelection ifTrue:[ |
|
4823 | 6204 |
t1 := self selectionAsString. |
3517 | 6205 |
] ifFalse:[ |
4823 | 6206 |
t1 := self contents asString |
3517 | 6207 |
]. |
6208 |
t1 := t1 string. |
|
6209 |
||
6210 |
t1 = t2 ifTrue:[ |
|
4823 | 6211 |
Dialog information:'Strings are equal.'. |
6212 |
^ self. |
|
3517 | 6213 |
]. |
6214 |
DiffTextView |
|
4823 | 6215 |
openOn:t1 label:'Editor' |
6216 |
and:t2 label:'Clipboard' |
|
3517 | 6217 |
! |
6218 |
||
121 | 6219 |
cut |
6220 |
"cut selection into copybuffer" |
|
6221 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6222 |
self deleteCopyToClipboard:true |
121 | 6223 |
! |
6224 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6225 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6226 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6227 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6228 |
cursorLine notNil ifTrue:[ |
4823 | 6229 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6230 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6231 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6232 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6233 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6234 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6235 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6236 |
|
4129 | 6237 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6238 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6239 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6240 |
self flashReadOnly. |
3786 | 6241 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6242 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6243 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6244 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6245 |
sel notNil ifTrue:[ |
4129 | 6246 |
self setLastStringToReplace: sel. |
4053 | 6247 |
|
3786 | 6248 |
line := selectionStartLine. |
6249 |
col := selectionStartCol. |
|
6250 |
||
6251 |
toClipboard ifTrue:[ |
|
6252 |
" |
|
6253 |
remember in CopyBuffer |
|
6254 |
" |
|
6255 |
self setClipboardText:sel. "/ lastString. |
|
6256 |
]. |
|
6257 |
||
6258 |
" |
|
6259 |
append to DeleteHistory (if there is one) |
|
6260 |
" |
|
6261 |
history := Smalltalk at:#DeleteHistory. |
|
6262 |
history notNil ifTrue:[ |
|
6263 |
history addAll:(sel asStringCollection). |
|
6264 |
history size > 1000 ifTrue:[ |
|
6265 |
history := history copyFrom:(history size - 1000) |
|
6266 |
]. |
|
6267 |
]. |
|
6268 |
||
6269 |
" |
|
6270 |
now, delete it |
|
6271 |
" |
|
6272 |
self |
|
6273 |
undoableDo:[self deleteSelection] |
|
6274 |
info:'Delete'. |
|
4048 | 6275 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6276 |
] ifFalse:[ |
3786 | 6277 |
" |
6278 |
a cut without selection will search&cut again |
|
6279 |
" |
|
6280 |
self undoableDo:[ |
|
6281 |
self again |
|
6282 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6283 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6284 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6285 |
"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
|
6286 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6287 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6288 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6289 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6290 |
|
3781 | 6291 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
6292 |
#Find #GotoLine #SaveAs #Print |
|
3890 | 6293 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6294 |
#ToggleAutoIndent #ToggleInsertMode |
6295 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6296 |
<resource: #programMenu> |
1054 | 6297 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6298 |
|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
|
6299 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6300 |
|
2460 | 6301 |
items := #( |
3781 | 6302 |
('Redo' redo Redo ) |
6303 |
('Again (for All)' multipleAgain AgainForAll ) |
|
3731 | 6304 |
('-' ) |
6305 |
('Search...' search Find ) |
|
6306 |
('Goto Line...' gotoLine GotoLine ) |
|
6307 |
('-' ) |
|
4940 | 6308 |
('Tools' tools ) |
6309 |
('Insert Unicode...' insertUnicode ) |
|
6310 |
). |
|
4213 | 6311 |
CharacterSetView notNil ifTrue:[ |
6312 |
items := items , |
|
6313 |
#( |
|
6314 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6315 |
). |
|
6316 |
]. |
|
6317 |
items := items , #( |
|
3731 | 6318 |
('-' ) |
6319 |
('Save As...' save SaveAs ) |
|
6320 |
('Print' doPrint Print ) |
|
6321 |
('=' ) |
|
4213 | 6322 |
('Misc' misc ShiftCtrl) ). |
2460 | 6323 |
|
2866 | 6324 |
miscItems := #( |
3781 | 6325 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6326 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
3731 | 6327 |
('-' ) |
6328 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
3781 | 6329 |
('Join Lines' joinLines Join ) |
4388 | 6330 |
('Wrap Lines...' wrapLines Wrap ) |
3731 | 6331 |
('-' ) |
3781 | 6332 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
6333 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
3731 | 6334 |
('-' ) |
3811 | 6335 |
('Insert File...' insertFile ) |
6336 |
('Insert URL Contents...' insertURL ) |
|
3781 | 6337 |
('Insert new UUID' insertUUID ) |
6338 |
('Insert Date && Time' insertDateAndTime ) |
|
3732 | 6339 |
('-' ) |
6340 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6341 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
3731 | 6342 |
('-' ) |
6343 |
). |
|
4213 | 6344 |
"/ CharacterSetView notNil ifTrue:[ |
6345 |
"/ miscItems := miscItems , |
|
6346 |
"/ #( |
|
6347 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6348 |
"/ ). |
|
6349 |
"/ ]. |
|
3406
c5efa51e7929
dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents:
3402
diff
changeset
|
6350 |
miscItems := miscItems , |
3731 | 6351 |
#( |
6352 |
('Font...' changeFont ) |
|
2870 | 6353 |
"/ ('Encoding...' changeEncoding ) |
3731 | 6354 |
). |
2866 | 6355 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6356 |
translateItems := #( |
3731 | 6357 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6358 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6359 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6360 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6361 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6362 |
('-' ) |
|
6363 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6364 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6365 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6366 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6367 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6368 |
). |
|
3221 | 6369 |
|
6370 |
sortItems := #( |
|
3731 | 6371 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6372 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4373 | 6373 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
6374 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6375 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
3731 | 6376 |
('Words' (sortSelection:ignoreCase: #words false) ) |
6377 |
('-' ) |
|
4373 | 6378 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
6379 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6380 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6381 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
4763 | 6382 |
('-' ) |
6383 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6384 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
3731 | 6385 |
). |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6386 |
|
2762 | 6387 |
toolItems := #( |
3731 | 6388 |
('Indent' indent ) |
4287 | 6389 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
3731 | 6390 |
('Sort' sort ) |
5370 | 6391 |
('Split...' splitLinesAtCharacterOrString ) |
3731 | 6392 |
('-' ) |
4742 | 6393 |
('Google Spell Check' googleSpellingSuggestion ) |
6394 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
3731 | 6395 |
('Translate' babelFishTranslate ) |
6396 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6397 |
). |
|
2762 | 6398 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6399 |
Smalltalk isStandAloneApp ifFalse:[ |
3731 | 6400 |
toolItems := toolItems , #( |
6401 |
('-' ) |
|
6402 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6403 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
5331 | 6404 |
('Inspect String' inspectSelectedString ) |
3731 | 6405 |
). |
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6406 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6407 |
|
2460 | 6408 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6409 |
sub receiver:self. |
2460 | 6410 |
|
2919 | 6411 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6412 |
toolSub receiver:self. |
|
6413 |
sub subMenuAt:#tools put:toolSub. |
|
6414 |
||
3495 | 6415 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6416 |
transSub receiver:self. |
|
6417 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6418 |
||
6419 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6420 |
sortSub receiver:self. |
|
6421 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6422 |
|
2866 | 6423 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6424 |
subSub receiver:self. |
|
2952 | 6425 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6426 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6427 |
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
|
6428 |
|
2866 | 6429 |
sub subMenuAt:#misc put:subSub. |
6430 |
||
3495 | 6431 |
mainItems := #( |
3731 | 6432 |
('Undo' undo Undo ) |
6433 |
('Again' again Again ) |
|
6434 |
('-' ) |
|
6435 |
('Cut' cut Cut ) |
|
6436 |
('Copy' copySelection Copy ) |
|
6437 |
('Paste' pasteOrReplace Paste ) |
|
6438 |
('-' ) |
|
6439 |
('Accept' accept Accept ) |
|
6440 |
('=' ) |
|
6441 |
('More' others Ctrl ) |
|
6442 |
). |
|
3495 | 6443 |
main := PopUpMenu itemList:mainItems resources:resources. |
6444 |
main subMenuAt:#others put:sub. |
|
6445 |
||
6446 |
sensor := self sensor. |
|
6447 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6448 |
sensor shiftDown ifTrue:[ |
|
3731 | 6449 |
m := subSub |
6450 |
] ifFalse:[ |
|
6451 |
m := sub |
|
6452 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6453 |
] ifFalse:[ |
3731 | 6454 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6455 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6456 |
|
4742 | 6457 |
"/ the 'Smalltalk at:' code is here to |
6458 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6459 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
3731 | 6460 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6461 |
m disable:#googleSpellingSuggestion |
|
2676 | 6462 |
]. |
4742 | 6463 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
6464 |
m disable:#internalSpellingSuggestion |
|
6465 |
]. |
|
2676 | 6466 |
|
3811 | 6467 |
HTTPInterface isNil ifTrue:[ |
6468 |
m disableAll:#(insertURL) |
|
6469 |
]. |
|
6470 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6471 |
self isReadOnly ifTrue:[ |
4475 | 6472 |
m disableAll:#(accept undo again multipleAgain redo |
3731 | 6473 |
paste pasteOrReplace pasteOrReplaceFromHistory |
6474 |
cut indent autoIndent: insertMode: |
|
3811 | 6475 |
insertFile insertFileAsStringLiteral insertURL |
6476 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6477 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
4764 | 6478 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
4940 | 6479 |
insertUnicode specialCharacters) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6480 |
]. |
2817 | 6481 |
self hasSelectionForCopy ifFalse:[ |
3731 | 6482 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6483 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6484 |
self hasSelection ifFalse:[ |
5371 | 6485 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
6486 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString). |
|
2762 | 6487 |
] ifTrue:[ |
3731 | 6488 |
(Error handle:[:ex | |
6489 |
ex return:false |
|
6490 |
] do:[ |
|
4042 | 6491 |
|fn| |
6492 |
fn := self selectionAsString. |
|
6493 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
3731 | 6494 |
]) ifFalse:[ |
6495 |
m disableAll:#(openFileBrowserOnIt). |
|
6496 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6497 |
]. |
2569 | 6498 |
self hasUndoAction ifFalse:[ |
3731 | 6499 |
m disable:#undo. |
3115 | 6500 |
] ifTrue:[ |
3731 | 6501 |
what := undoSupport undoActionInfo. |
6502 |
what notNil ifTrue:[ |
|
6503 |
undoIdx := m indexOf:#undo. |
|
6504 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6505 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6506 |
]. |
2952 | 6507 |
self hasRedoAction ifFalse:[ |
3731 | 6508 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6509 |
] ifTrue:[ |
3731 | 6510 |
what := undoSupport redoActionInfo. |
6511 |
what notNil ifTrue:[ |
|
6512 |
redoIdx := sub indexOf:#redo. |
|
6513 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6514 |
] |
|
2952 | 6515 |
]. |
5216 | 6516 |
self canAccept ifFalse:[ |
3731 | 6517 |
m disable:#accept |
1108 | 6518 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6519 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6520 |
|
4388 | 6521 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6522 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6523 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6524 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6525 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6526 |
|
4940 | 6527 |
history := self graphicsDevice getCopyBufferHistory copy. |
3160 | 6528 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6529 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6530 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6531 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6532 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6533 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6534 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6535 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6536 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6537 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6538 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6539 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6540 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6541 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6542 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6543 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6544 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6545 |
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
|
6546 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6547 |
box show. |
3160 | 6548 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6549 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6550 |
"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
|
6551 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6552 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6553 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6554 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6555 |
self sensor shiftDown ifTrue:[ |
3855 | 6556 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6557 |
]. |
2724 | 6558 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6559 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6560 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6561 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6562 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6563 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6564 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6565 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6566 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6567 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6568 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6569 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6570 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6571 |
"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
|
6572 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6573 |
|
2676 | 6574 |
googleSpellingSuggestion |
6575 |
"insert the google-spelling suggestion for the selected text. |
|
6576 |
Requires that the SOAP stuff is loaded and working." |
|
6577 |
||
2677 | 6578 |
|text suggestion| |
2676 | 6579 |
|
6580 |
self withWaitCursorDo:[ |
|
3799 | 6581 |
text := self selection asString string withoutSeparators. |
6582 |
text size == 0 ifTrue:[^ self]. |
|
6583 |
||
4742 | 6584 |
"/ the 'Smalltalk at:' code is here to |
6585 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6586 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6587 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6588 |
^ self. |
|
6589 |
] do:[ |
|
4742 | 6590 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6591 |
]. |
6592 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6593 |
self information:('No spelling suggestion from Google for: ' , text). |
6594 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6595 |
^ self. |
6596 |
]. |
|
6597 |
]. |
|
6598 |
self |
|
6599 |
undoablePaste:suggestion |
|
6600 |
info:'Spelling Suggestion'. |
|
3495 | 6601 |
|
6602 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6603 |
! |
6604 |
||
3595 | 6605 |
insertDateAndTime |
6606 |
"insert the curent date and time string" |
|
6607 |
||
6608 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6609 |
self |
3786 | 6610 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6611 |
info:'Paste Date and Time' |
3595 | 6612 |
! |
6613 |
||
2676 | 6614 |
insertFile |
3160 | 6615 |
"insert contents of a file |
2676 | 6616 |
- ask user for filename using a fileSelectionBox." |
6617 |
||
3731 | 6618 |
self insertFileAsStringLiteral:false |
6619 |
! |
|
6620 |
||
6621 |
insertFileAsStringLiteral |
|
6622 |
"insert a file's contents as a string literal. |
|
6623 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6624 |
to make it a legal string literal" |
|
6625 |
||
6626 |
self insertFileAsStringLiteral:true |
|
6627 |
! |
|
6628 |
||
6629 |
insertFileAsStringLiteral:asStringLiteral |
|
6630 |
"insert contents of a file; either as-is or as a string literal. |
|
6631 |
- ask user for filename using a fileSelectionBox." |
|
6632 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6633 |
|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
|
6634 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6635 |
((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
|
6636 |
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
|
6637 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6638 |
ifTrue:[ |
3731 | 6639 |
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
|
6640 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6641 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6642 |
[ |
3731 | 6643 |
|why| |
6644 |
||
6645 |
file := Dialog |
|
6646 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6647 |
default:initial |
|
6648 |
ok:(resources string:'Insert') |
|
6649 |
abort:(resources string:'Cancel') |
|
6650 |
pattern:nil |
|
6651 |
fromDirectory:directoryForFileDialog. |
|
6652 |
file isNil ifTrue:[ |
|
6653 |
"cancel" |
|
6654 |
^ self. |
|
6655 |
]. |
|
6656 |
file := file asFilename. |
|
6657 |
directoryForFileDialog := file. |
|
6658 |
||
6659 |
ok := file isReadable and:[file isDirectory not]. |
|
6660 |
ok ifFalse:[ |
|
6661 |
file isReadable ifFalse:[ |
|
6662 |
why := '%1 is unreadable.\\Please try again.' |
|
6663 |
] ifTrue:[ |
|
6664 |
why := '%1 is a directory.\\Please try again.' |
|
6665 |
]. |
|
6666 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6667 |
]. |
|
2909 | 6668 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6669 |
|
5063 | 6670 |
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
|
6671 |
self |
3786 | 6672 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6673 |
info:'Paste File' |
3495 | 6674 |
|
6675 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6676 |
! |
|
6677 |
||
3811 | 6678 |
insertURL |
6679 |
"insert contents of a URL |
|
6680 |
- ask user for URL using a dialog." |
|
6681 |
||
6682 |
self insertURLAsStringLiteral:false |
|
6683 |
! |
|
6684 |
||
6685 |
insertURLAsStringLiteral:asStringLiteral |
|
6686 |
"insert contents of a file; either as-is or as a string literal. |
|
6687 |
- ask user for filename using a fileSelectionBox." |
|
6688 |
||
6689 |
|sel url text response initial| |
|
6690 |
||
6691 |
(sel := self selectionAsString) notEmptyOrNil |
|
6692 |
ifTrue:[ |
|
6693 |
initial := sel. |
|
6694 |
]. |
|
6695 |
||
6696 |
url := Dialog |
|
6697 |
request:(resources string:'Insert Contents of URL:') |
|
6698 |
initialAnswer:initial |
|
6699 |
okLabel:(resources string:'Insert') |
|
6700 |
title:(resources string:'URL'). |
|
6701 |
url isNil ifTrue:[ |
|
6702 |
"cancel" |
|
6703 |
^ self. |
|
6704 |
]. |
|
6705 |
response := HTTPInterface get:url. |
|
6706 |
response isErrorResponse ifTrue:[ |
|
6707 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6708 |
^ self. |
|
6709 |
]. |
|
6710 |
text := response data asString. |
|
6711 |
||
6712 |
self |
|
6713 |
undoableDo:[ |
|
6714 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6715 |
] |
|
6716 |
info:'Insert Contents of URL' |
|
6717 |
! |
|
6718 |
||
3495 | 6719 |
insertUUID |
6720 |
"insert a new UUID's string" |
|
6721 |
||
6722 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6723 |
self |
3786 | 6724 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6725 |
info:'Paste New UUID' |
3495 | 6726 |
|
6727 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6728 |
! |
6729 |
||
4940 | 6730 |
insertUnicode |
6731 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
6732 |
||
6733 |
|unicodePoint unicodeChar unicodeString| |
|
6734 |
||
6735 |
unicodeString := Dialog request:'Enter unicode (U+01FF or decimal number):'. |
|
6736 |
unicodeString size < 2 ifTrue:[ |
|
6737 |
^ self. |
|
6738 |
]. |
|
6739 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
6740 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
|
6741 |
] ifFalse:[ |
|
6742 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
|
6743 |
]. |
|
6744 |
||
6745 |
unicodeChar := Character value:unicodePoint. |
|
6746 |
self keyPress:unicodeChar x:0 y:0. |
|
6747 |
self keyRelease:unicodeChar x:0 y:0. |
|
6748 |
! |
|
6749 |
||
5331 | 6750 |
inspectSelectedString |
6751 |
"inspect the selected text" |
|
6752 |
||
6753 |
self selectionAsString inspect. |
|
6754 |
! |
|
6755 |
||
4742 | 6756 |
internalSpellingSuggestion |
6757 |
"insert the internal-spelling suggestion for the selected text. |
|
6758 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
6759 |
||
6760 |
|text suggestions best| |
|
6761 |
||
6762 |
self withWaitCursorDo:[ |
|
6763 |
text := self selection asString string withoutSeparators. |
|
6764 |
text size == 0 ifTrue:[^ self]. |
|
6765 |
||
6766 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
6767 |
suggestions size == 0 ifTrue:[ |
|
6768 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
6769 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
6770 |
^ self. |
|
6771 |
]. |
|
6772 |
Transcript showCR:suggestions. |
|
6773 |
best := suggestions first. |
|
6774 |
]. |
|
6775 |
self |
|
6776 |
undoablePaste:best |
|
6777 |
info:'Spelling Suggestion'. |
|
6778 |
! |
|
6779 |
||
4884 | 6780 |
openFileBrowserOnFileNamed:fileNameString |
6781 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 6782 |
|
4630 | 6783 |
|fn| |
2762 | 6784 |
|
4884 | 6785 |
fn := fileNameString asFilename. |
2762 | 6786 |
fn exists ifFalse:[ |
4884 | 6787 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 6788 |
fn exists ifFalse:[ |
5082 | 6789 |
^ self warn:(resources |
6790 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
6791 |
with:fn baseName allBold |
|
6792 |
with:fn directory baseName allBold). |
|
4042 | 6793 |
]. |
2762 | 6794 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6795 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6796 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6797 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 6798 |
! |
6799 |
||
4884 | 6800 |
openFileBrowserOnIt |
6801 |
"open a fileBrowser on the selected fileName" |
|
6802 |
||
6803 |
|fileNameString| |
|
6804 |
||
6805 |
fileNameString := self selectionAsString. |
|
6806 |
self openFileBrowserOnFileNamed:fileNameString |
|
6807 |
||
6808 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
6809 |
! |
|
6810 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6811 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6812 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6813 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6814 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6815 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6816 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6817 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6818 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6819 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6820 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6821 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6822 |
paste |
1289 | 6823 |
"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
|
6824 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6825 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6826 |
self checkModificationsAllowed ifTrue:[ |
4823 | 6827 |
self withSelfAndTextForPasteDo:[:me :text | |
6828 |
me unselect. |
|
6829 |
me undoablePaste:text |
|
6830 |
] |
|
2952 | 6831 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6832 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6833 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6834 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6835 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6836 |
|
3825 | 6837 |
self paste:someText withCR:false |
6838 |
! |
|
6839 |
||
6840 |
paste:someText withCR:withCR |
|
6841 |
"paste someText at cursor" |
|
6842 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6843 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6844 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6845 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6846 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6847 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6848 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6849 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6850 |
CharacterEncoderError handle:[:ex | |
3825 | 6851 |
|code msg| |
6852 |
||
6853 |
code := ex parameter. |
|
6854 |
codingErrorReported ifFalse:[ |
|
4940 | 6855 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 6856 |
code notNil ifTrue:[ |
6857 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
6858 |
]. |
|
6859 |
Dialog warn:(resources stringWithCRs:msg). |
|
6860 |
codingErrorReported := true. |
|
6861 |
]. |
|
6862 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6863 |
] do:[ |
3825 | 6864 |
s isString ifTrue:[ |
4940 | 6865 |
s encoding ~~ gc characterEncoding ifTrue:[ |
6866 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 6867 |
]. |
6868 |
||
6869 |
s := s asStringCollection. |
|
6870 |
(someText endsWith:Character cr) ifTrue:[ |
|
6871 |
"/ s := s copyWith:nil. |
|
6872 |
s := s copyWith:'' "/ an empty line at the end |
|
6873 |
||
6874 |
] |
|
6875 |
] ifFalse:[ |
|
6876 |
s isStringCollection ifTrue:[ |
|
4940 | 6877 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 6878 |
] ifFalse:[ |
6879 |
(self |
|
6880 |
confirm:(resources |
|
6881 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
6882 |
with:s class name)) ifFalse:[^ self]. |
|
6883 |
s := StringCollection with:s storeString . |
|
6884 |
"/ ^ self |
|
6885 |
]. |
|
6886 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6887 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6888 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6889 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6890 |
(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
|
6891 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6892 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6893 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6894 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6895 |
startCol := c1 := cursorCol. |
3180 | 6896 |
|
5194 | 6897 |
"do not autoindent here. |
6898 |
It does make things very ugly, in the inspector |
|
6899 |
(try inspecting a multiline string)..." |
|
6900 |
self withAutoIndent:false do:[ |
|
6901 |
"do not expand tabs into spaces here - |
|
6902 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
6903 |
Some Subviews want to paste with unexpanded tabs!!" |
|
6904 |
||
6905 |
self insertLines:s withCR:withCR. |
|
6906 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6907 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6908 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6909 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6910 |
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
|
6911 |
"/ 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
|
6912 |
"/ 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
|
6913 |
"/ 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
|
6914 |
self setCursorLine: l1. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
6915 |
self setCursorCol: c1. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6916 |
|
4328 | 6917 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 6918 |
"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
|
6919 |
"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
|
6920 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6921 |
|
3731 | 6922 |
pasteAsStringLiteral |
6923 |
"insert clipboard string as a string literal. |
|
6924 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
6925 |
to make it a legal string literal" |
|
6926 |
||
6927 |
typeOfSelection := nil. |
|
6928 |
self |
|
5107 | 6929 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 6930 |
info:'Paste as String Literal' |
3731 | 6931 |
! |
6932 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6933 |
pasteOrReplace |
1289 | 6934 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 6935 |
otherwise paste at cursor position. |
6936 |
Replace is not done for selections which were created by a paste, |
|
2010 | 6937 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6938 |
|
2724 | 6939 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6940 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6941 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6942 |
pasteOrReplace:someText |
1289 | 6943 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6944 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6945 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6946 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6947 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6948 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6949 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6950 |
self undoableDo:[ |
4823 | 6951 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
6952 |
self replace:someText |
|
6953 |
] ifFalse:[ |
|
6954 |
self paste:someText. |
|
6955 |
] |
|
3542 | 6956 |
] info:'Paste/Replace'. |
1289 | 6957 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
6958 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6959 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6960 |
|
5387 | 6961 |
pasteOrReplaceByKeyPress |
6962 |
"paste a previous item from the copybuffer history. |
|
6963 |
(i.e. repaste some previously deleted or copied text)" |
|
6964 |
||
6965 |
|text| |
|
6966 |
||
6967 |
self checkModificationsAllowed ifFalse:[ |
|
6968 |
self flashReadOnly. |
|
6969 |
^ self |
|
6970 |
]. |
|
6971 |
text := self getClipboardText:#clipboard. |
|
6972 |
text notNil ifTrue:[ |
|
6973 |
self pasteOrReplace:text |
|
6974 |
] |
|
6975 |
! |
|
6976 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6977 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6978 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6979 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6980 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6981 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6982 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6983 |
self checkModificationsAllowed ifFalse:[ |
4988 | 6984 |
self flashReadOnly. |
4823 | 6985 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6986 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6987 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6988 |
text notNil ifTrue:[ |
4823 | 6989 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6990 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6991 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6992 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6993 |
replace |
1289 | 6994 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6995 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6996 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6997 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6998 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6999 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 7000 |
me undoableDo:[ me replace:text ] |
7001 |
info:'Replace' |
|
2952 | 7002 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7003 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7004 |
|
121 | 7005 |
replace:someText |
1289 | 7006 |
"replace the selection by someText" |
121 | 7007 |
|
3160 | 7008 |
|selected selectedString |
7009 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7010 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7011 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7012 |
|
3130 | 7013 |
self undoableDo:[ |
4010 | 7014 |
selected := self selection. |
7015 |
selected isNil ifTrue:[ |
|
7016 |
^ self paste:someText |
|
7017 |
]. |
|
7018 |
||
7019 |
self deleteSelection. |
|
7020 |
||
7021 |
"take care, if we replace a selection without space by a word selected |
|
7022 |
with one - in this case we usually do not want the space. |
|
7023 |
But, if we replace a word-selected selection by something without a |
|
7024 |
space, we DO want the space added." |
|
7025 |
||
7026 |
selected size == 1 ifTrue:[ |
|
7027 |
selectedString := selected at:1. |
|
7028 |
]. |
|
7029 |
||
7030 |
someText size == 1 ifTrue:[ |
|
7031 |
|cutOffSpace addSpace replacement replacementString| |
|
7032 |
||
7033 |
cutOffSpace := false. |
|
7034 |
addSpace := false. |
|
7035 |
replacement := someText copyFrom:1. |
|
7036 |
||
7037 |
selectedString notNil ifTrue:[ |
|
7038 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7039 |
"selection has no space" |
|
7040 |
||
7041 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7042 |
cutOffSpace := true |
|
7043 |
] |
|
7044 |
] ifTrue:[ |
|
7045 |
addSpace := true |
|
7046 |
] |
|
7047 |
]. |
|
7048 |
replacementString := replacement at:1. |
|
7049 |
cutOffSpace ifTrue:[ |
|
7050 |
(replacementString startsWith:' ') ifTrue:[ |
|
7051 |
replacementString := replacementString withoutSpaces |
|
7052 |
]. |
|
7053 |
] ifFalse:[ |
|
7054 |
selectStyle == #wordLeft ifTrue:[ |
|
7055 |
"want a space at left" |
|
7056 |
(replacementString startsWith:' ') ifFalse:[ |
|
7057 |
replacementString := replacementString withoutSpaces. |
|
7058 |
replacementString := ' ' , replacementString |
|
7059 |
] |
|
7060 |
]. |
|
7061 |
selectStyle == #wordRight ifTrue:[ |
|
7062 |
"want a space at right" |
|
7063 |
||
7064 |
(replacementString endsWith:' ') ifFalse:[ |
|
7065 |
replacementString := replacementString withoutSpaces. |
|
7066 |
replacementString := replacementString , ' ' |
|
7067 |
] |
|
7068 |
]. |
|
7069 |
]. |
|
7070 |
replacement at:1 put: replacementString. |
|
7071 |
self paste:replacement. |
|
7072 |
] ifFalse:[ |
|
7073 |
self paste:someText |
|
7074 |
]. |
|
4053 | 7075 |
self setLastStringToReplace: selectedString. |
7076 |
||
4048 | 7077 |
lastReplacementInfo lastReplacement: someText. |
4010 | 7078 |
|
7079 |
selStartLine := selectionStartLine. |
|
7080 |
selStartCol := self selectionStartCol. |
|
7081 |
selEndLine := selectionEndLine. |
|
7082 |
selEndCol := self selectionEndCol. |
|
3130 | 7083 |
] |
3542 | 7084 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7085 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7086 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7087 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7088 |
! |
7089 |
||
3430 | 7090 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7091 |
"search for a string - show a box to enter searchpattern |
3430 | 7092 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7093 |
- 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
|
7094 |
|
3430 | 7095 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7096 |
||
7097 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7098 |
lastSearchDirection := #forward. |
|
7099 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7100 |
caseHolder := ValueHolder with:ign. |
7101 |
patternHolder := ValueHolder with:''. |
|
7102 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7103 |
lastSearchPattern notNil ifTrue:[ |
4823 | 7104 |
initialString := lastSearchPattern |
3430 | 7105 |
]. |
7106 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 7107 |
initialString := self selectionAsString |
3430 | 7108 |
]. |
7109 |
initialString isNil ifTrue:[ |
|
4823 | 7110 |
LastSearchPatterns size > 0 ifTrue:[ |
7111 |
initialString := LastSearchPatterns first |
|
7112 |
] |
|
3430 | 7113 |
]. |
7114 |
initialString notNil ifTrue:[ |
|
4823 | 7115 |
patternHolder value:initialString. |
7116 |
replacePatternHolder value:initialString. |
|
3430 | 7117 |
]. |
7118 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7119 |
search := [:fwd | |
4823 | 7120 |
self |
7121 |
search:patternHolder value |
|
7122 |
ignoreCase:caseHolder value |
|
7123 |
forward:fwd. |
|
7124 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7125 |
replace := [:all | |
4823 | 7126 |
self |
7127 |
replace:patternHolder value |
|
7128 |
by:replacePatternHolder value |
|
7129 |
all:all |
|
7130 |
ignoreCase:caseHolder value |
|
7131 |
]. |
|
3430 | 7132 |
bindings := IdentityDictionary new. |
7133 |
bindings at:#searchPattern put:patternHolder. |
|
7134 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7135 |
modal ifTrue:[ |
|
4823 | 7136 |
bindings at:#nextAction |
7137 |
put:[ |
|
7138 |
flag := true. |
|
7139 |
action := search. |
|
7140 |
searchBox doAccept. |
|
7141 |
]. |
|
7142 |
bindings at:#prevAction |
|
7143 |
put:[ |
|
7144 |
flag := false. |
|
7145 |
action := search. |
|
7146 |
searchBox doAccept. |
|
7147 |
]. |
|
7148 |
bindings at:#replaceAction |
|
7149 |
put:[ |
|
7150 |
flag := false. |
|
7151 |
action := replace. |
|
7152 |
searchBox doAccept. |
|
7153 |
]. |
|
7154 |
bindings at:#replaceAllAction |
|
7155 |
put:[ |
|
7156 |
flag := true. |
|
7157 |
action := replace. |
|
7158 |
searchBox doAccept. |
|
7159 |
]. |
|
3430 | 7160 |
] ifFalse:[ |
4823 | 7161 |
bindings at:#nextAction put:[ search value:true. ]. |
7162 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7163 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7164 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7165 |
]. |
7166 |
bindings at:#ignoreCase put:caseHolder. |
|
7167 |
bindings at:#patternList put:LastSearchPatterns. |
|
7168 |
modal ifTrue:[ |
|
4823 | 7169 |
searchBox := SimpleDialog new. |
3430 | 7170 |
] ifFalse:[ |
4823 | 7171 |
searchBox := ApplicationModel new. |
7172 |
searchBox createBuilder. |
|
3430 | 7173 |
]. |
7174 |
searchBox resources:(self resources). |
|
7175 |
bldr := searchBox builder. |
|
7176 |
bldr addBindings:bindings. |
|
7177 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7178 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7179 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7180 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7181 |
modal ifTrue:[ |
|
4823 | 7182 |
searchBox openDialog. |
7183 |
searchBox accepted ifTrue:[ |
|
7184 |
action value:flag |
|
7185 |
]. |
|
3430 | 7186 |
] ifFalse:[ |
4823 | 7187 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7188 |
(bldr componentAt:#cancelButton) |
|
7189 |
label:(resources string:'Close'); |
|
7190 |
action:[ searchBox closeRequest ]. |
|
7191 |
||
7192 |
"/ searchBox masterApplication:self application. |
|
7193 |
||
7194 |
self topView beMaster. |
|
7195 |
(searchBox window) |
|
7196 |
beSlave; |
|
7197 |
openInGroup:(self windowGroup). |
|
7198 |
||
7199 |
"/ searchBox window open. |
|
7200 |
||
5283 | 7201 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
3430 | 7202 |
] |
7203 |
||
7204 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7205 |
! |
|
7206 |
||
121 | 7207 |
showDeleted |
7208 |
"open a readonly editor on all deleted text" |
|
7209 |
||
7210 |
|v| |
|
7211 |
||
7212 |
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
|
7213 |
v readOnly:true. |
121 | 7214 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7215 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7216 |
|
3221 | 7217 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7218 |
"sort/reorder the selected lines. |
7219 |
how: |
|
7220 |
#lines |
|
7221 |
#linesByFirstWord |
|
7222 |
#linesByNthWord |
|
7223 |
#linesByNthNumber |
|
7224 |
#linesByNthHexNumber |
|
7225 |
#words |
|
7226 |
#linesByLength |
|
7227 |
#reverse |
|
7228 |
" |
|
7229 |
||
7230 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7231 |
|
7232 |
lineWise := true. |
|
7233 |
||
4763 | 7234 |
how == #reverse ifTrue:[ |
7235 |
operation := [:lines | lines reverse]. |
|
7236 |
] ifFalse:[ |
|
7237 |
operation := [:linesOrWords | |
|
7238 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7239 |
]. |
|
7240 |
||
7241 |
how == #linesByLength ifTrue:[ |
|
7242 |
fetcher := [:l | l size]. |
|
7243 |
] ifFalse:[ |
|
7244 |
how == #lines ifTrue:[ |
|
7245 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7246 |
] ifFalse:[ |
|
7247 |
how == #linesByFirstWord ifTrue:[ |
|
7248 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7249 |
] ifFalse:[ |
|
7250 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7251 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7252 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7253 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7254 |
LastColumnNumberForSort := n. |
|
7255 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7256 |
how == #linesByNthNumber ifTrue:[ |
|
7257 |
innerExtractor := extractor. |
|
7258 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7259 |
] ifFalse:[ |
|
7260 |
how == #linesByNthHexNumber ifTrue:[ |
|
7261 |
innerExtractor := extractor. |
|
7262 |
extractor := [:l | |
|
7263 |
|s| |
|
7264 |
s := innerExtractor value:l. |
|
7265 |
(s startsWith:'16r') ifTrue:[ |
|
7266 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7267 |
] ifFalse:[ |
|
7268 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7269 |
] |
|
7270 |
] |
|
4753 | 7271 |
] |
4763 | 7272 |
]. |
7273 |
] ifFalse:[ |
|
7274 |
how == #words ifTrue:[ |
|
7275 |
lineWise := false. |
|
7276 |
extractor := [:w | w]. |
|
7277 |
] ifFalse:[ |
|
7278 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7279 |
] |
4373 | 7280 |
] |
7281 |
] |
|
4763 | 7282 |
]. |
7283 |
ignoreCase ifTrue:[ |
|
7284 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7285 |
] ifFalse:[ |
|
7286 |
fetcher := extractor. |
|
7287 |
]. |
|
7288 |
]. |
|
3221 | 7289 |
]. |
7290 |
||
7291 |
lineWise ifTrue:[ |
|
4763 | 7292 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7293 |
start == end ifTrue:[^ self ]. |
7294 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7295 |
lines := operation value:lines. |
4373 | 7296 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7297 |
] ifFalse:[ |
7298 |
"process the whole selection as a string" |
|
7299 |
s := self selectionAsString. |
|
7300 |
words := s asCollectionOfWords. |
|
7301 |
words := operation value:words. |
|
7302 |
s := words asStringCollection asStringWith:Character space. |
|
7303 |
self replace:s. |
|
7304 |
]. |
|
3221 | 7305 |
self textChanged. |
4373 | 7306 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7307 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7308 |
! |
7309 |
||
7310 |
sortSelection:how ignoreCase:ignoreCase |
|
7311 |
"sort the selected lines" |
|
7312 |
||
7313 |
|start end| |
|
7314 |
||
7315 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7316 |
||
7317 |
start := selectionStartLine. |
|
7318 |
end := selectionEndLine. |
|
7319 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7320 |
end := end - 1 |
3221 | 7321 |
]. |
7322 |
||
7323 |
self |
|
4373 | 7324 |
undoableDo:[ |
7325 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7326 |
] |
|
3786 | 7327 |
info:'Sort' |
4373 | 7328 |
|
7329 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7330 |
! |
7331 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7332 |
specialCharacters |
2915 | 7333 |
CharacterSetView |
4823 | 7334 |
openAsInputFor:self |
7335 |
label:'Special Character Input' |
|
7336 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7337 |
! |
7338 |
||
5370 | 7339 |
splitLinesAtCharacterOrString |
7340 |
"ask user for the character and split after it" |
|
7341 |
||
7342 |
|sel in out separator record| |
|
7343 |
||
7344 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7345 |
||
7346 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7347 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7348 |
||
7349 |
sel := self selectionAsString. |
|
7350 |
in := sel readStream. |
|
7351 |
out := CharacterWriteStream on:(String new). |
|
7352 |
[in atEnd] whileFalse:[ |
|
7353 |
record := in throughAll:separator. |
|
7354 |
out nextPutLine:record. |
|
7355 |
]. |
|
7356 |
self |
|
7357 |
undoableDo:[ |
|
7358 |
self replaceSelectionBy:(out contents). |
|
7359 |
] |
|
7360 |
info:'Split Selection' |
|
7361 |
! |
|
7362 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7363 |
undoablePaste:someText |
3495 | 7364 |
self undoablePaste:someText info:nil. |
7365 |
||
7366 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7367 |
! |
|
7368 |
||
7369 |
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
|
7370 |
self |
4823 | 7371 |
undoableDo:[ |
7372 |
self paste:someText. |
|
7373 |
] |
|
7374 |
info:infoOrNil |
|
3495 | 7375 |
|
7376 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7377 |
! |
|
7378 |
||
7379 |
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
|
7380 |
self |
4823 | 7381 |
undoableDo:[ |
7382 |
self pasteOrReplace:someText. |
|
7383 |
] |
|
7384 |
info:infoOrNil |
|
3495 | 7385 |
|
7386 |
"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
|
7387 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7388 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7389 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7390 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7391 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7392 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7393 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7394 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7395 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7396 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7397 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7398 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7399 |
|
2724 | 7400 |
withSelfAndTextForPasteDo:aBlock |
7401 |
"common code for paste/replace of the copybuffer" |
|
7402 |
||
7403 |
|sel| |
|
7404 |
||
7405 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7406 |
self flashReadOnly. |
4823 | 7407 |
^ self |
2724 | 7408 |
]. |
7409 |
||
7410 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7411 |
sel notNil ifTrue:[ |
|
4823 | 7412 |
aBlock value:self value:sel. |
2724 | 7413 |
] |
105 | 7414 |
! ! |
7415 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7416 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7417 |
|
3880 | 7418 |
beep |
5244 | 7419 |
"output an audible beep or bell on my screen device" |
7420 |
||
3880 | 7421 |
UserPreferences current beepInEditor ifTrue:[ |
7422 |
super beep |
|
7423 |
] |
|
7424 |
! |
|
7425 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7426 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7427 |
"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
|
7428 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7429 |
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
|
7430 |
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
|
7431 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7432 |
self isReadOnly ifTrue: [ |
4823 | 7433 |
exceptionBlock isNil ifTrue:[ |
7434 |
^ false |
|
7435 |
]. |
|
7436 |
||
7437 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7438 |
^ false |
|
7439 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7440 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7441 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7442 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7443 |
"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
|
7444 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7445 |
|
2596 | 7446 |
currentSelectionBgColor |
7447 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7448 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7449 |
]. |
5216 | 7450 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 7451 |
^ super currentSelectionBgColor |
7452 |
||
7453 |
" |
|
7454 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7455 |
" |
|
7456 |
! |
|
7457 |
||
7458 |
currentSelectionFgColor |
|
7459 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7460 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7461 |
]. |
7462 |
^ super currentSelectionFgColor |
|
7463 |
! |
|
7464 |
||
3996 | 7465 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7466 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7467 |
|
7468 |
super resetVariablesBeforeNewSearch. |
|
7469 |
||
7470 |
"/ new search invalidates remembered string |
|
4048 | 7471 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7472 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7473 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7474 |
! |
7475 |
||
4053 | 7476 |
setLastStringToReplace: aString |
7477 |
||
7478 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7479 |
||
7480 |
|lastReplaceIgnoredCase| |
|
7481 |
||
4064 | 7482 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7483 |
self clearSearchAction. |
|
7484 |
||
4053 | 7485 |
lastReplacementInfo lastStringToReplace: aString. |
7486 |
lastStringFromReplaceForNextSearch := aString. |
|
7487 |
||
7488 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7489 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7490 |
ifTrue: [lastSearchIgnoredCase] |
|
7491 |
ifFalse: [nil]. |
|
4053 | 7492 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7493 |
! |
|
7494 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7495 |
st80EditMode |
5255 | 7496 |
"If on, the cursor wraps at the line end (like in vi or st80); |
7497 |
if off, we have the Rand-editor behavior (random access)" |
|
7498 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7499 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7500 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7501 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7502 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7503 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7504 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7505 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7506 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7507 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7508 |
textChanged |
522 | 7509 |
"my text was modified (internally). |
7510 |
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
|
7511 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7512 |
is used to notify scrollers, other views etc.). |
7513 |
||
7514 |
As some authors of this code have been very sloppy in tha past |
|
7515 |
(not sending contentsChanged, but textChanged), |
|
7516 |
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
|
7517 |
|
641 | 7518 |
self contentsChanged. |
1015 | 7519 |
self modified:true. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7520 |
contentsWasSaved := false |
641 | 7521 |
|
1015 | 7522 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7523 |
! |
7524 |
||
2617 | 7525 |
textChangedButNoSizeChange |
2207 | 7526 |
"my text was modified (internally). |
7527 |
Sent whenever text has been edited (not to confuse with |
|
7528 |
contentsChanged, which is triggered when the size has changed, and |
|
7529 |
is used to notify scrollers, other views etc.)" |
|
7530 |
||
7531 |
self modified:true. |
|
7532 |
contentsWasSaved := false |
|
7533 |
||
7534 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7535 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7536 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7537 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7538 |
|
5216 | 7539 |
canAccept |
7540 |
"true if text can be accepts. |
|
7541 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7542 |
||
7543 |
^ acceptEnabled ~~ false |
|
7544 |
! |
|
7545 |
||
7546 |
canCut |
|
7547 |
"true if there is a selection possibly to be cut. |
|
7548 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7549 |
||
7550 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7551 |
^ self hasSelection |
|
7552 |
! |
|
7553 |
||
7554 |
canDoAgain |
|
7555 |
"true if there is a possible repeat last edit operation. |
|
7556 |
Used to disable the menu if there is nothing" |
|
7557 |
||
7558 |
|lastStringToReplace| |
|
7559 |
||
7560 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7561 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
7562 |
^ lastStringToReplace notNil |
|
7563 |
! |
|
7564 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7565 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7566 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7567 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7568 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7569 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7570 |
"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
|
7571 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7572 |
|
4064 | 7573 |
hasSearchActionSelection |
7574 |
||
7575 |
^ typeOfSelection == #searchAction |
|
7576 |
! |
|
7577 |
||
1878 | 7578 |
isKeyboardConsumer |
7579 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 7580 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 7581 |
|
3476 | 7582 |
^ self isReadOnly not |
1878 | 7583 |
! |
7584 |
||
997 | 7585 |
specClass |
1390 | 7586 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7587 |
||
997 | 7588 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7589 |
^ super specClass |
7590 |
||
1390 | 7591 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7592 |
! |
7593 |
||
324 | 7594 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7595 |
"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
|
7596 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7597 |
"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
|
7598 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7599 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7600 |
|
7601 |
"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
|
7602 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7603 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7604 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7605 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7606 |
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
|
7607 |
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
|
7608 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7609 |
|
697 | 7610 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7611 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7612 |
w := super widthOfContents. |
4889 | 7613 |
(dev := self graphicsDevice ) isNil ifTrue:[ |
7614 |
"/ really don't know ... |
|
4823 | 7615 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7616 |
]. |
4889 | 7617 |
^ w + (gc font widthOn:dev) |
697 | 7618 |
|
7619 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7620 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7621 |
|
1588 | 7622 |
!EditTextView methodsFor:'realization'! |
7623 |
||
7624 |
realize |
|
7625 |
"make the view visible - scroll to make the cursor visible." |
|
7626 |
||
7627 |
super realize. |
|
7628 |
||
7629 |
self makeCursorVisible. |
|
4940 | 7630 |
cursorFgColor := cursorFgColor onDevice:self graphicsDevice. |
7631 |
cursorBgColor := cursorBgColor onDevice:self graphicsDevice. |
|
1588 | 7632 |
|
7633 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7634 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7635 |
! ! |
|
7636 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7637 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7638 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7639 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7640 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7641 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7642 |
cursorShown ifTrue:[ |
4823 | 7643 |
cursorVisibleLine notNil ifTrue:[ |
7644 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7645 |
self drawCursorCharacter |
|
7646 |
] |
|
7647 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7648 |
] |
105 | 7649 |
! |
7650 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7651 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7652 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7653 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7654 |
cursorShown ifTrue:[ |
4823 | 7655 |
(visLine == cursorVisibleLine) ifTrue:[ |
7656 |
self drawCursorCharacter |
|
7657 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7658 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7659 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7660 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7661 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7662 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7663 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7664 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7665 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7666 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7667 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7668 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7669 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7670 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7671 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7672 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7673 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7674 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7675 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7676 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7677 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7678 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7679 |
cursorShown ifTrue:[ |
4823 | 7680 |
(visLine == cursorVisibleLine) ifTrue:[ |
7681 |
(colNr == cursorCol) ifTrue:[ |
|
7682 |
self drawCursorCharacter. |
|
7683 |
^ self |
|
7684 |
] |
|
7685 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7686 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7687 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7688 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7689 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7690 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7691 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7692 |
"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
|
7693 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7694 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7695 |
cursorShown ifTrue:[ |
7696 |
self redrawCursorIfInVisibleLine:visLine |
|
7697 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7698 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7699 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7700 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7701 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7702 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7703 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7704 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7705 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7706 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7707 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7708 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7709 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7710 |
"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
|
7711 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7712 |
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
|
7713 |
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
|
7714 |
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
|
7715 |
|
4889 | 7716 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7717 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7718 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7719 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7720 |
"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
|
7721 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7722 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7723 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7724 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7725 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7726 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7727 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7728 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7729 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7730 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7731 |
"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
|
7732 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7733 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7734 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7735 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7736 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7737 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7738 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7739 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7740 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7741 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7742 |
"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
|
7743 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7744 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7745 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7746 |
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
|
7747 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7748 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7749 |
prevCursorState ifTrue:[ |
4823 | 7750 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7751 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7752 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7753 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7754 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7755 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7756 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7757 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7758 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7759 |
prevCursorState := cursorShown. |
1601 | 7760 |
"/ cursorShown := false. |
1591 | 7761 |
cursorShown ifTrue:[ |
4823 | 7762 |
self hideCursor |
1591 | 7763 |
] |
7764 |
||
1601 | 7765 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7766 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7767 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7768 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7769 |
"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
|
7770 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7771 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7772 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7773 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7774 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7775 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7776 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7777 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7778 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7779 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7780 |
"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
|
7781 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7782 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7783 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7784 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7785 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7786 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7787 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7788 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7789 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7790 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7791 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7792 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7793 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7794 |
|
2822 | 7795 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 7796 |
! |
7797 |
||
7798 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
7799 |
"do a backward search" |
|
7800 |
||
7801 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
7802 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 7803 |
! |
7804 |
||
7805 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7806 |
"do a backward search" |
|
7807 |
||
7808 |
cursorLine isNil ifTrue:[^ self]. |
|
7809 |
||
3160 | 7810 |
self |
4119 | 7811 |
searchBackwardFor:pattern |
7812 |
ignoreCase:ign |
|
7813 |
startingAtLine:startLine col:startCol |
|
7814 |
ifFound:[:line :col | |
|
7815 |
self cursorMovementAllowed ifTrue:[ |
|
7816 |
self cursorLine:line col:col. |
|
7817 |
]. |
|
7818 |
self showMatch:pattern isMatch:false atLine:line col:col. |
|
1339 | 7819 |
"/ self makeLineVisible:cursorLine |
4119 | 7820 |
typeOfSelection := #search] |
7821 |
ifAbsent:aBlock |
|
1339 | 7822 |
|
7823 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7824 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7825 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7826 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7827 |
"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
|
7828 |
|
2554 | 7829 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7830 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7831 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7832 |
searchForMatchingParenthesis |
3160 | 7833 |
"search for a matching parenthesis starting at cursor position. |
7834 |
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
|
7835 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7836 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7837 |
|
2822 | 7838 |
self cursorMovementAllowed ifFalse:[^ self]. |
7839 |
||
3160 | 7840 |
self |
4823 | 7841 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
7842 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
7843 |
ifNotFound:[self showNotFound] |
|
7844 |
onError:[self beep] |
|
1339 | 7845 |
|
7846 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7847 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7848 |
|
3967 | 7849 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 7850 |
"do a forward search" |
7851 |
||
7852 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 7853 |
self |
7854 |
searchForwardFor:pattern |
|
7855 |
ignoreCase:ign |
|
7856 |
match: match |
|
7857 |
startingAtLine:startLine col:startCol |
|
7858 |
ifFound:[:line :col | |
|
7859 |
self cursorMovementAllowed ifTrue:[ |
|
7860 |
self cursorLine:line col:col. |
|
7861 |
]. |
|
4119 | 7862 |
self showMatch:pattern isMatch:match atLine:line col:col. |
1339 | 7863 |
"/ self makeLineVisible:cursorLine |
3967 | 7864 |
typeOfSelection := #search |
7865 |
] |
|
7866 |
ifAbsent:aBlock |
|
1339 | 7867 |
|
7868 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
7869 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7870 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7871 |
|
3967 | 7872 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
7873 |
"do a forward search" |
|
7874 |
||
7875 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7876 |
! |
|
7877 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7878 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7879 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7880 |
|
2822 | 7881 |
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
|
7882 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7883 |
|
3982 | 7884 |
searchPatternForSearchBar |
7885 |
||
7886 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
7887 |
||
7888 |
|searchPattern| |
|
7889 |
||
4138 | 7890 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 7891 |
searchPattern isNil |
7892 |
ifTrue: [searchPattern := lastSearchPattern] |
|
7893 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
7894 |
^ searchPattern |
|
7895 |
! |
|
7896 |
||
3578 | 7897 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7898 |
"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
|
7899 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7900 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7901 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7902 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7903 |
"/ |
3967 | 7904 |
"/ 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
|
7905 |
"/ original string (for search after again) |
4121 | 7906 |
"/ 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
|
7907 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7908 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7909 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7910 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7911 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7912 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7913 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7914 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7915 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7916 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7917 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7918 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7919 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7920 |
"/ 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
|
7921 |
"/ if there was a previous search, only take the selection if |
3967 | 7922 |
"/ 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
|
7923 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7924 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7925 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7926 |
sel notNil ifTrue:[ |
3967 | 7927 |
(lastSearchPattern isNil |
4484 | 7928 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
7929 |
) ifTrue:[ |
|
3967 | 7930 |
self cursorLine:selectionStartLine col:selectionStartCol. |
7931 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
7932 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
7933 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7934 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7935 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7936 |
"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
|
7937 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7938 |
|
4484 | 7939 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
7940 |
super showMatch:pattern isMatch:isMatch atLine:line col:col. |
|
7941 |
typeOfSelection := #search. |
|
7942 |
! |
|
7943 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7944 |
startPositionForSearchBackward |
2822 | 7945 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
7946 |
! |
|
7947 |
||
7948 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7949 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7950 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7951 |
selectionStartLine notNil ifTrue:[ |
4823 | 7952 |
startLine := selectionStartLine. |
7953 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7954 |
] ifFalse:[ |
4823 | 7955 |
cursorLine isNil ifTrue:[ |
7956 |
startLine := list size. |
|
7957 |
startCol := self listAt:startLine size. |
|
7958 |
] ifFalse:[ |
|
7959 |
startLine := cursorLine min:list size. |
|
7960 |
startCol := cursorCol |
|
7961 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7962 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7963 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7964 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7965 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7966 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7967 |
startPositionForSearchForward |
2822 | 7968 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
7969 |
! |
|
7970 |
||
7971 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7972 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7973 |
|
3160 | 7974 |
"/ 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
|
7975 |
"/ 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
|
7976 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7977 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7978 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7979 |
] ifFalse:[ |
4064 | 7980 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
7981 |
startCol := 0 |
|
7982 |
]. |
|
7983 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7984 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7985 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7986 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7987 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7988 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7989 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7990 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7991 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7992 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
7993 |
addToSelectionAfter:aBlock |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7994 |
"Extends the selection accroding to cursor position |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7995 |
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
|
7996 |
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
|
7997 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
7998 |
"/ Following comment is in czech and thus now very useful. |
4970 | 7999 |
"/ 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
|
8000 |
"/ 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
|
8001 |
"/ 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
|
8002 |
"/ written by Martin Dvorak. Yeah, being bit nostalgic... |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8003 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8004 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8005 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8006 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8007 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8008 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8009 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8010 |
| 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
|
8011 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8012 |
curLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8013 |
curCol := cursorCol. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8014 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8015 |
self hasSelection ifTrue: [ |
4970 | 8016 |
startLine := selectionStartLine. |
8017 |
startCol := selectionStartCol. |
|
8018 |
endLine := selectionEndLine. |
|
8019 |
endCol := selectionEndCol. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8020 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8021 |
startLine := endLine := curLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8022 |
startCol := curCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8023 |
endCol := curCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8024 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8025 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8026 |
cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8027 |
cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8028 |
self assert: cursorAtTheBeginning | cursorAtTheEnd. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8029 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8030 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8031 |
cursorWasShown := self hideCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8032 |
aBlock value. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8033 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8034 |
cursorAtTheBeginning ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8035 |
(cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8036 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8037 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8038 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8039 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8040 |
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
|
8041 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8042 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8043 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8044 |
(cursorLine > endLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8045 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8046 |
startLine := endLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8047 |
startCol := endCol + 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8048 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8049 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8050 |
endCol := cursorCol - 1 |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8051 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8052 |
startLine := cursorLine. |
4823 | 8053 |
startCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8054 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8055 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8056 |
cursorAtTheEnd ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8057 |
(cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8058 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8059 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8060 |
]. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8061 |
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
|
8062 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8063 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8064 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8065 |
(cursorLine < startLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8066 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8067 |
endLine := startLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8068 |
endCol := startCol - 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8069 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8070 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8071 |
startCol := cursorCol |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8072 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8073 |
endLine := cursorLine. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8074 |
endCol := cursorCol - 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8075 |
] |
4823 | 8076 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8077 |
]. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8078 |
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
|
8079 |
cursorWasShown ifTrue:[self showCursor]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8080 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8081 |
"Modified: / 27-03-2014 / 10:05:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4970 | 8082 |
"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
|
8083 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8084 |
|
1850 | 8085 |
autoMoveCursorToEndOfSelection |
8086 |
"return true, if the cursor should be automatically moved to the |
|
8087 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8088 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8089 |
not be affected by selecting" |
8090 |
||
8091 |
^ true |
|
8092 |
! |
|
8093 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8094 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8095 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 8096 |
typeOfSelection := newType. |
8097 |
selectionStartLine notNil ifTrue:[ |
|
8098 |
self |
|
8099 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8100 |
toLine:selectionEndLine col:selectionEndCol |
|
8101 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8102 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8103 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8104 |
|
4707 | 8105 |
findNextWordAfterSelectionAndAddToSelection |
8106 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8107 |
||
8108 |
selectionStartCol isNil ifTrue:[ |
|
8109 |
self selectWordUnderCursor. |
|
8110 |
^ self |
|
8111 |
]. |
|
8112 |
||
8113 |
selStartCol := selectionStartCol. |
|
8114 |
selEndCol := selectionEndCol. |
|
8115 |
selStartLine := selectionStartLine. |
|
8116 |
selEndLine := selectionEndLine. |
|
8117 |
||
8118 |
self cursorToNextWord. |
|
8119 |
self selectWordUnderCursor. |
|
8120 |
||
8121 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8122 |
! |
|
8123 |
||
4138 | 8124 |
searchPatternFromUserSelectionOrReplace |
8125 |
||
8126 |
|sel searchPattern| |
|
8127 |
||
8128 |
"/ |
|
8129 |
"/ if the last operation was a replace, set pattern to last |
|
8130 |
"/ original string (for search after again) |
|
8131 |
"/ |
|
8132 |
(lastStringFromReplaceForNextSearch notNil |
|
8133 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
8134 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
8135 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8136 |
] ifFalse:[ |
|
8137 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8138 |
]. |
|
8139 |
^ searchPattern |
|
8140 |
]. |
|
8141 |
||
8142 |
"/ |
|
8143 |
"/ if there is a selection: |
|
8144 |
"/ if there was no previous search, take it as search pattern. |
|
8145 |
"/ if there was a previous search, only take the selection if |
|
8146 |
"/ it did not result from a paste. |
|
8147 |
"/ (to allow search-paste to be repeated) |
|
8148 |
"/ |
|
8149 |
sel := self selection. |
|
8150 |
sel notNil ifTrue:[ |
|
8151 |
typeOfSelection ~~ #search ifTrue:[ |
|
8152 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8153 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8154 |
searchPattern := sel asStringWithoutFinalCR. |
|
8155 |
] |
|
8156 |
]. |
|
8157 |
]. |
|
8158 |
||
8159 |
^ searchPattern |
|
8160 |
! |
|
8161 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8162 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8163 |
"select the whole text. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8164 |
redefined to send super selectFrom... since we dont want the |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8165 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8166 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8167 |
list isNil ifTrue:[ |
4823 | 8168 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8169 |
] ifFalse:[ |
4823 | 8170 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8171 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8172 |
] |
1082 | 8173 |
|
8174 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8175 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8176 |
|
4117 | 8177 |
selectAllInitially |
8178 |
"select the whole text. This is called only once during the initialization |
|
8179 |
for editFields which are shown in a table or tree. |
|
8180 |
The selectAll is called via this method to allow for easier redefinition and |
|
8181 |
to distinguish auto-select from user-initiated selects." |
|
8182 |
||
8183 |
self selectAll |
|
8184 |
! |
|
8185 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8186 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8187 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8188 |
|
3160 | 8189 |
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
|
8190 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8191 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8192 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8193 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8194 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8195 |
cursorCol > 1 ifTrue:[ |
4823 | 8196 |
self selectFromLine:cursorLine col:1 |
8197 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8198 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8199 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8200 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8201 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8202 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8203 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8204 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8205 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8206 |
selectionStartLine isNil ifTrue:[ |
4823 | 8207 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8208 |
] ifFalse:[ |
4823 | 8209 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8210 |
toLine:cursorLine+1 col:0. |
|
8211 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8212 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8213 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8214 |
|
4257 | 8215 |
selectFromBeginOfLine |
8216 |
"select the text from the beginning of the current line to the current cursor position." |
|
8217 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8218 |
| newCursorCol ln | |
4271 | 8219 |
|
4257 | 8220 |
list isNil ifTrue:[ |
8221 |
self unselect |
|
8222 |
] ifFalse:[ |
|
8223 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8224 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8225 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 8226 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
8227 |
cursorCol := newCursorCol. |
|
4257 | 8228 |
typeOfSelection := nil |
8229 |
] |
|
8230 |
] |
|
8231 |
||
8232 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8233 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8234 |
! |
8235 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8236 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8237 |
"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
|
8238 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8239 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8240 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8241 |
list isNil ifTrue:[ |
4823 | 8242 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8243 |
] ifFalse:[ |
4823 | 8244 |
cursorCol == 0 ifTrue:[ |
8245 |
col := 0 |
|
8246 |
] ifFalse:[ |
|
8247 |
col := cursorCol - 1 |
|
8248 |
]. |
|
8249 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8250 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8251 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8252 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8253 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8254 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8255 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8256 |
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
|
8257 |
"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
|
8258 |
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
|
8259 |
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
|
8260 |
"/ (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
|
8261 |
"/ 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
|
8262 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8263 |
typeOfSelection := nil |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8264 |
|
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8265 |
"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
|
8266 |
"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
|
8267 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8268 |
|
4257 | 8269 |
selectToEndOfLine |
8270 |
"select the text from the current cursor position to the end of the current line" |
|
8271 |
||
4271 | 8272 |
| newCursorCol line | |
8273 |
||
4257 | 8274 |
list isNil ifTrue:[ |
8275 |
self unselect |
|
8276 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
8277 |
cursorCol >= 1 ifTrue:[ |
4271 | 8278 |
line := list at: cursorLine. |
8279 |
newCursorCol := line size. |
|
8280 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8281 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8282 |
||
8283 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
8284 |
cursorCol := newCursorCol. |
|
4257 | 8285 |
typeOfSelection := nil |
8286 |
] |
|
8287 |
] |
|
8288 |
||
8289 |
"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
|
8290 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8291 |
! |
8292 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8293 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8294 |
"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
|
8295 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8296 |
list isNil ifTrue:[ |
4823 | 8297 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8298 |
] ifFalse:[ |
4823 | 8299 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8300 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8301 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8302 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8303 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8304 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8305 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8306 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8307 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8308 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8309 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8310 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8311 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8312 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8313 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8314 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8315 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8316 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8317 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8318 |
wasOn ifTrue:[self showCursor] |
105 | 8319 |
! ! |
8320 |
||
8321 |
!EditTextView methodsFor:'undo & again'! |
|
8322 |
||
2952 | 8323 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8324 |
^ undoSupport addUndo:action. |
2952 | 8325 |
! |
8326 |
||
105 | 8327 |
again |
8328 |
"repeat the last action (which was a cut or replace). |
|
8329 |
If current selection is not last string, search forward to |
|
3160 | 8330 |
next occurrence of it before repeating the last operation." |
105 | 8331 |
|
4048 | 8332 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8333 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8334 |
|
8335 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8336 |
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
|
8337 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8338 |
]. |
4048 | 8339 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8340 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8341 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8342 |
self undoableDo:[ |
4010 | 8343 |
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
|
8344 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8345 |
(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
|
8346 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8347 |
|
4053 | 8348 |
"set lastStringToReplace as the next search string |
8349 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8350 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8351 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8352 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8353 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8354 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8355 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8356 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8357 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8358 |
"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
|
8359 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8360 |
(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
|
8361 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8362 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8363 |
self deleteSelection. |
4051 | 8364 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8365 |
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
|
8366 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8367 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8368 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8369 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8370 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8371 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8372 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8373 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8374 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8375 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8376 |
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
|
8377 |
]. |
4048 | 8378 |
self |
8379 |
searchForwardFor:s |
|
8380 |
ignoreCase: lastReplaceIgnoredCase |
|
8381 |
match: lastReplaceWasMatch |
|
8382 |
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
|
8383 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8384 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8385 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8386 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8387 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8388 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8389 |
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
|
8390 |
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
|
8391 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8392 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8393 |
self deleteSelection. |
4051 | 8394 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8395 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8396 |
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
|
8397 |
] ifTrue:[ |
4051 | 8398 |
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
|
8399 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8400 |
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
|
8401 |
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
|
8402 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8403 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8404 |
selectStyle := savedSelectStyle. |
4484 | 8405 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8406 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8407 |
] |
4048 | 8408 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8409 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8410 |
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
|
8411 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8412 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8413 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8414 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8415 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8416 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8417 |
^ true. |
501 | 8418 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8419 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8420 |
! |
8421 |
||
2952 | 8422 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8423 |
^ undoSupport hasRedoAction. |
2952 | 8424 |
! |
8425 |
||
8426 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8427 |
^ undoSupport hasUndoAction. |
2952 | 8428 |
! |
8429 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8430 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8431 |
"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
|
8432 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8433 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8434 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8435 |
|
2952 | 8436 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8437 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8438 |
! |
8439 |
||
8440 |
redo |
|
3780 | 8441 |
"undo the last undo" |
8442 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8443 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8444 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8445 |
] ifTrue:[ |
3780 | 8446 |
undoSupport redo. |
2952 | 8447 |
] |
8448 |
! |
|
8449 |
||
121 | 8450 |
undo |
3780 | 8451 |
"undo the last edit operation" |
8452 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8453 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 8454 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8455 |
] ifTrue:[ |
3780 | 8456 |
undoSupport undo. |
121 | 8457 |
] |
2952 | 8458 |
! |
8459 |
||
8460 |
undoableDo:aBlock |
|
3495 | 8461 |
self undoableDo:aBlock info:nil. |
8462 |
||
8463 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8464 |
! |
8465 |
||
8466 |
undoableDo:aBlock info:aString |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8467 |
self checkModificationsAllowed ifFalse:[ |
4823 | 8468 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8469 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8470 |
] ifTrue:[ |
4823 | 8471 |
undoSupport undoableDo:aBlock info:aString. |
3495 | 8472 |
]. |
8473 |
||
8474 |
"Modified: / 28-07-2007 / 13:21:00 / cg" |
|
2952 | 8475 |
! ! |
8476 |
||
8477 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8478 |
||
8479 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8480 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8481 |
! |
|
8482 |
||
3115 | 8483 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8484 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8485 |
! |
8486 |
||
2952 | 8487 |
line:arg1 col:arg2 character:arg3 |
8488 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8489 |
! |
|
8490 |
||
3115 | 8491 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8492 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8493 |
! |
8494 |
||
3235 | 8495 |
line:arg1 col:arg2 characters:arg3 info:info |
8496 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8497 |
! |
|
8498 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8499 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8500 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8501 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8502 |
|
2952 | 8503 |
line:arg1 col:arg2 string:arg3 |
8504 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8505 |
! |
8506 |
||
8507 |
line:arg1 col:arg2 string:arg3 info:info |
|
8508 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8509 |
! |
8510 |
||
8511 |
line:arg1 string:arg3 info:info |
|
8512 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8513 |
! |
8514 |
||
8515 |
text:arg info:info |
|
8516 |
^ (self new text:arg) info:info |
|
3115 | 8517 |
! ! |
8518 |
||
8519 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8520 |
||
8521 |
info |
|
8522 |
^ userFriendlyInfo |
|
8523 |
! |
|
8524 |
||
8525 |
info:aString |
|
8526 |
userFriendlyInfo := aString |
|
2952 | 8527 |
! ! |
8528 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8529 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8530 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8531 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8532 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8533 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8534 |
"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
|
8535 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8536 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8537 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8538 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8539 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8540 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8541 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8542 |
|
2952 | 8543 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8544 |
||
3160 | 8545 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8546 |
"set instance variables (automatically generated)" |
8547 |
||
8548 |
self assert:(line1Arg notNil). |
|
8549 |
self assert:(col1Arg notNil). |
|
8550 |
self assert:(line2Arg notNil). |
|
8551 |
self assert:(col2Arg notNil). |
|
8552 |
||
8553 |
line1 := line1Arg. |
|
8554 |
col1 := col1Arg. |
|
8555 |
line2 := line2Arg. |
|
8556 |
col2 := col2Arg. |
|
8557 |
! ! |
|
8558 |
||
8559 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8560 |
||
3160 | 8561 |
executeIn:editor |
2952 | 8562 |
editor unselect. |
3160 | 8563 |
editor |
4823 | 8564 |
deleteFromLine:line1 |
8565 |
col:col1 |
|
8566 |
toLine:line2 |
|
8567 |
col:col2. |
|
2952 | 8568 |
editor cursorLine:line1 col:col1. |
8569 |
! ! |
|
8570 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8571 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8572 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8573 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8574 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8575 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8576 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8577 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8578 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8579 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8580 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8581 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8582 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8583 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8584 |
|
3160 | 8585 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8586 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8587 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8588 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8589 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8590 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8591 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8592 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8593 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8594 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8595 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8596 |
|
3160 | 8597 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8598 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8599 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8600 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8601 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8602 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8603 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8604 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8605 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8606 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8607 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8608 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8609 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8610 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8611 |
|
3160 | 8612 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8613 |
"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
|
8614 |
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
|
8615 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8616 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8617 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8618 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8619 |
^ true |
|
8620 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8621 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8622 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8623 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8624 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8625 |
|
3160 | 8626 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8627 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8628 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8629 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8630 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8631 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8632 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8633 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8634 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8635 |
|
3160 | 8636 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8637 |
editor unselect. |
3160 | 8638 |
editor |
4823 | 8639 |
deleteFromLine:line |
8640 |
col:col1 |
|
8641 |
toLine:line |
|
8642 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8643 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8644 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8645 |
|
3235 | 8646 |
!EditTextView::EditMode class methodsFor:'constants'! |
8647 |
||
8648 |
insertAndSelectMode |
|
8649 |
^ InsertAndSelectMode |
|
8650 |
! |
|
8651 |
||
8652 |
insertMode |
|
8653 |
^ InsertMode |
|
8654 |
! |
|
8655 |
||
8656 |
overwriteMode |
|
8657 |
^ OverwriteMode |
|
8658 |
! ! |
|
8659 |
||
8660 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8661 |
||
8662 |
isInsertAndSelectMode |
|
8663 |
^ false |
|
8664 |
! |
|
8665 |
||
8666 |
isInsertMode |
|
8667 |
^ false |
|
8668 |
! |
|
8669 |
||
8670 |
symbolicName |
|
8671 |
self subclassResponsibility |
|
8672 |
! ! |
|
8673 |
||
8674 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8675 |
||
8676 |
infoPrintString |
|
8677 |
^ 'IS' |
|
8678 |
! ! |
|
8679 |
||
8680 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8681 |
||
8682 |
isInsertAndSelectMode |
|
8683 |
^ true |
|
8684 |
! |
|
8685 |
||
8686 |
isInsertMode |
|
8687 |
^ true |
|
8688 |
! ! |
|
8689 |
||
8690 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8691 |
||
8692 |
infoPrintString |
|
8693 |
^ 'I' |
|
8694 |
! ! |
|
8695 |
||
8696 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8697 |
||
8698 |
isInsertMode |
|
8699 |
^ true |
|
8700 |
! ! |
|
8701 |
||
8702 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8703 |
||
8704 |
infoPrintString |
|
8705 |
^ 'O' |
|
8706 |
! ! |
|
8707 |
||
4048 | 8708 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8709 |
||
8710 |
lastReplaceIgnoredCase |
|
8711 |
^ lastReplaceIgnoredCase ? false |
|
8712 |
! |
|
8713 |
||
8714 |
lastReplaceIgnoredCase:something |
|
8715 |
lastReplaceIgnoredCase := something. |
|
8716 |
! |
|
8717 |
||
8718 |
lastReplaceWasMatch |
|
8719 |
^ lastReplaceWasMatch ? false |
|
8720 |
! |
|
8721 |
||
8722 |
lastReplaceWasMatch:something |
|
8723 |
lastReplaceWasMatch := something. |
|
8724 |
! |
|
8725 |
||
8726 |
lastReplacement |
|
8727 |
^ lastReplacement |
|
8728 |
! |
|
8729 |
||
8730 |
lastReplacement:something |
|
4053 | 8731 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8732 |
lastReplacement := something. |
8733 |
! |
|
8734 |
||
8735 |
lastStringToReplace |
|
8736 |
^ lastStringToReplace |
|
8737 |
! |
|
8738 |
||
8739 |
lastStringToReplace:something |
|
8740 |
lastStringToReplace := something. |
|
4818 | 8741 |
! |
8742 |
||
8743 |
previousReplacements |
|
8744 |
^ previousReplacements ? #() |
|
8745 |
! |
|
8746 |
||
8747 |
stillCollectingInput |
|
8748 |
^ stillCollectingInput |
|
8749 |
! |
|
8750 |
||
8751 |
stillCollectingInput:aBoolean |
|
8752 |
stillCollectingInput := aBoolean. |
|
8753 |
! ! |
|
8754 |
||
8755 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
8756 |
||
8757 |
rememberReplacement |
|
8758 |
"remember the previous replacement (called when a new one appears). |
|
8759 |
Mostly for the benefit of the code completion..." |
|
8760 |
||
8761 |
|oldString newString| |
|
8762 |
||
8763 |
oldString := lastStringToReplace. |
|
8764 |
newString := lastReplacement. |
|
8765 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
8766 |
previousReplacements isNil ifTrue:[ |
|
8767 |
previousReplacements := OrderedCollection new. |
|
8768 |
]. |
|
8769 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
8770 |
previousReplacements addFirst:(oldString -> newString). |
|
8771 |
previousReplacements size > 20 ifTrue:[ |
|
8772 |
previousReplacements removeLast. |
|
8773 |
] |
|
8774 |
]. |
|
4048 | 8775 |
! ! |
8776 |
||
2952 | 8777 |
!EditTextView::PasteString methodsFor:'accessing'! |
8778 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8779 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8780 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8781 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8782 |
"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
|
8783 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8784 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8785 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8786 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8787 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8788 |
"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
|
8789 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8790 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8791 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8792 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8793 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8794 |
"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
|
8795 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8796 |
|
3160 | 8797 |
line:lineArg col:colArg string:stringArg |
2952 | 8798 |
self assert:(lineArg notNil). |
8799 |
self assert:(colArg notNil). |
|
8800 |
self assert:(stringArg notNil). |
|
8801 |
||
8802 |
line := lineArg. |
|
8803 |
col := colArg. |
|
8804 |
string := stringArg. |
|
8805 |
! |
|
8806 |
||
8807 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
8808 |
self assert:(lineArg notNil). |
|
8809 |
self assert:(colArg notNil). |
|
8810 |
self assert:(stringArg notNil). |
|
8811 |
||
8812 |
line := lineArg. |
|
8813 |
col := colArg. |
|
8814 |
string := stringArg. |
|
8815 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8816 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8817 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8818 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8819 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8820 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8821 |
"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
|
8822 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8823 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8824 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8825 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8826 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8827 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8828 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8829 |
"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
|
8830 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8831 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8832 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8833 |
"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
|
8834 |
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
|
8835 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8836 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8837 |
previousPasteAction line == line ifTrue:[ |
4823 | 8838 |
previousPasteAction col == (self col2+1) ifTrue:[ |
8839 |
^ true |
|
8840 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8841 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8842 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8843 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8844 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8845 |
"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
|
8846 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8847 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8848 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8849 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8850 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8851 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8852 |
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
|
8853 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8854 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8855 |
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
|
8856 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8857 |
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
|
8858 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8859 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8860 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8861 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8862 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8863 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 8864 |
! ! |
8865 |
||
8866 |
!EditTextView::PasteString methodsFor:'execution'! |
|
8867 |
||
3160 | 8868 |
executeIn:editor |
2952 | 8869 |
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
|
8870 |
editor paste:string. |
2952 | 8871 |
selected ~~ true ifTrue:[ |
4823 | 8872 |
editor unselect |
2952 | 8873 |
]. |
8874 |
! ! |
|
8875 |
||
8876 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
8877 |
||
3235 | 8878 |
col |
8879 |
^ col |
|
8880 |
! |
|
8881 |
||
8882 |
col1 |
|
8883 |
^ col |
|
8884 |
! |
|
8885 |
||
8886 |
col2 |
|
8887 |
^ col |
|
8888 |
! |
|
8889 |
||
8890 |
line |
|
8891 |
^ line |
|
8892 |
! |
|
8893 |
||
3160 | 8894 |
line:lineArg col:colArg character:characterArg |
2952 | 8895 |
line := lineArg. |
8896 |
col := colArg. |
|
8897 |
character := characterArg. |
|
8898 |
! ! |
|
8899 |
||
8900 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
8901 |
||
3160 | 8902 |
executeIn:editor |
8903 |
editor |
|
4823 | 8904 |
replace:character |
8905 |
atLine:line |
|
8906 |
col:col. |
|
2952 | 8907 |
editor cursorLine:line col:col. |
105 | 8908 |
! ! |
8909 |
||
3235 | 8910 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
8911 |
||
8912 |
characters |
|
8913 |
^ characters |
|
8914 |
! |
|
8915 |
||
8916 |
col1 |
|
8917 |
^ col1 |
|
8918 |
! |
|
8919 |
||
8920 |
col2 |
|
8921 |
^ col2 |
|
8922 |
! |
|
8923 |
||
8924 |
line |
|
8925 |
^ line |
|
8926 |
! |
|
8927 |
||
8928 |
line:lineArg col:colArg character:characterArg |
|
8929 |
line := lineArg. |
|
8930 |
col1 := col2 := colArg. |
|
8931 |
characters := characterArg asString. |
|
8932 |
! |
|
8933 |
||
8934 |
line:lineArg col:colArg characters:charactersArg |
|
8935 |
line := lineArg. |
|
8936 |
col1 := colArg. |
|
8937 |
characters := charactersArg asString. |
|
8938 |
col2 := col1 + charactersArg size - 1 |
|
8939 |
! ! |
|
8940 |
||
8941 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
8942 |
||
8943 |
canCombineWithNext:anotherAction |
|
8944 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
8945 |
! |
|
8946 |
||
8947 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
8948 |
"I will combine only if we both are single character deletes, |
|
8949 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
8950 |
(i.e. single-character typing)" |
|
8951 |
||
8952 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 8953 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
8954 |
^ true |
|
8955 |
]. |
|
3235 | 8956 |
]. |
8957 |
||
8958 |
^ false |
|
8959 |
! |
|
8960 |
||
8961 |
combineWithNext:nextReplaceAction |
|
8962 |
self assert:(line == nextReplaceAction line). |
|
8963 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
8964 |
||
8965 |
col2 := nextReplaceAction col2. |
|
8966 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
8967 |
characters := characters , nextReplaceAction characters. |
|
8968 |
! ! |
|
8969 |
||
8970 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
8971 |
||
8972 |
executeIn:editor |
|
8973 |
editor |
|
4823 | 8974 |
replaceString:characters |
8975 |
atLine:line |
|
8976 |
col:col1. |
|
3235 | 8977 |
editor cursorLine:line col:col1. |
8978 |
! ! |
|
8979 |
||
3131 | 8980 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
8981 |
||
8982 |
text:something |
|
8983 |
text := something. |
|
8984 |
! ! |
|
8985 |
||
8986 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
8987 |
||
3160 | 8988 |
executeIn:editor |
3131 | 8989 |
editor contents:text |
8990 |
! ! |
|
8991 |
||
3130 | 8992 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
8993 |
||
3160 | 8994 |
line:lineArg string:stringArg |
3130 | 8995 |
line := lineArg. |
8996 |
text := stringArg. |
|
8997 |
! ! |
|
8998 |
||
8999 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9000 |
||
3160 | 9001 |
executeIn:editor |
3130 | 9002 |
editor list at:line put:text. |
9003 |
editor invalidateLine:line |
|
9004 |
! ! |
|
9005 |
||
3402 | 9006 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9007 |
||
9008 |
line:lineArg lines:lineCollectionArg |
|
9009 |
line := lineArg. |
|
9010 |
text := lineCollectionArg. |
|
9011 |
||
9012 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9013 |
! ! |
|
9014 |
||
9015 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9016 |
||
9017 |
executeIn:editor |
|
9018 |
|lnr| |
|
9019 |
||
9020 |
lnr := line. |
|
9021 |
text do:[:eachLine | |
|
4823 | 9022 |
editor list at:lnr put:eachLine. |
9023 |
editor invalidateLine:lnr. |
|
9024 |
lnr := lnr + 1. |
|
3402 | 9025 |
]. |
9026 |
||
9027 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9028 |
! ! |
|
9029 |
||
865 | 9030 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9031 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9032 |
version |
5361 | 9033 |
^ '$Header$' |
3945 | 9034 |
! |
9035 |
||
9036 |
version_CVS |
|
5361 | 9037 |
^ '$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
|
9038 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9039 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9040 |
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
|
9041 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9042 |
^ '$Changeset: <not expanded> $' |
0 | 9043 |
! ! |
4481 | 9044 |