author | Claus Gittinger <cg@exept.de> |
Sat, 07 May 2016 12:39:25 +0200 | |
changeset 5710 | 7757eb8d4d3e |
parent 5689 | 05b065914682 |
child 5717 | 94a8cc3be8ec |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4823 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
5239 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
TextView subclass:#EditTextView |
4826 | 17 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
18 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
19 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
20 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
21 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
22 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
23 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
24 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
25 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
26 |
undoSupport lastStringFromReplaceForNextSearch |
|
27 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
28 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
29 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
30 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Views-Text' |
|
0 | 33 |
! |
34 |
||
2952 | 35 |
Object subclass:#EditAction |
4826 | 36 |
instanceVariableNames:'userFriendlyInfo' |
37 |
classVariableNames:'' |
|
38 |
poolDictionaries:'' |
|
39 |
privateIn:EditTextView |
|
2952 | 40 |
! |
41 |
||
42 |
EditTextView::EditAction subclass:#DeleteRange |
|
4826 | 43 |
instanceVariableNames:'line1 col1 line2 col2' |
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:EditTextView |
|
2952 | 47 |
! |
48 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
EditTextView::EditAction subclass:#DeleteCharacters |
4826 | 50 |
instanceVariableNames:'line col1 col2' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
54 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
55 |
|
3235 | 56 |
Object subclass:#EditMode |
4826 | 57 |
instanceVariableNames:'' |
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:EditTextView |
|
3235 | 61 |
! |
62 |
||
63 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
4826 | 64 |
instanceVariableNames:'' |
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:EditTextView::EditMode |
|
3235 | 68 |
! |
69 |
||
70 |
EditTextView::EditMode subclass:#InsertMode |
|
4826 | 71 |
instanceVariableNames:'' |
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:EditTextView::EditMode |
|
3235 | 75 |
! |
76 |
||
77 |
EditTextView::EditMode subclass:#OverwriteMode |
|
4826 | 78 |
instanceVariableNames:'' |
79 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
80 |
poolDictionaries:'' |
|
81 |
privateIn:EditTextView::EditMode |
|
3235 | 82 |
! |
83 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
84 |
Query subclass:#ExecutingMacroQuery |
4826 | 85 |
instanceVariableNames:'' |
86 |
classVariableNames:'' |
|
87 |
poolDictionaries:'' |
|
88 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
89 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
90 |
|
4048 | 91 |
Object subclass:#LastReplacementInfo |
4826 | 92 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
93 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
94 |
classVariableNames:'' |
|
95 |
poolDictionaries:'' |
|
96 |
privateIn:EditTextView |
|
4048 | 97 |
! |
98 |
||
2952 | 99 |
EditTextView::EditAction subclass:#PasteString |
4826 | 100 |
instanceVariableNames:'line col string selected' |
101 |
classVariableNames:'' |
|
102 |
poolDictionaries:'' |
|
103 |
privateIn:EditTextView |
|
2952 | 104 |
! |
105 |
||
106 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
4826 | 107 |
instanceVariableNames:'line col character' |
108 |
classVariableNames:'' |
|
109 |
poolDictionaries:'' |
|
110 |
privateIn:EditTextView |
|
2952 | 111 |
! |
112 |
||
3235 | 113 |
EditTextView::EditAction subclass:#ReplaceCharacters |
4826 | 114 |
instanceVariableNames:'line col1 col2 characters' |
115 |
classVariableNames:'' |
|
116 |
poolDictionaries:'' |
|
117 |
privateIn:EditTextView |
|
3235 | 118 |
! |
119 |
||
3131 | 120 |
EditTextView::EditAction subclass:#ReplaceContents |
4826 | 121 |
instanceVariableNames:'text' |
122 |
classVariableNames:'' |
|
123 |
poolDictionaries:'' |
|
124 |
privateIn:EditTextView |
|
3131 | 125 |
! |
126 |
||
3130 | 127 |
EditTextView::EditAction subclass:#ReplaceLine |
4826 | 128 |
instanceVariableNames:'line text' |
129 |
classVariableNames:'' |
|
130 |
poolDictionaries:'' |
|
131 |
privateIn:EditTextView |
|
3130 | 132 |
! |
133 |
||
3402 | 134 |
EditTextView::EditAction subclass:#ReplaceLines |
4826 | 135 |
instanceVariableNames:'line text' |
136 |
classVariableNames:'' |
|
137 |
poolDictionaries:'' |
|
138 |
privateIn:EditTextView |
|
3402 | 139 |
! |
140 |
||
5689 | 141 |
EditTextView::EditAction subclass:#RestoreSelectionAndCursor |
142 |
instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol |
|
143 |
selectionEndLine selectionEndCol' |
|
144 |
classVariableNames:'' |
|
145 |
poolDictionaries:'' |
|
146 |
privateIn:EditTextView |
|
147 |
! |
|
148 |
||
865 | 149 |
!EditTextView class methodsFor:'documentation'! |
0 | 150 |
|
33 | 151 |
copyright |
152 |
" |
|
153 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 154 |
All Rights Reserved |
33 | 155 |
|
156 |
This software is furnished under a license and may be used |
|
157 |
only in accordance with the terms of that license and with the |
|
158 |
inclusion of the above copyright notice. This software may not |
|
159 |
be provided or otherwise made available to, or used by, any |
|
160 |
other person. No title to or ownership of the software is |
|
161 |
hereby transferred. |
|
162 |
" |
|
163 |
! |
|
164 |
||
0 | 165 |
documentation |
166 |
" |
|
167 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 168 |
Also, it adds accept functionality, and defines a new actionBlock: |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
169 |
acceptAction to be performed for accept |
125 | 170 |
|
171 |
If used with a model, this is informed by sending it a changeMsg with |
|
172 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
173 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 174 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
175 |
Please read the historic notice in the ListView class. |
0 | 176 |
|
586 | 177 |
[Instance variables:] |
0 | 178 |
|
4010 | 179 |
cursorLine <Number> line where cursor sits (1..) |
180 |
||
181 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
182 |
||
183 |
cursorCol <Number> col where cursor sits (1..) |
|
184 |
||
185 |
cursorShown <Boolean> true, if cursor is currently shown |
|
186 |
||
187 |
readOnly <Boolean> true, if text may not be edited |
|
188 |
||
189 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
190 |
cleared on accept. |
|
191 |
||
192 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
193 |
||
194 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
195 |
||
196 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
197 |
if it returns true, the modification will be done anyway. |
|
198 |
if it returns anything else, the modification is not done. |
|
199 |
||
200 |
cursorFgColor <Color> color used for cursor drawing |
|
201 |
cursorBgColor <Color> color used for cursor drawing |
|
202 |
||
203 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 204 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 205 |
(vertical bar at insertion point) |
4721 | 206 |
and #caret (caret below insertion-point). |
207 |
see cursorType: for an up-to-date list. |
|
4010 | 208 |
|
209 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
210 |
nil means: hide the cursor. |
|
211 |
||
212 |
undoAction <Block> block which undoes last cut, paste or replace |
|
213 |
(not yet fully implemented) |
|
214 |
||
215 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
216 |
this affects the next keyPress: if #paste it does not |
|
217 |
replace; otherwise it replaces the selection. |
|
218 |
||
219 |
lastCut <String> last cut or replaced string |
|
220 |
||
4053 | 221 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
222 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
223 |
lastReplacement is the string to replace lastStringToReplace |
|
224 |
||
225 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
226 |
(cleared after a new selection) |
|
4010 | 227 |
|
228 |
replacing <Boolean> true if entered characters replace last selection |
|
229 |
||
230 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
231 |
when entering one; this is the default. |
|
232 |
||
233 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
234 |
||
235 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
236 |
argument |
|
237 |
||
238 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
239 |
focus to the next field. For editTextViews, this is false |
|
240 |
by default (i.e. tabs can be entered into the text). |
|
241 |
For some subclasses (inputFields), this may be true. |
|
242 |
||
243 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
244 |
removed when editing. |
|
245 |
Default is true. |
|
246 |
||
247 |
wordWrap <Boolean> Currently not used. |
|
248 |
||
249 |
lockUpdates <Boolean> internal, private |
|
250 |
||
251 |
prevCursorState <Boolean> temporary, private |
|
252 |
||
253 |
cursorMovementWhenUpdating |
|
254 |
<Symbol> defines where the cursor is to be positioned if the |
|
255 |
model changes its value by some outside activity |
|
256 |
(i.e. not by user input into the field). |
|
257 |
Can be one of: |
|
258 |
#keep / nil -> stay where it was |
|
259 |
#endOfText -> cursor to the end |
|
260 |
#endOfLine -> stay in the line, but move to end |
|
261 |
#beginOfText -> cursor to the beginning |
|
262 |
#beginOfLine -> stay in the line, but move to begin |
|
263 |
The default is #beginOfText |
|
264 |
||
265 |
||
266 |
||
267 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 268 |
|
269 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
270 |
userPreference values: |
4010 | 271 |
userPreferences.st80EditMode |
272 |
<Boolean> if true, cursor positioning is |
|
273 |
done as in vi or ST80; i.e. |
|
274 |
wysiwyg mode is somewhat relaxed, |
|
275 |
in that the cursor cannot be |
|
276 |
positioned behind a lines end. |
|
277 |
This is not yet completely implemented. |
|
33 | 278 |
used globals: |
279 |
||
4010 | 280 |
DeleteHistory <Text> last 1000 lines of deleted text |
281 |
(but only if this variable exists already) |
|
586 | 282 |
|
283 |
[styleSheet parameters:] |
|
121 | 284 |
|
4010 | 285 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
286 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
287 |
textCursorNoFocusForegroundColor |
|
288 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
289 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 290 |
|
291 |
[author:] |
|
4010 | 292 |
Claus Gittinger |
586 | 293 |
|
294 |
[see also:] |
|
4010 | 295 |
CodeView Workspace TextView ListView |
296 |
EditField |
|
0 | 297 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
298 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
299 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
300 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
301 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
302 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
303 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
304 |
basic setup: |
4823 | 305 |
[exBegin] |
306 |
|top textView| |
|
307 |
||
308 |
top := StandardSystemView new. |
|
309 |
top extent:300@200. |
|
310 |
||
311 |
textView := EditTextView new. |
|
312 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
313 |
top addSubView:textView. |
|
314 |
||
315 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
316 |
||
317 |
top open. |
|
318 |
[exEnd] |
|
594 | 319 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
320 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
321 |
with vertical scrollbar: |
4823 | 322 |
[exBegin] |
323 |
|top scrollView textView| |
|
324 |
||
325 |
top := StandardSystemView new. |
|
326 |
top extent:300@200. |
|
327 |
||
328 |
scrollView := ScrollableView for:EditTextView. |
|
329 |
textView := scrollView scrolledView. |
|
330 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
331 |
top addSubView:scrollView. |
|
332 |
||
333 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
334 |
||
335 |
top open. |
|
336 |
[exEnd] |
|
594 | 337 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
338 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
339 |
with horizontal & vertical scrollbars: |
4823 | 340 |
[exBegin] |
341 |
|top scrollView textView| |
|
342 |
||
343 |
top := StandardSystemView new. |
|
344 |
top extent:300@200. |
|
345 |
||
346 |
scrollView := HVScrollableView for:EditTextView. |
|
347 |
textView := scrollView scrolledView. |
|
348 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
349 |
top addSubView:scrollView. |
|
350 |
||
351 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
352 |
||
353 |
top open. |
|
354 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
355 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
356 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
357 |
set the action for accept: |
4823 | 358 |
[exBegin] |
359 |
|top textView| |
|
360 |
||
361 |
top := StandardSystemView new. |
|
362 |
top extent:300@200. |
|
363 |
||
364 |
textView := EditTextView new. |
|
365 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
366 |
top addSubView:textView. |
|
367 |
||
368 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
369 |
textView acceptAction:[:contents | |
|
370 |
Transcript showCR:'will not overwrite the file with:'. |
|
371 |
Transcript showCR:contents asString |
|
372 |
]. |
|
373 |
top open. |
|
374 |
[exEnd] |
|
594 | 375 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
376 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
377 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
378 |
non-string (text) items: |
4823 | 379 |
[exBegin] |
380 |
|top textView list| |
|
381 |
||
382 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
383 |
1 to:list size by:2 do:[:nr | |
|
384 |
list at:nr put:(Text string:(list at:nr) |
|
385 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
386 |
]. |
|
387 |
||
388 |
top := StandardSystemView new. |
|
389 |
top extent:300@200. |
|
390 |
||
391 |
textView := EditTextView new. |
|
392 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
393 |
top addSubView:textView. |
|
394 |
||
395 |
textView contents:list. |
|
396 |
top open. |
|
397 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
398 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
399 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
400 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
401 |
MVC operation: |
594 | 402 |
(the examples model here is a plug simulating a real model; |
403 |
real world applications would not use a plug ..) |
|
4823 | 404 |
[exBegin] |
405 |
|top textView model| |
|
406 |
||
407 |
model := Plug new. |
|
408 |
model respondTo:#accepted: |
|
409 |
with:[:newContents | |
|
410 |
Transcript showCR:'will not overwrite the file with:'. |
|
411 |
Transcript showCR:newContents asString |
|
412 |
]. |
|
413 |
model respondTo:#getList |
|
414 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
415 |
||
416 |
||
417 |
top := StandardSystemView new. |
|
418 |
top extent:300@200. |
|
419 |
||
420 |
textView := EditTextView new. |
|
421 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
422 |
top addSubView:textView. |
|
423 |
||
424 |
textView listMessage:#getList; |
|
425 |
model:model; |
|
426 |
changeMessage:#accepted:; |
|
427 |
aspect:#list. |
|
428 |
top open. |
|
429 |
[exEnd] |
|
594 | 430 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
431 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
432 |
two textViews on the same model: |
4823 | 433 |
[exBegin] |
434 |
|top1 textView1 top2 textView2 model currentContents| |
|
435 |
||
436 |
model := Plug new. |
|
437 |
model respondTo:#accepted: |
|
438 |
with:[:newContents | |
|
439 |
Transcript showCR:'accepted:'. |
|
440 |
Transcript showCR:newContents asString. |
|
441 |
currentContents := newContents. |
|
442 |
model changed:#contents |
|
443 |
]. |
|
444 |
model respondTo:#getList |
|
445 |
with:[Transcript showCR:'query'. |
|
446 |
currentContents]. |
|
447 |
||
448 |
||
449 |
top1 := StandardSystemView new. |
|
450 |
top1 extent:300@200. |
|
451 |
||
452 |
textView1 := EditTextView new. |
|
453 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
454 |
top1 addSubView:textView1. |
|
455 |
||
456 |
textView1 listMessage:#getList; |
|
457 |
model:model; |
|
458 |
aspect:#contents; |
|
459 |
changeMessage:#accepted:. |
|
460 |
top1 open. |
|
461 |
||
462 |
top2 := StandardSystemView new. |
|
463 |
top2 extent:300@200. |
|
464 |
||
465 |
textView2 := EditTextView new. |
|
466 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
467 |
top2 addSubView:textView2. |
|
468 |
||
469 |
textView2 listMessage:#getList; |
|
470 |
model:model; |
|
471 |
aspect:#contents; |
|
472 |
changeMessage:#accepted:. |
|
473 |
top2 open. |
|
474 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
475 |
" |
0 | 476 |
! ! |
477 |
||
865 | 478 |
!EditTextView class methodsFor:'defaults'! |
59 | 479 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
480 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
481 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
482 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
483 |
"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
|
484 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
485 |
|
1419 | 486 |
st80Mode |
487 |
"return true, if the st80 editing mode is turned on. |
|
488 |
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
|
489 |
beyond the end of a line or the end of the text." |
1419 | 490 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
491 |
^ UserPreferences current st80EditMode |
1419 | 492 |
|
493 |
" |
|
494 |
EditTextView st80Mode:true |
|
495 |
EditTextView st80Mode:false |
|
496 |
" |
|
497 |
||
498 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
499 |
! |
|
500 |
||
501 |
st80Mode:aBoolean |
|
502 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 503 |
beyond the end of a line or the last line" |
1419 | 504 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
505 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 506 |
|
507 |
" |
|
508 |
EditTextView st80Mode:true |
|
509 |
EditTextView st80Mode:false |
|
510 |
" |
|
511 |
||
512 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
513 |
! |
|
514 |
||
59 | 515 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
516 |
"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
|
517 |
|
1390 | 518 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 519 |
#'textCursor.noFocusForegroundColor' |
520 |
#'textCursor.type' |
|
521 |
#'textCursor.typeNoFocus' |
|
522 |
#'editText.st80Mode')> |
|
1355 | 523 |
|
524 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
525 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
526 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
527 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
528 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
529 |
|
1419 | 530 |
" |
531 |
self updateStyleCache |
|
532 |
" |
|
533 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
534 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 535 |
! ! |
536 |
||
3431 | 537 |
!EditTextView class methodsFor:'specs'! |
538 |
||
539 |
searchReplaceDialogSpec |
|
540 |
"This resource specification was automatically generated |
|
541 |
by the UIPainter of ST/X." |
|
542 |
||
543 |
"Do not manually edit this!! If it is corrupted, |
|
544 |
the UIPainter may not be able to read the specification." |
|
545 |
||
546 |
" |
|
547 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
548 |
" |
|
549 |
||
550 |
<resource: #canvas> |
|
551 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
552 |
^ |
3431 | 553 |
#(FullSpec |
4823 | 554 |
name: searchReplaceDialogSpec |
555 |
window: |
|
3431 | 556 |
(WindowSpec |
4823 | 557 |
label: 'String Search and Replace' |
558 |
name: 'String Search and Replace' |
|
559 |
min: (Point 283 196) |
|
560 |
max: (Point 283 196) |
|
561 |
bounds: (Rectangle 0 0 279 192) |
|
562 |
) |
|
563 |
component: |
|
3431 | 564 |
(SpecCollection |
4823 | 565 |
collection: ( |
566 |
(LabelSpec |
|
567 |
label: 'Search Pattern:' |
|
568 |
name: 'label' |
|
569 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
570 |
level: 0 |
|
571 |
translateLabel: true |
|
572 |
adjust: left |
|
573 |
) |
|
574 |
(ComboBoxSpec |
|
575 |
name: 'patternComboBox' |
|
576 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
577 |
tabable: true |
|
578 |
model: searchPattern |
|
579 |
immediateAccept: false |
|
580 |
acceptOnLeave: true |
|
581 |
acceptOnReturn: true |
|
582 |
acceptOnTab: true |
|
583 |
acceptOnLostFocus: true |
|
584 |
acceptOnPointerLeave: false |
|
585 |
autoSelectInitialText: true |
|
586 |
comboList: patternList |
|
587 |
) |
|
588 |
(ComboBoxSpec |
|
589 |
name: 'replaceComboBox' |
|
590 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
591 |
tabable: true |
|
592 |
model: replacePattern |
|
593 |
immediateAccept: false |
|
594 |
acceptOnLeave: true |
|
595 |
acceptOnReturn: true |
|
596 |
acceptOnTab: true |
|
597 |
acceptOnLostFocus: true |
|
598 |
acceptOnPointerLeave: false |
|
599 |
autoSelectInitialText: true |
|
600 |
comboList: patternList |
|
601 |
) |
|
602 |
(CheckBoxSpec |
|
603 |
label: 'Ignore Case' |
|
604 |
name: 'ignoreCaseCheckBox' |
|
605 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
606 |
level: 0 |
|
607 |
tabable: true |
|
608 |
model: ignoreCase |
|
609 |
translateLabel: true |
|
610 |
) |
|
611 |
(VariableVerticalPanelSpec |
|
612 |
name: 'VariableVerticalPanel1' |
|
613 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
614 |
component: |
|
615 |
(SpecCollection |
|
616 |
collection: ( |
|
617 |
(HorizontalPanelViewSpec |
|
618 |
name: 'HorizontalPanel1' |
|
619 |
level: 0 |
|
620 |
horizontalLayout: fitSpace |
|
621 |
verticalLayout: center |
|
622 |
horizontalSpace: 3 |
|
623 |
verticalSpace: 3 |
|
624 |
ignoreInvisibleComponents: true |
|
625 |
reverseOrderIfOKAtLeft: true |
|
626 |
component: |
|
627 |
(SpecCollection |
|
628 |
collection: ( |
|
629 |
(ActionButtonSpec |
|
630 |
label: 'Replace' |
|
631 |
name: 'replaceButton' |
|
632 |
level: 2 |
|
633 |
translateLabel: true |
|
634 |
tabable: true |
|
635 |
model: replaceAction |
|
636 |
extent: (Point 134 21) |
|
637 |
) |
|
638 |
(ActionButtonSpec |
|
639 |
label: 'Replace All' |
|
640 |
name: 'replaceAllButton' |
|
641 |
level: 2 |
|
642 |
borderWidth: 1 |
|
643 |
translateLabel: true |
|
644 |
tabable: true |
|
645 |
model: replaceAllAction |
|
646 |
extent: (Point 134 21) |
|
647 |
) |
|
648 |
) |
|
649 |
||
650 |
) |
|
651 |
) |
|
652 |
(HorizontalPanelViewSpec |
|
653 |
name: 'horizontalPanelView' |
|
654 |
level: 0 |
|
655 |
horizontalLayout: fitSpace |
|
656 |
verticalLayout: center |
|
657 |
horizontalSpace: 3 |
|
658 |
verticalSpace: 3 |
|
659 |
ignoreInvisibleComponents: true |
|
660 |
reverseOrderIfOKAtLeft: true |
|
661 |
component: |
|
662 |
(SpecCollection |
|
663 |
collection: ( |
|
664 |
(ActionButtonSpec |
|
665 |
label: 'Cancel' |
|
666 |
name: 'cancelButton' |
|
667 |
level: 2 |
|
668 |
translateLabel: true |
|
669 |
tabable: true |
|
670 |
model: cancel |
|
671 |
extent: (Point 88 21) |
|
672 |
) |
|
673 |
(ActionButtonSpec |
|
674 |
label: 'Prev' |
|
675 |
name: 'prevButton' |
|
676 |
level: 2 |
|
677 |
translateLabel: true |
|
678 |
tabable: true |
|
679 |
model: prevAction |
|
680 |
extent: (Point 89 21) |
|
681 |
) |
|
682 |
(ActionButtonSpec |
|
683 |
label: 'Next' |
|
684 |
name: 'nextButton' |
|
685 |
level: 2 |
|
686 |
borderWidth: 1 |
|
687 |
translateLabel: true |
|
688 |
tabable: true |
|
689 |
model: nextAction |
|
690 |
isDefault: true |
|
691 |
extent: (Point 88 21) |
|
692 |
) |
|
693 |
) |
|
694 |
||
695 |
) |
|
696 |
) |
|
697 |
) |
|
698 |
||
699 |
) |
|
700 |
handles: (Any 0.5 1.0) |
|
701 |
) |
|
702 |
(LabelSpec |
|
703 |
label: 'Replace By:' |
|
704 |
name: 'ReplaceLabel' |
|
705 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
706 |
level: 0 |
|
707 |
translateLabel: true |
|
708 |
adjust: left |
|
709 |
) |
|
710 |
) |
|
711 |
||
712 |
) |
|
3431 | 713 |
) |
714 |
||
715 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
716 |
! ! |
|
717 |
||
2744 | 718 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
719 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
720 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
721 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
722 |
|
2019 | 723 |
"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
|
724 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
725 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
726 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
727 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
728 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
729 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
730 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
731 |
|
1390 | 732 |
cutSelection |
733 |
self cut |
|
734 |
||
735 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
736 |
! |
|
737 |
||
1590 | 738 |
deselect |
739 |
"remove the selection" |
|
740 |
||
741 |
^ self unselect |
|
742 |
||
743 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
744 |
! |
|
745 |
||
2101 | 746 |
enabled:aBoolean |
747 |
||
748 |
self readOnly:aBoolean not |
|
749 |
||
750 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
751 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
752 |
! |
|
753 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
754 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
755 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
756 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
757 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
758 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
759 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
760 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
761 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
762 |
"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
|
763 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
764 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
765 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
766 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
767 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
768 |
col < 1 ifTrue:[ |
4823 | 769 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
770 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
771 |
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
|
772 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
773 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
774 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
775 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
776 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
777 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
778 |
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
|
779 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
780 |
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
|
781 |
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
|
782 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
783 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
784 |
"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
|
785 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
786 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
787 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
788 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
789 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
790 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
791 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
792 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 793 |
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
|
794 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
795 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 796 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
797 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
798 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
799 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
800 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
801 |
v insertAndSelect:'<- hello there' at:5. |
125 | 802 |
" |
1390 | 803 |
! |
804 |
||
805 |
pasteSelection |
|
806 |
self paste |
|
807 |
||
808 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 809 |
! |
810 |
||
811 |
replaceSelectionWith:aString |
|
812 |
^ self replaceSelectionBy:aString |
|
813 |
||
814 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
815 |
! |
|
816 |
||
817 |
selectAt:pos |
|
818 |
"move the cursor before cursorPosition." |
|
819 |
||
820 |
self cursorToCharacterPosition:pos |
|
821 |
||
822 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
823 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
824 |
! |
|
825 |
||
2101 | 826 |
textHasChanged |
827 |
^ self modified |
|
828 |
||
829 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
830 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
831 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
832 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
833 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
834 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
835 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
836 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
837 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
838 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
839 |
|
4585 | 840 |
!EditTextView methodsFor:'accessing'! |
841 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
842 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
843 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
844 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
845 |
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
|
846 |
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
|
847 |
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
|
848 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
849 |
"/ 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
|
850 |
"/ 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
|
851 |
^((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
|
852 |
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
|
853 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
854 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
855 |
"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
|
856 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
857 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
858 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
859 |
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
|
860 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
861 |
"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
|
862 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
863 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
864 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
865 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
866 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
867 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
868 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
869 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
870 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
871 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
872 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
873 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
874 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
875 |
"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
|
876 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
877 |
|
4609 | 878 |
editedClass |
879 |
|cm| |
|
880 |
||
881 |
cm := self editedMethodOrClass. |
|
882 |
cm isBehavior ifTrue:[^ cm]. |
|
883 |
cm isMethod ifTrue:[^ cm mclass]. |
|
884 |
^ nil |
|
885 |
! |
|
886 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
887 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
888 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
889 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
890 |
"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
|
891 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
892 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
893 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
894 |
"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
|
895 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
896 |
"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
|
897 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
898 |
|
4609 | 899 |
editedMethod |
900 |
|cm| |
|
901 |
||
902 |
cm := self editedMethodOrClass. |
|
903 |
cm isMethod ifTrue:[^ cm]. |
|
904 |
cm isBehavior ifTrue:[^ nil]. |
|
905 |
^ nil |
|
906 |
! |
|
907 |
||
908 |
editedMethodOrClass |
|
909 |
^ nil |
|
910 |
! |
|
911 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
912 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
913 |
"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
|
914 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
915 |
"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
|
916 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
917 |
|
4585 | 918 |
hasSelectionOrTextInCursorLine |
919 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
920 |
! |
|
921 |
||
4589 | 922 |
selectionOrTextOfCursorLine |
923 |
^ self selectionOrTextOfCursorLine:true |
|
924 |
! |
|
925 |
||
4585 | 926 |
selectionOrTextOfCursorLine:doSelect |
927 |
|sel lNr line| |
|
928 |
||
929 |
sel := self selectionAsString. |
|
930 |
sel notNil ifTrue:[^ sel]. |
|
931 |
||
932 |
lNr := self cursorLine. |
|
933 |
line := self listAt:lNr. |
|
934 |
line notEmptyOrNil ifTrue:[ |
|
935 |
doSelect ifTrue:[ |
|
936 |
self selectLine:lNr. |
|
937 |
]. |
|
938 |
^ line |
|
939 |
]. |
|
940 |
||
941 |
^ nil |
|
942 |
! ! |
|
943 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
944 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
945 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
946 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
947 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
948 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
949 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
950 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
952 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
953 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
954 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
955 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
956 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
957 |
|
2792 | 958 |
acceptChannel |
959 |
"return the valueHolder holding true if text was accepted. |
|
960 |
By placing a true into this channel, an accept can also be forced." |
|
961 |
||
962 |
^ acceptChannel |
|
963 |
||
964 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
965 |
! |
|
966 |
||
967 |
acceptChannel:aValueHolder |
|
968 |
"set the valueHolder holding true if text was accepted. |
|
969 |
By placing a true into this channel, an accept can also be forced." |
|
970 |
||
971 |
|prev| |
|
972 |
||
973 |
prev := acceptChannel. |
|
974 |
acceptChannel := aValueHolder. |
|
975 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
976 |
||
977 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
978 |
! |
|
979 |
||
1108 | 980 |
acceptEnabled:aBoolean |
981 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
982 |
||
983 |
acceptEnabled := aBoolean |
|
984 |
||
985 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
986 |
! |
|
987 |
||
2792 | 988 |
accepted |
989 |
"return true if text was accepted" |
|
990 |
||
991 |
^ acceptChannel value |
|
992 |
||
993 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
994 |
! |
|
995 |
||
996 |
accepted:aBoolean |
|
997 |
"set/clear the accepted flag. |
|
998 |
This may force my current contents to be placed into my model." |
|
999 |
||
1000 |
acceptChannel value:aBoolean. |
|
1001 |
||
1002 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1003 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1004 |
! |
|
1005 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1006 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1007 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1008 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1009 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1010 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1011 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1012 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1013 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1014 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1015 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1016 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1017 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1018 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1019 |
|
2774 | 1020 |
cursorMovementWhenUpdating |
3160 | 1021 |
"return what is be done with the cursor, |
2774 | 1022 |
when I get a new text (via the model or the #contents/#list) |
1023 |
Allowed arguments are: |
|
4823 | 1024 |
#keep / nil -> stay where it was |
1025 |
#endOfText -> position cursor to the end |
|
1026 |
#beginOfText -> position cursor to the beginning |
|
1027 |
#endOfLine -> position cursor to the current lines end |
|
1028 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1029 |
The default is #beginOfText. |
1030 |
This may be useful for fields which get new values assigned from |
|
1031 |
the program (i.e. not from the user)" |
|
1032 |
||
1033 |
^ cursorMovementWhenUpdating |
|
1034 |
||
1035 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1036 |
! |
|
1037 |
||
2133 | 1038 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1039 |
"define what should be done with the cursor, |
2133 | 1040 |
when I get a new text (via the model or the #contents/#list) |
1041 |
Allowed arguments are: |
|
4823 | 1042 |
#keep / nil -> stay where it was |
1043 |
#endOfText -> position cursor to the end |
|
1044 |
#beginOfText -> position cursor to the beginning |
|
1045 |
#endOfLine -> position cursor to the current lines end |
|
1046 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1047 |
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
|
1048 |
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
|
1049 |
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
|
1050 |
|
2133 | 1051 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1052 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1053 |
"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
|
1054 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1055 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1056 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1057 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1058 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1059 |
|
2438 | 1060 |
dontReplaceSelectionOnInput |
4742 | 1061 |
"remember that the current selection was created by a paste operation |
1062 |
(as opposed to an explicit selection by the user). |
|
1063 |
This selection will not be replaced by followup user input, |
|
1064 |
so multiple pastes will be possible." |
|
1065 |
||
2438 | 1066 |
typeOfSelection := #paste |
1067 |
! |
|
1068 |
||
3235 | 1069 |
editModeHolder |
1070 |
^ editMode. |
|
1071 |
! |
|
1072 |
||
1073 |
editModeInsert |
|
1074 |
editMode value:EditMode insertMode |
|
1075 |
! |
|
1076 |
||
1077 |
editModeInsertAndSelect |
|
1078 |
editMode value:EditMode insertAndSelectMode |
|
1079 |
! |
|
1080 |
||
1081 |
editModeOverwrite |
|
1082 |
editMode value:EditMode overwriteMode |
|
1083 |
! |
|
1084 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1085 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1086 |
"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
|
1087 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1088 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1089 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1090 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1091 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1092 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1093 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1094 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1095 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1096 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1097 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1098 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1099 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1100 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1101 |
readOnly == true ifFalse:[ |
4823 | 1102 |
readOnly := true. |
1103 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1104 |
menu disableAll:#(cut paste replace indent) |
|
1105 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1106 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1107 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1108 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1109 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1110 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1111 |
insertMode:aBoolean |
3235 | 1112 |
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
|
1113 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1114 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1115 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1116 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1117 |
insertModeHolder |
3235 | 1118 |
^ BlockValue |
4823 | 1119 |
with:[:m | m isInsertMode] |
1120 |
argument:(editMode). |
|
3465 | 1121 |
|
1122 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1123 |
! |
1124 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1125 |
isInInsertMode |
3235 | 1126 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1127 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1128 |
|
5216 | 1129 |
isNotReadOnly |
1130 |
"return true, if the text is not readonly." |
|
1131 |
||
1132 |
^ self isReadOnly not |
|
1133 |
! |
|
1134 |
||
2792 | 1135 |
isReadOnly |
1136 |
"return true, if the text is readonly." |
|
1137 |
||
1138 |
^ readOnly value |
|
1139 |
||
1140 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1141 |
! |
|
1142 |
||
2796 | 1143 |
modeLabelHolder |
1144 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1145 |
||
3160 | 1146 |
^ BlockValue |
4041 | 1147 |
with:[:e :l | |
1148 |
self isReadOnly ifTrue:[ |
|
1149 |
'' |
|
1150 |
] ifFalse:[ |
|
1151 |
l ifTrue:[ 'L' allBold colorizeAllWith:Color red] |
|
1152 |
ifFalse:[ e infoPrintString]]] |
|
1153 |
argument:(self editModeHolder) |
|
1154 |
argument:(self learnModeHolder). |
|
3465 | 1155 |
|
1156 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1157 |
! |
1158 |
||
2792 | 1159 |
modified |
1160 |
"return true if text was modified" |
|
1161 |
||
1162 |
^ modifiedChannel value |
|
1163 |
! |
|
1164 |
||
1165 |
modified:aBoolean |
|
1166 |
"set/clear the modified flag" |
|
1167 |
||
1168 |
modifiedChannel value:aBoolean |
|
1169 |
||
1170 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1171 |
! |
|
1172 |
||
1173 |
modifiedChannel |
|
1174 |
"return the valueHolder holding true if text was modified" |
|
1175 |
||
1176 |
^ modifiedChannel |
|
1177 |
! |
|
1178 |
||
1179 |
modifiedChannel:aValueHolder |
|
1180 |
"set the valueHolder holding true if text was modified" |
|
1181 |
||
1182 |
|prev| |
|
1183 |
||
1184 |
prev := modifiedChannel. |
|
1185 |
modifiedChannel := aValueHolder. |
|
1186 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1187 |
||
1188 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1189 |
! |
|
1190 |
||
1191 |
readOnly |
|
1192 |
"make the text readonly. |
|
4664 | 1193 |
Obsolete because it is obfuscating (looks like a getter) |
1194 |
- use #readOnly:" |
|
2792 | 1195 |
|
1196 |
<resource:#obsolete> |
|
1197 |
||
1198 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1199 |
self readOnly:true. |
2792 | 1200 |
|
4664 | 1201 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1202 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1203 |
! |
1204 |
||
1205 |
readOnly:aBoolean |
|
1206 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1207 |
The argument may also be a valueHolder." |
|
1208 |
||
1209 |
readOnly := aBoolean |
|
1210 |
||
1211 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1212 |
! |
|
1213 |
||
4782 | 1214 |
reallyModifiedChannel |
1215 |
"return the valueHolder holding true if text was really modified. |
|
1216 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1217 |
||
1218 |
^ self modifiedChannel |
|
1219 |
! |
|
1220 |
||
5255 | 1221 |
st80Mode:aBooleanOrNil |
4192 | 1222 |
"set/clear the st80Mode flag. |
1223 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1224 |
if off, we have the Rand-editor behavior (random access) |
1225 |
if nil, the setting follows the current userPref setting." |
|
1226 |
||
1227 |
st80Mode := aBooleanOrNil |
|
4192 | 1228 |
|
1229 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1230 |
! |
|
1231 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1232 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1233 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1234 |
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
|
1235 |
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
|
1236 |
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
|
1237 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1238 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1239 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1240 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1241 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1242 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1243 |
"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
|
1244 |
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
|
1245 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1246 |
|
3160 | 1247 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1248 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1249 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1250 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1251 |
"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
|
1252 |
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
|
1253 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1254 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1255 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1256 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1257 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1258 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1259 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1260 |
at:lineNr basicPut:aLine |
5413 | 1261 |
"change a line without change notification. |
1262 |
this is not undoably, unless you care for yourself" |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1263 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1264 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1265 |
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
|
1266 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1267 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1268 |
|
522 | 1269 |
at:lineNr put:aLine |
5413 | 1270 |
"replace a line by something new. |
1271 |
this is not undoably, unless you care for yourself" |
|
1272 |
||
5393 | 1273 |
|oldLine| |
1274 |
||
1275 |
oldLine := (self at:lineNr) ? ''. |
|
1276 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
4823 | 1277 |
super at:lineNr put:aLine. |
1278 |
self textChanged |
|
522 | 1279 |
]. |
1280 |
! |
|
1281 |
||
4700 | 1282 |
characterAfterCursor |
1283 |
"return the character one after the cursor - space if beyond line." |
|
1284 |
||
1285 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1286 |
! |
|
1287 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1288 |
characterBeforeCursor |
4700 | 1289 |
"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
|
1290 |
|
5142 | 1291 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1292 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1293 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1294 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1295 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1296 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1297 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1298 |
characterUnderCursor |
2707 | 1299 |
"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
|
1300 |
For non-block cursors, this is the character immediately to the right |
5413 | 1301 |
of the insertion-bar or caret. |
1302 |
For block cursors, this is the highlighted cursor-character" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1303 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1304 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1305 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1306 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1307 |
contents |
2213 | 1308 |
"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
|
1309 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1310 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1311 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1312 |
^ super contents. |
3313 | 1313 |
|
1314 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
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 |
|
5413 | 1317 |
contents:aStringOrStringCollectionOrNil |
1318 |
"replace the whole contents by something new. |
|
5414 | 1319 |
this is not undoably, unless you care for yourself. |
1320 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1321 |
|
1322 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1323 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1324 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1325 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1326 |
"set the contents and optionally clear the undo history. |
1327 |
The contents-change is not undoable." |
|
1328 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1329 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1330 |
keepUndoHistory ifFalse:[ |
4823 | 1331 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1332 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1333 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1334 |
|
2213 | 1335 |
contentsAsString |
1336 |
"return the contents as a String (i.e. without emphasis)" |
|
1337 |
||
1338 |
list isNil ifTrue:[^ '']. |
|
1339 |
self removeTrailingBlankLines. |
|
1340 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1341 |
ifFalse:[each string] |
1342 |
]) asStringWithCRs |
|
2213 | 1343 |
! |
1344 |
||
5067 | 1345 |
contentsAsStringWithTabs |
1346 |
"return the contents as a String (i.e. without emphasis) |
|
1347 |
and with leading spaces replaced by tab characters |
|
1348 |
(i.e. as would be written to a file)" |
|
1349 |
||
1350 |
list isNil ifTrue:[^ '']. |
|
1351 |
self removeTrailingBlankLines. |
|
1352 |
^ (list collect:[:each | |
|
1353 |
each isNil |
|
1354 |
ifTrue:[''] |
|
1355 |
ifFalse:[each string withTabs] |
|
1356 |
]) asStringWithCRs |
|
1357 |
! |
|
1358 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1359 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1360 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1361 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1362 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1363 |
^ cursorCol |
125 | 1364 |
! |
1365 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1366 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1367 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1368 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1369 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1370 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1371 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1372 |
cursorLine |
3160 | 1373 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1374 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1375 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1376 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1377 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1378 |
|
5400 | 1379 |
cursorLineAndColumnLabelHolder |
5399 | 1380 |
"return a valueHolder for the cursors line and column as an info string |
1381 |
of the form 'line : col'. |
|
1382 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
|
1383 |
||
1384 |
^ BlockValue |
|
1385 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
|
1386 |
argument:self cursorLineHolder |
|
1387 |
argument:self cursorColHolder |
|
1388 |
! |
|
1389 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1390 |
cursorLineHolder |
3160 | 1391 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1392 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1393 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1394 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1395 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1396 |
|
4713 | 1397 |
lineStringBeforeCursor |
1398 |
"return the line's string before the cursor. |
|
1399 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1400 |
||
1401 |
|line| |
|
1402 |
||
1403 |
line := ((self at:cursorLine) ? '') string. |
|
1404 |
line size < (cursorCol-1) ifTrue:[ |
|
1405 |
^ line paddedTo:(cursorCol-1) |
|
1406 |
]. |
|
1407 |
^ line copyTo:(cursorCol-1) |
|
1408 |
! |
|
1409 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1410 |
list:something |
5413 | 1411 |
"replace the whole contents by something new. |
1412 |
this is not undoably, unless you care for yourself. |
|
1413 |
position cursor home when setting contents" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1414 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1415 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1416 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1417 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1418 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1419 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1420 |
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
|
1421 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1422 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1423 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1424 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1425 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1426 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1427 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1428 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1429 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1430 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1431 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1432 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1433 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1434 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1435 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1436 |
^ 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
|
1437 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1438 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1439 |
"/ 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
|
1440 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1441 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1442 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1443 |
setContents:something |
5413 | 1444 |
"replace the whole contents by something new |
1445 |
AND clear the remembered undo actions" |
|
1446 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1447 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1448 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1449 |
undoSupport resetHistories. |
2955 | 1450 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1451 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1452 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1453 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1454 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1455 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1456 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1457 |
|
4609 | 1458 |
!EditTextView methodsFor:'accessing-dimensions'! |
1459 |
||
1460 |
xOfCursor |
|
4728 | 1461 |
|point| |
1462 |
||
1463 |
cursorVisibleLine isNil ifTrue:[ |
|
1464 |
"/ take the end of the selection, if any |
|
1465 |
(selectionStartLine notNil |
|
1466 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1467 |
ifTrue:[ |
|
1468 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1469 |
]. |
|
1470 |
||
1471 |
"/ point := device |
|
1472 |
"/ translatePoint:(device pointerPosition) |
|
1473 |
"/ fromView:nil |
|
1474 |
"/ toView:self. |
|
1475 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1476 |
"/ ^ point x |
|
1477 |
"/ ]. |
|
1478 |
"/ ^ 0 |
|
1479 |
^ nil |
|
1480 |
]. |
|
4609 | 1481 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1482 |
||
1483 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1484 |
! ! |
|
4590 | 1485 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1486 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1487 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1488 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1489 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1490 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1491 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1492 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1493 |
wasOn := self hideCursor. |
5643 | 1494 |
cursorFgColor := color1 onDevice:device. |
1495 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1496 |
wasOn ifTrue:[self showCursor] |
1333 | 1497 |
! |
1498 |
||
1899 | 1499 |
cursorType |
1500 |
"return the style of the text cursor. |
|
4721 | 1501 |
Currently, supported are: #none |
1502 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1503 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1504 |
|
1505 |
^ cursorType |
|
1506 |
||
1507 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1508 |
! |
|
1509 |
||
1333 | 1510 |
cursorType:aCursorTypeSymbol |
1511 |
"set the style of the text cursor. |
|
4721 | 1512 |
Currently, supported are: #none |
1513 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1514 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1515 |
|
1334 | 1516 |
cursorType := aCursorTypeSymbol. |
1333 | 1517 |
|
1518 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1519 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1520 |
! |
1521 |
||
1899 | 1522 |
cursorTypeNoFocus |
1523 |
"return the style of the text cursor when the view has no focus. |
|
1524 |
If left unspecified, this is the same as the regular cursorType." |
|
1525 |
||
1526 |
^ cursorTypeNoFocus |
|
1527 |
||
1528 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1529 |
! |
|
1530 |
||
1334 | 1531 |
cursorTypeNoFocus:aCursorTypeSymbol |
1532 |
"set the style of the text cursor when the view has no focus. |
|
1533 |
If left unspecified, this is the same as the regular cursorType." |
|
1534 |
||
1535 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1536 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1537 |
|
4048 | 1538 |
!EditTextView methodsFor:'accessing-replace'! |
1539 |
||
4746 | 1540 |
lastReplacementInfo |
1541 |
^ lastReplacementInfo |
|
1542 |
! |
|
1543 |
||
4048 | 1544 |
lastStringToReplace: aString |
4818 | 1545 |
! |
1546 |
||
1547 |
previousReplacements |
|
1548 |
"accessor for the code completion" |
|
1549 |
||
1550 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1551 |
! ! |
1552 |
||
2119 | 1553 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1554 |
|
125 | 1555 |
accept |
1556 |
"accept the current contents by executing the accept-action and/or |
|
1557 |
changeMessage." |
|
1558 |
||
1108 | 1559 |
acceptEnabled == false ifTrue:[ |
3945 | 1560 |
self beep. |
1561 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1562 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1563 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1564 |
^ self |
1108 | 1565 |
]. |
1566 |
||
125 | 1567 |
lockUpdates := true. |
1013 | 1568 |
|
1569 |
"/ |
|
1570 |
"/ ST-80 way of doing it |
|
1571 |
"/ |
|
1572 |
model notNil ifTrue:[ |
|
4142 | 1573 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
5525 | 1574 |
acceptChannel notNil ifTrue:[ |
1575 |
acceptChannel value:true withoutNotifying:self. |
|
1576 |
]. |
|
2999 | 1577 |
]. |
1578 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1579 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1580 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1581 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1582 |
"/ 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
|
1583 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1584 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1585 |
acceptAction notNil ifTrue:[ |
3945 | 1586 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1587 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1588 |
|
125 | 1589 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1590 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1591 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1592 |
! |
1593 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1594 |
argForChangeMessage |
597 | 1595 |
"return the argument to be passed with the change notification. |
1596 |
Defined as separate method for easier subclassability." |
|
1597 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1598 |
^ self contents |
597 | 1599 |
|
1600 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1601 |
! |
1602 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1603 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1604 |
"get my contents from the model. |
597 | 1605 |
Redefined to ignore updates resulting from my own changes |
1606 |
(i.e. if lockUpdates is true)." |
|
121 | 1607 |
|
1608 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1609 |
ignore updates from my own change |
121 | 1610 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1611 |
lockUpdates ifTrue:[ |
4823 | 1612 |
lockUpdates := false. |
1613 |
^ self |
|
121 | 1614 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1615 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1616 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1617 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1618 |
"/ validate the cursorLine |
3160 | 1619 |
(cursorLine notNil |
2310 | 1620 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1621 |
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
|
1622 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1623 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1624 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1625 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1626 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1627 |
acceptChannel value == true ifTrue:[ |
1628 |
self accept. |
|
1629 |
]. |
|
1630 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1631 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1632 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1633 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1634 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1635 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1636 |
! ! |
1637 |
||
1638 |
!EditTextView methodsFor:'cursor handling'! |
|
1639 |
||
4820 | 1640 |
basicCursorReturn |
1641 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1642 |
||
1643 |
|wasOn| |
|
1644 |
||
1645 |
self checkForExistingLine:(cursorLine + 1). |
|
1646 |
cursorVisibleLine notNil ifTrue:[ |
|
1647 |
nFullLinesShown notNil ifTrue:[ |
|
1648 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1649 |
] |
|
1650 |
]. |
|
1651 |
||
1652 |
wasOn := self hideCursor. |
|
1653 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1654 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1655 |
||
1656 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1657 |
! |
|
1658 |
||
2406 | 1659 |
characterPositionOfCursor |
1660 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1661 |
! |
|
1662 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1663 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1664 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1665 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1666 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1667 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1668 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1669 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1670 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1671 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1672 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1673 |
|
2822 | 1674 |
(cursorCol == newCol) ifTrue:[^ self]. |
1675 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1676 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1677 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1678 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1679 |
|
1680 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1681 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1682 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1683 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1684 |
"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
|
1685 |
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
|
1686 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1687 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1688 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1689 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1690 |
|
2707 | 1691 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1692 |
cursorLine > list size ifTrue:[ |
4595 | 1693 |
wasOn := self hideCursor. |
1694 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1695 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1696 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1697 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1698 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1699 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1702 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1703 |
"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
|
1704 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1705 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1706 |
|
4595 | 1707 |
(nL := cursorLine) isNil ifTrue:[ |
1708 |
nL := firstLineShown |
|
1709 |
]. |
|
1710 |
||
1711 |
self st80EditMode ifTrue:[ |
|
1712 |
nL == list size ifTrue:[ |
|
1713 |
wasOn := self hideCursor. |
|
1714 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1715 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1716 |
self beep. |
|
1717 |
^ self. |
|
1718 |
] |
|
1719 |
]. |
|
1720 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1721 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1722 |
wasOn := self hideCursor. |
1723 |
nv := cursorVisibleLine + n - 1. |
|
1724 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1725 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1726 |
]. |
|
1727 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1728 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1729 |
] ifFalse:[ |
4595 | 1730 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1731 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1732 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1733 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1734 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1735 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1736 |
|
121 | 1737 |
cursorHome |
597 | 1738 |
"scroll to top AND move cursor to first line of text." |
121 | 1739 |
|
674 | 1740 |
self cursorLine:1 col:1 |
1741 |
||
1742 |
"/ |wasOn| |
|
1743 |
"/ |
|
1744 |
"/ wasOn := self hideCursor. |
|
1745 |
"/ self scrollToTop. |
|
1746 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1747 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1748 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1749 |
||
1750 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1751 |
! |
1752 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1753 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1754 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1755 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1756 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1757 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1758 |
] ifFalse:[ |
4823 | 1759 |
cursorLine ~~ 1 ifTrue:[ |
1760 |
self st80EditMode ifTrue:[ |
|
1761 |
self cursorUp. |
|
1762 |
self cursorToEndOfLine. |
|
1763 |
] |
|
1764 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1765 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1766 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1767 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1768 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1769 |
|
4126 | 1770 |
cursorLeft:n |
1771 |
"move cursor to left" |
|
1772 |
||
1773 |
n timesRepeat:[ |
|
1774 |
self cursorLeft |
|
1775 |
]. |
|
1776 |
! |
|
1777 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1778 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1779 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1780 |
|
5056 | 1781 |
self cursorLine:line col:col makeVisible:true |
1782 |
! |
|
1783 |
||
1784 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
1785 |
"this positions onto physical - not visible - line" |
|
1786 |
||
676 | 1787 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1788 |
|
2822 | 1789 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1790 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1791 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1792 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1793 |
|
672 | 1794 |
(col < 1) ifTrue:[ |
4823 | 1795 |
newCol := 1 |
672 | 1796 |
] ifFalse:[ |
4823 | 1797 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1798 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1799 |
self st80EditMode ifTrue:[ |
4823 | 1800 |
(cursorLine == list size |
1801 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1802 |
newCol := (self listAt:(list size)) size + 1. |
|
1803 |
] |
|
1419 | 1804 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1805 |
self setValidatedCursorCol:newCol. |
5056 | 1806 |
makeVisibleBoolean ifTrue:[ |
1807 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1808 |
] ifFalse:[ |
|
1809 |
wasOn ifTrue:[self showCursor] |
|
1810 |
]. |
|
672 | 1811 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1812 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1813 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1814 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1815 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1816 |
"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
|
1817 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1818 |
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
|
1819 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1820 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1821 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1822 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1823 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1824 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1825 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1826 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1827 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1828 |
"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
|
1829 |
|
4820 | 1830 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1831 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1832 |
|
5529 | 1833 |
cursorReturn:withPossibleAutoIndent |
1834 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1835 |
||
1836 |
self basicCursorReturn |
|
1837 |
! |
|
1838 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1839 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1840 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1841 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1842 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1843 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1844 |
self st80EditMode ifTrue:[ |
4823 | 1845 |
l := (self listAt:cursorLine). |
1846 |
cursorCol >= (l size + 1) ifTrue:[ |
|
5529 | 1847 |
cursorLine <= list size ifTrue:[ |
1848 |
self cursorReturn:false. "/ no autoindent |
|
4823 | 1849 |
]. |
1850 |
^ self |
|
1851 |
] |
|
3160 | 1852 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1853 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1854 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1855 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1856 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1857 |
|
4126 | 1858 |
cursorRight:n |
1859 |
"move cursor to right" |
|
1860 |
||
1861 |
n timesRepeat:[ |
|
1862 |
self cursorRight |
|
1863 |
]. |
|
1864 |
! |
|
1865 |
||
1833 | 1866 |
cursorShown:aBoolean |
1867 |
"change cursor visibility |
|
1868 |
return true if cursor was visible before." |
|
1869 |
||
1870 |
|oldState| |
|
1871 |
||
4494 | 1872 |
aBoolean == cursorShown ifTrue:[ |
1873 |
^ cursorShown |
|
1874 |
]. |
|
1833 | 1875 |
oldState := cursorShown. |
1876 |
||
1877 |
aBoolean ifTrue:[ |
|
4494 | 1878 |
self drawCursor. |
1833 | 1879 |
] ifFalse:[ |
4494 | 1880 |
(cursorShown and:[shown]) ifTrue: [ |
1881 |
self undrawCursor. |
|
1882 |
]. |
|
1833 | 1883 |
]. |
1884 |
cursorShown := aBoolean. |
|
1885 |
||
1886 |
^ oldState |
|
1887 |
||
1888 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1889 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1890 |
! |
|
1891 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1892 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1893 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1894 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1895 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1896 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1897 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1898 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1899 |
"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
|
1900 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1901 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1902 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1903 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1904 |
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
|
1905 |
cursorCol > textStart ifTrue:[ |
4823 | 1906 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1907 |
] ifFalse:[ |
4823 | 1908 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1909 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1910 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1911 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1912 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1913 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1914 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1915 |
"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
|
1916 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1917 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1918 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1919 |
wasOn := self hideCursor. |
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 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1922 |
(newTop < 1) ifTrue:[ |
4823 | 1923 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1924 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1925 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1926 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1927 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1928 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1929 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1930 |
|
674 | 1931 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1932 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1933 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1934 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1935 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1936 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1937 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1938 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1939 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1940 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1941 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1942 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1943 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1944 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1945 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
1946 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1947 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1948 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1949 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1950 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1951 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1952 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1953 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1954 |
cursorLine >= lineNr ifTrue:[ |
4823 | 1955 |
line := self listAt:cursorLine. |
1956 |
(line isEmptyOrNil) ifTrue:[ |
|
1957 |
^ self |
|
1958 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1959 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1960 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1961 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1962 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1963 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1964 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1965 |
(newTop < 1) ifTrue:[ |
4823 | 1966 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1967 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1968 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1969 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1970 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1971 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1972 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1973 |
|
674 | 1974 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1975 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1976 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1977 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1978 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1979 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1980 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1981 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1982 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1983 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1984 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1985 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1986 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1987 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1988 |
cursorToEndOfText |
4288 | 1989 |
"move cursor to the end of the text (behind the last character in last line)" |
1990 |
||
1991 |
|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
|
1992 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1993 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1994 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1995 |
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
|
1996 |
(newTop < 1) ifTrue:[ |
4288 | 1997 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1998 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1999 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2000 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2001 |
self setValidatedCursorLine:list size. |
4288 | 2002 |
lastLineLength := (self listAt:cursorLine) size. |
2003 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2004 |
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
|
2005 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2006 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2007 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2008 |
"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
|
2009 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2010 |
|
3310 | 2011 |
cursorToEndOfWord |
2012 |
"move the cursor to the end of the word" |
|
2013 |
||
2014 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2015 |
||
2016 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2017 |
:beginLine :beginCol :endLine :endCol :style | |
2018 |
||
2019 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2020 |
] |
2021 |
||
2022 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2023 |
! |
|
2024 |
||
131 | 2025 |
cursorToFirstVisibleLine |
2026 |
"place cursor into the first visible line; do not scroll." |
|
2027 |
||
2028 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2029 |
! |
|
2030 |
||
2031 |
cursorToLastVisibleLine |
|
2032 |
"place cursor into the first visible line; do not scroll." |
|
2033 |
||
2034 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2035 |
! |
|
2036 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2037 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2038 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2039 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2040 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2041 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2042 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2043 |
|
3890 | 2044 |
self |
4707 | 2045 |
wordAtLine:cursorLine col:cursorCol |
2046 |
do:[ |
|
3890 | 2047 |
:beginLine :beginCol :endLine :endCol :style | |
2048 |
||
2049 |
line := endLine. |
|
2050 |
col := endCol + 1. |
|
2051 |
searching := true. |
|
4707 | 2052 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2053 |
self wordAtLine:line col:col do:[ |
2054 |
:beginLine :beginCol :endLine :endCol :style | |
|
2055 |
||
2056 |
(line > list size) ifTrue:[ |
|
2057 |
"break out" |
|
2058 |
searching := false |
|
2059 |
] ifFalse:[ |
|
2060 |
line := endLine. |
|
2061 |
col := endCol + 1. |
|
2062 |
] |
|
2063 |
] |
|
2064 |
]. |
|
2065 |
self cursorLine:line col:col |
|
4707 | 2066 |
] |
121 | 2067 |
! |
2068 |
||
499 | 2069 |
cursorToPreviousWord |
2070 |
"move the cursor to the beginning of this or the previous word" |
|
2071 |
||
2072 |
|col line searching l| |
|
2073 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2074 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2075 |
|
2076 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2077 |
:beginLine :beginCol :endLine :endCol :style | |
2078 |
||
2079 |
line := beginLine. |
|
2080 |
col := beginCol. |
|
2081 |
style == #wordLeft ifTrue:[ |
|
2082 |
col := col + 1 |
|
2083 |
]. |
|
2084 |
||
2085 |
(cursorLine == line |
|
2086 |
and:[cursorCol == col]) ifTrue:[ |
|
2087 |
searching := true. |
|
2088 |
||
2089 |
col > 1 ifTrue:[ |
|
2090 |
col := col - 1. |
|
2091 |
]. |
|
2092 |
||
2093 |
[searching] whileTrue:[ |
|
2094 |
(col == 1) ifTrue:[ |
|
2095 |
line == 1 ifTrue:[ |
|
2096 |
searching := false |
|
2097 |
] ifFalse:[ |
|
2098 |
line := line - 1. |
|
2099 |
l := list at:line. |
|
2100 |
col := l size + 1. |
|
2101 |
] |
|
2102 |
] ifFalse:[ |
|
2103 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2104 |
self wordAtLine:line col:col do:[ |
|
2105 |
:beginLine :beginCol :endLine :endCol :style | |
|
2106 |
||
2107 |
line := beginLine. |
|
2108 |
col := beginCol. |
|
2109 |
style == #wordLeft ifTrue:[ |
|
2110 |
col := col + 1 |
|
2111 |
]. |
|
2112 |
searching := false. |
|
2113 |
] |
|
2114 |
] ifTrue:[ |
|
2115 |
col := col - 1 |
|
2116 |
] |
|
2117 |
] |
|
2118 |
] |
|
2119 |
]. |
|
2120 |
self cursorLine:line col:col |
|
499 | 2121 |
] |
2122 |
||
2123 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2124 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2125 |
! |
|
2126 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2127 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2128 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2129 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2130 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2131 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2132 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2133 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2134 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2135 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2136 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2137 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2139 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2140 |
"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
|
2141 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2142 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2143 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2144 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2145 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2146 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2147 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2148 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2149 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2150 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2151 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2152 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2153 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2154 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2155 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2156 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2157 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2158 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2159 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2160 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2161 |
] |
672 | 2162 |
|
674 | 2163 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2166 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2167 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2168 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2169 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2170 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2171 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2172 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2173 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2174 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2175 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2176 |
|
676 | 2177 |
newCol := colNr. |
2178 |
(newCol < 1) ifTrue:[ |
|
4823 | 2179 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2180 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2181 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2182 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2183 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2184 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2185 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2186 |
! |
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 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2189 |
"put cursor to position next to x/y coordinate in view" |
121 | 2190 |
|
2191 |
|line col| |
|
2192 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2193 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2194 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2195 |
self cursorVisibleLine:line col:col. |
121 | 2196 |
! |
2197 |
||
2198 |
drawCursor |
|
2199 |
"draw the cursor if shown and cursor is visible. |
|
2200 |
(but not, if there is a selection - to avoid confusion)" |
|
2201 |
||
2202 |
shown ifTrue:[ |
|
4823 | 2203 |
cursorVisibleLine notNil ifTrue:[ |
2204 |
self hasSelection ifFalse:[ |
|
2205 |
self drawCursorCharacter |
|
2206 |
] |
|
2207 |
] |
|
121 | 2208 |
] |
2209 |
! |
|
2210 |
||
2211 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2212 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2213 |
of cursor should be drawn. |
4721 | 2214 |
Currently, supported are: #none, |
2215 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2216 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2217 |
|
2570 | 2218 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2219 |
|
2220 |
self hasSelection ifTrue:[ |
|
4580 | 2221 |
" |
2222 |
hide cursor, if there is a selection |
|
2223 |
" |
|
2224 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2225 |
]. |
2226 |
||
1334 | 2227 |
cursorType == #none ifTrue:[ |
4580 | 2228 |
^ self |
1334 | 2229 |
]. |
2230 |
||
121 | 2231 |
cursorType == #block ifTrue:[ |
4829 | 2232 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2233 |
^ self |
121 | 2234 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2235 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2236 |
y := self yOfVisibleLine:cursorVisibleLine. |
2237 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2238 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2239 |
cursorType == #frame ifTrue:[ |
4580 | 2240 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2241 |
||
2242 |
char := self characterUnderCursor asString. |
|
4829 | 2243 |
self paint:bgColor. |
4889 | 2244 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2245 |
] ifFalse:[ |
4580 | 2246 |
self paint:bgColor. |
2247 |
cursorType == #ibeam ifTrue:[ |
|
2248 |
x1 := x - 1. |
|
5581 | 2249 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2250 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2251 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2252 |
^ self |
|
2253 |
]. |
|
2254 |
||
2255 |
cursorType == #Ibeam ifTrue:[ |
|
2256 |
x1 := x - 1. |
|
2257 |
y := y + 1. |
|
5581 | 2258 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2259 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2260 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2261 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2262 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2263 |
^ self |
|
2264 |
]. |
|
2265 |
||
2266 |
y := y + fontHeight - 3. |
|
2267 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2268 |
w := (fontWidth * 2 // 3) max:4. |
|
2269 |
y2 := y + w + (w//2). |
|
2270 |
] ifFalse:[ |
|
2271 |
w := (fontWidth // 2) max:4. |
|
2272 |
y2 := y + w. |
|
2273 |
]. |
|
2274 |
x1 := x - w. |
|
2275 |
x2 := x + w. |
|
2276 |
||
2277 |
oldClip := self clippingRectangleOrNil. |
|
2278 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2279 |
||
2280 |
cursorType == #caret ifTrue:[ |
|
2281 |
self lineWidth:2. |
|
2282 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2283 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2284 |
] ifFalse:[ |
|
2285 |
"anything else: solidCaret" |
|
2286 |
||
2287 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2288 |
with:(x @ y) |
|
2289 |
with:(x2 @ y2)) |
|
2290 |
]. |
|
2291 |
||
2292 |
self clippingRectangle:oldClip |
|
121 | 2293 |
]. |
133 | 2294 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2295 |
|
2088 | 2296 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2297 |
! |
2298 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2299 |
drawCursorCharacter |
3160 | 2300 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2301 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2302 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2303 |
|
3160 | 2304 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2305 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2306 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2307 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2308 |
] ifFalse:[ |
4823 | 2309 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2310 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2311 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2312 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2313 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2314 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2315 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2316 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2317 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2318 |
self hasSelection ifTrue:[ |
5260 | 2319 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2320 |
]. |
2321 |
cursorType == #none ifTrue:[ |
|
4823 | 2322 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2323 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2324 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2325 |
|
2326 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2327 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2328 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2329 |
drawNoFocusCursor |
3160 | 2330 |
"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
|
2331 |
|
1334 | 2332 |
|cType| |
2333 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2334 |
self hasSelection ifTrue:[ |
4823 | 2335 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2336 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2337 |
|
1334 | 2338 |
cType := cursorTypeNoFocus ? cursorType. |
2339 |
cType == #none ifTrue:[ |
|
4823 | 2340 |
^ self undrawCursor |
1334 | 2341 |
]. |
2342 |
||
2343 |
cType == #block ifTrue:[ |
|
4823 | 2344 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2345 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2346 |
|
1334 | 2347 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2348 |
||
2349 |
"Modified: 22.9.1997 / 00:16:13 / 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 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2353 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2354 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2355 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2356 |
self makeLineVisible:aLineNumber. |
2951 | 2357 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2358 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2359 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2360 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2361 |
hideCursor |
1833 | 2362 |
"make cursor invisible if currently invisible" |
2363 |
||
2364 |
^ self cursorShown:false |
|
2365 |
||
2366 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2367 |
! |
2368 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2369 |
makeCursorVisible |
3160 | 2370 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2371 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2372 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2373 |
|line col| |
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 |
cursorLine notNil ifTrue:[ |
4823 | 2376 |
line := cursorLine. |
2377 |
col := cursorCol. |
|
2378 |
" |
|
2379 |
if there is a selection, its better to |
|
2380 |
have its start being visible, instead of the end |
|
2381 |
" |
|
2382 |
(selectionStartLine notNil |
|
2383 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2384 |
expandingTop ~~ false ifTrue:[ |
|
2385 |
line := selectionStartLine. |
|
2386 |
col := selectionStartCol. |
|
2387 |
] ifFalse:[ |
|
2388 |
line := selectionEndLine. |
|
2389 |
col := selectionEndCol |
|
2390 |
] |
|
2391 |
]. |
|
2392 |
self makeLineVisible:line. |
|
2393 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2394 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2395 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2396 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2399 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2400 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2401 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2402 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2403 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2404 |
flag ifTrue:[self showCursor] |
121 | 2405 |
! |
2406 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2407 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2408 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2409 |
|
2815 | 2410 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2411 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2412 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2413 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2414 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2415 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2416 |
|
3303 | 2417 |
"/ self assert:(lineNr notNil). |
2418 |
||
2419 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2420 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2421 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2422 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2423 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2424 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2425 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2426 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2427 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2428 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2429 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2430 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2431 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2432 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2433 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2434 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
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 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2438 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2439 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2440 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2441 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2442 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2443 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2444 |
"strictly private: set the cursorLine, col and update the visibleLine" |
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 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2447 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2448 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2449 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2450 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2451 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2452 |
|
1833 | 2453 |
^ self cursorShown:true |
2454 |
||
2455 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2456 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2457 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2458 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2459 |
"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
|
2460 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2461 |
|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
|
2462 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2463 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2464 |
prevCol := cursorCol - 1. |
2465 |
||
2466 |
"/ if there is any italic stuff in the cursor line, |
|
2467 |
"/ redraw it completely (because characters overlap). |
|
2468 |
cursorCol > 1 ifTrue:[ |
|
2469 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2470 |
line hasChangeOfEmphasis ifTrue:[ |
|
2471 |
line size >= (cursorCol-1) ifTrue:[ |
|
2472 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2473 |
line size >= (cursorCol) ifTrue:[ |
|
2474 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2475 |
line size >= (cursorCol+1) ifTrue:[ |
|
2476 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2477 |
]. |
|
2478 |
]. |
|
2479 |
]. |
|
2480 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2481 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2482 |
] |
|
2483 |
] |
|
2484 |
] |
|
2485 |
]. |
|
2486 |
||
2487 |
((cursorType == #caret) |
|
2488 |
or:[cursorType == #solidCaret |
|
2489 |
or:[cursorType == #bigSolidCaret |
|
2490 |
or:[cursorType == #bigCaret |
|
2491 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2492 |
"caret-cursor touches 4 characters" |
|
2493 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2494 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2495 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2496 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2497 |
] ifFalse:[ |
|
2498 |
"care for left margin" |
|
2499 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2500 |
]. |
|
2501 |
^ self |
|
2502 |
]. |
|
2503 |
||
2504 |
cursorType == #ibeam ifTrue:[ |
|
2505 |
"ibeam-cursor touches 2 characters" |
|
2506 |
cursorCol > 1 ifTrue:[ |
|
2507 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2508 |
] ifFalse:[ |
|
2509 |
"care for left margin" |
|
2510 |
super redrawVisibleLine:cursorVisibleLine. |
|
2511 |
]. |
|
2512 |
^ self |
|
2513 |
]. |
|
2514 |
||
2515 |
"block cursor is simple - just one character under cursor" |
|
2516 |
||
2517 |
"/ however, if italic characters are involved, we must care |
|
2518 |
"/ for the chars before/after the cursor. |
|
2519 |
"/ We redraw the part of the previous character which got |
|
2520 |
"/ detroyed by the block cursor. |
|
2521 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2522 |
||
2523 |
line := self visibleAt:cursorVisibleLine. |
|
2524 |
(line notNil and:[line isText]) ifTrue:[ |
|
2525 |
cursorCol > 1 ifTrue:[ |
|
2526 |
oldClip := self clippingRectangleOrNil. |
|
2527 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2528 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2529 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2530 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2531 |
self clippingRectangle:oldClip. |
|
2532 |
^ self. |
|
2533 |
]. |
|
2534 |
]. |
|
2535 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2536 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2537 |
|
2088 | 2538 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2539 |
! |
2540 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2541 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2542 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2543 |
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
|
2544 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2545 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2546 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2547 |
|
672 | 2548 |
validateCursorCol:col inLine:line |
674 | 2549 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2550 |
Here, no limits are enforced (and col is returned), |
5593 | 2551 |
but it may be redefined in EditFields or views which don't like the |
674 | 2552 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2553 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2554 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2555 |
|
1419 | 2556 |
"/ in ST80 mode, |
2707 | 2557 |
"/ the cursor may not be positioned beyond the |
2558 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2559 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2560 |
self st80EditMode ifTrue:[ |
4823 | 2561 |
l := (self listAt:line). |
2562 |
max := l size + 1. |
|
2563 |
col > max ifTrue:[ |
|
2564 |
^ max |
|
2565 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2566 |
]. |
672 | 2567 |
^ col |
2568 |
||
1419 | 2569 |
"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
|
2570 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2571 |
! |
2572 |
||
2573 |
validateCursorLine:line |
|
2574 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2575 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2576 |
redefined in views which don't like the cursor to be positioned |
674 | 2577 |
behind the end of the text (vi/st-80 behavior), or want to |
2578 |
skip reserved regions" |
|
2579 |
||
1419 | 2580 |
"/ |
2581 |
"/ in st80Mode, the cursor may not be positioned |
|
5367 | 2582 |
"/ beyond the last line |
2583 |
"/ (but it must be posible to place it on one line below the last one |
|
2584 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
|
1419 | 2585 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2586 |
self st80EditMode ifTrue:[ |
5367 | 2587 |
^ (line min:(list size + 1)) max:1 |
1419 | 2588 |
]. |
674 | 2589 |
^ line |
2590 |
||
1419 | 2591 |
"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
|
2592 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2593 |
! |
2594 |
||
121 | 2595 |
withCursorOffDo:aBlock |
2596 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2597 |
||
2598 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2599 |
^ aBlock value |
121 | 2600 |
]. |
2601 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2602 |
aBlock ensure:[ |
4823 | 2603 |
self showCursor |
121 | 2604 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2605 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2606 |
|
2589 | 2607 |
!EditTextView methodsFor:'drag & drop'! |
2608 |
||
2609 |
allowDrop:aBoolean |
|
3236 | 2610 |
"enable/disable drop support" |
2611 |
||
2589 | 2612 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2613 |
dropTarget := nil. |
2589 | 2614 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2615 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2616 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2617 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2618 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2619 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2620 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2621 |
] |
3236 | 2622 |
]. |
2623 |
! |
|
2624 |
||
3412 | 2625 |
canDrop:aDropContext |
2626 |
"public from d&d. |
|
2627 |
I accept textObjects and fileObjects only." |
|
2628 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2629 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2630 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2631 |
^ self canDropObjects:aDropContext dropObjects |
|
2632 |
||
2633 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2634 |
! |
|
2635 |
||
2636 |
canDropObjects:aCollectionOfDropObjects |
|
2637 |
"public from d&d. |
|
2638 |
I accept textObjects and fileObjects only." |
|
2589 | 2639 |
|
2640 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2641 |
||
3412 | 2642 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2643 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2644 |
||
2645 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2646 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2647 |
! |
|
2648 |
||
2649 |
drop:aDropContext |
|
2650 |
"public from d&d. |
|
2651 |
drop objects (new API)" |
|
2652 |
||
2653 |
self dropObjects:(aDropContext dropObjects) |
|
2654 |
||
2655 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2656 |
! |
|
2657 |
||
2658 |
dropFileObject:aDropObject |
|
2589 | 2659 |
"drop objects |
3236 | 2660 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2661 |
||
4136 | 2662 |
|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
|
2663 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2664 |
pasteWhat := #name. |
3412 | 2665 |
|
2666 |
fn := aDropObject asFilename. |
|
2667 |
(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
|
2668 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2669 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2670 |
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
|
2671 |
pasteWhat := enforcedDropMode. |
3886 | 2672 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2673 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2674 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2675 |
pasteWhat := #name. |
3886 | 2676 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2677 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2678 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2679 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2680 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2681 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2682 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2683 |
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
|
2684 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2685 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2686 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2687 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2688 |
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
|
2689 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2690 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2691 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2692 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2693 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2694 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2695 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2696 |
] |
3886 | 2697 |
] |
2698 |
]. |
|
2699 |
]. |
|
2700 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2701 |
pasteWhat == #name ifTrue:[ |
3886 | 2702 |
text := fn pathName |
2703 |
] ifFalse:[ |
|
2704 |
self withWaitCursorDo:[ |
|
5063 | 2705 |
text := fn contentsAsString |
4136 | 2706 |
]. |
2707 |
(app := self application) notNil ifTrue:[ |
|
2708 |
app droppedFile:fn in:self |
|
2709 |
]. |
|
3886 | 2710 |
]. |
2711 |
||
3799 | 2712 |
self |
2713 |
undoablePaste:text |
|
2714 |
info:'Drop File'. |
|
3412 | 2715 |
|
2716 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2717 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2718 |
! |
2719 |
||
2720 |
dropObject:aDropObject |
|
2721 |
"drop objects |
|
2722 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2723 |
||
3415 | 2724 |
|text| |
2725 |
||
3412 | 2726 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2727 |
self dropFileObject:aDropObject |
3412 | 2728 |
] ifFalse:[ |
3799 | 2729 |
aDropObject isTextObject ifTrue:[ |
2730 |
text := aDropObject theObject. |
|
2731 |
text isStringCollection ifTrue:[ |
|
2732 |
text := text asStringWithoutFinalCR |
|
2733 |
]. |
|
2734 |
] ifFalse:[ |
|
2735 |
text := aDropObject theObject asString |
|
2736 |
]. |
|
2737 |
self |
|
2738 |
undoablePaste:text |
|
2739 |
info:'Drop'. |
|
3412 | 2740 |
]. |
2741 |
||
2742 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2743 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2744 |
! |
2745 |
||
2746 |
dropObjects:aCollectionOfDropObjects |
|
2747 |
"public from d&d. |
|
2748 |
drop objects (old API)" |
|
2749 |
||
3868 | 2750 |
aCollectionOfDropObjects do:[:el | |
2751 |
self dropObject:el |
|
3412 | 2752 |
]. |
2753 |
||
2754 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2755 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2756 |
! ! |
2757 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2758 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2759 |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2760 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2761 |
"toLower/toUppercaseFirst/toUpper selected text" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2762 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2763 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2764 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2765 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2766 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2767 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2768 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2769 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2770 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2771 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2772 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2773 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2774 |
line1 to:line2 do:[:lineNr | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2775 |
|line col1 col2 isAllLower isLowerFirst isAllUpper isUpperFirst |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2776 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2777 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2778 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2779 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2780 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2781 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2782 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2783 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2784 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2785 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2786 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2787 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2788 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2789 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2790 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2791 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2792 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2793 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2794 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2795 |
ch isUppercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2796 |
isAllLower := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2797 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2798 |
isLowerFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2799 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2800 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2801 |
ch isLowercase ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2802 |
isAllUpper := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2803 |
col == col1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2804 |
isUpperFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2805 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2806 |
] |
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 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2809 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2810 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2811 |
isLowerFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2812 |
makeUppercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2813 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2814 |
"/ must remember where we come from - otherwise, we end up |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2815 |
"/ in upperFirst - lowerFirst cycle. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2816 |
"/ think about a good place to store this state |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2817 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2818 |
makeLowercaseFirst := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2819 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2820 |
isAllUpper ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2821 |
makeLowercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2822 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2823 |
makeUppercase := true. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2824 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2825 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2826 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2827 |
makeUppercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2828 |
line at:col1 put:(line at:col1) asUppercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2829 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2830 |
makeLowercaseFirst ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2831 |
line at:col1 put:(line at:col1) asLowercase. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2832 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2833 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2834 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2835 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2836 |
ch := line at:col. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2837 |
ch := makeLowercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2838 |
ifTrue:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2839 |
ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2840 |
makeUppercase |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2841 |
ifTrue:[ ch asUppercase ] |
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 |
col == col1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2844 |
ifTrue:[ ch asUppercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2845 |
ifFalse:[ ch asLowercase ] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2846 |
] |
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 |
line at:col put:ch. |
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 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2851 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2852 |
self withoutRedrawAt:lineNr put:line. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2853 |
self invalidateLine:lineNr. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2854 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2855 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2856 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2857 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2858 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2859 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2860 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2861 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2862 |
"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
|
2863 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2864 |
selectionStartLine notNil ifTrue:[ |
4823 | 2865 |
self setClipboardText:(self selection). |
2866 |
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
|
2867 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2868 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2869 |
"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
|
2870 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
2871 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2872 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2873 |
"delete single character under cursor; does not merge lines" |
121 | 2874 |
|
2875 |
|wasOn| |
|
2876 |
||
2877 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2878 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 2879 |
wasOn ifTrue:[self showCursor] |
2880 |
! |
|
2881 |
||
827 | 2882 |
deleteCharAtLine:lineNr col:colNr |
2883 |
"delete a single character at colNr in line lineNr" |
|
2884 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2885 |
self st80EditMode ifTrue:[ |
4823 | 2886 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
2887 |
| wasOn | |
|
2888 |
wasOn := self hideCursor. |
|
2889 |
self |
|
2890 |
cursorReturn; |
|
2891 |
cursorCol:1; |
|
2892 |
deleteCharBeforeCursor. |
|
2893 |
wasOn ifTrue:[ self showCursor]. |
|
2894 |
^ self. |
|
2895 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2896 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2897 |
|
827 | 2898 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
2899 |
! |
|
2900 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2901 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2902 |
"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
|
2903 |
|
4592 | 2904 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 2905 |
|
2906 |
wasOn := self hideCursor. |
|
4814 | 2907 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 2908 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
4966 | 2909 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
4592 | 2910 |
ln size < prevTab ifTrue:[ |
2911 |
ln := ln , (String new:prevTab withAll:Character space). |
|
2912 |
]. |
|
2913 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
2914 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
2915 |
cursorCol > prevTab ifTrue:[ |
|
2916 |
self st80EditMode ifTrue:[ |
|
2917 |
"/ ensure that there is no conflict here: st80EditMode will |
|
2918 |
"/ not allow a cursor position beyond the end of line, |
|
2919 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
|
2920 |
originalLine size < prevTab ifTrue:[ |
|
4771 | 2921 |
self basicListAt:cursorLine put:ln |
4592 | 2922 |
] |
2923 |
]. |
|
2924 |
self cursorLine:cursorLine col:prevTab. |
|
2925 |
wasOn ifTrue:[ self showCursor ]. |
|
2926 |
^ self |
|
2927 |
]. |
|
2928 |
] ifFalse:[ |
|
2929 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
2930 |
self cursorLine:cursorLine col:prevTab. |
|
2931 |
wasOn ifTrue:[ self showCursor ]. |
|
2932 |
^ self. |
|
2933 |
] |
|
2934 |
]. |
|
827 | 2935 |
]. |
2936 |
||
2491 | 2937 |
"/ (autoIndent |
2938 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 2939 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 2940 |
"/ ifTrue:[ |
2941 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
2942 |
"/ |
|
2943 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
2944 |
"/ ln := list at:cursorLine. |
|
2945 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
2946 |
"/ soCol := 1 |
|
2947 |
"/ ] |
|
2948 |
"/ ] |
|
2949 |
"/ ] ifFalse:[ |
|
4592 | 2950 |
soCol := 1. |
2491 | 2951 |
"/ ]. |
2952 |
||
1419 | 2953 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 2954 |
" |
2955 |
somewhere in the middle of a line |
|
2956 |
" |
|
2957 |
self cursorLeft. |
|
2958 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 2959 |
] ifFalse:[ |
4592 | 2960 |
" |
2961 |
at begin of line - merge with previous line; |
|
2962 |
except for the very first line. |
|
2963 |
" |
|
2964 |
(cursorLine == 1) ifFalse:[ |
|
2965 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
2966 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
2967 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
2968 |
"/ we are beyond the end of the text. |
|
2969 |
"/ move the cursor to the previous line. |
|
2970 |
self cursorLine:lineNrAboveCursor col:1. |
|
2971 |
] ifFalse:[ |
|
2972 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
2973 |
] |
|
2974 |
] |
|
2975 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2976 |
]. |
827 | 2977 |
wasOn ifTrue:[ self showCursor ] |
2978 |
||
1419 | 2979 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 2980 |
! |
2981 |
||
2982 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
2983 |
"delete characters from colNr up to the end in line lineNr" |
|
2984 |
||
2985 |
|line| |
|
2986 |
||
2987 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 2988 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 2989 |
] |
2990 |
||
2991 |
! |
|
2992 |
||
4458 | 2993 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
2994 |
"delete characters from startCol to endCol in line lineNr" |
|
2995 |
||
2996 |
|deleted| |
|
2997 |
||
2998 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
2999 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3000 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3001 |
! |
|
3002 |
||
827 | 3003 |
deleteCharsAtLine:lineNr toCol:colNr |
3004 |
"delete characters from start up to colNr in line lineNr" |
|
3005 |
||
3006 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3007 |
||
3008 |
||
121 | 3009 |
! |
3010 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3011 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3012 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3013 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3014 |
self deleteLine:cursorLine |
121 | 3015 |
! |
3016 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3017 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3018 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3019 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3020 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3021 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3022 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3023 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3024 |
col1 == 0 ifTrue:[ |
4823 | 3025 |
line1 := line1 - 1. |
3026 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3027 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3028 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3029 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3030 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3031 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3032 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3033 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3034 |
|
2954 | 3035 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3036 |
"delete all text from startLine/startCol to endLine/endCol - |
|
3037 |
joining lines if nescessary" |
|
3038 |
||
3039 |
|line newLine lineSize nMore| |
|
3040 |
||
3041 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3042 |
list isNil ifTrue:[^ self]. |
|
3043 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3044 |
||
3045 |
(startLine == endLine) ifTrue:[ |
|
4225 | 3046 |
"/ delete chars within a line |
3047 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3048 |
^ self |
|
2954 | 3049 |
]. |
3050 |
||
3051 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3052 |
"/ delete full lines only |
3053 |
endLine > startLine ifTrue:[ |
|
3054 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3055 |
]. |
|
3056 |
^ self |
|
2954 | 3057 |
]. |
3058 |
||
3059 |
"/ delete right rest of 1st line |
|
4786 | 3060 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3061 |
|
3062 |
"/ delete the inner lines ... |
|
3063 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3064 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3065 |
]. |
3066 |
||
3067 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3068 |
"/ delete the left rest of the last line |
3069 |
||
3070 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3071 |
||
3072 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3073 |
startLine <= list size ifTrue:[ |
|
3074 |
line := list at:startLine. |
|
3075 |
lineSize := line size. |
|
3076 |
(startCol > lineSize) ifTrue:[ |
|
3077 |
newLine := line. |
|
3078 |
line isNil ifTrue:[ |
|
3079 |
newLine := String new:(startCol - 1) |
|
3080 |
] ifFalse:[ |
|
3081 |
nMore := startCol - 1 - lineSize. |
|
3082 |
nMore > 0 ifTrue:[ |
|
3083 |
newLine := line , (line species new:nMore) |
|
3084 |
] |
|
3085 |
]. |
|
3086 |
newLine ~~ line ifTrue:[ |
|
4771 | 3087 |
self basicListAt:startLine put:newLine. |
4225 | 3088 |
]. |
3089 |
"/ TODO: remember old maxwidth of linerange, |
|
3090 |
"/ only clear widthOfWidestLine, if this max |
|
3091 |
"/ length was (one of) the longest. |
|
3092 |
"/ avoids slow delete with huge texts. |
|
3093 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3094 |
self textChanged. |
|
3095 |
] |
|
3096 |
] |
|
2954 | 3097 |
]. |
3098 |
||
3099 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3100 |
self mergeLine:startLine removeBlanks:false |
|
3101 |
||
4225 | 3102 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3103 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3104 |
! |
3105 |
||
4458 | 3106 |
deleteFromLine:startLineNr toLine:endLineNr |
3107 |
"delete some lines" |
|
3108 |
||
3109 |
|deleted| |
|
3110 |
||
3111 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3112 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3113 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3114 |
! |
|
3115 |
||
827 | 3116 |
deleteLine:lineNr |
3117 |
"delete line" |
|
3118 |
||
3119 |
self deleteFromLine:lineNr toLine:lineNr |
|
3120 |
||
3121 |
||
3122 |
! |
|
3123 |
||
4458 | 3124 |
deleteLineWithoutRedraw:lineNr |
3125 |
"delete line - no redraw; |
|
3126 |
return true, if something was really deleted" |
|
3127 |
||
3128 |
|deleted ret| |
|
3129 |
||
3130 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3131 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3132 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3133 |
^ ret. |
|
3134 |
! |
|
3135 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3136 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3137 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3138 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3139 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3140 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3141 |
|
4771 | 3142 |
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
|
3143 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3144 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3145 |
(endLine > list size) ifTrue:[ |
4771 | 3146 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3147 |
] ifFalse:[ |
4771 | 3148 |
lastLine := endLine |
3149 |
]. |
|
3150 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3151 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3152 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3153 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3154 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3155 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3156 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3157 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3158 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3159 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3160 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3161 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3162 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3163 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3164 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3165 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3166 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3167 |
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
|
3168 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3169 |
selectionStartLine notNil ifTrue:[ |
4823 | 3170 |
wasOn := self hideCursor. |
3171 |
||
3172 |
startLine := selectionStartLine. |
|
3173 |
startCol := selectionStartCol. |
|
3174 |
endLine := selectionEndLine. |
|
3175 |
endCol := selectionEndCol. |
|
3176 |
self unselectWithoutRedraw. |
|
3177 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3178 |
self setCursorLine:startLine col:startCol. |
|
3179 |
||
3180 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3181 |
] |
121 | 3182 |
! |
3183 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3184 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3185 |
"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
|
3186 |
|
2952 | 3187 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3188 |
|
3799 | 3189 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3190 |
cursorCol <= 1 ifTrue:[ |
3191 |
self deleteCharBeforeCursor. |
|
3192 |
^ self |
|
3193 |
]. |
|
3799 | 3194 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3195 |
wasOn := self hideCursor. |
3799 | 3196 |
self |
3197 |
undoableDo:[ |
|
3198 |
endCol := cursorCol-1. |
|
3199 |
endLine := cursorLine. |
|
3200 |
self cursorToPreviousWord. |
|
3201 |
beginCol := cursorCol. |
|
3202 |
beginLine := cursorLine. |
|
3203 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5361 | 3204 |
self cursorLine:cursorLine col:beginCol. |
3799 | 3205 |
] |
3206 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3207 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3208 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3209 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3210 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3211 |
|
4458 | 3212 |
insert:aCharacter atLine:lineNr col:colNr |
3213 |
"insert a single character at lineNr/colNr; |
|
3214 |
set emphasis to character at current position" |
|
3215 |
||
3216 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3217 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3218 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3219 |
] |
3220 |
! |
|
3221 |
||
121 | 3222 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3223 |
"insert a single character at cursor-position - advance cursor." |
121 | 3224 |
|
3225 |
|wasOn| |
|
3226 |
||
3227 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3228 |
aCharacter == Character tab ifTrue:[ |
4820 | 3229 |
"/ needs special care to advance cursor correctly |
3230 |
self insertTabAtCursor |
|
121 | 3231 |
] ifFalse:[ |
4820 | 3232 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3233 |
aCharacter == (Character cr) ifTrue:[ |
|
3234 |
self basicCursorReturn |
|
3235 |
] ifFalse:[ |
|
3236 |
self cursorRight. |
|
3237 |
]. |
|
121 | 3238 |
]. |
3239 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3240 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3241 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3242 |
! |
3243 |
||
641 | 3244 |
insertLine:aString before:lineNr |
3245 |
"insert the line aString before line lineNr" |
|
3246 |
||
3247 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3248 |
||
3249 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3250 |
! |
|
3251 |
||
155 | 3252 |
insertLines:aStringCollection before:lineNr |
3253 |
"insert a bunch before line lineNr" |
|
3254 |
||
3255 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3256 |
||
3257 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3258 |
! |
|
3259 |
||
4771 | 3260 |
insertLines:someText from:start to:end before:lineNr |
3261 |
"insert a bunch of lines before line lineNr. |
|
3262 |
The cursor position is left unchanged." |
|
3263 |
||
3264 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3265 |
srcY "{ Class: SmallInteger }" |
|
3266 |
dstY "{ Class: SmallInteger }" | |
|
3267 |
||
5357 | 3268 |
"wrong when pasting multiple lines" |
3269 |
false "autoIndent" ifTrue:[ |
|
4771 | 3270 |
indent := self leftIndentForLine:lineNr. |
3271 |
||
4812 | 3272 |
text := someText |
3273 |
collect:[:ln||line| |
|
3274 |
ln notNil ifTrue:[ |
|
3275 |
line := ln withoutLeadingSeparators. |
|
3276 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3277 |
line := (String new:indent), line |
|
3278 |
]. |
|
3279 |
line |
|
3280 |
] ifFalse:[ |
|
3281 |
nil |
|
3282 |
] |
|
3283 |
]. |
|
4771 | 3284 |
] ifFalse:[ |
3285 |
text := someText |
|
3286 |
]. |
|
3287 |
||
3288 |
visLine := self listLineToVisibleLine:lineNr. |
|
3289 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3290 |
self withoutRedrawInsertLines:text |
|
3291 |
from:start to:end |
|
3292 |
before:lineNr. |
|
3293 |
] ifFalse:[ |
|
3294 |
nLines := end - start + 1. |
|
3295 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3296 |
self withoutRedrawInsertLines:text |
|
3297 |
from:start to:end |
|
3298 |
before:lineNr. |
|
3299 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3300 |
] ifFalse:[ |
|
3301 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3302 |
and:(firstLineShown + nLines + nLinesShown). |
|
3303 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3304 |
dstY := srcY + (nLines * fontHeight). |
|
3305 |
||
3306 |
"/ |
|
3307 |
"/ scroll ... |
|
3308 |
"/ |
|
3309 |
" |
|
3310 |
stupid: must catchExpose before inserting new |
|
3311 |
stuff - since catchExpose may perform redraws |
|
3312 |
" |
|
3313 |
self catchExpose. |
|
3314 |
self withoutRedrawInsertLines:text |
|
3315 |
from:start to:end |
|
3316 |
before:lineNr. |
|
3317 |
self |
|
3318 |
copyFrom:self |
|
3319 |
x:textStartLeft y:srcY |
|
3320 |
toX:textStartLeft y:dstY |
|
3321 |
width:w |
|
3322 |
height:(height - dstY) |
|
3323 |
async:true. |
|
3324 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3325 |
self waitForExpose |
|
3326 |
]. |
|
3327 |
]. |
|
3328 |
widthOfWidestLine notNil ifTrue:[ |
|
3329 |
text do:[:line | |
|
3330 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3331 |
] |
|
3332 |
]. |
|
3333 |
self textChanged. |
|
3334 |
||
3335 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3336 |
! |
|
3337 |
||
654 | 3338 |
insertLines:lines withCR:withCr |
3160 | 3339 |
"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
|
3340 |
Cursor is moved behind insertion. |
641 | 3341 |
If withCr is true, append cr after last line" |
3342 |
||
3343 |
|start end nLines wasOn| |
|
3344 |
||
3345 |
lines notNil ifTrue:[ |
|
4649 | 3346 |
nLines := lines size. |
3347 |
(nLines == 1) ifTrue:[ |
|
3348 |
self insertStringAtCursor:(lines at:1). |
|
3349 |
withCr ifTrue:[ |
|
3350 |
self insertCharAtCursor:(Character cr) |
|
3351 |
] |
|
3352 |
] ifFalse:[ |
|
3353 |
(cursorCol ~~ 1) ifTrue:[ |
|
3354 |
self insertStringAtCursor:(lines at:1). |
|
3355 |
self insertCharAtCursor:(Character cr). |
|
3356 |
start := 2 |
|
3357 |
] ifFalse:[ |
|
3358 |
start := 1 |
|
3359 |
]. |
|
3360 |
withCr ifTrue:[ |
|
3361 |
end := nLines |
|
3362 |
] ifFalse:[ |
|
3363 |
end := nLines - 1 |
|
3364 |
]. |
|
3365 |
(start <= nLines) ifTrue:[ |
|
3366 |
(end >= start) ifTrue:[ |
|
3367 |
wasOn := self hideCursor. |
|
3368 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3369 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3370 |
wasOn ifTrue:[self showCursor]. |
|
3371 |
] |
|
3372 |
]. |
|
3373 |
withCr ifFalse:[ |
|
3374 |
"last line without cr" |
|
3375 |
self insertStringAtCursor:(lines at:nLines) |
|
3376 |
] |
|
3377 |
] |
|
641 | 3378 |
] |
654 | 3379 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3380 |
"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
|
3381 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3382 |
! |
3383 |
||
3384 |
insertLines:lines withCr:withCr |
|
3385 |
"insert a bunch of lines at cursor position. Cursor |
|
3386 |
is moved behind insertion. |
|
3387 |
If withCr is true, append cr after last line" |
|
3388 |
||
2363 | 3389 |
<resource:#obsolete> |
3390 |
||
1292 | 3391 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3392 |
self insertLines:lines withCR:withCr. |
|
3393 |
||
3394 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3395 |
! |
3396 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3397 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3398 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3399 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3400 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3401 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3402 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3403 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3404 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3405 |
self selectFromLine:startLine col:startCol |
4823 | 3406 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3407 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3408 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3409 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3410 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3411 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3412 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3413 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3414 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3415 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3416 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3417 |
col == 0 ifTrue:[ |
3418 |
line > 1 ifTrue:[ |
|
3419 |
line := line - 1. |
|
5216 | 3420 |
col := (self listAt:line) size + 1. |
5060 | 3421 |
] ifFalse:[ |
3422 |
col := 1. |
|
3423 |
] |
|
3424 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3425 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3426 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3427 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3428 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3429 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3430 |
handle cr's correctly" |
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 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3433 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3434 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3435 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3436 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3437 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3438 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3439 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3440 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3441 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3442 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3443 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3444 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3445 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3446 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3447 |
[start <= end] whileTrue:[ |
4823 | 3448 |
stop := aString indexOf:(Character cr) startingAt:start. |
3449 |
stop == 0 ifTrue:[ |
|
3450 |
stop := end + 1 |
|
3451 |
]. |
|
3452 |
subString := aString copyFrom:start to:(stop - 1). |
|
3453 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3454 |
(stop <= end) ifTrue:[ |
|
3455 |
c := c + subString size. |
|
3456 |
self insert:(Character cr) atLine:l col:c. |
|
3457 |
l := l + 1. |
|
3458 |
c := 1 |
|
3459 |
]. |
|
3460 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3461 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3462 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3463 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3464 |
! |
3465 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3466 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3467 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3468 |
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
|
3469 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3470 |
aString isNil ifTrue:[ |
4823 | 3471 |
"new:" |
3472 |
self insertCharAtCursor:(Character cr). |
|
3473 |
^ self |
|
105 | 3474 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3475 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3476 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3477 |
]. |
3478 |
||
654 | 3479 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3480 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3481 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3482 |
! |
3483 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3484 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3485 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3486 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3487 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3488 |
shown ifTrue:[ |
4889 | 3489 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3490 |
self invalidateLine:lineNr. |
3491 |
] ifFalse:[ |
|
3492 |
self redrawLine:lineNr from:colNr |
|
3493 |
] |
|
3494 |
] |
|
3495 |
||
4191 | 3496 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3497 |
! |
3498 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3499 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3500 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3501 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3502 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3503 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3504 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3505 |
aString size > 0 ifTrue:[ |
4823 | 3506 |
wasOn := self hideCursor. |
3507 |
(aString includes:Character tab) ifTrue:[ |
|
3508 |
self checkForExistingLine:cursorLine. |
|
3509 |
oldLen := (list at:cursorLine) size. |
|
3510 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3511 |
newLen := (list at:cursorLine) size. |
|
3512 |
deltaLen := newLen - oldLen. |
|
3513 |
] ifFalse:[ |
|
3514 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3515 |
deltaLen := aString size. |
|
3516 |
]. |
|
3517 |
self setCursorCol:(cursorCol + deltaLen). |
|
3518 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3519 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3520 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3521 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3522 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3523 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3524 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3525 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3526 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3527 |
|wasOn nextTab| |
105 | 3528 |
|
121 | 3529 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3530 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3531 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3532 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3533 |
! |
3534 |
||
3542 | 3535 |
joinLines |
3890 | 3536 |
"join lines (remove line-break)" |
3537 |
||
3583 | 3538 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3539 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3540 |
self |
3890 | 3541 |
undoableDo:[ |
3542 |
|line col lineLen| |
|
3543 |
||
3544 |
line := cursorLine. |
|
3545 |
col := cursorCol. |
|
3546 |
lineLen := (list at:line) size. |
|
3547 |
col > lineLen ifTrue:[ |
|
3548 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3549 |
] ifFalse:[ |
|
3550 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3551 |
]. |
|
3552 |
self mergeLine:line removeBlanks:true. |
|
3553 |
self cursorLine:line col:col. |
|
3554 |
] |
|
3555 |
info:'Join' |
|
3542 | 3556 |
! |
3557 |
||
2952 | 3558 |
mergeLine:lineNr |
3559 |
"merge line lineNr with line lineNr+1" |
|
3560 |
||
3561 |
self mergeLine:lineNr removeBlanks:true |
|
3562 |
||
3563 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3564 |
! |
|
3565 |
||
4458 | 3566 |
mergeLine:lineNr removeBlanks:removeBlanks |
3567 |
"merge line lineNr with line lineNr+1" |
|
3568 |
||
3569 |
|len| |
|
3570 |
||
3571 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3572 |
||
3573 |
len := (self listAt:lineNr) size. |
|
3574 |
self nonUndoableDo:[ |
|
4823 | 3575 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3576 |
]. |
3577 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3578 |
! |
|
3579 |
||
2506 | 3580 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5560 | 3581 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3582 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3583 |
self hasSelection ifFalse:[^ self]. |
5560 | 3584 |
startLine := selectionStartLine. |
3585 |
endLine := selectionEndLine. |
|
3586 |
startCol := selectionStartCol. |
|
3587 |
endCol := selectionEndCol. |
|
3588 |
||
3589 |
newSelectionEnd := endCol. |
|
3590 |
||
3591 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
|
3592 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
|
3593 |
self deleteCharAtLine:endLine col:endCol. |
|
4823 | 3594 |
newSelectionEnd := newSelectionEnd-1. |
3595 |
]. |
|
5560 | 3596 |
self deleteCharAtLine:startLine col:startCol. |
3597 |
startLine == endLine ifTrue:[ |
|
4823 | 3598 |
newSelectionEnd := newSelectionEnd-1. |
3599 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3600 |
] ifFalse:[ |
5560 | 3601 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4823 | 3602 |
newSelectionEnd := newSelectionEnd+1. |
5560 | 3603 |
self insert:openingCharacter atLine:startLine col:startCol. |
3604 |
startLine == endLine ifTrue:[ |
|
4823 | 3605 |
newSelectionEnd := newSelectionEnd+1. |
3606 |
] |
|
3160 | 3607 |
]. |
3608 |
self |
|
5560 | 3609 |
selectFromLine:startLine col:startCol |
3610 |
toLine:endLine col:newSelectionEnd. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3611 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3612 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3613 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3614 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3615 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3616 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3617 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3618 |
|
5114 | 3619 |
NoModificationError handle:[:ex | |
3620 |
^ self |
|
3621 |
] do:[ |
|
3622 |
lastLine := list size. |
|
3623 |
finished := false. |
|
3624 |
[finished] whileFalse:[ |
|
3625 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 3626 |
finished := true |
3627 |
] ifFalse:[ |
|
5114 | 3628 |
line := list at:lastLine. |
3629 |
line notNil ifTrue:[ |
|
3630 |
line isBlank ifTrue:[ |
|
3631 |
self basicListAt:lastLine put:nil. |
|
3632 |
line := nil |
|
3633 |
] |
|
3634 |
]. |
|
3635 |
line notNil ifTrue:[ |
|
3636 |
finished := true |
|
3637 |
] ifFalse:[ |
|
3638 |
lastLine := lastLine - 1 |
|
3639 |
] |
|
4771 | 3640 |
] |
5114 | 3641 |
]. |
3642 |
(lastLine ~~ list size) ifTrue:[ |
|
3643 |
list grow:lastLine. |
|
3644 |
"/ self textChanged |
|
4771 | 3645 |
] |
118 | 3646 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3647 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3648 |
|
4458 | 3649 |
replace:aCharacter atLine:lineNr col:colNr |
3650 |
"replace a single character at lineNr/colNr" |
|
3651 |
||
3652 |
|originalChar| |
|
3653 |
||
3654 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3655 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3656 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3657 |
! |
|
3658 |
||
4713 | 3659 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3660 |
|pattern replacePattern| |
3661 |
||
3662 |
pattern := patternArg string. |
|
3663 |
replacePattern := replacePatternArg string. |
|
4630 | 3664 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3665 |
self rememberSearchPattern:pattern. |
|
3666 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3667 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3668 |
self |
3669 |
undoableDo:[ |
|
3670 |
all ifTrue:[ |
|
3671 |
self |
|
3672 |
replaceString:pattern |
|
3673 |
to:replacePattern |
|
4713 | 3674 |
ignoreCase:ignoreCase |
4630 | 3675 |
] ifFalse:[ |
3676 |
(self selectionAsString notNil |
|
4713 | 3677 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3678 |
ifTrue:[ |
4742 | 3679 |
self replaceSelectionBy:replacePattern. |
4630 | 3680 |
self |
3681 |
search:pattern |
|
4713 | 3682 |
ignoreCase:ignoreCase |
4630 | 3683 |
forward:(lastSearchDirection = #forward). |
3684 |
]. |
|
3685 |
] |
|
3686 |
] |
|
3687 |
info:'Replace' |
|
3430 | 3688 |
] |
3689 |
||
3690 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3691 |
! |
|
3692 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3693 |
replaceCharAtCursor:aCharacter |
5413 | 3694 |
"undoably replace a single character at cursor-position - advance cursor" |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3695 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3696 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3697 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3698 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3699 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3700 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3701 |
] ifFalse:[ |
4823 | 3702 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3703 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3704 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3705 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3706 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3707 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3708 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3709 |
|
4458 | 3710 |
replaceContentsWith:newContents |
5413 | 3711 |
"undoably replace everything" |
4458 | 3712 |
|
3713 |
|originalContents| |
|
3714 |
||
3715 |
originalContents := self contents. |
|
3716 |
self contents:newContents keepUndoHistory:true. |
|
3717 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3718 |
! |
|
3719 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3720 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 3721 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3722 |
|
5216 | 3723 |
"/ 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
|
3724 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3725 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3726 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3727 |
|
4458 | 3728 |
replaceLine:lineNr with:newText |
5413 | 3729 |
"undoably replace a line at lineNr" |
4458 | 3730 |
|
3731 |
|originalLine| |
|
3732 |
||
3733 |
originalLine := self listAt:lineNr. |
|
3734 |
originalLine isNil ifTrue:[ |
|
4823 | 3735 |
self checkForExistingLine:lineNr |
4458 | 3736 |
]. |
3737 |
self list at:lineNr put:newText. |
|
3738 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3739 |
self invalidateLine:lineNr. |
|
3740 |
||
3741 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3742 |
! |
|
3743 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3744 |
replaceLines:lines withCR:withCr |
5413 | 3745 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3746 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3747 |
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
|
3748 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3749 |
|
1809 | 3750 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3751 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3752 |
lines notNil ifTrue:[ |
4661 | 3753 |
wasOn := self hideCursor. |
3754 |
nLines := lines size. |
|
3755 |
line := cursorLine. |
|
3756 |
col := cursorCol. |
|
3757 |
lines keysAndValuesDo:[:i :l | |
|
3758 |
self replaceString:(l ? '') atLine:line col:col. |
|
3759 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3760 |
line := line + 1. |
|
3761 |
col := 1. |
|
3762 |
] ifFalse:[ |
|
3763 |
col := col + (l size). |
|
3764 |
] |
|
3765 |
]. |
|
3766 |
self cursorLine:line col:col. |
|
3767 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3768 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3769 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3770 |
|
4661 | 3771 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3772 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3773 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3774 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3775 |
replaceSelectionBy:something |
5413 | 3776 |
"undoably delete the selection (if any) and insert something, a character or string; |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3777 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3778 |
|
4666 | 3779 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3780 |
! |
3781 |
||
3782 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 3783 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 3784 |
leave cursor after insertion or leave it, depending on keep" |
3785 |
||
4666 | 3786 |
self replaceSelectionBy:something keepCursor:keep select:false |
3787 |
||
3788 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3789 |
! |
|
3790 |
||
3791 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 3792 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 3793 |
leave cursor after insertion or leave it, depending on keep. |
3794 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3795 |
||
3796 |
|sel l c selStartLine selStartCol| |
|
105 | 3797 |
|
3798 |
l := cursorLine. |
|
3799 |
c := cursorCol. |
|
3800 |
||
4818 | 3801 |
sel := self selectionAsString. |
4666 | 3802 |
sel isNil ifTrue:[ |
3803 |
selStartLine := l. |
|
3804 |
selStartCol := c. |
|
3805 |
] ifFalse:[ |
|
3806 |
selStartLine := selectionStartLine. |
|
3807 |
selStartCol := selectionStartCol. |
|
3808 |
||
4053 | 3809 |
self setLastStringToReplace: sel. |
3810 |
||
4010 | 3811 |
self deleteSelection. |
3812 |
replacing := true. |
|
4818 | 3813 |
lastReplacementInfo rememberReplacement. |
4048 | 3814 |
lastReplacementInfo lastReplacement: ''. |
4818 | 3815 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 3816 |
undoSupport actionInfo:'replace'. |
3161 | 3817 |
]. |
3818 |
||
3819 |
something isCharacter ifTrue:[ |
|
4051 | 3820 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 3821 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 3822 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 3823 |
]. |
4010 | 3824 |
]. |
3825 |
self isInInsertMode ifTrue:[ |
|
3826 |
self insertCharAtCursor:something |
|
3827 |
] ifFalse:[ |
|
3828 |
self replaceCharAtCursor:something |
|
3829 |
] |
|
105 | 3830 |
] ifFalse:[ |
4010 | 3831 |
something isString ifTrue:[ |
4048 | 3832 |
lastReplacementInfo lastReplacement: something. |
4010 | 3833 |
self isInInsertMode ifTrue:[ |
3834 |
self insertStringAtCursor:something |
|
3835 |
] ifFalse:[ |
|
3836 |
self replaceStringAtCursor:something |
|
3837 |
] |
|
3838 |
] ifFalse:[ |
|
3839 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
3840 |
]. |
|
105 | 3841 |
]. |
3842 |
keep ifTrue:[ |
|
4010 | 3843 |
self cursorLine:l col:c |
4666 | 3844 |
]. |
3845 |
selectNewText ifTrue:[ |
|
3846 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 3847 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3848 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
3849 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3850 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3851 |
|
4458 | 3852 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 3853 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 3854 |
This is not prepared to encounter special chars (except TAB) in the string." |
3855 |
||
3856 |
|originalString| |
|
3857 |
||
3858 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3859 |
||
3860 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
3861 |
||
3862 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
3863 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
3864 |
! |
|
3865 |
||
4713 | 3866 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 3867 |
|continue count| |
3868 |
||
3869 |
self cursorToTop. |
|
3870 |
self selectFromBeginning. |
|
3871 |
count := 0. |
|
3872 |
continue := true. |
|
3873 |
[ continue ] whileTrue:[ |
|
4713 | 3874 |
(self selectionAsString notNil |
3875 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
3876 |
ifTrue:[ |
|
4742 | 3877 |
self replaceSelectionBy:aNewString. |
4713 | 3878 |
count := count + 1. |
3879 |
]. |
|
3880 |
self |
|
3881 |
searchFwd:aString |
|
3882 |
ignoreCase:ignoreCase |
|
3883 |
ifAbsent:[ |
|
3884 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
3885 |
bindWith:aString with:aNewString with:count). |
|
3886 |
continue := false. |
|
3887 |
]. |
|
3549 | 3888 |
]. |
3430 | 3889 |
|
3890 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
3891 |
! |
|
3892 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3893 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3894 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3895 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3896 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3897 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3898 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3899 |
(aString includes:Character tab) ifTrue:[ |
4823 | 3900 |
"/ need special care for TAB (to move cursor correctly) |
3901 |
i1 := 1. |
|
3902 |
[i1 ~~ 0] whileTrue:[ |
|
3903 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
3904 |
i2 ~~ 0 ifTrue:[ |
|
3905 |
i1 ~~ i2 ifTrue:[ |
|
3906 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
3907 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
3908 |
]. |
|
3909 |
self replaceTABAtCursor. |
|
3910 |
i2 := i2 + 1. |
|
3911 |
] ifFalse:[ |
|
3912 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
3913 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
3914 |
]. |
|
3915 |
i1 := i2. |
|
3916 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3917 |
] ifFalse:[ |
4823 | 3918 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
5325 | 3919 |
self setValidatedCursorCol:(cursorCol + aString size). |
3920 |
"/ self cursorCol:(cursorCol + aString size). |
|
3921 |
]. |
|
3922 |
wasOn ifTrue:[ |
|
3923 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
|
3924 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
3925 |
]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3926 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3927 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
3928 |
"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
|
3929 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3930 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3931 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3932 |
"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
|
3933 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3934 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3935 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3936 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3937 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3938 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3939 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3940 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3941 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 3942 |
! |
3943 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3944 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3945 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3946 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3947 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3948 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3949 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3950 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3951 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3952 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3953 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3954 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3955 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3956 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3957 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3958 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3959 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3960 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3961 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
3962 |
|
4458 | 3963 |
splitLine:lineNr before:colNr |
3964 |
"split the line linNr before colNr; the right part (from colNr) |
|
3965 |
is cut off and inserted after lineNr; the view is redrawn" |
|
3966 |
||
3967 |
self basicSplitLine:lineNr before:colNr. |
|
3968 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
3969 |
! |
|
3970 |
||
5146 | 3971 |
withAutoIndent:aBoolean do:aBlock |
3972 |
|sav| |
|
3973 |
||
3974 |
sav := autoIndent. |
|
3975 |
autoIndent := aBoolean. |
|
3976 |
aBlock ensure:[ autoIndent := sav ]. |
|
3977 |
! |
|
3978 |
||
4458 | 3979 |
withoutRedrawAt:lineNr put:aString |
3980 |
"replace a line at lineNr" |
|
3981 |
||
3982 |
|originalLine| |
|
3983 |
||
3984 |
originalLine := self listAt:lineNr. |
|
3985 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3986 |
super withoutRedrawAt:lineNr put:aString. |
|
3987 |
! |
|
3988 |
||
3989 |
withoutRedrawInsertLine:aString before:lineNr |
|
3990 |
"insert the argument, aString before line lineNr; the string |
|
3991 |
becomes line lineNr; everything else is moved down; the view |
|
3992 |
is not redrawn" |
|
3993 |
||
4771 | 3994 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 3995 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
3996 |
! |
|
3997 |
||
3998 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
3999 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4000 |
||
4001 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4002 |
self isReadOnly ifFalse:[ |
|
4823 | 4003 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4004 |
]. |
4005 |
! |
|
4006 |
||
4007 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4008 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4009 |
||
4010 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4011 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4012 |
! |
|
4013 |
||
3890 | 4014 |
wrapLines |
4015 |
"wrap lines (insert line-break)" |
|
4016 |
||
4017 |
|lineLength answerString string| |
|
4018 |
||
4019 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4020 |
||
4021 |
self hasSelection ifFalse:[ |
|
4022 |
self selectLine:cursorLine. |
|
4023 |
]. |
|
4024 |
string := self selectionAsString. |
|
4025 |
string isEmptyOrNil ifTrue:[ |
|
4026 |
Dialog information:(resources string:'Nothing selected.'). |
|
4027 |
^ self. |
|
4028 |
]. |
|
4029 |
||
4030 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4031 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4032 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4033 |
lineLength < 1 ifTrue:[ |
4034 |
lineLength := 1. |
|
4035 |
]. |
|
4036 |
||
4037 |
self |
|
4038 |
undoableDo:[ |
|
4039 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4040 |
||
4041 |
line := selectionStartLine. |
|
4042 |
col := selectionStartCol. |
|
4043 |
||
4044 |
self cutSelection. |
|
4045 |
self cursorLine:line col:col. |
|
4046 |
||
4047 |
lastGoodCol := col. |
|
4048 |
||
4049 |
inStream := string readStream. |
|
4050 |
[ inStream atEnd ] whileFalse:[ |
|
4051 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4052 |
word := WriteStream on:(String new:10). |
|
4053 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4054 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4055 |
self insertCharAtCursor:(Character cr). |
|
4056 |
col := 1. |
|
4057 |
] ifFalse:[ |
|
4058 |
col ~~ 1 ifTrue:[ |
|
4059 |
self insertStringAtCursor:' '. |
|
4060 |
col := col + 1. |
|
4061 |
] |
|
4062 |
]. |
|
4063 |
self insertStringAtCursor:word contents. |
|
4064 |
col := col + word size. |
|
4065 |
]. |
|
4066 |
] |
|
4067 |
info:'Wrap' |
|
4388 | 4068 |
|
4069 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4070 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4071 |
|
2752 | 4072 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4073 |
|
2952 | 4074 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4075 |
"delete characters from startCol to endCol in line lineNr" |
4076 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4077 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4078 |
|
4673 | 4079 |
self unselect. |
4080 |
||
4081 |
cursorLine == lineNr ifTrue:[ |
|
4082 |
cursorCol >= startCol ifTrue:[ |
|
4083 |
cursorCol >= endCol ifTrue:[ |
|
4084 |
cursorCol := startCol. |
|
4085 |
] ifFalse:[ |
|
4086 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
5489 | 4087 |
"/ self assert:(cursorCol >= 0). |
4088 |
cursorCol := cursorCol max:1. |
|
4673 | 4089 |
] |
4090 |
]. |
|
4091 |
]. |
|
4092 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4093 |
line := self listAt:lineNr. |
827 | 4094 |
|
4673 | 4095 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4096 |
||
4097 |
lineSize := line size. |
|
4098 |
||
4099 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4100 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4101 |
||
4102 |
stop >= start ifTrue:[ |
|
4103 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
4104 |
ifFalse:[ newLine := '' ]. |
|
4105 |
||
4106 |
stop == lineSize ifFalse:[ |
|
4107 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4108 |
newLine := line string species fromString:newLine. |
|
4190 | 4109 |
]. |
4673 | 4110 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
4111 |
]. |
|
4112 |
||
4113 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4114 |
newLine := nil |
|
4115 |
]. |
|
4116 |
||
4117 |
prevWidth := self widthOfLine:lineNr. |
|
4118 |
||
4771 | 4119 |
self basicListAt:lineNr put:newLine. |
4673 | 4120 |
|
4121 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4122 |
"/ remember old width of this line, |
|
4123 |
"/ only clear widthOfWidestLine, if this lines |
|
4124 |
"/ length was (one of) the longest. |
|
4125 |
"/ avoids slow delete with huge texts. |
|
4126 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4127 |
||
4128 |
"/ scroll left if reqiured |
|
4129 |
viewOrigin x > 0 ifTrue:[ |
|
4130 |
newWidth := self widthOfLine:lineNr. |
|
4131 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4132 |
self scrollHorizontalTo:(newWidth |
|
4133 |
- width |
|
4134 |
+ margin + margin |
|
4889 | 4135 |
+ (gc font widthOf:' ')) |
4673 | 4136 |
] |
4190 | 4137 |
]. |
4673 | 4138 |
self textChanged. |
4139 |
] ifFalse:[ |
|
4140 |
self textChanged "/ textChangedButNoSizeChange |
|
4141 |
]. |
|
4889 | 4142 |
gc font hasOverlappingCharacters ifTrue:[ |
4673 | 4143 |
self invalidateLine:lineNr. |
4144 |
] ifFalse:[ |
|
4145 |
self redrawLine:lineNr from:start. |
|
4146 |
]. |
|
4147 |
]. |
|
827 | 4148 |
|
4191 | 4149 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4150 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4151 |
|
2952 | 4152 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4153 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4154 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4155 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4156 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4157 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4158 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4159 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4160 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4161 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4162 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4163 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4164 |
startLineNr <= list size ifTrue:[ |
4771 | 4165 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4166 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4167 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4168 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4169 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4170 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4171 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4172 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4173 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4174 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4175 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4176 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4177 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4178 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4179 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4180 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4181 |
|
4226 | 4182 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4183 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4184 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4185 |
|
2952 | 4186 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4187 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4188 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4189 |
|
2952 | 4190 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4191 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4192 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4193 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4194 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4195 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4196 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4197 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4198 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4199 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4200 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4201 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4202 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4203 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4204 |
|
2952 | 4205 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4206 |
"insert a single character at lineNr/colNr; |
827 | 4207 |
set emphasis to character at current position" |
4208 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4209 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4210 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4211 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4212 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4213 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4214 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4215 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4216 |
]. |
827 | 4217 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4218 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4219 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4220 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4221 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4222 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4223 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4224 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4225 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4226 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4227 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4228 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4229 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4230 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4231 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4232 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4233 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4234 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4235 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4236 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4237 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4238 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4239 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4240 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4241 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4242 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4243 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4244 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4245 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4246 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4247 |
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
|
4248 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4249 |
]. |
827 | 4250 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4251 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4252 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4253 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4254 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4255 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4256 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4257 |
newLine at:colNr put:aCharacter. |
827 | 4258 |
|
4259 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4260 |
newLine emphasisAt:colNr put:attribute. |
827 | 4261 |
]. |
4262 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4263 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4264 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4265 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4266 |
]. |
827 | 4267 |
|
4771 | 4268 |
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
|
4269 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4270 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4271 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4272 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4273 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4274 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4275 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4276 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4277 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4278 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4279 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4280 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4281 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4282 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4283 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 4284 |
|
4889 | 4285 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4286 |
self invalidateLine:lineNr. |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4287 |
] ifFalse:[ |
4190 | 4288 |
drawCharacterOnly ifTrue:[ |
4889 | 4289 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4190 | 4290 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4291 |
] ifFalse:[ |
|
4292 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4293 |
self redrawLine:lineNr from:colNr-1 |
|
4294 |
]. |
|
4295 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4296 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4297 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4298 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4299 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4300 |
]. |
4889 | 4301 |
gc font hasOverlappingCharacters ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4302 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4303 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4304 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4305 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4306 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4307 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4308 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4309 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4310 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4311 |
|
4191 | 4312 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4313 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4314 |
|
4771 | 4315 |
basicListAt:lineNr put:newLine |
4316 |
"redefinable for special subclasses (with virtual list)" |
|
4317 |
||
4318 |
list at:lineNr put:newLine. |
|
4319 |
! |
|
4320 |
||
4321 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4322 |
"redefinable for special subclasses (with virtual list)" |
|
4323 |
||
4324 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4325 |
! |
|
4326 |
||
2952 | 4327 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4328 |
"merge line lineNr with line lineNr+1" |
4329 |
||
827 | 4330 |
|leftPart rightPart bothParts nextLineNr i| |
4331 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4332 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
4771 | 4333 |
"/ empty list or beyond end of text |
4334 |
^ self |
|
827 | 4335 |
]. |
4336 |
leftPart := self listAt:lineNr. |
|
4337 |
||
4338 |
leftPart isNil ifTrue:[ |
|
4771 | 4339 |
leftPart := ''. |
4340 |
autoIndent ifTrue:[ |
|
4341 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4342 |
leftPart := String new:i |
|
4343 |
] |
|
4344 |
] |
|
827 | 4345 |
]. |
4346 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4347 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4348 |
||
4349 |
nextLineNr > (list size) ifFalse:[ |
|
4771 | 4350 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4351 |
rightPart := '' |
|
4352 |
] ifFalse:[ |
|
4353 |
removeBlanks ifTrue:[ |
|
4354 |
rightPart := rightPart withoutLeadingSeparators. |
|
4355 |
] |
|
4356 |
]. |
|
4357 |
||
4358 |
bothParts := leftPart , rightPart. |
|
4359 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4360 |
self basicListAt:lineNr put:bothParts. |
|
4361 |
self redrawLine:lineNr. |
|
4362 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4363 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4364 |
|
1319 | 4365 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4366 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4367 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4368 |
|
2952 | 4369 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4370 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4371 |
|
5045 | 4372 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4373 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4374 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4375 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4376 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4377 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4378 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4379 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4380 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4381 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4382 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4383 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4384 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4385 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4386 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4387 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4388 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4389 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4390 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4391 |
(lineSize == 0) ifTrue:[ |
4190 | 4392 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4393 |
] ifFalse: [ |
5045 | 4394 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4395 |
newLineSpecies := aCharacter stringSpecies |
|
4396 |
] ifFalse:[ |
|
4397 |
newLineSpecies := line species |
|
4398 |
]. |
|
4399 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4400 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4401 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4402 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4403 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4404 |
newLine := self withTabsExpanded:newLine. |
4405 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4406 |
]. |
4771 | 4407 |
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
|
4408 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4409 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4410 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4411 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4412 |
shown ifTrue:[ |
4889 | 4413 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4414 |
self invalidateLine:lineNr. |
4415 |
] ifFalse:[ |
|
4416 |
drawCharacterOnly ifTrue:[ |
|
4417 |
self redrawLine:lineNr col:colNr |
|
4418 |
] ifFalse:[ |
|
4419 |
self redrawLine:lineNr from:colNr |
|
4420 |
] |
|
4421 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4422 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4423 |
|
4190 | 4424 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4425 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4426 |
! |
4427 |
||
3235 | 4428 |
basicReplaceString:aString atLine:lineNr col:colNr |
4429 |
"replace multiple characters starting at lineNr/colNr. |
|
4430 |
This is not prepared to encounter special chars (except TAB) |
|
4431 |
in the string." |
|
4432 |
||
5045 | 4433 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4434 |
|
4435 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4436 |
||
4437 |
self checkForExistingLine:lineNr. |
|
4438 |
line := list at:lineNr. |
|
4439 |
lineSize := line size. |
|
4440 |
||
4441 |
endCol := colNr + aString size - 1. |
|
4442 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4443 |
newLine := aString species new:endCol. |
3235 | 4444 |
] ifFalse: [ |
5571 | 4445 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5045 | 4446 |
newLineSpecies := aString stringSpecies |
4447 |
] ifFalse:[ |
|
4448 |
newLineSpecies := line species |
|
4449 |
]. |
|
4450 |
||
4451 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4452 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4453 |
]. |
4454 |
newLine replaceFrom:colNr with:aString. |
|
4455 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4456 |
newLine := self withTabsExpanded:newLine. |
3235 | 4457 |
]. |
4771 | 4458 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4459 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4460 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4461 |
]. |
4462 |
self textChanged. |
|
4463 |
shown ifTrue:[ |
|
4889 | 4464 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4465 |
self invalidateLine:lineNr. |
4466 |
] ifFalse:[ |
|
4467 |
self redrawLine:lineNr from:colNr |
|
4468 |
] |
|
3235 | 4469 |
] |
4470 |
||
4190 | 4471 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4472 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4473 |
! |
4474 |
||
2952 | 4475 |
basicSplitLine:lineNr before:colNr |
4476 |
"split the line linNr before colNr; the right part (from colNr) |
|
4477 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4478 |
||
3160 | 4479 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4480 |
srcY "{ Class: SmallInteger }" | |
4481 |
||
3027 | 4482 |
list isNil ifTrue:[ ^ self ]. |
4483 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4484 |
||
4485 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4486 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4487 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4488 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4489 |
^ self |
3027 | 4490 |
]. |
4491 |
||
4492 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4493 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4494 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4495 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4496 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4497 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4498 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4499 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4500 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4501 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4502 |
] |
3027 | 4503 |
]. |
4504 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4505 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4506 |
]. |
4771 | 4507 |
self basicListAt:lineNr put:leftRest. |
3027 | 4508 |
self nonUndoableDo:[ |
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4509 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4510 |
]. |
4511 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4512 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4513 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4514 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4515 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4516 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4517 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4518 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4519 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4520 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4521 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4522 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4523 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4524 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4525 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4526 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4527 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4528 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4529 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4530 |
]. |
4531 |
widthOfWidestLine := nil. "/ unknown |
|
4532 |
self textChanged. |
|
2952 | 4533 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4534 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4535 |
! |
4536 |
||
2954 | 4537 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4538 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4539 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4540 |
because the text might have been pasted from an alien view." |
|
2954 | 4541 |
|
4542 |
|newLine newLines nLines| |
|
4543 |
||
4544 |
nLines := end - start + 1. |
|
4545 |
newLines := Array new:(lines size). |
|
4546 |
start to:end do:[:index | |
|
4328 | 4547 |
newLine := lines at:index. |
4548 |
newLine notNil ifTrue:[ |
|
4549 |
newLine isString ifTrue:[ |
|
4550 |
newLine isBlank ifTrue:[ |
|
4551 |
newLine := nil |
|
4552 |
] ifFalse:[ |
|
4553 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4554 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4555 |
] |
|
4556 |
] |
|
4557 |
] |
|
4558 |
]. |
|
4559 |
newLines at:index put:newLine |
|
2954 | 4560 |
]. |
4561 |
list isNil ifTrue: [ |
|
4328 | 4562 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4563 |
] ifFalse: [ |
4328 | 4564 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4565 |
]. |
4566 |
||
4567 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4568 |
overlapping copy - if it didn't, we had to use:" |
4569 |
" |
|
4570 |
index := list size. |
|
4571 |
[index > lineNr] whileTrue: [ |
|
4328 | 4572 |
pIndex := index - 1. |
4573 |
list at:index put:(list at:pIndex). |
|
4574 |
index := pIndex |
|
2954 | 4575 |
]. |
4576 |
" |
|
4577 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4578 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4579 |
self contentsChanged |
|
4580 |
||
4328 | 4581 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4582 |
! |
4583 |
||
4584 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4585 |
"insert aString (which has no crs) at lineNr/colNr. |
4586 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4587 |
because the text might have been pasted from an alien view." |
|
2954 | 4588 |
|
4360 | 4589 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4590 |
|
4623 | 4591 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4592 |
|
4593 |
strLen := aString size. |
|
4594 |
self checkForExistingLine:lineNr. |
|
4595 |
||
4596 |
stringType := aString string species. |
|
4597 |
isText := aString isText. |
|
4598 |
line := list at:lineNr. |
|
4599 |
||
4600 |
line notNil ifTrue:[ |
|
4328 | 4601 |
lineSize := line size. |
4602 |
line isString ifFalse:[ |
|
4603 |
stringType := line species |
|
4604 |
] ifTrue:[ |
|
4360 | 4605 |
lineCharWidth := line bitsPerCharacter. |
4606 |
stringCharWidth := aString bitsPerCharacter. |
|
4607 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4608 |
stringType := line string species |
4360 | 4609 |
] ifFalse:[ |
4610 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4611 |
stringType := aString string species |
|
4612 |
] |
|
4328 | 4613 |
]. |
4614 |
line isText ifTrue:[ isText := true ] |
|
4615 |
]. |
|
2954 | 4616 |
] ifFalse:[ |
4328 | 4617 |
lineSize := 0 |
2954 | 4618 |
]. |
4619 |
||
4620 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4621 |
newLine := aString |
2954 | 4622 |
] ifFalse:[ |
4328 | 4623 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4624 |
sz := colNr + strLen - 1 |
|
4625 |
] ifFalse:[ |
|
4626 |
sz := lineSize + strLen |
|
4627 |
]. |
|
4628 |
||
4360 | 4629 |
newLine := stringType new:sz. |
4630 |
isText ifTrue:[ |
|
4631 |
newLine := Text string:newLine |
|
4328 | 4632 |
]. |
4633 |
||
4634 |
(lineSize ~~ 0) ifTrue: [ |
|
4635 |
(colNr > lineSize) ifTrue: [ |
|
4636 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4637 |
] ifFalse: [ |
|
4638 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4639 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4640 |
] |
|
4641 |
]. |
|
4642 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4643 |
]. |
4644 |
||
4645 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4646 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4647 |
]. |
4648 |
||
4771 | 4649 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4650 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4651 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4652 |
]. |
4653 |
self textChanged. |
|
4654 |
||
4360 | 4655 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4656 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4657 |
|
2752 | 4658 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4659 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4660 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4661 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4662 |
|
5216 | 4663 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 4664 |
dragIsActive := false. |
4665 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4666 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4667 |
"/ 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
|
4668 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4669 |
]. |
4609 | 4670 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4671 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4672 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4673 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4674 |
|
4420 | 4675 |
"On X11, be nice and paste PRIMARY when middle click. |
4676 |
Note, that middle button on X11 is translated to button |
|
4677 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 4678 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 4679 |
self undoableDo:[ |
4680 |
self paste: (self getClipboardText:#selection). |
|
4681 |
]. |
|
4682 |
^self. |
|
4683 |
]. |
|
4684 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4685 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4686 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4687 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4688 |
"/ 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
|
4689 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4690 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4691 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4692 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4693 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4694 |
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
|
4695 |
|
4420 | 4696 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4697 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4698 |
! |
4699 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4700 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4701 |
"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
|
4702 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4703 |
|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
|
4704 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4705 |
(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
|
4706 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4707 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4708 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4709 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4710 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4711 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4712 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4713 |
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
|
4714 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4715 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4716 |
cursorType ~~ #block ifTrue:[ |
3790 | 4717 |
clickPos notNil ifTrue:[ |
4718 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4719 |
"/ (i.e. if its an ibeam). |
|
4720 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4721 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4722 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4723 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4724 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4725 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4726 |
]. |
5056 | 4727 |
"/ the following fixes the ugly select behavior when double clicking on |
4728 |
"/ a partially visible last line (where the first click used to |
|
4729 |
"/ scroll the text so that the second click was handled on another |
|
4730 |
"/ line. An alternative (possibly better) solution would be to |
|
4731 |
"/ remember the last click posision and adjust in the double click |
|
4732 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
4733 |
"/ Time will show, if this hack works. |
|
5057 | 4734 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
4735 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
4736 |
Processor |
|
4737 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
4738 |
afterSeconds:0.3. |
|
4739 |
] ifFalse:[ |
|
4740 |
self cursorLine:clickLine col:newCursorCol. |
|
4741 |
]. |
|
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4742 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4743 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4744 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4745 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4746 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4747 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4748 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4749 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4750 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4751 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4752 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4753 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4754 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4755 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4756 |
] ifFalse:[ |
4048 | 4757 |
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
|
4758 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4759 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4760 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4761 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4762 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4763 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4764 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4765 |
|
2580 | 4766 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4767 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4768 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4769 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4770 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4771 |
self changeTypeOfSelectionTo:nil. |
2580 | 4772 |
|
4773 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4774 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4775 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4776 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4777 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4778 |
self validateNewSelection. |
4420 | 4779 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4780 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4781 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4782 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4783 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4784 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4785 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4786 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4787 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4788 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4789 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4790 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4791 |
selectionEndCol == 0 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4792 |
selectionEndCol := 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4793 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4794 |
self setCursorCol:selectionEndCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4795 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4796 |
self expandSelectionRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4797 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4798 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4799 |
self unselect; makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4800 |
cursorCol == 1 ifTrue:[^ self]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4801 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4802 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4803 |
self cursorRight. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4804 |
^ self |
2580 | 4805 |
]. |
4806 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4807 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4808 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4809 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4810 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4811 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4812 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4813 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4814 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4815 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4816 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4817 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4818 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4819 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4820 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4821 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4822 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4823 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4824 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4825 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4826 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4827 |
self setCursorCol:selectionStartCol. |
4590 | 4828 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4829 |
self setCursorCol:1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4830 |
self setCursorLine:(cursorLine - 1). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4831 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4832 |
self makeCursorVisible. |
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 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4835 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4836 |
clickCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4837 |
self expandSelectionDown. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4838 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4839 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4840 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4841 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4842 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4843 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4844 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4845 |
self cursorDown:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4846 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4847 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4848 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4849 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4850 |
^ self |
2580 | 4851 |
]. |
4852 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4853 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4854 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4855 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4856 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4857 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4858 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4859 |
selectionStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4860 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4861 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4862 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4863 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4864 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4865 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4866 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4867 |
selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4868 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4869 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4870 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4871 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4872 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4873 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4874 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4875 |
self redrawFromLine:selectionStartLine to:cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4876 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4877 |
] |
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 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4880 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4881 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4882 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4883 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4884 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4885 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4886 |
self setCursorLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4887 |
self setCursorCol:selectionStartCol. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4888 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4889 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4890 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4891 |
self makeCursorVisible. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4892 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4893 |
shifted ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4894 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4895 |
clickLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4896 |
self expandSelectionUp. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4897 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4898 |
self expandSelectionLeft. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4899 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4900 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4901 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4902 |
self unselect. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4903 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4904 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4905 |
(key == #CursorLeft) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4906 |
self cursorLeft. ^self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4907 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4908 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4909 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4910 |
self cursorUp:n. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4911 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4912 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4913 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4914 |
self sensor flushKeyboardFor:self. |
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 |
]. |
2580 | 4917 |
]. |
4420 | 4918 |
|
4919 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2580 | 4920 |
! |
4921 |
||
2952 | 4922 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4923 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4924 |
|
4521 | 4925 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 4926 |
#Replace #Undo #Redo #Accept |
3780 | 4927 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 4928 |
#DeleteSpaces #Join |
3780 | 4929 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 4930 |
#SelectWord #ExpandSelectionByWord |
3780 | 4931 |
#SelectToEnd #SelectFromBeginning |
4707 | 4932 |
#SelectLine #ExpandSelectionByLine |
3780 | 4933 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
4934 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
4935 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
4936 |
#GotoLine #BeginOfText #EndOfText |
|
4937 |
#InsertLine #DeleteLine |
|
4938 |
#SelectLineFromBeginning |
|
4939 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 4940 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 4941 |
#'F*' #'f*')> |
2017 | 4942 |
|
4730 | 4943 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 4944 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 4945 |
|
4946 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
4947 |
|
4701 | 4948 |
"/ experimental |
4818 | 4949 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 4950 |
(immediateCompletion |
4818 | 4951 |
or:[currentUserPrefs codeCompletionOnControlKey |
4952 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4953 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4954 |
self initializeCompletionSupport. |
4609 | 4955 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4956 |
]. |
5394 | 4957 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4958 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4959 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4960 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4961 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4962 |
completionSupport notNil ifTrue:[ |
5394 | 4963 |
completionSupport stopCompletionProcess. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4964 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4965 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4966 |
|
4818 | 4967 |
key isSymbol ifTrue:[ |
5643 | 4968 |
(device modifierKeys includes:key) ifFalse:[ |
4818 | 4969 |
lastReplacementInfo stillCollectingInput:false. |
4970 |
] |
|
4971 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4972 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 4973 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4974 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4975 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4976 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4977 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 4978 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4979 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4980 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4981 |
]. |
3799 | 4982 |
(key == #Undo) ifTrue:[self undo. ^self]. |
4983 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
4984 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4985 |
self learnMode ifTrue:[ |
4482 | 4986 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4987 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4988 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
4989 |
|
4238 | 4990 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
4991 |
"the macro named key exists" |
|
3780 | 4992 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4993 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
4994 |
|
4482 | 4995 |
key isSymbol ifFalse:[ |
4996 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
4997 |
self handleNonCommandKey:key. |
|
4998 |
^ self |
|
4999 |
]. |
|
5000 |
||
5001 |
event isNil ifTrue:[ |
|
5002 |
event := WindowGroup lastEventQuerySignal query. |
|
5003 |
]. |
|
5004 |
shiftPressed := event hasShift. |
|
5005 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5006 |
rawKey := event rawKey. |
4482 | 5007 |
|
5133 | 5008 |
key == #InsertUUID ifTrue:[ |
5009 |
self insertUUID. |
|
5010 |
^ self. |
|
5011 |
]. |
|
5012 |
||
4253 | 5013 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
5014 |
self deleteWordBeforeCursor. |
|
5015 |
^ self. |
|
5016 |
]. |
|
5017 |
||
5119 | 5018 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 5019 |
selectionStartLine notNil ifTrue:[ |
5020 |
((key == #BasicBackspace) |
|
4818 | 5021 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 5022 |
ifTrue:[ |
5023 |
self deleteSelection. |
|
5024 |
] ifFalse: [ |
|
5025 |
self copyAndDeleteSelection. |
|
5026 |
]. |
|
4609 | 5027 |
] ifFalse:[ |
5028 |
self makeCursorVisible. |
|
5029 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
5030 |
"/ self deleteWordBeforeCursor. |
|
5031 |
"/ ] ifFalse:[ |
|
5032 |
self deleteCharBeforeCursor. |
|
5033 |
"/ ]. |
|
3780 | 5034 |
]. |
4738 | 5035 |
true "immediateCompletion" ifTrue:[ |
5394 | 5036 |
completionSupport notNil ifTrue:[ |
5037 |
completionSupport postKeyPress:key |
|
5038 |
]. |
|
4731 | 5039 |
]. |
3780 | 5040 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5041 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5042 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5043 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5044 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5045 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5046 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5047 |
|
3235 | 5048 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5049 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 5050 |
^ self. |
3160 | 5051 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5052 |
|
4162 | 5053 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
5054 |
CharacterSetView notNil ifTrue:[ |
|
5055 |
self specialCharacters. |
|
5056 |
^ self. |
|
5057 |
] |
|
5058 |
]. |
|
5059 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5060 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5061 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5062 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5063 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 5064 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5065 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5066 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5067 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5068 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5069 |
(('[fF][0-9]' match:key) |
5070 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5071 |
shiftPressed ifFalse:[ |
|
4818 | 5072 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5073 |
fKeyMacros notNil ifTrue:[ |
5074 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5075 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5076 |
^ self |
|
5077 |
] |
|
5078 |
] |
|
5079 |
] |
|
5080 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5081 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5082 |
|
2506 | 5083 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5084 |
self parenthizeSelectionWith:$( and:$). |
5085 |
^ self. |
|
2506 | 5086 |
]. |
5087 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5088 |
self parenthizeSelectionWith:$" and:$". |
5089 |
^ self. |
|
2506 | 5090 |
]. |
5091 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5092 |
self parenthizeSelectionWith:$' and:$'. |
5093 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5094 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5095 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5096 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5097 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5098 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5099 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5100 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5101 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5102 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5103 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5104 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5105 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5106 |
|
3542 | 5107 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5108 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5109 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5110 |
self makeCursorVisible. |
|
5111 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5112 |
^ self |
|
5113 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5114 |
(key == #SelectWord) ifTrue:[ |
3780 | 5115 |
self makeCursorVisible. |
5116 |
self selectWordUnderCursor. |
|
5117 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5118 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5119 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5120 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5121 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5122 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5123 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5124 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5125 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5126 |
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
|
5127 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5128 |
(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
|
5129 |
(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
|
5130 |
(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
|
5131 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5132 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5133 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5134 |
(key == #BeginOfLine) ifTrue:[ |
5226 | 5135 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5136 |
"/ some shifted key to selectFromBeginOfLine |
|
5137 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5138 |
"/ see code below. |
|
5139 |
false "shiftPressed" ifTrue: [ |
|
3780 | 5140 |
"/ "Original St/X code - now use Ctrl modifier" |
5141 |
"/ self unselect. |
|
5142 |
"/ self cursorHome. |
|
5143 |
"Jan's modification" |
|
4257 | 5144 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
5145 |
"/ Jan's modification modified by his own request ;-)) |
|
5146 |
self selectFromBeginOfLine. |
|
3780 | 5147 |
] ifFalse: [ |
5148 |
self unselect. |
|
5149 |
ctrlPressed ifTrue:[ |
|
5150 |
self cursorHome. |
|
5151 |
] ifFalse:[ |
|
5152 |
self cursorToBeginOfLine. |
|
5153 |
] |
|
5154 |
]. |
|
5155 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5156 |
]. |
5226 | 5157 |
(key == #BSelectFromeginOfLine) ifTrue:[ |
5158 |
self selectFromBeginOfLine. |
|
5159 |
^ self |
|
5160 |
]. |
|
5161 |
||
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5162 |
(key == #EndOfLine) ifTrue:[ |
5226 | 5163 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5164 |
"/ some shifted key to selectFromBeginOfLine |
|
5165 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5166 |
"/ see code below. |
|
5167 |
false "shiftPressed" ifTrue:[ |
|
3780 | 5168 |
"/ "Original St/X code - now use Ctrl modifier" |
5169 |
"/ self unselect. |
|
5170 |
"/ self cursorToBottom |
|
4257 | 5171 |
" Jan's modification" |
5172 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5173 |
"/ Jan's modification modified by his own request ;-)) |
|
5174 |
self selectToEndOfLine. |
|
3780 | 5175 |
] ifFalse:[ |
5176 |
self unselect. |
|
5177 |
ctrlPressed ifTrue:[ |
|
5178 |
self cursorToBottom |
|
5179 |
] ifFalse:[ |
|
5180 |
self cursorToEndOfLine. |
|
5181 |
] |
|
5182 |
]. |
|
5183 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5184 |
]. |
5226 | 5185 |
|
5186 |
(key == #SelectToEndOfLine) ifTrue:[ |
|
5187 |
self selectToEndOfLine. |
|
5188 |
^ self |
|
5189 |
]. |
|
5190 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5191 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5192 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5193 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5194 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5195 |
|
5119 | 5196 |
(rawKey == #CursorRight |
5197 |
or:[rawKey == #CursorDown |
|
5198 |
or:[rawKey == #CursorLeft |
|
5199 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5200 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5201 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5202 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5203 |
|
5119 | 5204 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5205 |
self unselect. self cursorReturn. |
5206 |
^ self |
|
3257 | 5207 |
]. |
5208 |
||
5209 |
(key == #Return) ifTrue:[ |
|
3780 | 5210 |
shiftPressed ifTrue:[ |
5211 |
self unselect. self cursorReturn. |
|
5212 |
^ self |
|
5213 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5214 |
|
3780 | 5215 |
self isReadOnly ifTrue:[ |
5216 |
self unselect; makeCursorVisible. |
|
5217 |
self cursorReturn |
|
5218 |
] ifFalse:[ |
|
5219 |
self isInInsertMode ifFalse:[ |
|
5529 | 5220 |
self cursorReturn:true. |
3780 | 5221 |
autoIndent == true ifTrue:[ |
5222 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5223 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5224 |
self cursorCol:(i+1 max:1) |
5225 |
] |
|
3780 | 5226 |
] |
5227 |
] ifTrue:[ |
|
4826 | 5228 |
|left right oldIndent| |
4812 | 5229 |
|
3780 | 5230 |
"/ old version just unselected ... |
5231 |
"/ self unselect; makeCursorVisible. |
|
5232 |
||
5233 |
"/ new version deletes ... |
|
5234 |
typeOfSelection == #paste ifTrue:[ |
|
5235 |
self unselect; makeCursorVisible. |
|
5236 |
] ifFalse:[ |
|
5237 |
self copyAndDeleteSelection. |
|
5238 |
]. |
|
4816 | 5239 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5240 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5241 |
self insertCharAtCursor:(Character cr). |
5112 | 5242 |
|
3780 | 5243 |
autoIndent == true ifTrue:[ |
4816 | 5244 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5245 |
"/ nothing to do. |
|
4812 | 5246 |
] ifFalse:[ |
5247 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5248 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5249 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5250 |
left := left withoutSeparators. |
5251 |
right := right withoutSeparators. |
|
5252 |
(left endsWith:'[') ifTrue:[ |
|
5253 |
"/ i := i + 4. |
|
4816 | 5254 |
] ifFalse:[ |
4823 | 5255 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5256 |
i := i - 4. |
5257 |
]. |
|
4812 | 5258 |
]. |
4826 | 5259 |
oldIndent := self leftIndentOfLine:cursorLine. |
5260 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5261 |
self st80EditMode ifTrue:[ |
|
5262 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5263 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5264 |
]. |
|
5265 |
]. |
|
4812 | 5266 |
self cursorCol:(i+1 max:1) |
5267 |
]. |
|
5268 |
] |
|
3780 | 5269 |
]. |
5270 |
]. |
|
5271 |
]. |
|
5272 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5273 |
]. |
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
|
5274 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5275 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5276 |
self unselect. self cursorTab. |
5277 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5278 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5279 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5280 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5281 |
||
5282 |
self hasSelection ifTrue:[ |
|
5283 |
selectStyle == #line ifTrue:[ |
|
4238 | 5284 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5285 |
macroName := #IndentBy4. |
|
5286 |
] ifFalse:[ |
|
5287 |
macroName := #UndentBy4. |
|
5288 |
]. |
|
5289 |
macroName notNil ifTrue:[ |
|
5290 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5291 |
]. |
5292 |
] |
|
5293 |
]. |
|
5294 |
||
5295 |
self unselect. |
|
5296 |
(key == #Tab) ifTrue:[ |
|
5297 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5298 |
self cursorTab. |
|
5299 |
^ self |
|
5300 |
]. |
|
5301 |
self insertTabAtCursor. |
|
5302 |
^ self |
|
5303 |
]. |
|
5304 |
self cursorBacktab. |
|
5305 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5306 |
]. |
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
|
5307 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5308 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5309 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5310 |
shiftPressed ifTrue:[ |
5311 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5312 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5313 |
self makeCursorVisible. |
|
5314 |
self deleteCharAtCursor. |
|
5315 |
]. |
|
5316 |
^ self |
|
5317 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5318 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5319 |
|
5119 | 5320 |
(rawKey == #Delete |
870 | 5321 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5322 |
selectionStartLine notNil ifTrue:[ |
4130 | 5323 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5324 |
"/ To remove text repetetively, use Cut instead. |
|
5325 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5326 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5327 |
((key == #BasicDelete) |
4818 | 5328 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5329 |
self deleteSelection. |
5330 |
] ifFalse:[ |
|
5331 |
self copyAndDeleteSelection. |
|
5332 |
]. |
|
5333 |
^ self |
|
5334 |
]. |
|
5335 |
self makeCursorVisible. |
|
5336 |
self deleteCharAtCursor. |
|
5337 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5338 |
]. |
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
|
5339 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5340 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5341 |
self unselect. |
5342 |
cursorVisibleLine == 1 ifTrue:[ |
|
5343 |
self cursorHome. |
|
5344 |
] ifFalse:[ |
|
5345 |
self cursorToFirstVisibleLine |
|
5346 |
]. |
|
5347 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5348 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5349 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5350 |
self unselect. |
5351 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5352 |
self cursorToBottom. |
|
5353 |
] ifFalse:[ |
|
5354 |
self cursorToLastVisibleLine |
|
5355 |
]. |
|
5356 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5357 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5358 |
((key == #Escape) |
3257 | 5359 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5360 |
self makeCursorVisible. |
5361 |
self unselect. self selectCursorLineFromBeginning. |
|
5362 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5363 |
]. |
3257 | 5364 |
(key == #SelectLine) ifTrue:[ |
3780 | 5365 |
self makeCursorVisible. |
5366 |
self unselect. self selectCursorLine. |
|
5367 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5368 |
]. |
3257 | 5369 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5370 |
"/ self makeCursorVisible. |
3780 | 5371 |
self selectExpandCursorLine. |
5372 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5373 |
]. |
3257 | 5374 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5375 |
self makeCursorVisible. |
5376 |
self unselect. self deleteCursorLine. |
|
5377 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5378 |
]. |
3257 | 5379 |
(key == #InsertLine) ifTrue:[ |
3780 | 5380 |
self makeCursorVisible. |
5381 |
self unselect. self insertLine:nil before:cursorLine. |
|
5382 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5383 |
]. |
3781 | 5384 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5385 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5386 |
|
3310 | 5387 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5388 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5389 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5390 |
! |
5391 |
||
2952 | 5392 |
executeKeyboardMacro:cmdMacro |
5393 |
Error handle:[:ex | |
|
4823 | 5394 |
self warn:'Error in keyboard macro: ' , ex description. |
5395 |
ex return. |
|
2952 | 5396 |
] do:[ |
4823 | 5397 |
AbortOperationRequest handle:[:ex | |
5398 |
self warn:'Keyboard macro aborted'. |
|
5399 |
ex return. |
|
5400 |
] do:[ |
|
5401 |
Parser |
|
5402 |
evaluate:cmdMacro asString |
|
5403 |
receiver:self |
|
5404 |
notifying:nil |
|
5405 |
compile:false. |
|
5406 |
]. |
|
2952 | 5407 |
]. |
5408 |
! |
|
5409 |
||
5410 |
handleNonCommandKey:keyArg |
|
4700 | 5411 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5412 |
|
5413 |
self isReadOnly ifTrue:[ |
|
4988 | 5414 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5415 |
^ self. |
2952 | 5416 |
]. |
5417 |
||
5418 |
key := keyArg. |
|
5419 |
||
5420 |
typeOfSelection == #paste ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5421 |
"pasted selection will NOT be replaced by keystroke" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5422 |
self unselect |
2952 | 5423 |
]. |
5424 |
||
4700 | 5425 |
selStartLineBefore := selectionStartLine. |
5426 |
selStartColBefore := self selectionStartCol. |
|
5427 |
selEndLineBefore := selectionEndLine. |
|
5428 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5429 |
|
4940 | 5430 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 5431 |
key isCharacter ifTrue:[ |
4940 | 5432 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5433 |
] ifFalse:[ |
4940 | 5434 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5435 |
]. |
2952 | 5436 |
]. |
5437 |
||
5438 |
"replace selection by what is typed in - |
|
3235 | 5439 |
if word was selected with a space, keep it. |
4700 | 5440 |
if there was no selection, the key's character is inserted" |
3235 | 5441 |
|
5442 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5443 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5444 |
]. |
2952 | 5445 |
|
5446 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5447 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5448 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5449 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5450 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5451 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5452 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5453 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5454 |
] |
3160 | 5455 |
]. |
2952 | 5456 |
selectStyle := nil. |
5457 |
||
3235 | 5458 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5459 |
selectionStartLine := selStartLineBefore. |
5460 |
selectionStartCol := selStartColBefore. |
|
5461 |
selectionEndLine := selEndLineBefore. |
|
5462 |
selectionEndCol := selEndColBefore. |
|
3235 | 5463 |
]. |
5464 |
||
2952 | 5465 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5466 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5467 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5468 |
"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
|
5469 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5470 |
" |
2952 | 5471 |
" |
4481 | 5472 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5473 |
" |
4481 | 5474 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5475 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5476 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5477 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5478 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5479 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5480 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5481 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5482 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5483 |
self cursorLine:line col:col. |
4940 | 5484 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5485 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5486 |
"/ 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
|
5487 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5488 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5489 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5490 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5491 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5492 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5493 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5494 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5495 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5496 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5497 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5498 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5499 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5500 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5501 |
] |
2952 | 5502 |
]. |
5503 |
||
5504 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5505 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5506 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5507 |
"/ |
|
5508 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5509 |
"/ self selection. |
|
5510 |
"/ typeOfSelection := #paste. |
|
3160 | 5511 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5512 |
"/ ]. |
3235 | 5513 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5514 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5515 |
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
|
5516 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5517 |
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
|
5518 |
]. |
3235 | 5519 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5520 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5521 |
|
5522 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
2952 | 5523 |
! |
5524 |
||
5525 |
keyPress:key x:x y:y |
|
5526 |
"handle keyboard input" |
|
5527 |
||
4771 | 5528 |
|wasOn| |
5529 |
||
5530 |
wasOn := cursorShown. |
|
5531 |
||
5689 | 5532 |
NoModificationError |
5533 |
handle:[:ex | |
|
5534 |
self flashReadOnly. |
|
5535 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
5536 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5537 |
]. |
|
5538 |
] |
|
5539 |
do:[ |
|
5540 |
self undoableDo:[ |
|
5541 |
self doKeyPress:key x:x y:y |
|
5542 |
]. |
|
5543 |
]. |
|
5544 |
||
4242 | 5545 |
self repairDamage |
5546 |
||
5547 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 5548 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 5549 |
! |
5550 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5551 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5552 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5553 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5554 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5555 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5556 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5557 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5558 |
requestAutoAccept |
5068 | 5559 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
5560 |
This forces my value to be accepted into my model. |
|
5561 |
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
|
5562 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5563 |
acceptEnabled == false ifTrue:[ |
4823 | 5564 |
"/ nope - |
5565 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5566 |
]. |
5404 | 5567 |
"/ cg: only do this if modified. |
5568 |
"/ otherwise, users would have to make sure that the contents is |
|
5569 |
"/ always correct (which they don't). If you change this back, |
|
5570 |
"/ please check the expecco file-save or file-reimport dialog, |
|
5571 |
"/ which has a problem with that behavior. |
|
5572 |
self modified ifTrue:[ |
|
5573 |
self accept. |
|
5574 |
]. |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5575 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5576 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5577 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5578 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5579 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5580 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5581 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5582 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5583 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5584 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5585 |
cv notNil ifTrue:[ |
4823 | 5586 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5587 |
] |
4967 | 5588 |
! |
5589 |
||
5590 |
unmapped |
|
5591 |
super unmapped. |
|
5592 |
||
5593 |
completionSupport notNil ifTrue:[ |
|
5594 |
completionSupport release. |
|
5595 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5596 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5597 |
|
1807 | 5598 |
!EditTextView methodsFor:'focus handling'! |
5599 |
||
4818 | 5600 |
focusOut |
5601 |
super focusOut. |
|
5602 |
||
5603 |
completionSupport notNil ifTrue:[ |
|
5604 |
completionSupport release. |
|
5605 |
]. |
|
5606 |
! |
|
5607 |
||
1807 | 5608 |
hasKeyboardFocus:aBoolean |
5609 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5610 |
(otherwise, I would not know about this)" |
|
5611 |
||
5612 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5613 |
|
3160 | 5614 |
(cursorShown |
5615 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5616 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5617 |
self drawCursor |
5618 |
]. |
|
5619 |
||
5620 |
hasKeyboardFocus ifFalse:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5621 |
completionSupport notNil ifTrue:[ |
4821 | 5622 |
"/ this is a hack for Windows: |
5623 |
"/ on windows, an activate:false event is first sent to my textView, |
|
5624 |
"/ then an activate is sent to the completion popup. |
|
5625 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
5626 |
"/ therefore, allow for the activate of the completionMenu and it's button event to be processed. |
|
5627 |
"/ before forcing it to be closed... |
|
5216 | 5628 |
Processor addTimedBlock:[completionSupport editViewLostFocus] afterMilliseconds:200. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5629 |
]. |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5630 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5631 |
|
4821 | 5632 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 5633 |
! |
5634 |
||
5635 |
showFocus:explicit |
|
5636 |
"in addition to however my superclass thinks how a focusView is to be |
|
5637 |
displayed, show the cursor when I got the focus" |
|
5638 |
||
5239 | 5639 |
self hasKeyboardFocus:true. |
1807 | 5640 |
self showCursor. |
5641 |
super showFocus:explicit |
|
5642 |
||
5643 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5644 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5645 |
|
4967 | 5646 |
showNoFocus:explicit |
5647 |
"the view lost the keyboard focus |
|
5648 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
5649 |
- change any display attributes as req'd." |
|
5650 |
||
5651 |
super showNoFocus:explicit. |
|
5149 | 5652 |
|
5653 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
5654 |
"/ not when the focus is lost normally (because this also happens when |
|
5655 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
5656 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
5657 |
explicit ifTrue:[ |
|
5658 |
completionSupport notNil ifTrue:[ |
|
5659 |
completionSupport release. |
|
5660 |
]. |
|
4818 | 5661 |
]. |
5662 |
! |
|
5663 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5664 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5665 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5666 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5667 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5668 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5669 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5670 |
and:[self enabled |
4781 | 5671 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5672 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5673 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5674 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5675 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5676 |
^ false |
1807 | 5677 |
! ! |
5678 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5679 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5680 |
|
4237 | 5681 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5682 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5683 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5684 |
|
4482 | 5685 |
|cmdMacro| |
5686 |
||
5687 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5688 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5689 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5690 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5691 |
^ true |
4238 | 5692 |
|
5693 |
" |
|
4483 | 5694 |
EditTextView open |
4238 | 5695 |
contents:'bla'; |
5696 |
selectAll; |
|
5697 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 5698 |
EditTextView open |
4238 | 5699 |
contents:'bla'; |
5700 |
selectAll; |
|
5701 |
executekeyboardMacroNamed:#blabla. |
|
5702 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5703 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5704 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 5705 |
! |
5706 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5707 |
indent |
3221 | 5708 |
"indent a line-range - this is done by searching for the |
5709 |
last non-empty line before the selection, and changing the indent |
|
4742 | 5710 |
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
|
5711 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5712 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5713 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5714 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 5715 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5716 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5717 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5718 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 5719 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5720 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5721 |
self unselect. |
3160 | 5722 |
self |
3786 | 5723 |
undoableDo:[self indentFromLine:start toLine:end] |
5724 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5725 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5726 |
|
4237 | 5727 |
indentBy4 |
5050 | 5728 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
5729 |
||
5730 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5731 |
! |
|
5732 |
||
5733 |
indentBy8 |
|
5734 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 5735 |
|
5736 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
5737 |
! |
|
5738 |
||
5050 | 5739 |
indentBy:n |
5740 |
|line1 line2| |
|
5741 |
||
5742 |
line1 := self selectionStartLine. |
|
5743 |
line2 := self selectionEndLine. |
|
5744 |
line1 isNil ifTrue:[ |
|
5745 |
line1 := self cursorLine. |
|
5746 |
line1 notNil ifTrue:[ |
|
5747 |
line2 := line1+1 |
|
5748 |
] |
|
5749 |
]. |
|
5750 |
line1 notNil ifTrue:[ |
|
5751 |
self indentFromLine:line1 toLine:line2 by:n. |
|
5752 |
] |
|
5753 |
! |
|
5754 |
||
5755 |
indentByTab |
|
5756 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
5757 |
! |
|
5758 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5759 |
indentFromLine:start toLine:end |
3221 | 5760 |
"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
|
5761 |
last non-empty line before start, and change the indent |
4742 | 5762 |
of the selected line-range based on that line's indent." |
5763 |
||
4811 | 5764 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5765 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5766 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5767 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5768 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5769 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5770 |
(delta == 0) ifTrue:[^ self]. |
4811 | 5771 |
self indentFromLine:start toLine:end by:delta |
5772 |
! |
|
5773 |
||
5774 |
indentFromLine:start toLine:end by:delta |
|
5775 |
"indent a line-range - this is done by searching for the |
|
5776 |
last non-empty line before start, and change the indent |
|
5777 |
of the selected line-range based on that line's indent." |
|
5778 |
||
5779 |
|d line spaces anyChange| |
|
5780 |
||
5781 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5782 |
(delta > 0) ifTrue:[ |
4742 | 5783 |
spaces := String new:delta |
5784 |
]. |
|
5785 |
||
5786 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5787 |
start to:end do:[:lineNr | |
4742 | 5788 |
line := self listAt:lineNr. |
5789 |
line notNil ifTrue:[ |
|
5790 |
line isBlank ifTrue:[ |
|
4771 | 5791 |
self basicListAt:lineNr put:nil |
4742 | 5792 |
] ifFalse:[ |
5793 |
(delta > 0) ifTrue:[ |
|
5794 |
line := spaces , line. |
|
5795 |
widthOfWidestLine notNil ifTrue:[ |
|
5796 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
5797 |
] |
|
5798 |
] ifFalse:[ |
|
5799 |
"check if deletion is ok" |
|
5800 |
d := delta negated + 1. |
|
5801 |
||
5802 |
line size > d ifTrue:[ |
|
5803 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
5804 |
line := line copyFrom:d |
|
5805 |
] |
|
5806 |
]. |
|
5807 |
widthOfWidestLine := nil |
|
5808 |
]. |
|
5809 |
self replaceLine:lineNr with:line. |
|
5810 |
anyChange := true. |
|
5811 |
] |
|
5812 |
] |
|
5813 |
]. |
|
5814 |
||
5815 |
anyChange ifTrue:[ self textChanged ]. |
|
5816 |
||
3221 | 5817 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5818 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5819 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5820 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5821 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5822 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5823 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5824 |
this is done by searching for the last non-empty line before it |
4823 | 5825 |
and returning its indent. |
5826 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5827 |
|
827 | 5828 |
"SHOULD GO TO ListView" |
5829 |
||
5830 |
|line lnr indent| |
|
5831 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5832 |
lnr := lineNr. |
827 | 5833 |
|
4823 | 5834 |
"/ [lnr ~~ 1] whileTrue:[ |
5835 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 5836 |
lnr := lnr - 1. |
5837 |
line := self listAt:lnr. |
|
5838 |
||
5839 |
line notNil ifTrue:[ |
|
5840 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
5841 |
indent ~~ 0 ifTrue:[ |
|
5842 |
(line endsWith:$[) ifTrue:[ |
|
5843 |
^ indent + 4 - 1 |
|
5844 |
]. |
|
5845 |
^ indent - 1 |
|
5846 |
] |
|
5847 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5848 |
]. |
827 | 5849 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5850 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
5851 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 5852 |
! |
5853 |
||
5854 |
undentBy4 |
|
5050 | 5855 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
5856 |
||
5857 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5858 |
! |
|
5859 |
||
5860 |
undentBy8 |
|
5861 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 5862 |
|
5863 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 5864 |
! |
5865 |
||
5866 |
undentBy:n |
|
5867 |
self indentBy:(n negated) |
|
5868 |
! |
|
5869 |
||
5870 |
undentByTab |
|
5871 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 5872 |
! ! |
5873 |
||
0 | 5874 |
!EditTextView methodsFor:'initialization'! |
5875 |
||
941 | 5876 |
fetchDeviceResources |
5877 |
"fetch device colors, to avoid reallocation at redraw time" |
|
5878 |
||
5879 |
super fetchDeviceResources. |
|
5880 |
||
5643 | 5881 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
5882 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
5883 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 5884 |
|
5885 |
"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
|
5886 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 5887 |
! |
5888 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5889 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5890 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5891 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5892 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5893 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5894 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5895 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5896 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5897 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5898 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5899 |
super initStyle. |
4576 | 5900 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5901 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5902 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5903 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5904 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5905 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5906 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 5907 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
5908 |
cursorTypeNoFocus isNil ifTrue:[ |
|
5909 |
cursorTypeNoFocus := cursorType. |
|
5910 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
5911 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
5912 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
5913 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5914 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5915 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 5916 |
cursorType ~~ #block ifTrue:[ |
5917 |
cursorNoFocusFgColor := cursorBgColor |
|
5918 |
] ifFalse:[ |
|
5919 |
cursorNoFocusFgColor := cursorFgColor |
|
5920 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5921 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
5922 |
|
2088 | 5923 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5924 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5925 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5926 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5927 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5928 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5929 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5930 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5931 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5932 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5933 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5934 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5935 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5936 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5937 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5938 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5939 |
cursorCol := 1. |
5251 | 5940 |
cursorLineHolder := ValueHolder with:1. |
5941 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 5942 |
modifiedChannel := ValueHolder with:false. |
5943 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
5944 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5945 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5946 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
5947 |
tabMeansNextField := false. |
5106 | 5948 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
5949 |
autoIndent := false. |
|
5251 | 5950 |
editMode := ValueHolder with:EditMode insertMode. |
5951 |
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
|
5952 |
trimBlankLines := self st80EditMode not. |
2131 | 5953 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 5954 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
5955 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5956 |
"/ enable drop by default |
2589 | 5957 |
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
|
5958 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
5959 |
undoSupport := UndoSupport for:self. |
5251 | 5960 |
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
|
5961 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
5962 |
"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
|
5963 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5964 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5965 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5966 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5967 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5968 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5969 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5970 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5971 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5972 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5973 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5974 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 5975 |
! |
5976 |
||
5977 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5978 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5979 |
completionSupport release |
4771 | 5980 |
]. |
5981 |
super release |
|
0 | 5982 |
! ! |
5983 |
||
2580 | 5984 |
!EditTextView methodsFor:'macros'! |
5985 |
||
5986 |
executeLearnedKeyboardMacro |
|
4673 | 5987 |
"replay the characters as learned previously" |
5988 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
5989 |
(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
|
5990 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5991 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5992 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5993 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5994 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5995 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5996 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5997 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5998 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5999 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6000 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6001 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6002 |
]. |
2580 | 6003 |
] ifFalse:[ |
5153 | 6004 |
self flash:'no macro'. |
2580 | 6005 |
]. |
6006 |
! |
|
6007 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6008 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6009 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6010 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6011 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6012 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6013 |
|
2580 | 6014 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6015 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6016 |
|
2580 | 6017 |
|fg bg| |
6018 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6019 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6020 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6021 |
aBoolean ifTrue:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6022 |
learnedMacro := OrderedCollection new. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6023 |
fg := Color white. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6024 |
bg := Color black. |
2580 | 6025 |
] ifFalse:[ |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6026 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6027 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
2580 | 6028 |
]. |
6029 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6030 |
! |
|
6031 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6032 |
learnModeHolder |
4673 | 6033 |
"a holder returning true, if in learn mode" |
6034 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6035 |
learnMode isNil ifTrue:[ |
5251 | 6036 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6037 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6038 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6039 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6040 |
|
4673 | 6041 |
rememberLearnedMacroAs: nameString |
6042 |
Macros isNil ifTrue:[ |
|
6043 |
Macros := Dictionary new. |
|
6044 |
]. |
|
6045 |
Macros at:nameString put:learnedMacro |
|
6046 |
! |
|
6047 |
||
2580 | 6048 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6049 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6050 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6051 |
self learnMode:(self learnMode not). |
2580 | 6052 |
! ! |
6053 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6054 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6055 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6056 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6057 |
"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
|
6058 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6059 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6060 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6061 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6062 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6063 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6064 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
6065 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 6066 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
6067 |
] do:[ |
|
6068 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
6069 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6070 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6071 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6072 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6073 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6074 |
self unselect. |
3799 | 6075 |
self |
6076 |
undoablePaste:translated |
|
6077 |
info:'Translate' |
|
3495 | 6078 |
|
6079 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6080 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6081 |
|
3517 | 6082 |
compareWithClipboard |
6083 |
"compare the selection against the clipboard contents" |
|
6084 |
||
6085 |
|t1 t2| |
|
6086 |
||
6087 |
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
|
6088 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6089 |
Dialog information:'Clipboard is empty.'. |
6090 |
^ self. |
|
3517 | 6091 |
]. |
6092 |
||
6093 |
self hasSelection ifTrue:[ |
|
4823 | 6094 |
t1 := self selectionAsString. |
3517 | 6095 |
] ifFalse:[ |
4823 | 6096 |
t1 := self contents asString |
3517 | 6097 |
]. |
6098 |
t1 := t1 string. |
|
6099 |
||
6100 |
t1 = t2 ifTrue:[ |
|
4823 | 6101 |
Dialog information:'Strings are equal.'. |
6102 |
^ self. |
|
3517 | 6103 |
]. |
6104 |
DiffTextView |
|
4823 | 6105 |
openOn:t1 label:'Editor' |
6106 |
and:t2 label:'Clipboard' |
|
3517 | 6107 |
! |
6108 |
||
5689 | 6109 |
copySelection |
6110 |
"copy contents into smalltalk copybuffer. |
|
6111 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6112 |
||
6113 |
self hasSelection ifTrue:[ |
|
6114 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
|
6115 |
]. |
|
6116 |
super copySelection. |
|
6117 |
||
6118 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6119 |
! |
|
6120 |
||
121 | 6121 |
cut |
6122 |
"cut selection into copybuffer" |
|
6123 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6124 |
self deleteCopyToClipboard:true |
121 | 6125 |
! |
6126 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6127 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6128 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6129 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6130 |
cursorLine notNil ifTrue:[ |
4823 | 6131 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6132 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6133 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6134 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6135 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6136 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6137 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6138 |
|
4129 | 6139 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6140 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6141 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6142 |
self flashReadOnly. |
3786 | 6143 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6144 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6145 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6146 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6147 |
sel notNil ifTrue:[ |
4129 | 6148 |
self setLastStringToReplace: sel. |
4053 | 6149 |
|
3786 | 6150 |
line := selectionStartLine. |
6151 |
col := selectionStartCol. |
|
6152 |
||
6153 |
toClipboard ifTrue:[ |
|
6154 |
" |
|
6155 |
remember in CopyBuffer |
|
6156 |
" |
|
6157 |
self setClipboardText:sel. "/ lastString. |
|
6158 |
]. |
|
6159 |
||
6160 |
" |
|
6161 |
append to DeleteHistory (if there is one) |
|
6162 |
" |
|
6163 |
history := Smalltalk at:#DeleteHistory. |
|
6164 |
history notNil ifTrue:[ |
|
6165 |
history addAll:(sel asStringCollection). |
|
6166 |
history size > 1000 ifTrue:[ |
|
6167 |
history := history copyFrom:(history size - 1000) |
|
6168 |
]. |
|
6169 |
]. |
|
6170 |
||
6171 |
" |
|
6172 |
now, delete it |
|
6173 |
" |
|
6174 |
self |
|
6175 |
undoableDo:[self deleteSelection] |
|
6176 |
info:'Delete'. |
|
4048 | 6177 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6178 |
] ifFalse:[ |
3786 | 6179 |
" |
6180 |
a cut without selection will search&cut again |
|
6181 |
" |
|
6182 |
self undoableDo:[ |
|
6183 |
self again |
|
6184 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6185 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6186 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6187 |
"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
|
6188 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6189 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6190 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6191 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6192 |
|
3781 | 6193 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
6194 |
#Find #GotoLine #SaveAs #Print |
|
3890 | 6195 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6196 |
#ToggleAutoIndent #ToggleInsertMode |
6197 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6198 |
<resource: #programMenu> |
1054 | 6199 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6200 |
|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
|
6201 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6202 |
|
2460 | 6203 |
items := #( |
3781 | 6204 |
('Redo' redo Redo ) |
6205 |
('Again (for All)' multipleAgain AgainForAll ) |
|
3731 | 6206 |
('-' ) |
6207 |
('Search...' search Find ) |
|
6208 |
('Goto Line...' gotoLine GotoLine ) |
|
6209 |
('-' ) |
|
4940 | 6210 |
('Tools' tools ) |
5529 | 6211 |
('Font...' changeFont ) |
4940 | 6212 |
('Insert Unicode...' insertUnicode ) |
6213 |
). |
|
4213 | 6214 |
CharacterSetView notNil ifTrue:[ |
6215 |
items := items , |
|
6216 |
#( |
|
6217 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6218 |
). |
|
6219 |
]. |
|
6220 |
items := items , #( |
|
3731 | 6221 |
('-' ) |
6222 |
('Save As...' save SaveAs ) |
|
6223 |
('Print' doPrint Print ) |
|
6224 |
('=' ) |
|
4213 | 6225 |
('Misc' misc ShiftCtrl) ). |
2460 | 6226 |
|
2866 | 6227 |
miscItems := #( |
3781 | 6228 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6229 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
3731 | 6230 |
('-' ) |
6231 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
3781 | 6232 |
('Join Lines' joinLines Join ) |
4388 | 6233 |
('Wrap Lines...' wrapLines Wrap ) |
3731 | 6234 |
('-' ) |
3781 | 6235 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
6236 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
3731 | 6237 |
('-' ) |
3811 | 6238 |
('Insert File...' insertFile ) |
6239 |
('Insert URL Contents...' insertURL ) |
|
3781 | 6240 |
('Insert new UUID' insertUUID ) |
6241 |
('Insert Date && Time' insertDateAndTime ) |
|
3732 | 6242 |
('-' ) |
6243 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6244 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
3731 | 6245 |
). |
4213 | 6246 |
"/ CharacterSetView notNil ifTrue:[ |
6247 |
"/ miscItems := miscItems , |
|
6248 |
"/ #( |
|
5529 | 6249 |
"/ ('-' ) |
4213 | 6250 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6251 |
"/ ('Font...' changeFont ) |
4213 | 6252 |
"/ ). |
5529 | 6253 |
"/ ] ifFalse:[ |
6254 |
"/ miscItems := miscItems , |
|
6255 |
"/ #( |
|
6256 |
"/ ('Font...' changeFont ) |
|
6257 |
"/"/ ('Encoding...' changeEncoding ) |
|
6258 |
"/ ). |
|
6259 |
"/ ]. |
|
2866 | 6260 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6261 |
translateItems := #( |
3731 | 6262 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6263 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6264 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6265 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6266 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6267 |
('-' ) |
|
6268 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6269 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6270 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6271 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6272 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6273 |
). |
|
3221 | 6274 |
|
6275 |
sortItems := #( |
|
3731 | 6276 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6277 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
4373 | 6278 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
6279 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6280 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
3731 | 6281 |
('Words' (sortSelection:ignoreCase: #words false) ) |
6282 |
('-' ) |
|
4373 | 6283 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
6284 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6285 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6286 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
4763 | 6287 |
('-' ) |
6288 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6289 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
3731 | 6290 |
). |
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6291 |
|
2762 | 6292 |
toolItems := #( |
3731 | 6293 |
('Indent' indent ) |
4287 | 6294 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
3731 | 6295 |
('Sort' sort ) |
5370 | 6296 |
('Split...' splitLinesAtCharacterOrString ) |
3731 | 6297 |
('-' ) |
4742 | 6298 |
('Google Spell Check' googleSpellingSuggestion ) |
6299 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
3731 | 6300 |
('Translate' babelFishTranslate ) |
6301 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6302 |
). |
|
2762 | 6303 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6304 |
Smalltalk isStandAloneApp ifFalse:[ |
3731 | 6305 |
toolItems := toolItems , #( |
6306 |
('-' ) |
|
6307 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6308 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
5578 | 6309 |
('Inspect Selected String' inspectSelectedString ) |
3731 | 6310 |
). |
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6311 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6312 |
|
2460 | 6313 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6314 |
sub receiver:self. |
2460 | 6315 |
|
2919 | 6316 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6317 |
toolSub receiver:self. |
|
6318 |
sub subMenuAt:#tools put:toolSub. |
|
6319 |
||
3495 | 6320 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6321 |
transSub receiver:self. |
|
6322 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6323 |
||
6324 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6325 |
sortSub receiver:self. |
|
6326 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6327 |
|
2866 | 6328 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6329 |
subSub receiver:self. |
|
2952 | 6330 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6331 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6332 |
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
|
6333 |
|
2866 | 6334 |
sub subMenuAt:#misc put:subSub. |
6335 |
||
3495 | 6336 |
mainItems := #( |
3731 | 6337 |
('Undo' undo Undo ) |
6338 |
('Again' again Again ) |
|
6339 |
('-' ) |
|
6340 |
('Cut' cut Cut ) |
|
6341 |
('Copy' copySelection Copy ) |
|
6342 |
('Paste' pasteOrReplace Paste ) |
|
6343 |
('-' ) |
|
6344 |
('Accept' accept Accept ) |
|
6345 |
('=' ) |
|
6346 |
('More' others Ctrl ) |
|
6347 |
). |
|
3495 | 6348 |
main := PopUpMenu itemList:mainItems resources:resources. |
6349 |
main subMenuAt:#others put:sub. |
|
6350 |
||
6351 |
sensor := self sensor. |
|
6352 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6353 |
sensor shiftDown ifTrue:[ |
|
3731 | 6354 |
m := subSub |
6355 |
] ifFalse:[ |
|
6356 |
m := sub |
|
6357 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6358 |
] ifFalse:[ |
3731 | 6359 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6360 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6361 |
|
4742 | 6362 |
"/ the 'Smalltalk at:' code is here to |
6363 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6364 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
3731 | 6365 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6366 |
m disable:#googleSpellingSuggestion |
|
2676 | 6367 |
]. |
4742 | 6368 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
6369 |
m disable:#internalSpellingSuggestion |
|
6370 |
]. |
|
2676 | 6371 |
|
3811 | 6372 |
HTTPInterface isNil ifTrue:[ |
6373 |
m disableAll:#(insertURL) |
|
6374 |
]. |
|
6375 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6376 |
self isReadOnly ifTrue:[ |
4475 | 6377 |
m disableAll:#(accept undo again multipleAgain redo |
3731 | 6378 |
paste pasteOrReplace pasteOrReplaceFromHistory |
6379 |
cut indent autoIndent: insertMode: |
|
3811 | 6380 |
insertFile insertFileAsStringLiteral insertURL |
6381 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6382 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
4764 | 6383 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
4940 | 6384 |
insertUnicode specialCharacters) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6385 |
]. |
2817 | 6386 |
self hasSelectionForCopy ifFalse:[ |
3731 | 6387 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6388 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6389 |
self hasSelection ifFalse:[ |
5371 | 6390 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
5578 | 6391 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString). |
2762 | 6392 |
] ifTrue:[ |
3731 | 6393 |
(Error handle:[:ex | |
6394 |
ex return:false |
|
6395 |
] do:[ |
|
4042 | 6396 |
|fn| |
6397 |
fn := self selectionAsString. |
|
6398 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
3731 | 6399 |
]) ifFalse:[ |
6400 |
m disableAll:#(openFileBrowserOnIt). |
|
6401 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6402 |
]. |
2569 | 6403 |
self hasUndoAction ifFalse:[ |
3731 | 6404 |
m disable:#undo. |
3115 | 6405 |
] ifTrue:[ |
3731 | 6406 |
what := undoSupport undoActionInfo. |
6407 |
what notNil ifTrue:[ |
|
6408 |
undoIdx := m indexOf:#undo. |
|
6409 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6410 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6411 |
]. |
2952 | 6412 |
self hasRedoAction ifFalse:[ |
3731 | 6413 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6414 |
] ifTrue:[ |
3731 | 6415 |
what := undoSupport redoActionInfo. |
6416 |
what notNil ifTrue:[ |
|
6417 |
redoIdx := sub indexOf:#redo. |
|
6418 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6419 |
] |
|
2952 | 6420 |
]. |
5216 | 6421 |
self canAccept ifFalse:[ |
3731 | 6422 |
m disable:#accept |
1108 | 6423 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6424 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6425 |
|
4388 | 6426 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6427 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6428 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6429 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6430 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6431 |
|
5643 | 6432 |
history := device getCopyBufferHistory copy. |
3160 | 6433 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6434 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6435 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6436 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6437 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6438 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6439 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6440 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6441 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6442 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6443 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6444 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6445 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6446 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6447 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6448 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6449 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6450 |
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
|
6451 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6452 |
box show. |
3160 | 6453 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6454 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6455 |
"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
|
6456 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6457 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6458 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6459 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6460 |
self sensor shiftDown ifTrue:[ |
3855 | 6461 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6462 |
]. |
2724 | 6463 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6464 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6465 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6466 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6467 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6468 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6469 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6470 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6471 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6472 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6473 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6474 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6475 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6476 |
"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
|
6477 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6478 |
|
2676 | 6479 |
googleSpellingSuggestion |
6480 |
"insert the google-spelling suggestion for the selected text. |
|
6481 |
Requires that the SOAP stuff is loaded and working." |
|
6482 |
||
2677 | 6483 |
|text suggestion| |
2676 | 6484 |
|
6485 |
self withWaitCursorDo:[ |
|
3799 | 6486 |
text := self selection asString string withoutSeparators. |
6487 |
text size == 0 ifTrue:[^ self]. |
|
6488 |
||
4742 | 6489 |
"/ the 'Smalltalk at:' code is here to |
6490 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6491 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6492 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6493 |
^ self. |
|
6494 |
] do:[ |
|
4742 | 6495 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6496 |
]. |
6497 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6498 |
self information:('No spelling suggestion from Google for: ' , text). |
6499 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6500 |
^ self. |
6501 |
]. |
|
6502 |
]. |
|
6503 |
self |
|
6504 |
undoablePaste:suggestion |
|
6505 |
info:'Spelling Suggestion'. |
|
3495 | 6506 |
|
6507 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6508 |
! |
6509 |
||
3595 | 6510 |
insertDateAndTime |
6511 |
"insert the curent date and time string" |
|
6512 |
||
6513 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6514 |
self |
3786 | 6515 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6516 |
info:'Paste Date and Time' |
3595 | 6517 |
! |
6518 |
||
2676 | 6519 |
insertFile |
3160 | 6520 |
"insert contents of a file |
2676 | 6521 |
- ask user for filename using a fileSelectionBox." |
6522 |
||
3731 | 6523 |
self insertFileAsStringLiteral:false |
6524 |
! |
|
6525 |
||
6526 |
insertFileAsStringLiteral |
|
6527 |
"insert a file's contents as a string literal. |
|
6528 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6529 |
to make it a legal string literal" |
|
6530 |
||
6531 |
self insertFileAsStringLiteral:true |
|
6532 |
! |
|
6533 |
||
6534 |
insertFileAsStringLiteral:asStringLiteral |
|
6535 |
"insert contents of a file; either as-is or as a string literal. |
|
6536 |
- ask user for filename using a fileSelectionBox." |
|
6537 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6538 |
|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
|
6539 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6540 |
((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
|
6541 |
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
|
6542 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6543 |
ifTrue:[ |
3731 | 6544 |
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
|
6545 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6546 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6547 |
[ |
3731 | 6548 |
|why| |
6549 |
||
6550 |
file := Dialog |
|
6551 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6552 |
default:initial |
|
6553 |
ok:(resources string:'Insert') |
|
6554 |
abort:(resources string:'Cancel') |
|
6555 |
pattern:nil |
|
6556 |
fromDirectory:directoryForFileDialog. |
|
6557 |
file isNil ifTrue:[ |
|
6558 |
"cancel" |
|
6559 |
^ self. |
|
6560 |
]. |
|
6561 |
file := file asFilename. |
|
6562 |
directoryForFileDialog := file. |
|
6563 |
||
6564 |
ok := file isReadable and:[file isDirectory not]. |
|
6565 |
ok ifFalse:[ |
|
6566 |
file isReadable ifFalse:[ |
|
6567 |
why := '%1 is unreadable.\\Please try again.' |
|
6568 |
] ifTrue:[ |
|
6569 |
why := '%1 is a directory.\\Please try again.' |
|
6570 |
]. |
|
6571 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6572 |
]. |
|
2909 | 6573 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6574 |
|
5063 | 6575 |
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
|
6576 |
self |
3786 | 6577 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6578 |
info:'Paste File' |
3495 | 6579 |
|
6580 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6581 |
! |
|
6582 |
||
3811 | 6583 |
insertURL |
6584 |
"insert contents of a URL |
|
6585 |
- ask user for URL using a dialog." |
|
6586 |
||
6587 |
self insertURLAsStringLiteral:false |
|
6588 |
! |
|
6589 |
||
6590 |
insertURLAsStringLiteral:asStringLiteral |
|
6591 |
"insert contents of a file; either as-is or as a string literal. |
|
6592 |
- ask user for filename using a fileSelectionBox." |
|
6593 |
||
6594 |
|sel url text response initial| |
|
6595 |
||
6596 |
(sel := self selectionAsString) notEmptyOrNil |
|
6597 |
ifTrue:[ |
|
6598 |
initial := sel. |
|
6599 |
]. |
|
6600 |
||
6601 |
url := Dialog |
|
6602 |
request:(resources string:'Insert Contents of URL:') |
|
6603 |
initialAnswer:initial |
|
6604 |
okLabel:(resources string:'Insert') |
|
6605 |
title:(resources string:'URL'). |
|
6606 |
url isNil ifTrue:[ |
|
6607 |
"cancel" |
|
6608 |
^ self. |
|
6609 |
]. |
|
6610 |
response := HTTPInterface get:url. |
|
6611 |
response isErrorResponse ifTrue:[ |
|
6612 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6613 |
^ self. |
|
6614 |
]. |
|
6615 |
text := response data asString. |
|
6616 |
||
6617 |
self |
|
6618 |
undoableDo:[ |
|
6619 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6620 |
] |
|
6621 |
info:'Insert Contents of URL' |
|
6622 |
! |
|
6623 |
||
3495 | 6624 |
insertUUID |
6625 |
"insert a new UUID's string" |
|
6626 |
||
6627 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6628 |
self |
3786 | 6629 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6630 |
info:'Paste New UUID' |
3495 | 6631 |
|
6632 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6633 |
! |
6634 |
||
4940 | 6635 |
insertUnicode |
6636 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
6637 |
||
6638 |
|unicodePoint unicodeChar unicodeString| |
|
6639 |
||
6640 |
unicodeString := Dialog request:'Enter unicode (U+01FF or decimal number):'. |
|
6641 |
unicodeString size < 2 ifTrue:[ |
|
6642 |
^ self. |
|
6643 |
]. |
|
6644 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
6645 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
|
6646 |
] ifFalse:[ |
|
6647 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
|
6648 |
]. |
|
6649 |
||
6650 |
unicodeChar := Character value:unicodePoint. |
|
6651 |
self keyPress:unicodeChar x:0 y:0. |
|
6652 |
self keyRelease:unicodeChar x:0 y:0. |
|
6653 |
! |
|
6654 |
||
5331 | 6655 |
inspectSelectedString |
6656 |
"inspect the selected text" |
|
6657 |
||
6658 |
self selectionAsString inspect. |
|
6659 |
! |
|
6660 |
||
4742 | 6661 |
internalSpellingSuggestion |
6662 |
"insert the internal-spelling suggestion for the selected text. |
|
6663 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
6664 |
||
6665 |
|text suggestions best| |
|
6666 |
||
6667 |
self withWaitCursorDo:[ |
|
6668 |
text := self selection asString string withoutSeparators. |
|
6669 |
text size == 0 ifTrue:[^ self]. |
|
6670 |
||
6671 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
6672 |
suggestions size == 0 ifTrue:[ |
|
6673 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
6674 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
6675 |
^ self. |
|
6676 |
]. |
|
6677 |
Transcript showCR:suggestions. |
|
6678 |
best := suggestions first. |
|
6679 |
]. |
|
6680 |
self |
|
6681 |
undoablePaste:best |
|
6682 |
info:'Spelling Suggestion'. |
|
6683 |
! |
|
6684 |
||
4884 | 6685 |
openFileBrowserOnFileNamed:fileNameString |
6686 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 6687 |
|
4630 | 6688 |
|fn| |
2762 | 6689 |
|
4884 | 6690 |
fn := fileNameString asFilename. |
2762 | 6691 |
fn exists ifFalse:[ |
4884 | 6692 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 6693 |
fn exists ifFalse:[ |
5082 | 6694 |
^ self warn:(resources |
6695 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
6696 |
with:fn baseName allBold |
|
6697 |
with:fn directory baseName allBold). |
|
4042 | 6698 |
]. |
2762 | 6699 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6700 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6701 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6702 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 6703 |
! |
6704 |
||
4884 | 6705 |
openFileBrowserOnIt |
6706 |
"open a fileBrowser on the selected fileName" |
|
6707 |
||
6708 |
|fileNameString| |
|
6709 |
||
6710 |
fileNameString := self selectionAsString. |
|
6711 |
self openFileBrowserOnFileNamed:fileNameString |
|
6712 |
||
6713 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
6714 |
! |
|
6715 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6716 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6717 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6718 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6719 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6720 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6721 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6722 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6723 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6724 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6725 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
6726 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6727 |
paste |
1289 | 6728 |
"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
|
6729 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6730 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6731 |
self checkModificationsAllowed ifTrue:[ |
4823 | 6732 |
self withSelfAndTextForPasteDo:[:me :text | |
6733 |
me unselect. |
|
6734 |
me undoablePaste:text |
|
6735 |
] |
|
2952 | 6736 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6737 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6738 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6739 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6740 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6741 |
|
3825 | 6742 |
self paste:someText withCR:false |
6743 |
! |
|
6744 |
||
6745 |
paste:someText withCR:withCR |
|
6746 |
"paste someText at cursor" |
|
6747 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6748 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6749 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6750 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6751 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6752 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6753 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6754 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6755 |
CharacterEncoderError handle:[:ex | |
3825 | 6756 |
|code msg| |
6757 |
||
6758 |
code := ex parameter. |
|
6759 |
codingErrorReported ifFalse:[ |
|
4940 | 6760 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 6761 |
code notNil ifTrue:[ |
6762 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
6763 |
]. |
|
6764 |
Dialog warn:(resources stringWithCRs:msg). |
|
6765 |
codingErrorReported := true. |
|
6766 |
]. |
|
6767 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6768 |
] do:[ |
3825 | 6769 |
s isString ifTrue:[ |
4940 | 6770 |
s encoding ~~ gc characterEncoding ifTrue:[ |
6771 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 6772 |
]. |
6773 |
||
6774 |
s := s asStringCollection. |
|
6775 |
(someText endsWith:Character cr) ifTrue:[ |
|
6776 |
"/ s := s copyWith:nil. |
|
6777 |
s := s copyWith:'' "/ an empty line at the end |
|
6778 |
||
6779 |
] |
|
6780 |
] ifFalse:[ |
|
6781 |
s isStringCollection ifTrue:[ |
|
4940 | 6782 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 6783 |
] ifFalse:[ |
6784 |
(self |
|
6785 |
confirm:(resources |
|
6786 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
6787 |
with:s class name)) ifFalse:[^ self]. |
|
6788 |
s := StringCollection with:s storeString . |
|
6789 |
"/ ^ self |
|
6790 |
]. |
|
6791 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6792 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
6793 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6794 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6795 |
(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
|
6796 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6797 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6798 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6799 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6800 |
startCol := c1 := cursorCol. |
3180 | 6801 |
|
5194 | 6802 |
"do not autoindent here. |
6803 |
It does make things very ugly, in the inspector |
|
6804 |
(try inspecting a multiline string)..." |
|
6805 |
self withAutoIndent:false do:[ |
|
6806 |
"do not expand tabs into spaces here - |
|
6807 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
6808 |
Some Subviews want to paste with unexpanded tabs!!" |
|
6809 |
||
6810 |
self insertLines:s withCR:withCR. |
|
6811 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6812 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6813 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6814 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6815 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
6816 |
|
4328 | 6817 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 6818 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6819 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6820 |
|
3731 | 6821 |
pasteAsStringLiteral |
6822 |
"insert clipboard string as a string literal. |
|
6823 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
6824 |
to make it a legal string literal" |
|
6825 |
||
6826 |
typeOfSelection := nil. |
|
6827 |
self |
|
5107 | 6828 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 6829 |
info:'Paste as String Literal' |
3731 | 6830 |
! |
6831 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6832 |
pasteOrReplace |
1289 | 6833 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 6834 |
otherwise paste at cursor position. |
6835 |
Replace is not done for selections which were created by a paste, |
|
2010 | 6836 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6837 |
|
2724 | 6838 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6839 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6840 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6841 |
pasteOrReplace:someText |
1289 | 6842 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6843 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6844 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6845 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6846 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6847 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6848 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6849 |
self undoableDo:[ |
4823 | 6850 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
6851 |
self replace:someText |
|
6852 |
] ifFalse:[ |
|
6853 |
self paste:someText. |
|
6854 |
] |
|
3542 | 6855 |
] info:'Paste/Replace'. |
1289 | 6856 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
6857 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6858 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6859 |
|
5387 | 6860 |
pasteOrReplaceByKeyPress |
6861 |
"paste a previous item from the copybuffer history. |
|
6862 |
(i.e. repaste some previously deleted or copied text)" |
|
6863 |
||
6864 |
|text| |
|
6865 |
||
6866 |
self checkModificationsAllowed ifFalse:[ |
|
6867 |
self flashReadOnly. |
|
6868 |
^ self |
|
6869 |
]. |
|
6870 |
text := self getClipboardText:#clipboard. |
|
6871 |
text notNil ifTrue:[ |
|
6872 |
self pasteOrReplace:text |
|
6873 |
] |
|
6874 |
! |
|
6875 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6876 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6877 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6878 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6879 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6880 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6881 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6882 |
self checkModificationsAllowed ifFalse:[ |
4988 | 6883 |
self flashReadOnly. |
4823 | 6884 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6885 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6886 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6887 |
text notNil ifTrue:[ |
4823 | 6888 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6889 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6890 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
6891 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6892 |
replace |
1289 | 6893 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6894 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6895 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6896 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6897 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
6898 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 6899 |
me undoableDo:[ me replace:text ] |
6900 |
info:'Replace' |
|
2952 | 6901 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6902 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6903 |
|
121 | 6904 |
replace:someText |
1289 | 6905 |
"replace the selection by someText" |
121 | 6906 |
|
3160 | 6907 |
|selected selectedString |
6908 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 6909 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6910 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6911 |
|
3130 | 6912 |
self undoableDo:[ |
4010 | 6913 |
selected := self selection. |
6914 |
selected isNil ifTrue:[ |
|
6915 |
^ self paste:someText |
|
6916 |
]. |
|
6917 |
||
6918 |
self deleteSelection. |
|
6919 |
||
6920 |
"take care, if we replace a selection without space by a word selected |
|
6921 |
with one - in this case we usually do not want the space. |
|
6922 |
But, if we replace a word-selected selection by something without a |
|
6923 |
space, we DO want the space added." |
|
6924 |
||
6925 |
selected size == 1 ifTrue:[ |
|
6926 |
selectedString := selected at:1. |
|
6927 |
]. |
|
6928 |
||
6929 |
someText size == 1 ifTrue:[ |
|
6930 |
|cutOffSpace addSpace replacement replacementString| |
|
6931 |
||
6932 |
cutOffSpace := false. |
|
6933 |
addSpace := false. |
|
6934 |
replacement := someText copyFrom:1. |
|
6935 |
||
6936 |
selectedString notNil ifTrue:[ |
|
6937 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
6938 |
"selection has no space" |
|
6939 |
||
6940 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
6941 |
cutOffSpace := true |
|
6942 |
] |
|
6943 |
] ifTrue:[ |
|
6944 |
addSpace := true |
|
6945 |
] |
|
6946 |
]. |
|
6947 |
replacementString := replacement at:1. |
|
6948 |
cutOffSpace ifTrue:[ |
|
6949 |
(replacementString startsWith:' ') ifTrue:[ |
|
6950 |
replacementString := replacementString withoutSpaces |
|
6951 |
]. |
|
6952 |
] ifFalse:[ |
|
6953 |
selectStyle == #wordLeft ifTrue:[ |
|
6954 |
"want a space at left" |
|
6955 |
(replacementString startsWith:' ') ifFalse:[ |
|
6956 |
replacementString := replacementString withoutSpaces. |
|
6957 |
replacementString := ' ' , replacementString |
|
6958 |
] |
|
6959 |
]. |
|
6960 |
selectStyle == #wordRight ifTrue:[ |
|
6961 |
"want a space at right" |
|
6962 |
||
6963 |
(replacementString endsWith:' ') ifFalse:[ |
|
6964 |
replacementString := replacementString withoutSpaces. |
|
6965 |
replacementString := replacementString , ' ' |
|
6966 |
] |
|
6967 |
]. |
|
6968 |
]. |
|
6969 |
replacement at:1 put: replacementString. |
|
6970 |
self paste:replacement. |
|
6971 |
] ifFalse:[ |
|
6972 |
self paste:someText |
|
6973 |
]. |
|
4053 | 6974 |
self setLastStringToReplace: selectedString. |
6975 |
||
4048 | 6976 |
lastReplacementInfo lastReplacement: someText. |
4010 | 6977 |
|
6978 |
selStartLine := selectionStartLine. |
|
6979 |
selStartCol := self selectionStartCol. |
|
6980 |
selEndLine := selectionEndLine. |
|
6981 |
selEndCol := self selectionEndCol. |
|
3130 | 6982 |
] |
3542 | 6983 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
6984 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6985 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
6986 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 6987 |
! |
6988 |
||
3430 | 6989 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6990 |
"search for a string - show a box to enter searchpattern |
3430 | 6991 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
6992 |
- 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
|
6993 |
|
3430 | 6994 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
6995 |
||
6996 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
6997 |
lastSearchDirection := #forward. |
|
6998 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 6999 |
caseHolder := ValueHolder with:ign. |
7000 |
patternHolder := ValueHolder with:''. |
|
7001 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7002 |
lastSearchPattern notNil ifTrue:[ |
4823 | 7003 |
initialString := lastSearchPattern |
3430 | 7004 |
]. |
7005 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 7006 |
initialString := self selectionAsString |
3430 | 7007 |
]. |
7008 |
initialString isNil ifTrue:[ |
|
4823 | 7009 |
LastSearchPatterns size > 0 ifTrue:[ |
7010 |
initialString := LastSearchPatterns first |
|
7011 |
] |
|
3430 | 7012 |
]. |
7013 |
initialString notNil ifTrue:[ |
|
4823 | 7014 |
patternHolder value:initialString. |
7015 |
replacePatternHolder value:initialString. |
|
3430 | 7016 |
]. |
7017 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7018 |
search := [:fwd | |
4823 | 7019 |
self |
7020 |
search:patternHolder value |
|
7021 |
ignoreCase:caseHolder value |
|
7022 |
forward:fwd. |
|
7023 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7024 |
replace := [:all | |
4823 | 7025 |
self |
7026 |
replace:patternHolder value |
|
7027 |
by:replacePatternHolder value |
|
7028 |
all:all |
|
7029 |
ignoreCase:caseHolder value |
|
7030 |
]. |
|
3430 | 7031 |
bindings := IdentityDictionary new. |
7032 |
bindings at:#searchPattern put:patternHolder. |
|
7033 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7034 |
modal ifTrue:[ |
|
4823 | 7035 |
bindings at:#nextAction |
7036 |
put:[ |
|
7037 |
flag := true. |
|
7038 |
action := search. |
|
7039 |
searchBox doAccept. |
|
7040 |
]. |
|
7041 |
bindings at:#prevAction |
|
7042 |
put:[ |
|
7043 |
flag := false. |
|
7044 |
action := search. |
|
7045 |
searchBox doAccept. |
|
7046 |
]. |
|
7047 |
bindings at:#replaceAction |
|
7048 |
put:[ |
|
7049 |
flag := false. |
|
7050 |
action := replace. |
|
7051 |
searchBox doAccept. |
|
7052 |
]. |
|
7053 |
bindings at:#replaceAllAction |
|
7054 |
put:[ |
|
7055 |
flag := true. |
|
7056 |
action := replace. |
|
7057 |
searchBox doAccept. |
|
7058 |
]. |
|
3430 | 7059 |
] ifFalse:[ |
4823 | 7060 |
bindings at:#nextAction put:[ search value:true. ]. |
7061 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7062 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7063 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7064 |
]. |
7065 |
bindings at:#ignoreCase put:caseHolder. |
|
7066 |
bindings at:#patternList put:LastSearchPatterns. |
|
7067 |
modal ifTrue:[ |
|
4823 | 7068 |
searchBox := SimpleDialog new. |
3430 | 7069 |
] ifFalse:[ |
4823 | 7070 |
searchBox := ApplicationModel new. |
7071 |
searchBox createBuilder. |
|
3430 | 7072 |
]. |
7073 |
searchBox resources:(self resources). |
|
7074 |
bldr := searchBox builder. |
|
7075 |
bldr addBindings:bindings. |
|
7076 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7077 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7078 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7079 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7080 |
modal ifTrue:[ |
|
4823 | 7081 |
searchBox openDialog. |
7082 |
searchBox accepted ifTrue:[ |
|
7083 |
action value:flag |
|
7084 |
]. |
|
3430 | 7085 |
] ifFalse:[ |
4823 | 7086 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7087 |
(bldr componentAt:#cancelButton) |
|
7088 |
label:(resources string:'Close'); |
|
7089 |
action:[ searchBox closeRequest ]. |
|
7090 |
||
7091 |
"/ searchBox masterApplication:self application. |
|
7092 |
||
7093 |
self topView beMaster. |
|
7094 |
(searchBox window) |
|
7095 |
beSlave; |
|
7096 |
openInGroup:(self windowGroup). |
|
7097 |
||
7098 |
"/ searchBox window open. |
|
7099 |
||
5283 | 7100 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
3430 | 7101 |
] |
7102 |
||
7103 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7104 |
! |
|
7105 |
||
121 | 7106 |
showDeleted |
7107 |
"open a readonly editor on all deleted text" |
|
7108 |
||
7109 |
|v| |
|
7110 |
||
7111 |
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
|
7112 |
v readOnly:true. |
121 | 7113 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7114 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7115 |
|
3221 | 7116 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7117 |
"sort/reorder the selected lines. |
7118 |
how: |
|
7119 |
#lines |
|
7120 |
#linesByFirstWord |
|
7121 |
#linesByNthWord |
|
7122 |
#linesByNthNumber |
|
7123 |
#linesByNthHexNumber |
|
7124 |
#words |
|
7125 |
#linesByLength |
|
7126 |
#reverse |
|
7127 |
" |
|
7128 |
||
7129 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7130 |
|
7131 |
lineWise := true. |
|
7132 |
||
4763 | 7133 |
how == #reverse ifTrue:[ |
7134 |
operation := [:lines | lines reverse]. |
|
7135 |
] ifFalse:[ |
|
7136 |
operation := [:linesOrWords | |
|
7137 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7138 |
]. |
|
7139 |
||
7140 |
how == #linesByLength ifTrue:[ |
|
7141 |
fetcher := [:l | l size]. |
|
7142 |
] ifFalse:[ |
|
7143 |
how == #lines ifTrue:[ |
|
7144 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7145 |
] ifFalse:[ |
|
7146 |
how == #linesByFirstWord ifTrue:[ |
|
7147 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7148 |
] ifFalse:[ |
|
7149 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7150 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7151 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7152 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7153 |
LastColumnNumberForSort := n. |
|
7154 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7155 |
how == #linesByNthNumber ifTrue:[ |
|
7156 |
innerExtractor := extractor. |
|
7157 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7158 |
] ifFalse:[ |
|
7159 |
how == #linesByNthHexNumber ifTrue:[ |
|
7160 |
innerExtractor := extractor. |
|
7161 |
extractor := [:l | |
|
7162 |
|s| |
|
7163 |
s := innerExtractor value:l. |
|
7164 |
(s startsWith:'16r') ifTrue:[ |
|
7165 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7166 |
] ifFalse:[ |
|
7167 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7168 |
] |
|
7169 |
] |
|
4753 | 7170 |
] |
4763 | 7171 |
]. |
7172 |
] ifFalse:[ |
|
7173 |
how == #words ifTrue:[ |
|
7174 |
lineWise := false. |
|
7175 |
extractor := [:w | w]. |
|
7176 |
] ifFalse:[ |
|
7177 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7178 |
] |
4373 | 7179 |
] |
7180 |
] |
|
4763 | 7181 |
]. |
7182 |
ignoreCase ifTrue:[ |
|
7183 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7184 |
] ifFalse:[ |
|
7185 |
fetcher := extractor. |
|
7186 |
]. |
|
7187 |
]. |
|
3221 | 7188 |
]. |
7189 |
||
7190 |
lineWise ifTrue:[ |
|
4763 | 7191 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7192 |
start == end ifTrue:[^ self ]. |
7193 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7194 |
lines := operation value:lines. |
4373 | 7195 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7196 |
] ifFalse:[ |
7197 |
"process the whole selection as a string" |
|
7198 |
s := self selectionAsString. |
|
7199 |
words := s asCollectionOfWords. |
|
7200 |
words := operation value:words. |
|
7201 |
s := words asStringCollection asStringWith:Character space. |
|
7202 |
self replace:s. |
|
7203 |
]. |
|
3221 | 7204 |
self textChanged. |
4373 | 7205 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7206 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7207 |
! |
7208 |
||
7209 |
sortSelection:how ignoreCase:ignoreCase |
|
7210 |
"sort the selected lines" |
|
7211 |
||
7212 |
|start end| |
|
7213 |
||
7214 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7215 |
||
7216 |
start := selectionStartLine. |
|
7217 |
end := selectionEndLine. |
|
7218 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7219 |
end := end - 1 |
3221 | 7220 |
]. |
7221 |
||
7222 |
self |
|
4373 | 7223 |
undoableDo:[ |
7224 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7225 |
] |
|
3786 | 7226 |
info:'Sort' |
4373 | 7227 |
|
7228 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7229 |
! |
7230 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7231 |
specialCharacters |
2915 | 7232 |
CharacterSetView |
4823 | 7233 |
openAsInputFor:self |
7234 |
label:'Special Character Input' |
|
7235 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7236 |
! |
7237 |
||
5370 | 7238 |
splitLinesAtCharacterOrString |
7239 |
"ask user for the character and split after it" |
|
7240 |
||
7241 |
|sel in out separator record| |
|
7242 |
||
7243 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7244 |
||
7245 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7246 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7247 |
||
7248 |
sel := self selectionAsString. |
|
7249 |
in := sel readStream. |
|
7250 |
out := CharacterWriteStream on:(String new). |
|
7251 |
[in atEnd] whileFalse:[ |
|
7252 |
record := in throughAll:separator. |
|
7253 |
out nextPutLine:record. |
|
7254 |
]. |
|
7255 |
self |
|
7256 |
undoableDo:[ |
|
7257 |
self replaceSelectionBy:(out contents). |
|
7258 |
] |
|
7259 |
info:'Split Selection' |
|
7260 |
! |
|
7261 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7262 |
undoablePaste:someText |
3495 | 7263 |
self undoablePaste:someText info:nil. |
7264 |
||
7265 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7266 |
! |
|
7267 |
||
7268 |
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
|
7269 |
self |
4823 | 7270 |
undoableDo:[ |
7271 |
self paste:someText. |
|
7272 |
] |
|
7273 |
info:infoOrNil |
|
3495 | 7274 |
|
7275 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7276 |
! |
|
7277 |
||
7278 |
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
|
7279 |
self |
4823 | 7280 |
undoableDo:[ |
7281 |
self pasteOrReplace:someText. |
|
7282 |
] |
|
7283 |
info:infoOrNil |
|
3495 | 7284 |
|
7285 |
"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
|
7286 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7287 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7288 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7289 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7290 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7291 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7292 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7293 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7294 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7295 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7296 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7297 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7298 |
|
2724 | 7299 |
withSelfAndTextForPasteDo:aBlock |
7300 |
"common code for paste/replace of the copybuffer" |
|
7301 |
||
7302 |
|sel| |
|
7303 |
||
7304 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7305 |
self flashReadOnly. |
4823 | 7306 |
^ self |
2724 | 7307 |
]. |
7308 |
||
7309 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7310 |
sel notNil ifTrue:[ |
|
4823 | 7311 |
aBlock value:self value:sel. |
2724 | 7312 |
] |
105 | 7313 |
! ! |
7314 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7315 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7316 |
|
3880 | 7317 |
beep |
5244 | 7318 |
"output an audible beep or bell on my screen device" |
7319 |
||
3880 | 7320 |
UserPreferences current beepInEditor ifTrue:[ |
7321 |
super beep |
|
7322 |
] |
|
7323 |
! |
|
7324 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7325 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7326 |
"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
|
7327 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7328 |
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
|
7329 |
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
|
7330 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7331 |
self isReadOnly ifTrue: [ |
4823 | 7332 |
exceptionBlock isNil ifTrue:[ |
7333 |
^ false |
|
7334 |
]. |
|
7335 |
||
7336 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7337 |
^ false |
|
7338 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7339 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7340 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7341 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7342 |
"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
|
7343 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7344 |
|
2596 | 7345 |
currentSelectionBgColor |
7346 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7347 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7348 |
]. |
5216 | 7349 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 7350 |
^ super currentSelectionBgColor |
7351 |
||
7352 |
" |
|
7353 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7354 |
" |
|
7355 |
! |
|
7356 |
||
7357 |
currentSelectionFgColor |
|
7358 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7359 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7360 |
]. |
7361 |
^ super currentSelectionFgColor |
|
7362 |
! |
|
7363 |
||
3996 | 7364 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7365 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7366 |
|
7367 |
super resetVariablesBeforeNewSearch. |
|
7368 |
||
7369 |
"/ new search invalidates remembered string |
|
4048 | 7370 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7371 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7372 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7373 |
! |
7374 |
||
4053 | 7375 |
setLastStringToReplace: aString |
7376 |
||
7377 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7378 |
||
7379 |
|lastReplaceIgnoredCase| |
|
7380 |
||
4064 | 7381 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7382 |
self clearSearchAction. |
|
7383 |
||
4053 | 7384 |
lastReplacementInfo lastStringToReplace: aString. |
7385 |
lastStringFromReplaceForNextSearch := aString. |
|
7386 |
||
7387 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7388 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7389 |
ifTrue: [lastSearchIgnoredCase] |
|
7390 |
ifFalse: [nil]. |
|
4053 | 7391 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7392 |
! |
|
7393 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7394 |
st80EditMode |
5255 | 7395 |
"If on, the cursor wraps at the line end (like in vi or st80); |
7396 |
if off, we have the Rand-editor behavior (random access)" |
|
7397 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7398 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7399 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7400 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7401 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7402 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7403 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7404 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7405 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7406 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7407 |
textChanged |
522 | 7408 |
"my text was modified (internally). |
7409 |
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
|
7410 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7411 |
is used to notify scrollers, other views etc.). |
7412 |
||
7413 |
As some authors of this code have been very sloppy in tha past |
|
7414 |
(not sending contentsChanged, but textChanged), |
|
7415 |
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
|
7416 |
|
641 | 7417 |
self contentsChanged. |
1015 | 7418 |
self modified:true. |
5525 | 7419 |
self changed:#textChanged. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7420 |
contentsWasSaved := false |
641 | 7421 |
|
1015 | 7422 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7423 |
! |
7424 |
||
2617 | 7425 |
textChangedButNoSizeChange |
2207 | 7426 |
"my text was modified (internally). |
7427 |
Sent whenever text has been edited (not to confuse with |
|
7428 |
contentsChanged, which is triggered when the size has changed, and |
|
7429 |
is used to notify scrollers, other views etc.)" |
|
7430 |
||
7431 |
self modified:true. |
|
7432 |
contentsWasSaved := false |
|
7433 |
||
7434 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7435 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7436 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7437 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7438 |
|
5216 | 7439 |
canAccept |
7440 |
"true if text can be accepts. |
|
7441 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7442 |
||
7443 |
^ acceptEnabled ~~ false |
|
7444 |
! |
|
7445 |
||
7446 |
canCut |
|
7447 |
"true if there is a selection possibly to be cut. |
|
7448 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7449 |
||
7450 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7451 |
^ self hasSelection |
|
7452 |
! |
|
7453 |
||
7454 |
canDoAgain |
|
7455 |
"true if there is a possible repeat last edit operation. |
|
7456 |
Used to disable the menu if there is nothing" |
|
7457 |
||
7458 |
|lastStringToReplace| |
|
7459 |
||
7460 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7461 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
7462 |
^ lastStringToReplace notNil |
|
7463 |
! |
|
7464 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7465 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7466 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7467 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7468 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7469 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7470 |
"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
|
7471 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7472 |
|
4064 | 7473 |
hasSearchActionSelection |
7474 |
||
7475 |
^ typeOfSelection == #searchAction |
|
7476 |
! |
|
7477 |
||
1878 | 7478 |
isKeyboardConsumer |
7479 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 7480 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 7481 |
|
3476 | 7482 |
^ self isReadOnly not |
1878 | 7483 |
! |
7484 |
||
997 | 7485 |
specClass |
1390 | 7486 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7487 |
||
997 | 7488 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7489 |
^ super specClass |
7490 |
||
1390 | 7491 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7492 |
! |
7493 |
||
324 | 7494 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7495 |
"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
|
7496 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7497 |
"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
|
7498 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7499 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7500 |
|
7501 |
"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
|
7502 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7503 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7504 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7505 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7506 |
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
|
7507 |
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
|
7508 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7509 |
|
697 | 7510 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7511 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7512 |
w := super widthOfContents. |
5643 | 7513 |
(dev := device ) isNil ifTrue:[ |
4889 | 7514 |
"/ really don't know ... |
4823 | 7515 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7516 |
]. |
4889 | 7517 |
^ w + (gc font widthOn:dev) |
697 | 7518 |
|
7519 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7520 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7521 |
|
1588 | 7522 |
!EditTextView methodsFor:'realization'! |
7523 |
||
7524 |
realize |
|
7525 |
"make the view visible - scroll to make the cursor visible." |
|
7526 |
||
7527 |
super realize. |
|
7528 |
||
7529 |
self makeCursorVisible. |
|
5643 | 7530 |
cursorFgColor := cursorFgColor onDevice:device. |
7531 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 7532 |
|
7533 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7534 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7535 |
! ! |
|
7536 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7537 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7538 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7539 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7540 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7541 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7542 |
cursorShown ifTrue:[ |
4823 | 7543 |
cursorVisibleLine notNil ifTrue:[ |
7544 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7545 |
self drawCursorCharacter |
|
7546 |
] |
|
7547 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7548 |
] |
105 | 7549 |
! |
7550 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7551 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7552 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7553 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7554 |
cursorShown ifTrue:[ |
4823 | 7555 |
(visLine == cursorVisibleLine) ifTrue:[ |
7556 |
self drawCursorCharacter |
|
7557 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7558 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7559 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7560 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7561 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7562 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7563 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7564 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7565 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7566 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7567 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7568 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7569 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7570 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7571 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7572 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7573 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7574 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7575 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7576 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7577 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7578 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7579 |
cursorShown ifTrue:[ |
4823 | 7580 |
(visLine == cursorVisibleLine) ifTrue:[ |
7581 |
(colNr == cursorCol) ifTrue:[ |
|
7582 |
self drawCursorCharacter. |
|
7583 |
^ self |
|
7584 |
] |
|
7585 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7586 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7587 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7588 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7589 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7590 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7591 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7592 |
"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
|
7593 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7594 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7595 |
cursorShown ifTrue:[ |
7596 |
self redrawCursorIfInVisibleLine:visLine |
|
7597 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7598 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7599 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7600 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7601 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7602 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7603 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7604 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7605 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7606 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7607 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7608 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7609 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7610 |
"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
|
7611 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7612 |
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
|
7613 |
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
|
7614 |
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
|
7615 |
|
4889 | 7616 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7617 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7618 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7619 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7620 |
"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
|
7621 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7622 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7623 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7624 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7625 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7626 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7627 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7628 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7629 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7630 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7631 |
"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
|
7632 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7633 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7634 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7635 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7636 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7637 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7638 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7639 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7640 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7641 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7642 |
"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
|
7643 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7644 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7645 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7646 |
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
|
7647 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7648 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7649 |
prevCursorState ifTrue:[ |
4823 | 7650 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7651 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7652 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7653 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7654 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7655 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7656 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7657 |
"sent before scrolling - have to hide the cursor" |
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 |
prevCursorState := cursorShown. |
1601 | 7660 |
"/ cursorShown := false. |
1591 | 7661 |
cursorShown ifTrue:[ |
4823 | 7662 |
self hideCursor |
1591 | 7663 |
] |
7664 |
||
1601 | 7665 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
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 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7669 |
"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
|
7670 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7671 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7672 |
|prevCursorLine| |
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 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7675 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7676 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7677 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7678 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7679 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7680 |
"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
|
7681 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7682 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7683 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7684 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7685 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7686 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7687 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7688 |
! ! |
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 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7691 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7692 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7693 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7694 |
|
2822 | 7695 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 7696 |
! |
7697 |
||
7698 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
7699 |
"do a backward search" |
|
7700 |
||
7701 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
7702 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 7703 |
! |
7704 |
||
7705 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7706 |
"do a backward search" |
|
7707 |
||
7708 |
cursorLine isNil ifTrue:[^ self]. |
|
7709 |
||
3160 | 7710 |
self |
4119 | 7711 |
searchBackwardFor:pattern |
7712 |
ignoreCase:ign |
|
7713 |
startingAtLine:startLine col:startCol |
|
7714 |
ifFound:[:line :col | |
|
7715 |
self cursorMovementAllowed ifTrue:[ |
|
7716 |
self cursorLine:line col:col. |
|
7717 |
]. |
|
7718 |
self showMatch:pattern isMatch:false atLine:line col:col. |
|
1339 | 7719 |
"/ self makeLineVisible:cursorLine |
4119 | 7720 |
typeOfSelection := #search] |
7721 |
ifAbsent:aBlock |
|
1339 | 7722 |
|
7723 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7726 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7727 |
"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
|
7728 |
|
2554 | 7729 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7730 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7731 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7732 |
searchForMatchingParenthesis |
3160 | 7733 |
"search for a matching parenthesis starting at cursor position. |
7734 |
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
|
7735 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7736 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7737 |
|
2822 | 7738 |
self cursorMovementAllowed ifFalse:[^ self]. |
7739 |
||
3160 | 7740 |
self |
4823 | 7741 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
7742 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
7743 |
ifNotFound:[self showNotFound] |
|
7744 |
onError:[self beep] |
|
1339 | 7745 |
|
7746 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7747 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7748 |
|
3967 | 7749 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 7750 |
"do a forward search" |
7751 |
||
7752 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 7753 |
self |
7754 |
searchForwardFor:pattern |
|
7755 |
ignoreCase:ign |
|
7756 |
match: match |
|
7757 |
startingAtLine:startLine col:startCol |
|
7758 |
ifFound:[:line :col | |
|
7759 |
self cursorMovementAllowed ifTrue:[ |
|
7760 |
self cursorLine:line col:col. |
|
7761 |
]. |
|
4119 | 7762 |
self showMatch:pattern isMatch:match atLine:line col:col. |
1339 | 7763 |
"/ self makeLineVisible:cursorLine |
3967 | 7764 |
typeOfSelection := #search |
7765 |
] |
|
7766 |
ifAbsent:aBlock |
|
1339 | 7767 |
|
7768 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
7769 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7770 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7771 |
|
3967 | 7772 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
7773 |
"do a forward search" |
|
7774 |
||
7775 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
7776 |
! |
|
7777 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7778 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7779 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7780 |
|
2822 | 7781 |
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
|
7782 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7783 |
|
3982 | 7784 |
searchPatternForSearchBar |
7785 |
||
7786 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
7787 |
||
7788 |
|searchPattern| |
|
7789 |
||
4138 | 7790 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 7791 |
searchPattern isNil |
7792 |
ifTrue: [searchPattern := lastSearchPattern] |
|
7793 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
7794 |
^ searchPattern |
|
7795 |
! |
|
7796 |
||
3578 | 7797 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7798 |
"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
|
7799 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7800 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7801 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7802 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7803 |
"/ |
3967 | 7804 |
"/ 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
|
7805 |
"/ original string (for search after again) |
4121 | 7806 |
"/ 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
|
7807 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7808 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7809 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7810 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7811 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7812 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7813 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7814 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7815 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7816 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7817 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7818 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7819 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7820 |
"/ 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
|
7821 |
"/ if there was a previous search, only take the selection if |
3967 | 7822 |
"/ 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
|
7823 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7824 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7825 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7826 |
sel notNil ifTrue:[ |
3967 | 7827 |
(lastSearchPattern isNil |
4484 | 7828 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
7829 |
) ifTrue:[ |
|
3967 | 7830 |
self cursorLine:selectionStartLine col:selectionStartCol. |
7831 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
7832 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
7833 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7834 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
7835 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
7836 |
"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
|
7837 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7838 |
|
4484 | 7839 |
showMatch:pattern isMatch:isMatch atLine:line col:col |
7840 |
super showMatch:pattern isMatch:isMatch atLine:line col:col. |
|
7841 |
typeOfSelection := #search. |
|
7842 |
! |
|
7843 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7844 |
startPositionForSearchBackward |
2822 | 7845 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
7846 |
! |
|
7847 |
||
7848 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7849 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7850 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7851 |
selectionStartLine notNil ifTrue:[ |
4823 | 7852 |
startLine := selectionStartLine. |
7853 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7854 |
] ifFalse:[ |
4823 | 7855 |
cursorLine isNil ifTrue:[ |
7856 |
startLine := list size. |
|
7857 |
startCol := self listAt:startLine size. |
|
7858 |
] ifFalse:[ |
|
7859 |
startLine := cursorLine min:list size. |
|
7860 |
startCol := cursorCol |
|
7861 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7862 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7863 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7864 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7865 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7866 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7867 |
startPositionForSearchForward |
2822 | 7868 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
7869 |
! |
|
7870 |
||
7871 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7872 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7873 |
|
3160 | 7874 |
"/ 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
|
7875 |
"/ 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
|
7876 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7877 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7878 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7879 |
] ifFalse:[ |
4064 | 7880 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
7881 |
startCol := 0 |
|
7882 |
]. |
|
7883 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7884 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7885 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
7886 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7887 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
7888 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7889 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7890 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7891 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7892 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7893 |
addToSelectionAfter:aBlock |
5145 | 7894 |
<resource: #obsolete> |
7895 |
||
7896 |
"evaluate aBlock while unselected. |
|
7897 |
Restore the previous selection afterwards. |
|
7898 |
CG: I am not sure, if this is a leftover and is still used at all. |
|
7899 |
It is therefore temporarily marked as obsolete. Please check |
|
7900 |
and let me know." |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7901 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7902 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7903 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7904 |
self hasSelection ifTrue: [ |
4823 | 7905 |
startLine := selectionStartLine . |
7906 |
startCol := selectionStartCol . |
|
7907 |
endLine := selectionEndLine . |
|
7908 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7909 |
] ifFalse: [ |
4823 | 7910 |
startLine := endLine := cursorLine . |
7911 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7912 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7913 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7914 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7915 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7916 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7917 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7918 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7919 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
4823 | 7920 |
ifTrue: [ |
7921 |
startCol := cursorCol. |
|
7922 |
] ifFalse: [ |
|
7923 |
endCol := cursorCol - 1. |
|
7924 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7925 |
self selectFromLine:startLine col:startCol toLine: endLine col:endCol . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7926 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
7927 |
|
1850 | 7928 |
autoMoveCursorToEndOfSelection |
7929 |
"return true, if the cursor should be automatically moved to the |
|
7930 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
7931 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 7932 |
not be affected by selecting" |
7933 |
||
7934 |
^ true |
|
7935 |
! |
|
7936 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7937 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7938 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 7939 |
typeOfSelection := newType. |
7940 |
selectionStartLine notNil ifTrue:[ |
|
7941 |
self |
|
7942 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
7943 |
toLine:selectionEndLine col:selectionEndCol |
|
7944 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7945 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7946 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
7947 |
|
4707 | 7948 |
findNextWordAfterSelectionAndAddToSelection |
7949 |
|selStartCol selStartLine selEndCol selEndLine| |
|
7950 |
||
7951 |
selectionStartCol isNil ifTrue:[ |
|
7952 |
self selectWordUnderCursor. |
|
7953 |
^ self |
|
7954 |
]. |
|
7955 |
||
7956 |
selStartCol := selectionStartCol. |
|
7957 |
selEndCol := selectionEndCol. |
|
7958 |
selStartLine := selectionStartLine. |
|
7959 |
selEndLine := selectionEndLine. |
|
7960 |
||
7961 |
self cursorToNextWord. |
|
7962 |
self selectWordUnderCursor. |
|
7963 |
||
7964 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
7965 |
! |
|
7966 |
||
4138 | 7967 |
searchPatternFromUserSelectionOrReplace |
7968 |
||
7969 |
|sel searchPattern| |
|
7970 |
||
7971 |
"/ |
|
7972 |
"/ if the last operation was a replace, set pattern to last |
|
7973 |
"/ original string (for search after again) |
|
7974 |
"/ |
|
7975 |
(lastStringFromReplaceForNextSearch notNil |
|
7976 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
7977 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
7978 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
7979 |
] ifFalse:[ |
|
7980 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
7981 |
]. |
|
7982 |
^ searchPattern |
|
7983 |
]. |
|
7984 |
||
7985 |
"/ |
|
7986 |
"/ if there is a selection: |
|
7987 |
"/ if there was no previous search, take it as search pattern. |
|
7988 |
"/ if there was a previous search, only take the selection if |
|
7989 |
"/ it did not result from a paste. |
|
7990 |
"/ (to allow search-paste to be repeated) |
|
7991 |
"/ |
|
7992 |
sel := self selection. |
|
7993 |
sel notNil ifTrue:[ |
|
7994 |
typeOfSelection ~~ #search ifTrue:[ |
|
7995 |
typeOfSelection ~~ #paste ifTrue:[ |
|
7996 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
7997 |
searchPattern := sel asStringWithoutFinalCR. |
|
7998 |
] |
|
7999 |
]. |
|
8000 |
]. |
|
8001 |
||
8002 |
^ searchPattern |
|
8003 |
! |
|
8004 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8005 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8006 |
"select the whole text. |
5593 | 8007 |
redefined to send super selectFrom... since we don't want the |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8008 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8009 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8010 |
list isNil ifTrue:[ |
4823 | 8011 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8012 |
] ifFalse:[ |
4823 | 8013 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8014 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8015 |
] |
1082 | 8016 |
|
8017 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8018 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8019 |
|
4117 | 8020 |
selectAllInitially |
8021 |
"select the whole text. This is called only once during the initialization |
|
8022 |
for editFields which are shown in a table or tree. |
|
8023 |
The selectAll is called via this method to allow for easier redefinition and |
|
8024 |
to distinguish auto-select from user-initiated selects." |
|
8025 |
||
8026 |
self selectAll |
|
8027 |
! |
|
8028 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8029 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8030 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8031 |
|
3160 | 8032 |
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
|
8033 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8034 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8035 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8036 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8037 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8038 |
cursorCol > 1 ifTrue:[ |
4823 | 8039 |
self selectFromLine:cursorLine col:1 |
8040 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8041 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8042 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8043 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8044 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8045 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8046 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8047 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8048 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8049 |
selectionStartLine isNil ifTrue:[ |
4823 | 8050 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8051 |
] ifFalse:[ |
4823 | 8052 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8053 |
toLine:cursorLine+1 col:0. |
|
8054 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8055 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8056 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8057 |
|
4257 | 8058 |
selectFromBeginOfLine |
8059 |
"select the text from the beginning of the current line to the current cursor position." |
|
8060 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8061 |
| newCursorCol ln | |
4271 | 8062 |
|
4257 | 8063 |
list isNil ifTrue:[ |
8064 |
self unselect |
|
8065 |
] ifFalse:[ |
|
8066 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8067 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8068 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 8069 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
8070 |
cursorCol := newCursorCol. |
|
4257 | 8071 |
typeOfSelection := nil |
8072 |
] |
|
8073 |
] |
|
8074 |
||
8075 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8076 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8077 |
! |
8078 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8079 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8080 |
"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
|
8081 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8082 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8083 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8084 |
list isNil ifTrue:[ |
4823 | 8085 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8086 |
] ifFalse:[ |
4823 | 8087 |
cursorCol == 0 ifTrue:[ |
8088 |
col := 0 |
|
8089 |
] ifFalse:[ |
|
8090 |
col := cursorCol - 1 |
|
8091 |
]. |
|
8092 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8093 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8094 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8095 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8096 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8097 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8098 |
"when a range is selected, position the cursor behind the selection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8099 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8100 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8101 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 8102 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
4823 | 8103 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 8104 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8105 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8106 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8107 |
|
4257 | 8108 |
selectToEndOfLine |
8109 |
"select the text from the current cursor position to the end of the current line" |
|
8110 |
||
4271 | 8111 |
| newCursorCol line | |
8112 |
||
4257 | 8113 |
list isNil ifTrue:[ |
8114 |
self unselect |
|
8115 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
8116 |
cursorCol >= 1 ifTrue:[ |
4271 | 8117 |
line := list at: cursorLine. |
8118 |
newCursorCol := line size. |
|
8119 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8120 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8121 |
||
8122 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
8123 |
cursorCol := newCursorCol. |
|
4257 | 8124 |
typeOfSelection := nil |
8125 |
] |
|
8126 |
] |
|
8127 |
||
8128 |
"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
|
8129 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8130 |
! |
8131 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8132 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8133 |
"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
|
8134 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8135 |
list isNil ifTrue:[ |
4823 | 8136 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8137 |
] ifFalse:[ |
4823 | 8138 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8139 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8140 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8141 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8142 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8143 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8144 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8145 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8146 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8147 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8148 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8149 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8150 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8151 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8152 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8153 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8154 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8155 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8156 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8157 |
wasOn ifTrue:[self showCursor] |
105 | 8158 |
! ! |
8159 |
||
8160 |
!EditTextView methodsFor:'undo & again'! |
|
8161 |
||
2952 | 8162 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8163 |
^ undoSupport addUndo:action. |
2952 | 8164 |
! |
8165 |
||
105 | 8166 |
again |
8167 |
"repeat the last action (which was a cut or replace). |
|
8168 |
If current selection is not last string, search forward to |
|
3160 | 8169 |
next occurrence of it before repeating the last operation." |
105 | 8170 |
|
4048 | 8171 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8172 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8173 |
|
8174 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8175 |
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
|
8176 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8177 |
]. |
4048 | 8178 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8179 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8180 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8181 |
self undoableDo:[ |
4010 | 8182 |
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
|
8183 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8184 |
(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
|
8185 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8186 |
|
4053 | 8187 |
"set lastStringToReplace as the next search string |
8188 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8189 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8190 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8191 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8192 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8193 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8194 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8195 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8196 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8197 |
"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
|
8198 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8199 |
(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
|
8200 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8201 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8202 |
self deleteSelection. |
4051 | 8203 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8204 |
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
|
8205 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8206 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8207 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8208 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8209 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8210 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8211 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8212 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8213 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8214 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8215 |
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
|
8216 |
]. |
4048 | 8217 |
self |
8218 |
searchForwardFor:s |
|
8219 |
ignoreCase: lastReplaceIgnoredCase |
|
8220 |
match: lastReplaceWasMatch |
|
8221 |
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
|
8222 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8223 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8224 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8225 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8226 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8227 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8228 |
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
|
8229 |
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
|
8230 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8231 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8232 |
self deleteSelection. |
4051 | 8233 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8234 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8235 |
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
|
8236 |
] ifTrue:[ |
4051 | 8237 |
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
|
8238 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8239 |
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
|
8240 |
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
|
8241 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8242 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8243 |
selectStyle := savedSelectStyle. |
4484 | 8244 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8245 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8246 |
] |
4048 | 8247 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8248 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8249 |
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
|
8250 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8251 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8252 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8253 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8254 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8255 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8256 |
^ true. |
501 | 8257 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8258 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8259 |
! |
8260 |
||
2952 | 8261 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8262 |
^ undoSupport hasRedoAction. |
2952 | 8263 |
! |
8264 |
||
8265 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8266 |
^ undoSupport hasUndoAction. |
2952 | 8267 |
! |
8268 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8269 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8270 |
"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
|
8271 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8272 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8273 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8274 |
|
2952 | 8275 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8276 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8277 |
! |
8278 |
||
8279 |
redo |
|
3780 | 8280 |
"undo the last undo" |
8281 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8282 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8283 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8284 |
] ifTrue:[ |
3780 | 8285 |
undoSupport redo. |
2952 | 8286 |
] |
8287 |
! |
|
8288 |
||
121 | 8289 |
undo |
3780 | 8290 |
"undo the last edit operation" |
8291 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8292 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 8293 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8294 |
] ifTrue:[ |
3780 | 8295 |
undoSupport undo. |
121 | 8296 |
] |
2952 | 8297 |
! |
8298 |
||
8299 |
undoableDo:aBlock |
|
3495 | 8300 |
self undoableDo:aBlock info:nil. |
8301 |
||
8302 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8303 |
! |
8304 |
||
8305 |
undoableDo:aBlock info:aString |
|
5689 | 8306 |
|selectionRestore| |
8307 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8308 |
self checkModificationsAllowed ifFalse:[ |
4823 | 8309 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8310 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8311 |
] ifTrue:[ |
5689 | 8312 |
undoSupport isInTransaction ifFalse:[ |
8313 |
selectionRestore := RestoreSelectionAndCursor new |
|
8314 |
cursorLine:cursorLine cursorCol:cursorCol |
|
8315 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
8316 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
8317 |
info:nil. |
|
8318 |
]. |
|
8319 |
undoSupport |
|
8320 |
undoableDo:[ |
|
8321 |
aBlock value. |
|
8322 |
selectionRestore notNil ifTrue:[ |
|
8323 |
undoSupport transactionNotEmpty ifTrue:[ |
|
8324 |
undoSupport addUndoFirst:selectionRestore |
|
8325 |
]. |
|
8326 |
]. |
|
8327 |
] |
|
8328 |
info:aString. |
|
8329 |
]. |
|
8330 |
||
8331 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 8332 |
! ! |
8333 |
||
8334 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8335 |
||
8336 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8337 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8338 |
! |
|
8339 |
||
3115 | 8340 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8341 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8342 |
! |
8343 |
||
2952 | 8344 |
line:arg1 col:arg2 character:arg3 |
8345 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8346 |
! |
|
8347 |
||
3115 | 8348 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8349 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8350 |
! |
8351 |
||
3235 | 8352 |
line:arg1 col:arg2 characters:arg3 info:info |
8353 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8354 |
! |
|
8355 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8356 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8357 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8358 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8359 |
|
2952 | 8360 |
line:arg1 col:arg2 string:arg3 |
8361 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8362 |
! |
8363 |
||
8364 |
line:arg1 col:arg2 string:arg3 info:info |
|
8365 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8366 |
! |
8367 |
||
8368 |
line:arg1 string:arg3 info:info |
|
8369 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8370 |
! |
8371 |
||
8372 |
text:arg info:info |
|
8373 |
^ (self new text:arg) info:info |
|
3115 | 8374 |
! ! |
8375 |
||
8376 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8377 |
||
8378 |
info |
|
8379 |
^ userFriendlyInfo |
|
8380 |
! |
|
8381 |
||
8382 |
info:aString |
|
8383 |
userFriendlyInfo := aString |
|
2952 | 8384 |
! ! |
8385 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8386 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8387 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8388 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8389 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8390 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8391 |
"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
|
8392 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8393 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8394 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8395 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8396 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8397 |
^ false |
5710 | 8398 |
! |
8399 |
||
8400 |
isRestoreSelectionAndCursor |
|
8401 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8402 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8403 |
|
2952 | 8404 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8405 |
||
3160 | 8406 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8407 |
"set instance variables (automatically generated)" |
8408 |
||
8409 |
self assert:(line1Arg notNil). |
|
8410 |
self assert:(col1Arg notNil). |
|
8411 |
self assert:(line2Arg notNil). |
|
8412 |
self assert:(col2Arg notNil). |
|
8413 |
||
8414 |
line1 := line1Arg. |
|
8415 |
col1 := col1Arg. |
|
8416 |
line2 := line2Arg. |
|
8417 |
col2 := col2Arg. |
|
8418 |
! ! |
|
8419 |
||
8420 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8421 |
||
3160 | 8422 |
executeIn:editor |
2952 | 8423 |
editor unselect. |
3160 | 8424 |
editor |
4823 | 8425 |
deleteFromLine:line1 |
8426 |
col:col1 |
|
8427 |
toLine:line2 |
|
8428 |
col:col2. |
|
2952 | 8429 |
editor cursorLine:line1 col:col1. |
8430 |
! ! |
|
8431 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8432 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8433 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8434 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8435 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8436 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8437 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8438 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8439 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8440 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8441 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8442 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8443 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8444 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8445 |
|
3160 | 8446 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8447 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8448 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8449 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8450 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8451 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8452 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8453 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8454 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8455 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8456 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8457 |
|
3160 | 8458 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8459 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8460 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8461 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8462 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8463 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8464 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8465 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8466 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8467 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8468 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8469 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8470 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8471 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8472 |
|
3160 | 8473 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8474 |
"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
|
8475 |
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
|
8476 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8477 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8478 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8479 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8480 |
^ true |
|
8481 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8482 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8483 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8484 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8485 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8486 |
|
3160 | 8487 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8488 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8489 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8490 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8491 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8492 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8493 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8494 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8495 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8496 |
|
3160 | 8497 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8498 |
editor unselect. |
3160 | 8499 |
editor |
4823 | 8500 |
deleteFromLine:line |
8501 |
col:col1 |
|
8502 |
toLine:line |
|
8503 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8504 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8505 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8506 |
|
3235 | 8507 |
!EditTextView::EditMode class methodsFor:'constants'! |
8508 |
||
8509 |
insertAndSelectMode |
|
8510 |
^ InsertAndSelectMode |
|
8511 |
! |
|
8512 |
||
8513 |
insertMode |
|
8514 |
^ InsertMode |
|
8515 |
! |
|
8516 |
||
8517 |
overwriteMode |
|
8518 |
^ OverwriteMode |
|
8519 |
! ! |
|
8520 |
||
8521 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8522 |
||
8523 |
isInsertAndSelectMode |
|
8524 |
^ false |
|
8525 |
! |
|
8526 |
||
8527 |
isInsertMode |
|
8528 |
^ false |
|
8529 |
! |
|
8530 |
||
8531 |
symbolicName |
|
8532 |
self subclassResponsibility |
|
8533 |
! ! |
|
8534 |
||
8535 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8536 |
||
8537 |
infoPrintString |
|
8538 |
^ 'IS' |
|
8539 |
! ! |
|
8540 |
||
8541 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8542 |
||
8543 |
isInsertAndSelectMode |
|
8544 |
^ true |
|
8545 |
! |
|
8546 |
||
8547 |
isInsertMode |
|
8548 |
^ true |
|
8549 |
! ! |
|
8550 |
||
8551 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8552 |
||
8553 |
infoPrintString |
|
8554 |
^ 'I' |
|
8555 |
! ! |
|
8556 |
||
8557 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8558 |
||
8559 |
isInsertMode |
|
8560 |
^ true |
|
8561 |
! ! |
|
8562 |
||
8563 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8564 |
||
8565 |
infoPrintString |
|
8566 |
^ 'O' |
|
8567 |
! ! |
|
8568 |
||
4048 | 8569 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8570 |
||
8571 |
lastReplaceIgnoredCase |
|
8572 |
^ lastReplaceIgnoredCase ? false |
|
8573 |
! |
|
8574 |
||
8575 |
lastReplaceIgnoredCase:something |
|
8576 |
lastReplaceIgnoredCase := something. |
|
8577 |
! |
|
8578 |
||
8579 |
lastReplaceWasMatch |
|
8580 |
^ lastReplaceWasMatch ? false |
|
8581 |
! |
|
8582 |
||
8583 |
lastReplaceWasMatch:something |
|
8584 |
lastReplaceWasMatch := something. |
|
8585 |
! |
|
8586 |
||
8587 |
lastReplacement |
|
8588 |
^ lastReplacement |
|
8589 |
! |
|
8590 |
||
8591 |
lastReplacement:something |
|
4053 | 8592 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8593 |
lastReplacement := something. |
8594 |
! |
|
8595 |
||
8596 |
lastStringToReplace |
|
8597 |
^ lastStringToReplace |
|
8598 |
! |
|
8599 |
||
8600 |
lastStringToReplace:something |
|
8601 |
lastStringToReplace := something. |
|
4818 | 8602 |
! |
8603 |
||
8604 |
previousReplacements |
|
8605 |
^ previousReplacements ? #() |
|
8606 |
! |
|
8607 |
||
8608 |
stillCollectingInput |
|
8609 |
^ stillCollectingInput |
|
8610 |
! |
|
8611 |
||
8612 |
stillCollectingInput:aBoolean |
|
8613 |
stillCollectingInput := aBoolean. |
|
8614 |
! ! |
|
8615 |
||
8616 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
8617 |
||
8618 |
rememberReplacement |
|
8619 |
"remember the previous replacement (called when a new one appears). |
|
8620 |
Mostly for the benefit of the code completion..." |
|
8621 |
||
8622 |
|oldString newString| |
|
8623 |
||
8624 |
oldString := lastStringToReplace. |
|
8625 |
newString := lastReplacement. |
|
8626 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
8627 |
previousReplacements isNil ifTrue:[ |
|
8628 |
previousReplacements := OrderedCollection new. |
|
8629 |
]. |
|
8630 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
8631 |
previousReplacements addFirst:(oldString -> newString). |
|
8632 |
previousReplacements size > 20 ifTrue:[ |
|
8633 |
previousReplacements removeLast. |
|
8634 |
] |
|
8635 |
]. |
|
4048 | 8636 |
! ! |
8637 |
||
2952 | 8638 |
!EditTextView::PasteString methodsFor:'accessing'! |
8639 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8640 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8641 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8642 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8643 |
"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
|
8644 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8645 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8646 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8647 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8648 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8649 |
"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
|
8650 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8651 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8652 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8653 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8654 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8655 |
"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
|
8656 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8657 |
|
3160 | 8658 |
line:lineArg col:colArg string:stringArg |
2952 | 8659 |
self assert:(lineArg notNil). |
8660 |
self assert:(colArg notNil). |
|
8661 |
self assert:(stringArg notNil). |
|
8662 |
||
8663 |
line := lineArg. |
|
8664 |
col := colArg. |
|
8665 |
string := stringArg. |
|
8666 |
! |
|
8667 |
||
8668 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
8669 |
self assert:(lineArg notNil). |
|
8670 |
self assert:(colArg notNil). |
|
8671 |
self assert:(stringArg notNil). |
|
8672 |
||
8673 |
line := lineArg. |
|
8674 |
col := colArg. |
|
8675 |
string := stringArg. |
|
8676 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8677 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8678 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8679 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8680 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8681 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8682 |
"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
|
8683 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8684 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8685 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8686 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8687 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8688 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8689 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8690 |
"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
|
8691 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8692 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8693 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8694 |
"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
|
8695 |
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
|
8696 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8697 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8698 |
previousPasteAction line == line ifTrue:[ |
4823 | 8699 |
previousPasteAction col == (self col2+1) ifTrue:[ |
8700 |
^ true |
|
8701 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8702 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8703 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8704 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8705 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8706 |
"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
|
8707 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8708 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8709 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8710 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8711 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8712 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8713 |
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
|
8714 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8715 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8716 |
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
|
8717 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8718 |
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
|
8719 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8720 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8721 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8722 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8723 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8724 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 8725 |
! ! |
8726 |
||
8727 |
!EditTextView::PasteString methodsFor:'execution'! |
|
8728 |
||
3160 | 8729 |
executeIn:editor |
2952 | 8730 |
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
|
8731 |
editor paste:string. |
2952 | 8732 |
selected ~~ true ifTrue:[ |
4823 | 8733 |
editor unselect |
2952 | 8734 |
]. |
8735 |
! ! |
|
8736 |
||
8737 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
8738 |
||
3235 | 8739 |
col |
8740 |
^ col |
|
8741 |
! |
|
8742 |
||
8743 |
col1 |
|
8744 |
^ col |
|
8745 |
! |
|
8746 |
||
8747 |
col2 |
|
8748 |
^ col |
|
8749 |
! |
|
8750 |
||
8751 |
line |
|
8752 |
^ line |
|
8753 |
! |
|
8754 |
||
3160 | 8755 |
line:lineArg col:colArg character:characterArg |
2952 | 8756 |
line := lineArg. |
8757 |
col := colArg. |
|
8758 |
character := characterArg. |
|
8759 |
! ! |
|
8760 |
||
8761 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
8762 |
||
3160 | 8763 |
executeIn:editor |
8764 |
editor |
|
4823 | 8765 |
replace:character |
8766 |
atLine:line |
|
8767 |
col:col. |
|
2952 | 8768 |
editor cursorLine:line col:col. |
105 | 8769 |
! ! |
8770 |
||
3235 | 8771 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
8772 |
||
8773 |
characters |
|
8774 |
^ characters |
|
8775 |
! |
|
8776 |
||
8777 |
col1 |
|
8778 |
^ col1 |
|
8779 |
! |
|
8780 |
||
8781 |
col2 |
|
8782 |
^ col2 |
|
8783 |
! |
|
8784 |
||
8785 |
line |
|
8786 |
^ line |
|
8787 |
! |
|
8788 |
||
8789 |
line:lineArg col:colArg character:characterArg |
|
8790 |
line := lineArg. |
|
8791 |
col1 := col2 := colArg. |
|
8792 |
characters := characterArg asString. |
|
8793 |
! |
|
8794 |
||
8795 |
line:lineArg col:colArg characters:charactersArg |
|
8796 |
line := lineArg. |
|
8797 |
col1 := colArg. |
|
8798 |
characters := charactersArg asString. |
|
8799 |
col2 := col1 + charactersArg size - 1 |
|
8800 |
! ! |
|
8801 |
||
8802 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
8803 |
||
8804 |
canCombineWithNext:anotherAction |
|
8805 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
8806 |
! |
|
8807 |
||
8808 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
8809 |
"I will combine only if we both are single character deletes, |
|
8810 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
8811 |
(i.e. single-character typing)" |
|
8812 |
||
8813 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 8814 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
8815 |
^ true |
|
8816 |
]. |
|
3235 | 8817 |
]. |
8818 |
||
8819 |
^ false |
|
8820 |
! |
|
8821 |
||
8822 |
combineWithNext:nextReplaceAction |
|
8823 |
self assert:(line == nextReplaceAction line). |
|
8824 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
8825 |
||
8826 |
col2 := nextReplaceAction col2. |
|
8827 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
8828 |
characters := characters , nextReplaceAction characters. |
|
8829 |
! ! |
|
8830 |
||
8831 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
8832 |
||
8833 |
executeIn:editor |
|
8834 |
editor |
|
4823 | 8835 |
replaceString:characters |
8836 |
atLine:line |
|
8837 |
col:col1. |
|
3235 | 8838 |
editor cursorLine:line col:col1. |
8839 |
! ! |
|
8840 |
||
3131 | 8841 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
8842 |
||
8843 |
text:something |
|
8844 |
text := something. |
|
8845 |
! ! |
|
8846 |
||
8847 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
8848 |
||
3160 | 8849 |
executeIn:editor |
3131 | 8850 |
editor contents:text |
8851 |
! ! |
|
8852 |
||
3130 | 8853 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
8854 |
||
3160 | 8855 |
line:lineArg string:stringArg |
3130 | 8856 |
line := lineArg. |
8857 |
text := stringArg. |
|
8858 |
! ! |
|
8859 |
||
8860 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
8861 |
||
3160 | 8862 |
executeIn:editor |
3130 | 8863 |
editor list at:line put:text. |
8864 |
editor invalidateLine:line |
|
8865 |
! ! |
|
8866 |
||
3402 | 8867 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
8868 |
||
8869 |
line:lineArg lines:lineCollectionArg |
|
8870 |
line := lineArg. |
|
8871 |
text := lineCollectionArg. |
|
8872 |
||
8873 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
8874 |
! ! |
|
8875 |
||
8876 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
8877 |
||
8878 |
executeIn:editor |
|
8879 |
|lnr| |
|
8880 |
||
8881 |
lnr := line. |
|
8882 |
text do:[:eachLine | |
|
4823 | 8883 |
editor list at:lnr put:eachLine. |
8884 |
editor invalidateLine:lnr. |
|
8885 |
lnr := lnr + 1. |
|
3402 | 8886 |
]. |
8887 |
||
8888 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
8889 |
! ! |
|
8890 |
||
5689 | 8891 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
8892 |
||
8893 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
8894 |
cursorLine := cursorLineArg. |
|
8895 |
cursorCol := cursorColArg. |
|
8896 |
selectionStartLine := selectionStartLineArg. |
|
8897 |
selectionStartCol := selectionStartColArg. |
|
8898 |
selectionEndLine := selectionEndLineArg. |
|
8899 |
selectionEndCol := selectionEndColArg. |
|
8900 |
! |
|
8901 |
||
8902 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
|
8903 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
|
8904 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
8905 |
info:info |
|
8906 |
||
8907 |
cursorLine := cursorLineArg. |
|
8908 |
cursorCol := cursorColArg. |
|
8909 |
selectionStartLine := selectionStartLineArg. |
|
8910 |
selectionStartCol := selectionStartColArg. |
|
8911 |
selectionEndLine := selectionEndLineArg. |
|
8912 |
selectionEndCol := selectionEndColArg. |
|
8913 |
userFriendlyInfo := info. |
|
8914 |
||
8915 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
8916 |
! ! |
|
8917 |
||
8918 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
8919 |
||
8920 |
executeIn:editor |
|
8921 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
8922 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
8923 |
editor setCursorLine:cursorLine col:cursorCol. |
|
8924 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
8925 |
] ifFalse:[ |
|
8926 |
editor cursorLine:cursorLine col:cursorCol. |
|
8927 |
]. |
|
8928 |
||
8929 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
8930 |
! ! |
|
8931 |
||
5710 | 8932 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
8933 |
||
8934 |
canCombineWithNext:anotherAction |
|
8935 |
^ true |
|
8936 |
! |
|
8937 |
||
8938 |
canCombineWithPreviousPasteStringAction:aPasteStringAction |
|
8939 |
^ true |
|
8940 |
! |
|
8941 |
||
8942 |
isRestoreSelectionAndCursor |
|
8943 |
^ true |
|
8944 |
! ! |
|
8945 |
||
865 | 8946 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8947 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8948 |
version |
5361 | 8949 |
^ '$Header$' |
3945 | 8950 |
! |
8951 |
||
8952 |
version_CVS |
|
5361 | 8953 |
^ '$Header$' |
0 | 8954 |
! ! |
4481 | 8955 |