author | Claus Gittinger <cg@exept.de> |
Sun, 24 Mar 2019 10:01:15 +0100 | |
changeset 6567 | bb0ac8be28cc |
parent 6564 | 60c2954e9dff |
child 6572 | 9cec05d7dbff |
permissions | -rw-r--r-- |
6567 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
6152 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
14 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
15 |
|
5239 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
TextView subclass:#EditTextView |
6154 | 19 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
20 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
21 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
22 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
23 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
24 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
25 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
26 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
27 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
28 |
undoSupport lastStringFromReplaceForNextSearch |
|
29 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
6227 | 30 |
classVariableNames:'DefaultCursorBackgroundColor DefaultCursorForegroundColor |
31 |
DefaultCursorNoFocusForegroundColor DefaultCursorType |
|
6517 | 32 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros |
33 |
CharacterInputViewSingleton' |
|
6154 | 34 |
poolDictionaries:'' |
35 |
category:'Views-Text' |
|
0 | 36 |
! |
37 |
||
2952 | 38 |
Object subclass:#EditAction |
6154 | 39 |
instanceVariableNames:'userFriendlyInfo' |
40 |
classVariableNames:'' |
|
41 |
poolDictionaries:'' |
|
42 |
privateIn:EditTextView |
|
2952 | 43 |
! |
44 |
||
45 |
EditTextView::EditAction subclass:#DeleteRange |
|
6154 | 46 |
instanceVariableNames:'line1 col1 line2 col2' |
47 |
classVariableNames:'' |
|
48 |
poolDictionaries:'' |
|
49 |
privateIn:EditTextView |
|
2952 | 50 |
! |
51 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
52 |
EditTextView::EditAction subclass:#DeleteCharacters |
6154 | 53 |
instanceVariableNames:'line col1 col2' |
54 |
classVariableNames:'' |
|
55 |
poolDictionaries:'' |
|
56 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
57 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
58 |
|
3235 | 59 |
Object subclass:#EditMode |
6154 | 60 |
instanceVariableNames:'' |
61 |
classVariableNames:'' |
|
62 |
poolDictionaries:'' |
|
63 |
privateIn:EditTextView |
|
3235 | 64 |
! |
65 |
||
66 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
6154 | 67 |
instanceVariableNames:'' |
68 |
classVariableNames:'' |
|
69 |
poolDictionaries:'' |
|
70 |
privateIn:EditTextView::EditMode |
|
3235 | 71 |
! |
72 |
||
73 |
EditTextView::EditMode subclass:#InsertMode |
|
6154 | 74 |
instanceVariableNames:'' |
75 |
classVariableNames:'' |
|
76 |
poolDictionaries:'' |
|
77 |
privateIn:EditTextView::EditMode |
|
3235 | 78 |
! |
79 |
||
80 |
EditTextView::EditMode subclass:#OverwriteMode |
|
6154 | 81 |
instanceVariableNames:'' |
82 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
83 |
poolDictionaries:'' |
|
84 |
privateIn:EditTextView::EditMode |
|
3235 | 85 |
! |
86 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
87 |
Query subclass:#ExecutingMacroQuery |
6154 | 88 |
instanceVariableNames:'' |
89 |
classVariableNames:'' |
|
90 |
poolDictionaries:'' |
|
91 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
92 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
93 |
|
4048 | 94 |
Object subclass:#LastReplacementInfo |
6154 | 95 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
96 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
97 |
classVariableNames:'' |
|
98 |
poolDictionaries:'' |
|
99 |
privateIn:EditTextView |
|
4048 | 100 |
! |
101 |
||
2952 | 102 |
EditTextView::EditAction subclass:#PasteString |
6154 | 103 |
instanceVariableNames:'line col string selected' |
104 |
classVariableNames:'' |
|
105 |
poolDictionaries:'' |
|
106 |
privateIn:EditTextView |
|
2952 | 107 |
! |
108 |
||
109 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
6154 | 110 |
instanceVariableNames:'line col character' |
111 |
classVariableNames:'' |
|
112 |
poolDictionaries:'' |
|
113 |
privateIn:EditTextView |
|
2952 | 114 |
! |
115 |
||
3235 | 116 |
EditTextView::EditAction subclass:#ReplaceCharacters |
6154 | 117 |
instanceVariableNames:'line col1 col2 characters' |
118 |
classVariableNames:'' |
|
119 |
poolDictionaries:'' |
|
120 |
privateIn:EditTextView |
|
3235 | 121 |
! |
122 |
||
3131 | 123 |
EditTextView::EditAction subclass:#ReplaceContents |
6154 | 124 |
instanceVariableNames:'text' |
125 |
classVariableNames:'' |
|
126 |
poolDictionaries:'' |
|
127 |
privateIn:EditTextView |
|
3131 | 128 |
! |
129 |
||
3130 | 130 |
EditTextView::EditAction subclass:#ReplaceLine |
6154 | 131 |
instanceVariableNames:'line text' |
132 |
classVariableNames:'' |
|
133 |
poolDictionaries:'' |
|
134 |
privateIn:EditTextView |
|
3130 | 135 |
! |
136 |
||
3402 | 137 |
EditTextView::EditAction subclass:#ReplaceLines |
6154 | 138 |
instanceVariableNames:'line text' |
139 |
classVariableNames:'' |
|
140 |
poolDictionaries:'' |
|
141 |
privateIn:EditTextView |
|
3402 | 142 |
! |
143 |
||
5689 | 144 |
EditTextView::EditAction subclass:#RestoreSelectionAndCursor |
6154 | 145 |
instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol |
146 |
selectionEndLine selectionEndCol' |
|
147 |
classVariableNames:'' |
|
148 |
poolDictionaries:'' |
|
149 |
privateIn:EditTextView |
|
5689 | 150 |
! |
151 |
||
865 | 152 |
!EditTextView class methodsFor:'documentation'! |
0 | 153 |
|
33 | 154 |
copyright |
155 |
" |
|
156 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
6152 | 157 |
All Rights Reserved |
33 | 158 |
|
159 |
This software is furnished under a license and may be used |
|
160 |
only in accordance with the terms of that license and with the |
|
161 |
inclusion of the above copyright notice. This software may not |
|
162 |
be provided or otherwise made available to, or used by, any |
|
163 |
other person. No title to or ownership of the software is |
|
164 |
hereby transferred. |
|
165 |
" |
|
166 |
! |
|
167 |
||
0 | 168 |
documentation |
169 |
" |
|
170 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 171 |
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
|
172 |
acceptAction to be performed for accept |
125 | 173 |
|
174 |
If used with a model, this is informed by sending it a changeMsg with |
|
175 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
176 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 177 |
|
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
|
178 |
Please read the historic notice in the ListView class. |
0 | 179 |
|
586 | 180 |
[Instance variables:] |
0 | 181 |
|
5988 | 182 |
cursorLine <Number> line where cursor sits (1..) |
183 |
||
184 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
185 |
||
186 |
cursorCol <Number> col where cursor sits (1..) |
|
187 |
||
188 |
cursorShown <Boolean> true, if cursor is currently shown |
|
189 |
||
190 |
readOnly <Boolean> true, if text may not be edited |
|
191 |
||
192 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
193 |
cleared on accept. |
|
194 |
||
195 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
196 |
||
197 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
198 |
||
199 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
200 |
if it returns true, the modification will be done anyway. |
|
201 |
if it returns anything else, the modification is not done. |
|
202 |
||
203 |
cursorFgColor <Color> color used for cursor drawing |
|
204 |
cursorBgColor <Color> color used for cursor drawing |
|
205 |
||
206 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
207 |
are #none, #block (solid-block cursor), #ibeam |
|
208 |
(vertical bar at insertion point) |
|
209 |
and #caret (caret below insertion-point). |
|
210 |
see cursorType: for an up-to-date list. |
|
211 |
||
212 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
213 |
nil means: hide the cursor. |
|
214 |
||
215 |
undoAction <Block> block which undoes last cut, paste or replace |
|
216 |
(not yet fully implemented) |
|
217 |
||
218 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
219 |
this affects the next keyPress: if #paste it does not |
|
220 |
replace; otherwise it replaces the selection. |
|
221 |
||
222 |
lastCut <String> last cut or replaced string |
|
223 |
||
224 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
|
225 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
226 |
lastReplacement is the string to replace lastStringToReplace |
|
227 |
||
228 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
229 |
(cleared after a new selection) |
|
230 |
||
231 |
replacing <Boolean> true if entered characters replace last selection |
|
232 |
||
233 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
234 |
when entering one; this is the default. |
|
235 |
||
236 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
237 |
||
238 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
239 |
argument |
|
240 |
||
241 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
242 |
focus to the next field. For editTextViews, this is false |
|
243 |
by default (i.e. tabs can be entered into the text). |
|
244 |
For some subclasses (inputFields), this may be true. |
|
245 |
||
246 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
247 |
removed when editing. |
|
248 |
Also, empty lines are represented as nil in the lines collection. |
|
249 |
Default is true. |
|
250 |
||
251 |
wordWrap <Boolean> Currently not used. |
|
252 |
||
253 |
lockUpdates <Boolean> internal, private |
|
254 |
||
255 |
prevCursorState <Boolean> temporary, private |
|
256 |
||
257 |
cursorMovementWhenUpdating |
|
258 |
<Symbol> defines where the cursor is to be positioned if the |
|
259 |
model changes its value by some outside activity |
|
260 |
(i.e. not by user input into the field). |
|
261 |
Can be one of: |
|
262 |
#keep / nil -> stay where it was |
|
263 |
#endOfText -> cursor to the end |
|
264 |
#endOfLine -> stay in the line, but move to end |
|
265 |
#beginOfText -> cursor to the beginning |
|
266 |
#beginOfLine -> stay in the line, but move to begin |
|
267 |
The default is #beginOfText |
|
268 |
||
269 |
||
270 |
||
271 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 272 |
|
273 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
274 |
userPreference values: |
5988 | 275 |
userPreferences.st80EditMode |
276 |
<Boolean> if true, cursor positioning is |
|
277 |
done as in vi or ST80; i.e. |
|
278 |
wysiwyg mode is somewhat relaxed, |
|
279 |
in that the cursor cannot be |
|
280 |
positioned behind a lines end. |
|
281 |
This is not yet completely implemented. |
|
33 | 282 |
used globals: |
283 |
||
5988 | 284 |
DeleteHistory <Text> last 1000 lines of deleted text |
285 |
(but only if this variable exists already) |
|
586 | 286 |
|
287 |
[styleSheet parameters:] |
|
121 | 288 |
|
5988 | 289 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
290 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
291 |
textCursorNoFocusForegroundColor |
|
292 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
293 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 294 |
|
295 |
[author:] |
|
5988 | 296 |
Claus Gittinger |
586 | 297 |
|
298 |
[see also:] |
|
5988 | 299 |
CodeView Workspace TextView ListView |
300 |
EditField |
|
0 | 301 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
302 |
! |
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 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
305 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
306 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
307 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
308 |
basic setup: |
6152 | 309 |
[exBegin] |
310 |
|top textView| |
|
311 |
||
312 |
top := StandardSystemView new. |
|
313 |
top extent:300@200. |
|
314 |
||
315 |
textView := EditTextView new. |
|
316 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
317 |
top addSubView:textView. |
|
318 |
||
319 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
320 |
||
321 |
top open. |
|
322 |
[exEnd] |
|
594 | 323 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
324 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
325 |
with vertical scrollbar: |
6152 | 326 |
[exBegin] |
327 |
|top scrollView textView| |
|
328 |
||
329 |
top := StandardSystemView new. |
|
330 |
top extent:300@200. |
|
331 |
||
332 |
scrollView := ScrollableView for:EditTextView. |
|
333 |
textView := scrollView scrolledView. |
|
334 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
335 |
top addSubView:scrollView. |
|
336 |
||
337 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
338 |
||
339 |
top open. |
|
340 |
[exEnd] |
|
594 | 341 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
342 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
343 |
with horizontal & vertical scrollbars: |
6152 | 344 |
[exBegin] |
345 |
|top scrollView textView| |
|
346 |
||
347 |
top := StandardSystemView new. |
|
348 |
top extent:300@200. |
|
349 |
||
350 |
scrollView := HVScrollableView for:EditTextView. |
|
351 |
textView := scrollView scrolledView. |
|
352 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
353 |
top addSubView:scrollView. |
|
354 |
||
355 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
356 |
||
357 |
top open. |
|
358 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
359 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
360 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
361 |
set the action for accept: |
6152 | 362 |
[exBegin] |
363 |
|top textView| |
|
364 |
||
365 |
top := StandardSystemView new. |
|
366 |
top extent:300@200. |
|
367 |
||
368 |
textView := EditTextView new. |
|
369 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
370 |
top addSubView:textView. |
|
371 |
||
372 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
373 |
textView acceptAction:[:contents | |
|
374 |
Transcript showCR:'will not overwrite the file with:'. |
|
375 |
Transcript showCR:contents asString |
|
376 |
]. |
|
377 |
top open. |
|
378 |
[exEnd] |
|
594 | 379 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
380 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
381 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
382 |
non-string (text) items: |
6152 | 383 |
[exBegin] |
384 |
|top textView list| |
|
385 |
||
386 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
387 |
1 to:list size by:2 do:[:nr | |
|
388 |
list at:nr put:(Text string:(list at:nr) |
|
389 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
390 |
]. |
|
391 |
||
392 |
top := StandardSystemView new. |
|
393 |
top extent:300@200. |
|
394 |
||
395 |
textView := EditTextView new. |
|
396 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
397 |
top addSubView:textView. |
|
398 |
||
399 |
textView contents:list. |
|
400 |
top open. |
|
401 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
402 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
403 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
404 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
405 |
MVC operation: |
594 | 406 |
(the examples model here is a plug simulating a real model; |
407 |
real world applications would not use a plug ..) |
|
6152 | 408 |
[exBegin] |
409 |
|top textView model| |
|
410 |
||
411 |
model := Plug new. |
|
412 |
model respondTo:#accepted: |
|
413 |
with:[:newContents | |
|
414 |
Transcript showCR:'will not overwrite the file with:'. |
|
415 |
Transcript showCR:newContents asString |
|
416 |
]. |
|
417 |
model respondTo:#getList |
|
418 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
419 |
||
420 |
||
421 |
top := StandardSystemView new. |
|
422 |
top extent:300@200. |
|
423 |
||
424 |
textView := EditTextView new. |
|
425 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
426 |
top addSubView:textView. |
|
427 |
||
428 |
textView listMessage:#getList; |
|
429 |
model:model; |
|
430 |
changeMessage:#accepted:; |
|
431 |
aspect:#list. |
|
432 |
top open. |
|
433 |
[exEnd] |
|
594 | 434 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
435 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
436 |
two textViews on the same model: |
6152 | 437 |
[exBegin] |
438 |
|top1 textView1 top2 textView2 model currentContents| |
|
439 |
||
440 |
model := Plug new. |
|
441 |
model respondTo:#accepted: |
|
442 |
with:[:newContents | |
|
443 |
Transcript showCR:'accepted:'. |
|
444 |
Transcript showCR:newContents asString. |
|
445 |
currentContents := newContents. |
|
446 |
model changed:#contents |
|
447 |
]. |
|
448 |
model respondTo:#getList |
|
449 |
with:[Transcript showCR:'query'. |
|
450 |
currentContents]. |
|
451 |
||
452 |
||
453 |
top1 := StandardSystemView new. |
|
454 |
top1 extent:300@200. |
|
455 |
||
456 |
textView1 := EditTextView new. |
|
457 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
458 |
top1 addSubView:textView1. |
|
459 |
||
460 |
textView1 listMessage:#getList; |
|
461 |
model:model; |
|
462 |
aspect:#contents; |
|
463 |
changeMessage:#accepted:. |
|
464 |
top1 open. |
|
465 |
||
466 |
top2 := StandardSystemView new. |
|
467 |
top2 extent:300@200. |
|
468 |
||
469 |
textView2 := EditTextView new. |
|
470 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
471 |
top2 addSubView:textView2. |
|
472 |
||
473 |
textView2 listMessage:#getList; |
|
474 |
model:model; |
|
475 |
aspect:#contents; |
|
476 |
changeMessage:#accepted:. |
|
477 |
top2 open. |
|
478 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
479 |
" |
0 | 480 |
! ! |
481 |
||
865 | 482 |
!EditTextView class methodsFor:'defaults'! |
59 | 483 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
484 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
485 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
486 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
487 |
"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
|
488 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
489 |
|
1419 | 490 |
st80Mode |
491 |
"return true, if the st80 editing mode is turned on. |
|
492 |
This setting affects the behavior of the cursor, when positioned |
|
5909 | 493 |
beyond the end of a line or the end of the text. |
494 |
This method is here for backward compatibility, when this flag was stored |
|
495 |
in a class var. It is now in the user's settings. |
|
496 |
Please do not call it, but go to the prefs directly, to make it easier to find those getters." |
|
1419 | 497 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
498 |
^ UserPreferences current st80EditMode |
1419 | 499 |
|
500 |
" |
|
501 |
EditTextView st80Mode:true |
|
502 |
EditTextView st80Mode:false |
|
503 |
" |
|
504 |
||
505 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
506 |
! |
|
507 |
||
508 |
st80Mode:aBoolean |
|
509 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
5909 | 510 |
beyond the end of a line or the last line. |
511 |
This method is here for backward compatibility, when this flag was stored |
|
512 |
in a class var. It is now in the user's settings. |
|
513 |
Please do not call it, but go to the prefs directly, to make it easier to find those setters." |
|
1419 | 514 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
515 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 516 |
|
517 |
" |
|
518 |
EditTextView st80Mode:true |
|
519 |
EditTextView st80Mode:false |
|
520 |
" |
|
521 |
||
522 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
523 |
! |
|
524 |
||
59 | 525 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
526 |
"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
|
527 |
|
1390 | 528 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
6152 | 529 |
#'textCursor.noFocusForegroundColor' |
530 |
#'textCursor.type' |
|
531 |
#'textCursor.typeNoFocus' |
|
532 |
#'editText.st80Mode')> |
|
1355 | 533 |
|
534 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
535 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
536 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
537 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
538 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
539 |
|
1419 | 540 |
" |
541 |
self updateStyleCache |
|
542 |
" |
|
543 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
544 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 545 |
! ! |
546 |
||
3431 | 547 |
!EditTextView class methodsFor:'specs'! |
548 |
||
549 |
searchReplaceDialogSpec |
|
550 |
"This resource specification was automatically generated |
|
551 |
by the UIPainter of ST/X." |
|
552 |
||
553 |
"Do not manually edit this!! If it is corrupted, |
|
554 |
the UIPainter may not be able to read the specification." |
|
555 |
||
556 |
" |
|
557 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
558 |
" |
|
559 |
||
560 |
<resource: #canvas> |
|
561 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
562 |
^ |
3431 | 563 |
#(FullSpec |
6152 | 564 |
name: searchReplaceDialogSpec |
565 |
window: |
|
3431 | 566 |
(WindowSpec |
6152 | 567 |
label: 'String Search and Replace' |
568 |
name: 'String Search and Replace' |
|
569 |
min: (Point 283 196) |
|
570 |
max: (Point 283 196) |
|
571 |
bounds: (Rectangle 0 0 279 192) |
|
572 |
) |
|
573 |
component: |
|
3431 | 574 |
(SpecCollection |
6152 | 575 |
collection: ( |
576 |
(LabelSpec |
|
577 |
label: 'Search Pattern:' |
|
578 |
name: 'label' |
|
579 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
580 |
level: 0 |
|
581 |
translateLabel: true |
|
582 |
adjust: left |
|
583 |
) |
|
584 |
(ComboBoxSpec |
|
585 |
name: 'patternComboBox' |
|
586 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
587 |
tabable: true |
|
588 |
model: searchPattern |
|
589 |
immediateAccept: false |
|
590 |
acceptOnLeave: true |
|
591 |
acceptOnReturn: true |
|
592 |
acceptOnTab: true |
|
593 |
acceptOnLostFocus: true |
|
594 |
acceptOnPointerLeave: false |
|
595 |
autoSelectInitialText: true |
|
596 |
comboList: patternList |
|
597 |
) |
|
598 |
(ComboBoxSpec |
|
599 |
name: 'replaceComboBox' |
|
600 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
601 |
tabable: true |
|
602 |
model: replacePattern |
|
603 |
immediateAccept: false |
|
604 |
acceptOnLeave: true |
|
605 |
acceptOnReturn: true |
|
606 |
acceptOnTab: true |
|
607 |
acceptOnLostFocus: true |
|
608 |
acceptOnPointerLeave: false |
|
609 |
autoSelectInitialText: true |
|
610 |
comboList: patternList |
|
611 |
) |
|
612 |
(CheckBoxSpec |
|
613 |
label: 'Ignore Case' |
|
614 |
name: 'ignoreCaseCheckBox' |
|
615 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
616 |
level: 0 |
|
617 |
tabable: true |
|
618 |
model: ignoreCase |
|
619 |
translateLabel: true |
|
620 |
) |
|
621 |
(VariableVerticalPanelSpec |
|
622 |
name: 'VariableVerticalPanel1' |
|
623 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
624 |
component: |
|
625 |
(SpecCollection |
|
626 |
collection: ( |
|
627 |
(HorizontalPanelViewSpec |
|
628 |
name: 'HorizontalPanel1' |
|
629 |
level: 0 |
|
630 |
horizontalLayout: fitSpace |
|
631 |
verticalLayout: center |
|
632 |
horizontalSpace: 3 |
|
633 |
verticalSpace: 3 |
|
634 |
ignoreInvisibleComponents: true |
|
635 |
reverseOrderIfOKAtLeft: true |
|
636 |
component: |
|
637 |
(SpecCollection |
|
638 |
collection: ( |
|
639 |
(ActionButtonSpec |
|
640 |
label: 'Replace' |
|
641 |
name: 'replaceButton' |
|
642 |
level: 2 |
|
643 |
translateLabel: true |
|
644 |
tabable: true |
|
645 |
model: replaceAction |
|
646 |
extent: (Point 134 21) |
|
647 |
) |
|
648 |
(ActionButtonSpec |
|
649 |
label: 'Replace All' |
|
650 |
name: 'replaceAllButton' |
|
651 |
level: 2 |
|
652 |
borderWidth: 1 |
|
653 |
translateLabel: true |
|
654 |
tabable: true |
|
655 |
model: replaceAllAction |
|
656 |
extent: (Point 134 21) |
|
657 |
) |
|
658 |
) |
|
659 |
||
660 |
) |
|
661 |
) |
|
662 |
(HorizontalPanelViewSpec |
|
663 |
name: 'horizontalPanelView' |
|
664 |
level: 0 |
|
665 |
horizontalLayout: fitSpace |
|
666 |
verticalLayout: center |
|
667 |
horizontalSpace: 3 |
|
668 |
verticalSpace: 3 |
|
669 |
ignoreInvisibleComponents: true |
|
670 |
reverseOrderIfOKAtLeft: true |
|
671 |
component: |
|
672 |
(SpecCollection |
|
673 |
collection: ( |
|
674 |
(ActionButtonSpec |
|
675 |
label: 'Cancel' |
|
676 |
name: 'cancelButton' |
|
677 |
level: 2 |
|
678 |
translateLabel: true |
|
679 |
tabable: true |
|
680 |
model: cancel |
|
681 |
extent: (Point 88 21) |
|
682 |
) |
|
683 |
(ActionButtonSpec |
|
684 |
label: 'Prev' |
|
685 |
name: 'prevButton' |
|
686 |
level: 2 |
|
687 |
translateLabel: true |
|
688 |
tabable: true |
|
689 |
model: prevAction |
|
690 |
extent: (Point 89 21) |
|
691 |
) |
|
692 |
(ActionButtonSpec |
|
693 |
label: 'Next' |
|
694 |
name: 'nextButton' |
|
695 |
level: 2 |
|
696 |
borderWidth: 1 |
|
697 |
translateLabel: true |
|
698 |
tabable: true |
|
699 |
model: nextAction |
|
700 |
isDefault: true |
|
701 |
extent: (Point 88 21) |
|
702 |
) |
|
703 |
) |
|
704 |
||
705 |
) |
|
706 |
) |
|
707 |
) |
|
708 |
||
709 |
) |
|
710 |
handles: (Any 0.5 1.0) |
|
711 |
) |
|
712 |
(LabelSpec |
|
713 |
label: 'Replace By:' |
|
714 |
name: 'ReplaceLabel' |
|
715 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
716 |
level: 0 |
|
717 |
translateLabel: true |
|
718 |
adjust: left |
|
719 |
) |
|
720 |
) |
|
721 |
||
722 |
) |
|
3431 | 723 |
) |
724 |
||
725 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
726 |
! ! |
|
727 |
||
2744 | 728 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
729 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
730 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
731 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
732 |
|
2019 | 733 |
"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
|
734 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
735 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
736 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
737 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
738 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
739 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
740 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
741 |
|
1390 | 742 |
cutSelection |
743 |
self cut |
|
744 |
||
745 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
746 |
! |
|
747 |
||
1590 | 748 |
deselect |
749 |
"remove the selection" |
|
750 |
||
751 |
^ self unselect |
|
752 |
||
753 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
754 |
! |
|
755 |
||
2101 | 756 |
enabled:aBoolean |
757 |
||
758 |
self readOnly:aBoolean not |
|
759 |
||
760 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
761 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
762 |
! |
|
763 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
764 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
765 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
766 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
767 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
768 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
769 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
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 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
772 |
"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
|
773 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
774 |
|line col| |
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 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
777 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
778 |
col < 1 ifTrue:[ |
6152 | 779 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
780 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
781 |
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
|
782 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
783 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
784 |
|top v| |
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 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
787 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
788 |
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
|
789 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
790 |
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
|
791 |
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
|
792 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
793 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
794 |
"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
|
795 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
796 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
797 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
798 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
799 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
800 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
801 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
802 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 803 |
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
|
804 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
805 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 806 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
807 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
808 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
809 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
810 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
811 |
v insertAndSelect:'<- hello there' at:5. |
125 | 812 |
" |
1390 | 813 |
! |
814 |
||
815 |
pasteSelection |
|
816 |
self paste |
|
817 |
||
818 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 819 |
! |
820 |
||
821 |
replaceSelectionWith:aString |
|
822 |
^ self replaceSelectionBy:aString |
|
823 |
||
824 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
825 |
! |
|
826 |
||
827 |
selectAt:pos |
|
828 |
"move the cursor before cursorPosition." |
|
829 |
||
830 |
self cursorToCharacterPosition:pos |
|
831 |
||
832 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
833 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
834 |
! |
|
835 |
||
2101 | 836 |
textHasChanged |
837 |
^ self modified |
|
838 |
||
839 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
840 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
841 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
842 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
843 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
844 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
845 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
846 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
847 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
848 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
849 |
|
4585 | 850 |
!EditTextView methodsFor:'accessing'! |
851 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
852 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
853 |
| codeAspect app | |
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 |
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
|
856 |
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
|
857 |
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
|
858 |
|
6314 | 859 |
"/ Applications should set it explictly, however, to make it behave like |
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
860 |
"/ 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
|
861 |
^((app := self topView application) notNil and:[app respondsTo: #codeAspect]) |
6152 | 862 |
ifTrue:[app codeAspect] |
863 |
ifFalse:[nil] |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
864 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
865 |
"Created: / 27-09-2013 / 09:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6314 | 866 |
"Modified (comment): / 27-04-2018 / 16:39:15 / stefan" |
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
867 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
868 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
869 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
870 |
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
|
871 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
872 |
"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
|
873 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
874 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
875 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
876 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
877 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
878 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
879 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
880 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
881 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
882 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
883 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
884 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
885 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
886 |
"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
|
887 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
888 |
|
4609 | 889 |
editedClass |
890 |
|cm| |
|
891 |
||
892 |
cm := self editedMethodOrClass. |
|
893 |
cm isBehavior ifTrue:[^ cm]. |
|
894 |
cm isMethod ifTrue:[^ cm mclass]. |
|
895 |
^ nil |
|
896 |
! |
|
897 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
898 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
899 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
900 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
901 |
"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
|
902 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
903 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
904 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
905 |
"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
|
906 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
907 |
"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
|
908 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
909 |
|
4609 | 910 |
editedMethod |
911 |
|cm| |
|
912 |
||
913 |
cm := self editedMethodOrClass. |
|
914 |
cm isMethod ifTrue:[^ cm]. |
|
915 |
cm isBehavior ifTrue:[^ nil]. |
|
916 |
^ nil |
|
917 |
! |
|
918 |
||
919 |
editedMethodOrClass |
|
920 |
^ nil |
|
921 |
! |
|
922 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
923 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
924 |
"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
|
925 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
926 |
"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
|
927 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
928 |
|
4585 | 929 |
hasSelectionOrTextInCursorLine |
930 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
931 |
! |
|
932 |
||
4589 | 933 |
selectionOrTextOfCursorLine |
934 |
^ self selectionOrTextOfCursorLine:true |
|
935 |
! |
|
936 |
||
4585 | 937 |
selectionOrTextOfCursorLine:doSelect |
938 |
|sel lNr line| |
|
939 |
||
940 |
sel := self selectionAsString. |
|
941 |
sel notNil ifTrue:[^ sel]. |
|
942 |
||
943 |
lNr := self cursorLine. |
|
944 |
line := self listAt:lNr. |
|
945 |
line notEmptyOrNil ifTrue:[ |
|
6152 | 946 |
doSelect ifTrue:[ |
947 |
self selectLine:lNr. |
|
948 |
]. |
|
949 |
^ line |
|
4585 | 950 |
]. |
951 |
||
952 |
^ nil |
|
953 |
! ! |
|
954 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
955 |
!EditTextView methodsFor:'accessing-behavior'! |
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 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
958 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
959 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
960 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
961 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
962 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
963 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
964 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
965 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
966 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
967 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
968 |
|
2792 | 969 |
acceptChannel |
970 |
"return the valueHolder holding true if text was accepted. |
|
971 |
By placing a true into this channel, an accept can also be forced." |
|
972 |
||
973 |
^ acceptChannel |
|
974 |
||
975 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
976 |
! |
|
977 |
||
978 |
acceptChannel:aValueHolder |
|
979 |
"set the valueHolder holding true if text was accepted. |
|
980 |
By placing a true into this channel, an accept can also be forced." |
|
981 |
||
982 |
|prev| |
|
983 |
||
984 |
prev := acceptChannel. |
|
985 |
acceptChannel := aValueHolder. |
|
986 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
987 |
||
988 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
989 |
! |
|
990 |
||
1108 | 991 |
acceptEnabled:aBoolean |
992 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
993 |
||
994 |
acceptEnabled := aBoolean |
|
995 |
||
996 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
997 |
! |
|
998 |
||
2792 | 999 |
accepted |
1000 |
"return true if text was accepted" |
|
1001 |
||
1002 |
^ acceptChannel value |
|
1003 |
||
1004 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1005 |
! |
|
1006 |
||
1007 |
accepted:aBoolean |
|
1008 |
"set/clear the accepted flag. |
|
1009 |
This may force my current contents to be placed into my model." |
|
1010 |
||
1011 |
acceptChannel value:aBoolean. |
|
1012 |
||
1013 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1014 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1015 |
! |
|
1016 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1017 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1018 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1019 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1020 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1021 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1022 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1023 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1024 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1025 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1026 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1027 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1028 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1029 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1030 |
|
2774 | 1031 |
cursorMovementWhenUpdating |
3160 | 1032 |
"return what is be done with the cursor, |
2774 | 1033 |
when I get a new text (via the model or the #contents/#list) |
1034 |
Allowed arguments are: |
|
6152 | 1035 |
#keep / nil -> stay where it was |
1036 |
#endOfText -> position cursor to the end |
|
1037 |
#beginOfText -> position cursor to the beginning |
|
1038 |
#endOfLine -> position cursor to the current lines end |
|
1039 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1040 |
The default is #beginOfText. |
1041 |
This may be useful for fields which get new values assigned from |
|
1042 |
the program (i.e. not from the user)" |
|
1043 |
||
1044 |
^ cursorMovementWhenUpdating |
|
1045 |
||
1046 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1047 |
! |
|
1048 |
||
2133 | 1049 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1050 |
"define what should be done with the cursor, |
2133 | 1051 |
when I get a new text (via the model or the #contents/#list) |
1052 |
Allowed arguments are: |
|
6152 | 1053 |
#keep / nil -> stay where it was |
1054 |
#endOfText -> position cursor to the end |
|
1055 |
#beginOfText -> position cursor to the beginning |
|
1056 |
#endOfLine -> position cursor to the current lines end |
|
1057 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1058 |
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
|
1059 |
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
|
1060 |
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
|
1061 |
|
2133 | 1062 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1063 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1064 |
"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
|
1065 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1066 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1067 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1068 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1069 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1070 |
|
2438 | 1071 |
dontReplaceSelectionOnInput |
4742 | 1072 |
"remember that the current selection was created by a paste operation |
1073 |
(as opposed to an explicit selection by the user). |
|
1074 |
This selection will not be replaced by followup user input, |
|
1075 |
so multiple pastes will be possible." |
|
1076 |
||
2438 | 1077 |
typeOfSelection := #paste |
1078 |
! |
|
1079 |
||
3235 | 1080 |
editModeHolder |
1081 |
^ editMode. |
|
1082 |
! |
|
1083 |
||
1084 |
editModeInsert |
|
1085 |
editMode value:EditMode insertMode |
|
1086 |
! |
|
1087 |
||
1088 |
editModeInsertAndSelect |
|
1089 |
editMode value:EditMode insertAndSelectMode |
|
1090 |
! |
|
1091 |
||
1092 |
editModeOverwrite |
|
1093 |
editMode value:EditMode overwriteMode |
|
1094 |
! |
|
1095 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1096 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1097 |
"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
|
1098 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1099 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1100 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1101 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1102 |
|
5858 | 1103 |
generateTextAfterEndHook:aBlock |
1104 |
"some applications may want to dynamically generate lines below the bottom line, |
|
1105 |
when the cursor is moved there. |
|
1106 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1107 |
which want to automatically generate additional lines lazily, |
|
1108 |
but which cannot afford to generate the whole text in advance |
|
1109 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1110 |
If set, this hook is called whenever the cursor is about to be moved below the |
5859 | 1111 |
last line, getting the new lineNr (i.e > contents size) as argument. |
5858 | 1112 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1113 |
number, into which the cursor should be moved |
1114 |
(eg. if 10 additional lines are generated, it may want to return oldSize+1, |
|
5858 | 1115 |
to make the cursor end in the last line which was inserted)" |
5890 | 1116 |
|
5858 | 1117 |
self setAttribute:#generateTextAfterEndHook to:aBlock |
1118 |
! |
|
1119 |
||
1120 |
generateTextBeforeStartHook:aBlock |
|
1121 |
"some applications may want to dynamically generate lines above the top |
|
1122 |
line, when the cursor is moved there. |
|
1123 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1124 |
which want to automatically generate additional lines lazily, |
|
1125 |
but which cannot afford to generate the whole text in advance |
|
1126 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1127 |
If set, this hook is called whenever the cursor is about to be moved above the |
5859 | 1128 |
top, getting the new lineNr (i.e < 1) as argument. |
5858 | 1129 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1130 |
number, into which the cursor should be moved |
1131 |
(eg. if 10 additional lines are generated, it may want to return 10, to make the |
|
5858 | 1132 |
cursor end in the last line which was inserted)" |
5890 | 1133 |
|
5858 | 1134 |
self setAttribute:#generateTextBeforeStartHook to:aBlock |
1135 |
! |
|
1136 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1137 |
insertMode:aBoolean |
3235 | 1138 |
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
|
1139 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1140 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1141 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1142 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1143 |
insertModeHolder |
3235 | 1144 |
^ BlockValue |
6152 | 1145 |
with:[:m | m isInsertMode] |
1146 |
argument:(editMode). |
|
3465 | 1147 |
|
1148 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1149 |
! |
1150 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1151 |
isInInsertMode |
3235 | 1152 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1153 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1154 |
|
5216 | 1155 |
isNotReadOnly |
1156 |
"return true, if the text is not readonly." |
|
1157 |
||
1158 |
^ self isReadOnly not |
|
1159 |
! |
|
1160 |
||
2792 | 1161 |
isReadOnly |
1162 |
"return true, if the text is readonly." |
|
1163 |
||
1164 |
^ readOnly value |
|
1165 |
||
1166 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1167 |
! |
|
1168 |
||
2796 | 1169 |
modeLabelHolder |
1170 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1171 |
||
3160 | 1172 |
^ BlockValue |
6152 | 1173 |
with:[:e :l | |
1174 |
self isReadOnly ifTrue:[ |
|
1175 |
'' |
|
1176 |
] ifFalse:[ |
|
1177 |
l ifTrue:[ 'L' allBold withColor:#red] |
|
1178 |
ifFalse:[ e infoPrintString]]] |
|
1179 |
argument:(self editModeHolder) |
|
1180 |
argument:(self learnModeHolder). |
|
3465 | 1181 |
|
1182 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1183 |
! |
1184 |
||
2792 | 1185 |
modified |
1186 |
"return true if text was modified" |
|
1187 |
||
1188 |
^ modifiedChannel value |
|
1189 |
! |
|
1190 |
||
1191 |
modified:aBoolean |
|
1192 |
"set/clear the modified flag" |
|
1193 |
||
1194 |
modifiedChannel value:aBoolean |
|
1195 |
||
1196 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1197 |
! |
|
1198 |
||
1199 |
modifiedChannel |
|
1200 |
"return the valueHolder holding true if text was modified" |
|
1201 |
||
1202 |
^ modifiedChannel |
|
1203 |
! |
|
1204 |
||
1205 |
modifiedChannel:aValueHolder |
|
1206 |
"set the valueHolder holding true if text was modified" |
|
1207 |
||
1208 |
|prev| |
|
1209 |
||
1210 |
prev := modifiedChannel. |
|
1211 |
modifiedChannel := aValueHolder. |
|
1212 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1213 |
||
1214 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1215 |
! |
|
1216 |
||
1217 |
readOnly |
|
1218 |
"make the text readonly. |
|
4664 | 1219 |
Obsolete because it is obfuscating (looks like a getter) |
1220 |
- use #readOnly:" |
|
2792 | 1221 |
|
1222 |
<resource:#obsolete> |
|
1223 |
||
1224 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1225 |
self readOnly:true. |
2792 | 1226 |
|
4664 | 1227 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1228 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1229 |
! |
1230 |
||
6401 | 1231 |
readOnly:aBooleanOrValueHolder |
2792 | 1232 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
1233 |
The argument may also be a valueHolder." |
|
1234 |
||
6401 | 1235 |
readOnly := aBooleanOrValueHolder |
1236 |
||
1237 |
"Created: / 14-02-1997 / 17:35:39 / cg" |
|
1238 |
"Modified (format): / 22-08-2018 / 15:35:14 / Claus Gittinger" |
|
2792 | 1239 |
! |
1240 |
||
4782 | 1241 |
reallyModifiedChannel |
1242 |
"return the valueHolder holding true if text was really modified. |
|
1243 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1244 |
||
1245 |
^ self modifiedChannel |
|
1246 |
! |
|
1247 |
||
5909 | 1248 |
st80EditMode |
1249 |
"If on, the cursor wraps at the line end (like in vi or st80); |
|
1250 |
if off, we have the Rand-editor behavior (random access)" |
|
1251 |
||
1252 |
^ st80Mode ? (UserPreferences current st80EditMode) |
|
1253 |
! |
|
1254 |
||
1255 |
st80EditMode:aBooleanOrNil |
|
4192 | 1256 |
"set/clear the st80Mode flag. |
1257 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1258 |
if off, we have the Rand-editor behavior (random access) |
1259 |
if nil, the setting follows the current userPref setting." |
|
1260 |
||
1261 |
st80Mode := aBooleanOrNil |
|
4192 | 1262 |
|
1263 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1264 |
! |
|
1265 |
||
5909 | 1266 |
st80Mode:aBooleanOrNil |
6070 | 1267 |
<resource: #obsolete> |
5909 | 1268 |
self obsoleteMethodWarning. |
1269 |
self st80EditMode:aBooleanOrNil |
|
1270 |
||
1271 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1272 |
! |
|
1273 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1274 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1275 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1276 |
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
|
1277 |
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
|
1278 |
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
|
1279 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1280 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1281 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1282 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1283 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1284 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1285 |
"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
|
1286 |
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
|
1287 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1288 |
|
3160 | 1289 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1290 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1291 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1292 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1293 |
"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
|
1294 |
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
|
1295 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1296 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1297 |
tabRequiresControl := aBoolean |
5909 | 1298 |
! |
1299 |
||
1300 |
trimBlankLines |
|
6310 | 1301 |
"If true, the blank lines are trimmed to zero size and trailing blank lines are removed; |
1302 |
if false, they are left as is; |
|
5909 | 1303 |
if nil, the setting follows the current userPref setting." |
1304 |
||
1305 |
^ trimBlankLines ? (UserPreferences current trimBlankLines) |
|
1306 |
! |
|
1307 |
||
1308 |
trimBlankLines:aBooleanOrNil |
|
6310 | 1309 |
"If true, the blank lines are trimmed to zero size and trailing blank lines are removed; |
1310 |
if false, they are left as is; |
|
5909 | 1311 |
if nil, the setting follows the current userPref setting." |
1312 |
||
1313 |
trimBlankLines := aBooleanOrNil. |
|
6329 | 1314 |
! |
1315 |
||
1316 |
trimLastCR |
|
1317 |
"If true, the last line is returned without a trailing CR character; |
|
1318 |
The default is false; this is only used by very specialized editors." |
|
1319 |
||
1320 |
^ (self objectAttributeAt:#trimLastCR) ? false |
|
1321 |
||
1322 |
"Created: / 28-05-2018 / 12:05:34 / Claus Gittinger" |
|
1323 |
! |
|
1324 |
||
1325 |
trimLastCR:aBooleanOrNil |
|
1326 |
"If true, the last line is returned without a trailing CR character; |
|
1327 |
The default is false; this is only used by very specialized editors." |
|
1328 |
||
1329 |
self objectAttributeAt:#trimLastCR put:aBooleanOrNil. |
|
1330 |
||
1331 |
"Created: / 28-05-2018 / 12:05:02 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1332 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1333 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1334 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1335 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1336 |
at:lineNr basicPut:aLine |
5413 | 1337 |
"change a line without change notification. |
1338 |
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
|
1339 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1340 |
(self at:lineNr) = aLine ifFalse:[ |
6152 | 1341 |
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
|
1342 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1343 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1344 |
|
522 | 1345 |
at:lineNr put:aLine |
5413 | 1346 |
"replace a line by something new. |
1347 |
this is not undoably, unless you care for yourself" |
|
1348 |
||
5393 | 1349 |
|oldLine| |
1350 |
||
1351 |
oldLine := (self at:lineNr) ? ''. |
|
1352 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
6152 | 1353 |
super at:lineNr put:aLine. |
1354 |
self textChanged |
|
522 | 1355 |
]. |
1356 |
! |
|
1357 |
||
4700 | 1358 |
characterAfterCursor |
1359 |
"return the character one after the cursor - space if beyond line." |
|
1360 |
||
1361 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1362 |
! |
|
1363 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1364 |
characterBeforeCursor |
4700 | 1365 |
"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
|
1366 |
|
5142 | 1367 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1368 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1369 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1370 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1371 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1372 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1373 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1374 |
characterUnderCursor |
2707 | 1375 |
"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
|
1376 |
For non-block cursors, this is the character immediately to the right |
5787 | 1377 |
of the insertion-bar or caret. |
5413 | 1378 |
For block cursors, this is the highlighted cursor-character" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1379 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1380 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1381 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1383 |
contents |
6330 | 1384 |
"return the contents as a String or Text (i.e. with emphasis). |
1385 |
Cares for trimBlankLines and trimLastCR options." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1386 |
|
6329 | 1387 |
|numLines contents| |
5988 | 1388 |
|
1389 |
list isNil ifTrue:[^ '']. |
|
1390 |
self trimBlankLines ifTrue:[ |
|
1391 |
self removeTrailingBlankLines. |
|
1392 |
] ifFalse:[ |
|
1393 |
"/ the last line does not count, if the cursor is at |
|
1394 |
"/ the begining |
|
1395 |
cursorCol == 1 ifTrue:[ |
|
1396 |
numLines := list size. |
|
1397 |
cursorLine == numLines ifTrue:[ |
|
1398 |
numLines > 1 ifTrue:[ |
|
1399 |
(self listAt:numLines) isEmptyOrNil ifTrue:[ |
|
1400 |
list grow:numLines-1. |
|
1401 |
]. |
|
1402 |
]. |
|
1403 |
]. |
|
1404 |
]. |
|
1405 |
]. |
|
6329 | 1406 |
contents := super contents. |
1407 |
(self trimLastCR) ifTrue:[ |
|
1408 |
contents isString ifTrue:[ |
|
1409 |
(contents endsWith:Character cr) ifTrue:[ |
|
1410 |
^ contents copyButLast |
|
1411 |
]. |
|
1412 |
]. |
|
1413 |
]. |
|
1414 |
^ contents |
|
3313 | 1415 |
|
1416 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
6330 | 1417 |
"Modified (comment): / 28-05-2018 / 12:28:11 / Claus Gittinger" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1418 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1419 |
|
5413 | 1420 |
contents:aStringOrStringCollectionOrNil |
1421 |
"replace the whole contents by something new. |
|
5414 | 1422 |
this is not undoably, unless you care for yourself. |
1423 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1424 |
|
1425 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1426 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1427 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1428 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1429 |
"set the contents and optionally clear the undo history. |
1430 |
The contents-change is not undoable." |
|
1431 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1432 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1433 |
keepUndoHistory ifFalse:[ |
6152 | 1434 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1435 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1436 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1437 |
|
2213 | 1438 |
contentsAsString |
6563 | 1439 |
"return the contents as a String (i.e. without emphasis). |
1440 |
Trims always (i.e. ignores trimBlankLines and trimLastCR options)" |
|
2213 | 1441 |
|
1442 |
list isNil ifTrue:[^ '']. |
|
1443 |
self removeTrailingBlankLines. |
|
6412 | 1444 |
^ (list collect:[:each | |
1445 |
each isNil |
|
1446 |
ifTrue:[''] |
|
1447 |
ifFalse:[each string] |
|
1448 |
]) asStringWithCRs |
|
1449 |
||
6563 | 1450 |
"Modified (comment): / 21-03-2019 / 13:09:54 / Claus Gittinger" |
2213 | 1451 |
! |
1452 |
||
5067 | 1453 |
contentsAsStringWithTabs |
1454 |
"return the contents as a String (i.e. without emphasis) |
|
1455 |
and with leading spaces replaced by tab characters |
|
6563 | 1456 |
(i.e. as would be written to a file). |
1457 |
Trims always (i.e. ignores trimBlankLines and trimLastCR options)" |
|
5067 | 1458 |
|
1459 |
list isNil ifTrue:[^ '']. |
|
1460 |
self removeTrailingBlankLines. |
|
5787 | 1461 |
^ (list collect:[:each | |
6152 | 1462 |
each isNil |
1463 |
ifTrue:[''] |
|
1464 |
ifFalse:[each string withTabs] |
|
5067 | 1465 |
]) asStringWithCRs |
6563 | 1466 |
|
1467 |
"Modified (format): / 21-03-2019 / 13:10:33 / Claus Gittinger" |
|
5067 | 1468 |
! |
1469 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1470 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1471 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1472 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1473 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1474 |
^ cursorCol |
125 | 1475 |
! |
1476 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1477 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1478 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1479 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1480 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1481 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1482 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1483 |
cursorLine |
3160 | 1484 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1485 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1486 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1487 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1488 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1489 |
|
6295 | 1490 |
cursorLineAndColumnHolder |
1491 |
"return a valueHolder for the cursors line and column as an |
|
1492 |
array of the form { lineNr . col } |
|
1493 |
This can be used directly as a model to react on cursor movement" |
|
1494 |
||
1495 |
^ BlockValue |
|
1496 |
with:[:l :c | (Array with:l with:c) ] |
|
1497 |
argument:self cursorLineHolder |
|
1498 |
argument:self cursorColHolder |
|
1499 |
! |
|
1500 |
||
5400 | 1501 |
cursorLineAndColumnLabelHolder |
5399 | 1502 |
"return a valueHolder for the cursors line and column as an info string |
5787 | 1503 |
of the form 'line : col'. |
5399 | 1504 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
1505 |
||
1506 |
^ BlockValue |
|
6152 | 1507 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
1508 |
argument:self cursorLineHolder |
|
1509 |
argument:self cursorColHolder |
|
5399 | 1510 |
! |
1511 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1512 |
cursorLineHolder |
3160 | 1513 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1514 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1515 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1516 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1517 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1518 |
|
4713 | 1519 |
lineStringBeforeCursor |
1520 |
"return the line's string before the cursor. |
|
1521 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1522 |
||
6563 | 1523 |
|line prevCol| |
1524 |
||
1525 |
prevCol := cursorCol-1. |
|
1526 |
line := ((self at:cursorLine) ? '') string. |
|
1527 |
line size < prevCol ifTrue:[ |
|
1528 |
^ line paddedTo:prevCol |
|
1529 |
]. |
|
1530 |
^ line copyTo:prevCol |
|
1531 |
||
1532 |
" |
|
1533 |
EditTextView new |
|
1534 |
contents:c'line1\nline2\nline3'; |
|
1535 |
lineStringBeforeCursor |
|
1536 |
||
1537 |
EditTextView new |
|
1538 |
contents:c'line1\nline2\nline3'; |
|
1539 |
cursorLine:2 col:1; |
|
1540 |
lineStringBeforeCursor |
|
1541 |
||
1542 |
EditTextView new |
|
1543 |
contents:c'line1\nline2\nline3'; |
|
1544 |
cursorLine:2 col:3; |
|
1545 |
lineStringBeforeCursor |
|
1546 |
||
1547 |
EditTextView new |
|
1548 |
contents:c'line1\nline2\nline3'; |
|
1549 |
cursorLine:2 col:20; |
|
1550 |
lineStringBeforeCursor |
|
1551 |
" |
|
1552 |
||
1553 |
"Modified: / 21-03-2019 / 12:55:56 / Claus Gittinger" |
|
1554 |
! |
|
1555 |
||
1556 |
lineStringFromCursor |
|
1557 |
"return the line's string beginning at the cursor position to the line's end." |
|
1558 |
||
4713 | 1559 |
|line| |
1560 |
||
1561 |
line := ((self at:cursorLine) ? '') string. |
|
6563 | 1562 |
line size < cursorCol ifTrue:[ |
1563 |
^ '' |
|
1564 |
]. |
|
1565 |
^ line copyFrom:cursorCol |
|
1566 |
||
1567 |
" |
|
1568 |
EditTextView new |
|
1569 |
contents:c'line1\nline2\nline3'; |
|
1570 |
lineStringFromCursor |
|
1571 |
||
1572 |
EditTextView new |
|
1573 |
contents:c'line1\nline2\nline3'; |
|
1574 |
cursorLine:2 col:1; |
|
1575 |
lineStringFromCursor |
|
1576 |
||
1577 |
EditTextView new |
|
1578 |
contents:c'line1\nline2\nline3'; |
|
1579 |
cursorLine:2 col:3; |
|
1580 |
lineStringFromCursor |
|
1581 |
" |
|
1582 |
||
1583 |
"Created: / 21-03-2019 / 12:51:08 / Claus Gittinger" |
|
4713 | 1584 |
! |
1585 |
||
6289 | 1586 |
list:newCollectionOfLinesOrNil |
5413 | 1587 |
"replace the whole contents by something new. |
1588 |
this is not undoably, unless you care for yourself. |
|
6289 | 1589 |
Positions the cursor as defined in cursorMovementWhenUpdating |
1590 |
(which defaults to: home)" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1591 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1592 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1593 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1594 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1595 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1596 |
|
6289 | 1597 |
super list:newCollectionOfLinesOrNil. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1598 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1599 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1600 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
6152 | 1601 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1602 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1603 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1604 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
6152 | 1605 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1606 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1607 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1608 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1609 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
6152 | 1610 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1611 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1612 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
6152 | 1613 |
^ 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
|
1614 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1615 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1616 |
"/ 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
|
1617 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1618 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1619 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1620 |
setContents:something |
5787 | 1621 |
"replace the whole contents by something new |
5413 | 1622 |
AND clear the remembered undo actions" |
1623 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1624 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1625 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1626 |
undoSupport resetHistories. |
2955 | 1627 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1628 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1629 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1630 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1631 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1632 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1633 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1634 |
|
4609 | 1635 |
!EditTextView methodsFor:'accessing-dimensions'! |
1636 |
||
1637 |
xOfCursor |
|
4728 | 1638 |
|point| |
1639 |
||
1640 |
cursorVisibleLine isNil ifTrue:[ |
|
6152 | 1641 |
"/ take the end of the selection, if any |
1642 |
(selectionStartLine notNil |
|
1643 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1644 |
ifTrue:[ |
|
1645 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1646 |
]. |
|
5787 | 1647 |
|
1648 |
"/ point := device |
|
4728 | 1649 |
"/ translatePoint:(device pointerPosition) |
1650 |
"/ fromView:nil |
|
1651 |
"/ toView:self. |
|
1652 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1653 |
"/ ^ point x |
|
1654 |
"/ ]. |
|
1655 |
"/ ^ 0 |
|
6152 | 1656 |
^ nil |
4728 | 1657 |
]. |
4609 | 1658 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1659 |
||
1660 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1661 |
! ! |
|
4590 | 1662 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1663 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1664 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1665 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1666 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1667 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1668 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1669 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1670 |
wasOn := self hideCursor. |
5643 | 1671 |
cursorFgColor := color1 onDevice:device. |
1672 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1673 |
wasOn ifTrue:[self showCursor] |
1333 | 1674 |
! |
1675 |
||
1899 | 1676 |
cursorType |
1677 |
"return the style of the text cursor. |
|
4721 | 1678 |
Currently, supported are: #none |
6152 | 1679 |
#block, #frame, #ibeam, #caret, #solidCaret |
1680 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1681 |
|
1682 |
^ cursorType |
|
1683 |
||
1684 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1685 |
! |
|
1686 |
||
1333 | 1687 |
cursorType:aCursorTypeSymbol |
1688 |
"set the style of the text cursor. |
|
4721 | 1689 |
Currently, supported are: #none |
6152 | 1690 |
#block, #frame, #ibeam, #caret, #solidCaret |
1691 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1692 |
|
1334 | 1693 |
cursorType := aCursorTypeSymbol. |
1333 | 1694 |
|
1695 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1696 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1697 |
! |
1698 |
||
1899 | 1699 |
cursorTypeNoFocus |
1700 |
"return the style of the text cursor when the view has no focus. |
|
1701 |
If left unspecified, this is the same as the regular cursorType." |
|
1702 |
||
1703 |
^ cursorTypeNoFocus |
|
1704 |
||
1705 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1706 |
! |
|
1707 |
||
1334 | 1708 |
cursorTypeNoFocus:aCursorTypeSymbol |
1709 |
"set the style of the text cursor when the view has no focus. |
|
1710 |
If left unspecified, this is the same as the regular cursorType." |
|
1711 |
||
1712 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1713 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1714 |
|
4048 | 1715 |
!EditTextView methodsFor:'accessing-replace'! |
1716 |
||
4746 | 1717 |
lastReplacementInfo |
1718 |
^ lastReplacementInfo |
|
1719 |
! |
|
1720 |
||
4048 | 1721 |
lastStringToReplace: aString |
4818 | 1722 |
! |
1723 |
||
1724 |
previousReplacements |
|
1725 |
"accessor for the code completion" |
|
1726 |
||
1727 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1728 |
! ! |
1729 |
||
2119 | 1730 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1731 |
|
125 | 1732 |
accept |
1733 |
"accept the current contents by executing the accept-action and/or |
|
5937 | 1734 |
changeMessage. |
1735 |
Historically, ST/X used a callBack (acceptAction); |
|
1736 |
and ST80/VW used the model, into which the text is stored. |
|
1737 |
We support both; if there is a mode, it gets a value: message, |
|
1738 |
If there is an acceptAction, it is called." |
|
125 | 1739 |
|
1108 | 1740 |
acceptEnabled == false ifTrue:[ |
6262 | 1741 |
self beepInEditor. |
5937 | 1742 |
^ self |
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1743 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1744 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
5937 | 1745 |
^ self |
1108 | 1746 |
]. |
1747 |
||
125 | 1748 |
lockUpdates := true. |
1013 | 1749 |
|
1750 |
"/ |
|
1751 |
"/ ST-80 way of doing it |
|
1752 |
"/ |
|
1753 |
model notNil ifTrue:[ |
|
5937 | 1754 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
1755 |
acceptChannel notNil ifTrue:[ |
|
1756 |
acceptChannel value:true withoutNotifying:self. |
|
1757 |
]. |
|
2999 | 1758 |
]. |
1759 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1760 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1761 |
"/ ST/X way of doing things |
5937 | 1762 |
"/ as a historic leftover, |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1763 |
"/ 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
|
1764 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1765 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1766 |
acceptAction notNil ifTrue:[ |
5937 | 1767 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1768 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1769 |
|
125 | 1770 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1771 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1772 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1773 |
! |
1774 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1775 |
argForChangeMessage |
597 | 1776 |
"return the argument to be passed with the change notification. |
1777 |
Defined as separate method for easier subclassability." |
|
1778 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1779 |
^ self contents |
597 | 1780 |
|
1781 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1782 |
! |
1783 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1784 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1785 |
"get my contents from the model. |
597 | 1786 |
Redefined to ignore updates resulting from my own changes |
1787 |
(i.e. if lockUpdates is true)." |
|
121 | 1788 |
|
1789 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1790 |
ignore updates from my own change |
121 | 1791 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1792 |
lockUpdates ifTrue:[ |
6152 | 1793 |
lockUpdates := false. |
1794 |
^ self |
|
121 | 1795 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1796 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1797 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1798 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1799 |
"/ validate the cursorLine |
3160 | 1800 |
(cursorLine notNil |
2310 | 1801 |
and:[ cursorLine > list size ]) ifTrue:[ |
6152 | 1802 |
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
|
1803 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1804 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1805 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1806 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1807 |
changedObject == acceptChannel ifTrue:[ |
6152 | 1808 |
acceptChannel value == true ifTrue:[ |
1809 |
self accept. |
|
1810 |
]. |
|
1811 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1812 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1813 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1814 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1815 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1816 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1817 |
! ! |
1818 |
||
6015 | 1819 |
!EditTextView methodsFor:'commenting'! |
1820 |
||
1821 |
commentFrom:line1 to:line2 commentStrings:commentStrings |
|
1822 |
"helper function to comment out a block. |
|
1823 |
All lines from line1 to line2 get an end-of-line comment |
|
1824 |
in the first col |
|
1825 |
(if no eol comment is available, a bracketing comment is used)." |
|
1826 |
||
1827 |
|eolComment opening closing| |
|
1828 |
||
1829 |
eolComment := commentStrings at:1. |
|
1830 |
eolComment isNil ifTrue:[ |
|
1831 |
opening := (commentStrings at:2) at:1. |
|
1832 |
closing := (commentStrings at:2) at:2. |
|
1833 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1834 |
]. |
|
1835 |
||
1836 |
line1 to:line2 do:[:lineNr | |
|
1837 |
|l| |
|
1838 |
||
1839 |
l := self listAt:lineNr. |
|
1840 |
l isNil ifTrue:[l := '']. |
|
1841 |
eolComment notNil ifTrue:[ |
|
1842 |
l := eolComment , l |
|
1843 |
] ifFalse:[ |
|
1844 |
l := opening , l , closing |
|
1845 |
]. |
|
1846 |
self replaceLine:lineNr with:l. |
|
1847 |
widthOfWidestLine notNil ifTrue:[ |
|
1848 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1849 |
]. |
|
1850 |
]. |
|
1851 |
self textChanged. |
|
1852 |
||
1853 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
|
1854 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1855 |
! |
|
1856 |
||
1857 |
commentSelection:commentStrings |
|
1858 |
"convenient function to comment out a block. |
|
1859 |
All lines from line1 to line2 get an end-of-line comment |
|
1860 |
in the first col." |
|
1861 |
||
1862 |
|e commentPair opening closing| |
|
1863 |
||
1864 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
6301 | 1865 |
commentStrings isEmptyOrNil ifTrue:[ self beepInEditor. ^ self]. |
6015 | 1866 |
|
1867 |
self |
|
1868 |
undoableDo:[ |
|
1869 |
selectionStartLine isNil ifTrue:[ |
|
1870 |
self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1871 |
] ifFalse:[ |
|
1872 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1873 |
self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1874 |
] ifFalse:[ |
|
1875 |
commentPair := commentStrings at:2 ifAbsent:nil. |
|
1876 |
commentPair isNil ifTrue:[ |
|
1877 |
self beep. |
|
1878 |
] ifFalse:[ |
|
1879 |
opening := commentPair at:1. |
|
1880 |
closing := commentPair at:2. |
|
1881 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1882 |
||
1883 |
e := selectionEndCol. |
|
1884 |
||
1885 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1886 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
1887 |
||
1888 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
|
1889 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1890 |
toLine:selectionEndLine col:e+closing size. |
|
1891 |
] |
|
1892 |
] |
|
1893 |
]. |
|
1894 |
] |
|
1895 |
info:'Comment'. |
|
1896 |
||
1897 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
|
1898 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
|
1899 |
! |
|
1900 |
||
1901 |
uncommentFrom:line1 to:line2 commentStrings:commentStrings |
|
1902 |
"helper function to comment out a block. |
|
1903 |
All lines from line1 to line2 get an end-of-line comment |
|
1904 |
in the first col. |
|
1905 |
(if no eol comment is available, a bracketing comment is removed)." |
|
1906 |
||
1907 |
|eolComment opening closing rest| |
|
1908 |
||
1909 |
eolComment := commentStrings at:1. |
|
1910 |
eolComment isNil ifTrue:[ |
|
1911 |
opening := (commentStrings at:2) at:1. |
|
1912 |
closing := (commentStrings at:2) at:2. |
|
1913 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1914 |
] ifFalse:[ |
|
1915 |
rest := eolComment size + 1. |
|
1916 |
]. |
|
1917 |
||
1918 |
line1 to:line2 do:[:lineNr | |
|
1919 |
|l| |
|
1920 |
||
1921 |
l := self listAt:lineNr. |
|
1922 |
l notNil ifTrue:[ |
|
1923 |
eolComment notNil ifTrue:[ |
|
1924 |
(l startsWith:eolComment) ifTrue:[ |
|
1925 |
l := l copyFrom:rest |
|
1926 |
] ifFalse:[ |
|
1927 |
(l withoutLeadingSeparators startsWith:eolComment) ifTrue:[ |
|
1928 |
"/ only for single lines? |
|
1929 |
true "line1 = line2" ifTrue:[ |
|
1930 |
|numSpaces| |
|
1931 |
||
1932 |
numSpaces := l indexOfNonSeparator - 1. |
|
1933 |
l := l copyFrom:numSpaces+1+rest. |
|
1934 |
l := (String new:numSpaces),l |
|
1935 |
]. |
|
1936 |
]. |
|
1937 |
] |
|
1938 |
] ifFalse:[ |
|
1939 |
((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[ |
|
1940 |
l := l copyFrom:opening size + 1. |
|
1941 |
l := l copyButLast:closing size. |
|
1942 |
]. |
|
1943 |
]. |
|
1944 |
self replaceLine:lineNr with:l. |
|
1945 |
] |
|
1946 |
]. |
|
1947 |
||
1948 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
1949 |
self textChanged. |
|
1950 |
! |
|
1951 |
||
1952 |
uncommentSelection:commentStrings |
|
1953 |
"convenient function to comment out a block. |
|
1954 |
All lines from line1 to line2 get an end-of-line comment |
|
1955 |
in the first col." |
|
1956 |
||
1957 |
|e commentPair opening closing sz1 sz2 l1 l2 c1 c2| |
|
1958 |
||
1959 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
6262 | 1960 |
commentStrings isNil ifTrue:[ self beepInEditor. ^ self]. |
6015 | 1961 |
|
1962 |
self |
|
1963 |
undoableDo:[ |
|
1964 |
selectionStartLine isNil ifTrue:[ |
|
1965 |
self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1966 |
] ifFalse:[ |
|
1967 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1968 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1969 |
] ifFalse:[ |
|
1970 |
commentPair := commentStrings at:2. |
|
1971 |
opening := commentPair at:1. |
|
1972 |
closing := commentPair at:2. |
|
1973 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1974 |
||
1975 |
sz1 := opening size. |
|
1976 |
sz2 := closing size. |
|
1977 |
||
1978 |
((self |
|
1979 |
stringAtLine:selectionStartLine |
|
1980 |
from:selectionStartCol |
|
1981 |
to:selectionStartCol+sz1 - 1) = opening |
|
1982 |
and:[(self |
|
1983 |
stringAtLine:selectionEndLine |
|
1984 |
from:selectionEndCol - sz2 + 1 |
|
1985 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1986 |
||
1987 |
l2 := selectionEndLine. c2 := selectionEndCol. |
|
1988 |
l1 := selectionStartLine. c1 := selectionStartCol. |
|
1989 |
self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2. |
|
1990 |
self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1. |
|
1991 |
||
1992 |
e := c2 - sz2. |
|
1993 |
l1 == l2 ifTrue:[e := e - sz1]. |
|
1994 |
self selectFromLine:l1 col:c1 toLine:l2 col:e. |
|
1995 |
] |
|
1996 |
] |
|
1997 |
]. |
|
1998 |
] |
|
1999 |
info:'Uncomment'. |
|
2000 |
||
2001 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
|
2002 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
|
2003 |
! ! |
|
2004 |
||
121 | 2005 |
!EditTextView methodsFor:'cursor handling'! |
2006 |
||
4820 | 2007 |
basicCursorReturn |
2008 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2009 |
||
2010 |
|wasOn| |
|
2011 |
||
2012 |
self checkForExistingLine:(cursorLine + 1). |
|
2013 |
cursorVisibleLine notNil ifTrue:[ |
|
6152 | 2014 |
nFullLinesShown notNil ifTrue:[ |
6339 | 2015 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDownLines:1] |
6152 | 2016 |
] |
4820 | 2017 |
]. |
2018 |
||
2019 |
wasOn := self hideCursor. |
|
2020 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
2021 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2022 |
||
6339 | 2023 |
"Modified: / 22-05-1996 / 18:27:34 / cg" |
2024 |
"Modified: / 13-06-2018 / 22:14:31 / Claus Gittinger" |
|
4820 | 2025 |
! |
2026 |
||
2406 | 2027 |
characterPositionOfCursor |
2028 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
2029 |
! |
|
2030 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2031 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2032 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2033 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2034 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2035 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2036 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2037 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2038 |
"move cursor to some column in the current line" |
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 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2041 |
|
2822 | 2042 |
(cursorCol == newCol) ifTrue:[^ self]. |
2043 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2044 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2045 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2046 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2047 |
|
2048 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2049 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2050 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2051 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2052 |
"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
|
2053 |
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
|
2054 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2055 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2056 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2057 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2058 |
|
2707 | 2059 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2060 |
cursorLine > list size ifTrue:[ |
6152 | 2061 |
wasOn := self hideCursor. |
2062 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
2063 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6262 | 2064 |
self beepInEditor. |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2065 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2066 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2067 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2068 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2069 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2070 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2071 |
"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
|
2072 |
|
5857 | 2073 |
|inLastLine wasOn nv nL cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2074 |
|
4595 | 2075 |
(nL := cursorLine) isNil ifTrue:[ |
5857 | 2076 |
nL := firstLineShown |
2077 |
]. |
|
2078 |
||
2079 |
inLastLine := (nL == list size). |
|
5890 | 2080 |
|
5857 | 2081 |
inLastLine ifTrue:[ |
5858 | 2082 |
|generateTextAfterEndHook| |
5857 | 2083 |
|
2084 |
cursorColBefore := cursorCol. |
|
5858 | 2085 |
(generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[ |
5860 | 2086 |
wasOn := self hideCursor. |
2087 |
nL := generateTextAfterEndHook value:(nL + n). |
|
2088 |
self setValidatedCursorLine:nL col:cursorColBefore. |
|
2089 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2090 |
^ self. |
|
5890 | 2091 |
]. |
4595 | 2092 |
]. |
2093 |
||
2094 |
self st80EditMode ifTrue:[ |
|
5857 | 2095 |
nL == list size ifTrue:[ |
2096 |
wasOn := self hideCursor. |
|
2097 |
self setValidatedCursorLine:nL col:(self listAt:nL) size + 1. |
|
2098 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6262 | 2099 |
self beepInEditor. |
5857 | 2100 |
^ self. |
2101 |
] |
|
4595 | 2102 |
]. |
2103 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2104 |
cursorVisibleLine notNil ifTrue:[ |
5857 | 2105 |
wasOn := self hideCursor. |
2106 |
nv := cursorVisibleLine + n - 1. |
|
2107 |
(nv >= nFullLinesShown) ifTrue:[ |
|
6339 | 2108 |
self scrollDownLines:(nv - nFullLinesShown + 1) |
5857 | 2109 |
]. |
2110 |
self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol). |
|
2111 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2112 |
] ifFalse:[ |
5857 | 2113 |
self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol). |
2114 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2115 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2116 |
|
6339 | 2117 |
"Modified: / 10-06-1998 / 16:59:17 / cg" |
2118 |
"Modified: / 13-06-2018 / 22:08:21 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2119 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2120 |
|
121 | 2121 |
cursorHome |
597 | 2122 |
"scroll to top AND move cursor to first line of text." |
121 | 2123 |
|
674 | 2124 |
self cursorLine:1 col:1 |
2125 |
||
2126 |
"/ |wasOn| |
|
2127 |
"/ |
|
2128 |
"/ wasOn := self hideCursor. |
|
2129 |
"/ self scrollToTop. |
|
2130 |
"/ cursorLine := cursorVisibleLine := 1. |
|
2131 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
2132 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
2133 |
||
2134 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 2135 |
! |
2136 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2137 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2139 |
|
6207 | 2140 |
|wasOn| |
2141 |
||
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2142 |
(cursorCol ~~ 1) ifTrue:[ |
6207 | 2143 |
wasOn := self hideCursor. |
2144 |
self setValidatedCursorCol:(cursorCol - 1). |
|
2145 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2146 |
"/ self cursorCol:(cursorCol - 1) |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2147 |
] ifFalse:[ |
6152 | 2148 |
cursorLine ~~ 1 ifTrue:[ |
2149 |
self st80EditMode ifTrue:[ |
|
2150 |
self cursorUp. |
|
2151 |
self cursorToEndOfLine. |
|
2152 |
] |
|
2153 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2154 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2155 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
2156 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2157 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2158 |
|
4126 | 2159 |
cursorLeft:n |
2160 |
"move cursor to left" |
|
2161 |
||
2162 |
n timesRepeat:[ |
|
6152 | 2163 |
self cursorLeft |
4126 | 2164 |
]. |
2165 |
! |
|
2166 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2167 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2168 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2169 |
|
5056 | 2170 |
self cursorLine:line col:col makeVisible:true |
2171 |
! |
|
2172 |
||
2173 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
2174 |
"this positions onto physical - not visible - line" |
|
2175 |
||
676 | 2176 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2177 |
|
2822 | 2178 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
2179 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2180 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2181 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2182 |
|
6563 | 2183 |
newCol := (col max:1). |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2184 |
self st80EditMode ifTrue:[ |
6152 | 2185 |
(cursorLine == list size |
2186 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
2187 |
newCol := (self listAt:(list size)) size + 1. |
|
2188 |
] |
|
1419 | 2189 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2190 |
self setValidatedCursorCol:newCol. |
5056 | 2191 |
makeVisibleBoolean ifTrue:[ |
6152 | 2192 |
self makeCursorVisibleAndShowCursor:wasOn. |
5056 | 2193 |
] ifFalse:[ |
6152 | 2194 |
wasOn ifTrue:[self showCursor] |
5056 | 2195 |
]. |
672 | 2196 |
|
6563 | 2197 |
"Modified: / 20-06-1998 / 18:19:06 / cg" |
2198 |
"Modified: / 21-03-2019 / 12:53:27 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2199 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2200 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2201 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2202 |
"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
|
2203 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2204 |
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
|
2205 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2206 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2207 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2208 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2209 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2210 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2211 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2212 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2213 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2214 |
"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
|
2215 |
|
4820 | 2216 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2217 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2218 |
|
5529 | 2219 |
cursorReturn:withPossibleAutoIndent |
2220 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2221 |
||
2222 |
self basicCursorReturn |
|
2223 |
! |
|
2224 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2225 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2226 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2227 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2228 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2229 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2230 |
self st80EditMode ifTrue:[ |
6210 | 2231 |
self isInputField ifFalse:[ |
2232 |
l := (self listAt:cursorLine). |
|
2233 |
cursorCol >= (l size + 1) ifTrue:[ |
|
2234 |
cursorLine <= list size ifTrue:[ |
|
2235 |
self cursorReturn:false. "/ no autoindent |
|
2236 |
]. |
|
2237 |
^ self |
|
2238 |
] |
|
2239 |
]. |
|
3160 | 2240 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2241 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2242 |
|
6210 | 2243 |
"Modified: / 27-09-2017 / 15:38:26 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2244 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2245 |
|
4126 | 2246 |
cursorRight:n |
2247 |
"move cursor to right" |
|
2248 |
||
2249 |
n timesRepeat:[ |
|
6152 | 2250 |
self cursorRight |
4126 | 2251 |
]. |
2252 |
! |
|
2253 |
||
1833 | 2254 |
cursorShown:aBoolean |
2255 |
"change cursor visibility |
|
2256 |
return true if cursor was visible before." |
|
2257 |
||
2258 |
|oldState| |
|
2259 |
||
4494 | 2260 |
aBoolean == cursorShown ifTrue:[ |
6152 | 2261 |
^ cursorShown |
4494 | 2262 |
]. |
1833 | 2263 |
oldState := cursorShown. |
2264 |
||
2265 |
aBoolean ifTrue:[ |
|
6152 | 2266 |
self drawCursor. |
1833 | 2267 |
] ifFalse:[ |
6152 | 2268 |
(cursorShown and:[shown]) ifTrue: [ |
2269 |
self undrawCursor. |
|
2270 |
]. |
|
1833 | 2271 |
]. |
2272 |
cursorShown := aBoolean. |
|
2273 |
||
2274 |
^ oldState |
|
2275 |
||
2276 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
2277 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
2278 |
! |
|
2279 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2280 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2281 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2282 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2283 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2284 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2285 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2286 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2287 |
"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
|
2288 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2289 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2290 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2291 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2292 |
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
|
2293 |
cursorCol > textStart ifTrue:[ |
6152 | 2294 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2295 |
] ifFalse:[ |
6152 | 2296 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2297 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2298 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2299 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2300 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2301 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2302 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2303 |
"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
|
2304 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2305 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2306 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2307 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2308 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2309 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2310 |
(newTop < 1) ifTrue:[ |
6152 | 2311 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2312 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2313 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2314 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2315 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2316 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2317 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2318 |
|
674 | 2319 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2320 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2321 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2322 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2323 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2324 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2325 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2326 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2327 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2328 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2329 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2330 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2331 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2332 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2333 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2334 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2335 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2336 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2337 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2338 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2339 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2340 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2341 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2342 |
cursorLine >= lineNr ifTrue:[ |
6152 | 2343 |
line := self listAt:cursorLine. |
2344 |
(line isEmptyOrNil) ifTrue:[ |
|
2345 |
^ self |
|
2346 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2347 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2348 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2349 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2350 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2351 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2352 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2353 |
(newTop < 1) ifTrue:[ |
6152 | 2354 |
newTop := 1 |
259
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 scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2357 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2358 |
self setValidatedCursorLine:lineNr col:1. |
259
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 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2361 |
|
674 | 2362 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2363 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2364 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2365 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2366 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2367 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2368 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2369 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2370 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2371 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2372 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2373 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
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 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2376 |
cursorToEndOfText |
4288 | 2377 |
"move cursor to the end of the text (behind the last character in last line)" |
2378 |
||
2379 |
|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
|
2380 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2381 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2382 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2383 |
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
|
2384 |
(newTop < 1) ifTrue:[ |
6152 | 2385 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2386 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2387 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2388 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2389 |
self setValidatedCursorLine:list size. |
4288 | 2390 |
lastLineLength := (self listAt:cursorLine) size. |
2391 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2392 |
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
|
2393 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2394 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2395 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2396 |
"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
|
2397 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2398 |
|
3310 | 2399 |
cursorToEndOfWord |
2400 |
"move the cursor to the end of the word" |
|
2401 |
||
2402 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2403 |
||
2404 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2405 |
:beginLine :beginCol :endLine :endCol :style | |
2406 |
||
2407 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2408 |
] |
2409 |
||
2410 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2411 |
! |
|
2412 |
||
131 | 2413 |
cursorToFirstVisibleLine |
2414 |
"place cursor into the first visible line; do not scroll." |
|
2415 |
||
2416 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2417 |
! |
|
2418 |
||
2419 |
cursorToLastVisibleLine |
|
2420 |
"place cursor into the first visible line; do not scroll." |
|
2421 |
||
2422 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2423 |
! |
|
2424 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2425 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2426 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2427 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2428 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2429 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2430 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2431 |
|
5787 | 2432 |
self |
6152 | 2433 |
wordAtLine:cursorLine col:cursorCol |
2434 |
do:[ |
|
2435 |
:beginLine :beginCol :endLine :endCol :style | |
|
6154 | 2436 |
|lineSize| |
6152 | 2437 |
|
2438 |
line := endLine. |
|
2439 |
col := endCol + 1. |
|
6154 | 2440 |
lineSize := (self listAt:line) size. |
2441 |
(endCol ~= lineSize or:[lineSize == 0]) ifTrue:[ |
|
2442 |
searching := true. |
|
2443 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
2444 |
self wordAtLine:line col:col do:[ |
|
2445 |
:beginLine :beginCol :endLine :endCol :style | |
|
2446 |
||
2447 |
(line > list size) ifTrue:[ |
|
2448 |
"break out" |
|
2449 |
searching := false |
|
2450 |
] ifFalse:[ |
|
2451 |
line := endLine. |
|
2452 |
col := endCol + 1. |
|
2453 |
] |
|
6152 | 2454 |
] |
6154 | 2455 |
]. |
6152 | 2456 |
]. |
2457 |
self cursorLine:line col:col |
|
4707 | 2458 |
] |
6154 | 2459 |
|
2460 |
"Modified: / 11-05-2017 / 17:50:47 / stefan" |
|
121 | 2461 |
! |
2462 |
||
499 | 2463 |
cursorToPreviousWord |
2464 |
"move the cursor to the beginning of this or the previous word" |
|
2465 |
||
6154 | 2466 |
|col line searching| |
499 | 2467 |
|
2468 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2469 |
:beginLine :beginCol :endLine :endCol :style | |
2470 |
||
2471 |
line := beginLine. |
|
2472 |
col := beginCol. |
|
2473 |
style == #wordLeft ifTrue:[ |
|
2474 |
col := col + 1 |
|
2475 |
]. |
|
2476 |
||
2477 |
(cursorLine == line |
|
2478 |
and:[cursorCol == col]) ifTrue:[ |
|
2479 |
searching := true. |
|
2480 |
||
2481 |
col > 1 ifTrue:[ |
|
2482 |
col := col - 1. |
|
2483 |
]. |
|
2484 |
||
2485 |
[searching] whileTrue:[ |
|
2486 |
(col == 1) ifTrue:[ |
|
2487 |
line == 1 ifTrue:[ |
|
2488 |
searching := false |
|
2489 |
] ifFalse:[ |
|
2490 |
line := line - 1. |
|
6154 | 2491 |
col := (list at:line) size + 1. |
2492 |
col ~~ 1 ifTrue:[ |
|
2493 |
"at end of word in previous line" |
|
2494 |
searching := false. |
|
2495 |
]. |
|
6152 | 2496 |
] |
2497 |
] ifFalse:[ |
|
2498 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2499 |
self wordAtLine:line col:col do:[ |
|
2500 |
:beginLine :beginCol :endLine :endCol :style | |
|
2501 |
||
2502 |
line := beginLine. |
|
2503 |
col := beginCol. |
|
2504 |
style == #wordLeft ifTrue:[ |
|
2505 |
col := col + 1 |
|
2506 |
]. |
|
2507 |
searching := false. |
|
2508 |
] |
|
2509 |
] ifTrue:[ |
|
2510 |
col := col - 1 |
|
2511 |
] |
|
2512 |
] |
|
2513 |
] |
|
2514 |
]. |
|
2515 |
self cursorLine:line col:col |
|
499 | 2516 |
] |
2517 |
||
6154 | 2518 |
"Created: / 08-03-1996 / 21:52:48 / cg" |
2519 |
"Modified (format): / 11-05-2017 / 17:45:11 / stefan" |
|
499 | 2520 |
! |
2521 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2522 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2523 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2524 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2525 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2526 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2527 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2528 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2529 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2530 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2531 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2532 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2533 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2534 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2535 |
"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
|
2536 |
|
5856 | 2537 |
|wasOn nv nl cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2538 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2539 |
cursorLine isNil ifTrue:[ |
5850 | 2540 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2541 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2542 |
nl := cursorLine - n. |
5850 | 2543 |
nl < 1 ifTrue:[ |
5858 | 2544 |
|generateTextBeforeStartHook| |
5890 | 2545 |
|
5856 | 2546 |
cursorColBefore := cursorCol. |
5858 | 2547 |
(generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[ |
2548 |
nl := generateTextBeforeStartHook value:nl |
|
5890 | 2549 |
]. |
5850 | 2550 |
nl := nl max:1 |
2551 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2552 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2553 |
(nl ~~ cursorLine) ifTrue: [ |
5850 | 2554 |
wasOn := self hideCursor. |
2555 |
cursorVisibleLine notNil ifTrue:[ |
|
2556 |
nv := cursorVisibleLine - n. |
|
2557 |
nv < 1 ifTrue:[ |
|
6339 | 2558 |
self scrollUpLines:(nv negated + 1) |
5850 | 2559 |
]. |
2560 |
]. |
|
5856 | 2561 |
self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol). |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2562 |
"/ wasOn ifTrue:[self showCursor]. |
5850 | 2563 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2564 |
] |
672 | 2565 |
|
6339 | 2566 |
"Modified: / 22-05-1996 / 18:28:11 / cg" |
2567 |
"Modified: / 13-06-2018 / 22:45:32 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2568 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2569 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2570 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2571 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2572 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2573 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2574 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2575 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2576 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2577 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2578 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2579 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2580 |
|
676 | 2581 |
newCol := colNr. |
2582 |
(newCol < 1) ifTrue:[ |
|
6152 | 2583 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2584 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2585 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2586 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2587 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2588 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2589 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2590 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2591 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2592 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2593 |
"put cursor to position next to x/y coordinate in view" |
121 | 2594 |
|
2595 |
|line col| |
|
2596 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2597 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2598 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2599 |
self cursorVisibleLine:line col:col. |
121 | 2600 |
! |
2601 |
||
2602 |
drawCursor |
|
2603 |
"draw the cursor if shown and cursor is visible. |
|
2604 |
(but not, if there is a selection - to avoid confusion)" |
|
2605 |
||
2606 |
shown ifTrue:[ |
|
6152 | 2607 |
cursorVisibleLine notNil ifTrue:[ |
2608 |
self hasSelection ifFalse:[ |
|
2609 |
self drawCursorCharacter |
|
2610 |
] |
|
2611 |
] |
|
121 | 2612 |
] |
2613 |
! |
|
2614 |
||
2615 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2616 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2617 |
of cursor should be drawn. |
5787 | 2618 |
Currently, supported are: #none, |
6031 | 2619 |
#block, #frame, #ibeam, #caret, #solidCaret |
2620 |
#bigCaret and #bigSolidCaret" |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2621 |
|
2570 | 2622 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2623 |
|
2624 |
self hasSelection ifTrue:[ |
|
6031 | 2625 |
" |
2626 |
hide cursor, if there is a selection |
|
2627 |
" |
|
2628 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2629 |
]. |
2630 |
||
1334 | 2631 |
cursorType == #none ifTrue:[ |
6031 | 2632 |
^ self |
1334 | 2633 |
]. |
2634 |
||
121 | 2635 |
cursorType == #block ifTrue:[ |
6031 | 2636 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
2637 |
^ self |
|
121 | 2638 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2639 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2640 |
y := self yOfVisibleLine:cursorVisibleLine. |
2641 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2642 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2643 |
cursorType == #frame ifTrue:[ |
6031 | 2644 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2645 |
||
2646 |
char := self characterUnderCursor asString. |
|
6068 | 2647 |
gc paint:bgColor. |
2648 |
gc displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
|
133 | 2649 |
] ifFalse:[ |
6031 | 2650 |
self paint:bgColor. |
2651 |
cursorType == #ibeam ifTrue:[ |
|
2652 |
x1 := x - 1. |
|
2653 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2654 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2655 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
6031 | 2656 |
^ self |
2657 |
]. |
|
2658 |
||
2659 |
cursorType == #Ibeam ifTrue:[ |
|
2660 |
x1 := x - 1. |
|
2661 |
y := y + 1. |
|
2662 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2663 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2664 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
2665 |
gc displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2666 |
gc displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
6031 | 2667 |
^ self |
2668 |
]. |
|
2669 |
||
2670 |
y := y + fontHeight - 3. |
|
2671 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2672 |
w := (fontWidth * 2 // 3) max:4. |
|
2673 |
y2 := y + w + (w//2). |
|
2674 |
] ifFalse:[ |
|
2675 |
w := (fontWidth // 2) max:4. |
|
2676 |
y2 := y + w. |
|
2677 |
]. |
|
2678 |
x1 := x - w. |
|
2679 |
x2 := x + w. |
|
2680 |
||
2681 |
oldClip := self clippingBoundsOrNil. |
|
2682 |
self clippingBounds:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2683 |
||
2684 |
cursorType == #caret ifTrue:[ |
|
6068 | 2685 |
gc lineWidth:2. |
2686 |
gc displayLineFromX:x1 y:y2 toX:x y:y. |
|
2687 |
gc displayLineFromX:x y:y toX:x2 y:y2. |
|
6031 | 2688 |
] ifFalse:[ |
2689 |
"anything else: solidCaret" |
|
2690 |
||
6068 | 2691 |
gc fillPolygon:(Array with:(x1 @ y2) |
2692 |
with:(x @ y) |
|
2693 |
with:(x2 @ y2)) |
|
6031 | 2694 |
]. |
2695 |
||
2696 |
self clippingBounds:oldClip |
|
121 | 2697 |
]. |
6068 | 2698 |
gc paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2699 |
|
2088 | 2700 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2701 |
! |
2702 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2703 |
drawCursorCharacter |
3160 | 2704 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2705 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2706 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2707 |
|
3160 | 2708 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2709 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2710 |
and:[self isReadOnly not]]) ifTrue:[ |
6152 | 2711 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2712 |
] ifFalse:[ |
6152 | 2713 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2714 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2715 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2716 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2717 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2718 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2719 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2720 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2721 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2722 |
self hasSelection ifTrue:[ |
6152 | 2723 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2724 |
]. |
2725 |
cursorType == #none ifTrue:[ |
|
6152 | 2726 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2727 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2728 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2729 |
|
2730 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2731 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2732 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2733 |
drawNoFocusCursor |
3160 | 2734 |
"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
|
2735 |
|
1334 | 2736 |
|cType| |
2737 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2738 |
self hasSelection ifTrue:[ |
6152 | 2739 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2740 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2741 |
|
1334 | 2742 |
cType := cursorTypeNoFocus ? cursorType. |
2743 |
cType == #none ifTrue:[ |
|
6152 | 2744 |
^ self undrawCursor |
1334 | 2745 |
]. |
2746 |
||
2747 |
cType == #block ifTrue:[ |
|
6152 | 2748 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2749 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2750 |
|
1334 | 2751 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2752 |
||
2753 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2754 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2755 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2756 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2757 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2758 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2759 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2760 |
self makeLineVisible:aLineNumber. |
2951 | 2761 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2762 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2763 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2764 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2765 |
hideCursor |
1833 | 2766 |
"make cursor invisible if currently invisible" |
2767 |
||
2768 |
^ self cursorShown:false |
|
2769 |
||
2770 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2771 |
! |
2772 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2773 |
makeCursorVisible |
3160 | 2774 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2775 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2776 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2777 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2778 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2779 |
cursorLine notNil ifTrue:[ |
6152 | 2780 |
line := cursorLine. |
2781 |
col := cursorCol. |
|
2782 |
" |
|
2783 |
if there is a selection, its better to |
|
2784 |
have its start being visible, instead of the end |
|
2785 |
" |
|
2786 |
(selectionStartLine notNil |
|
2787 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2788 |
expandingTop ~~ false ifTrue:[ |
|
2789 |
line := selectionStartLine. |
|
2790 |
col := selectionStartCol. |
|
2791 |
] ifFalse:[ |
|
2792 |
line := selectionEndLine. |
|
2793 |
col := selectionEndCol |
|
2794 |
] |
|
2795 |
]. |
|
2796 |
self makeLineVisible:line. |
|
2797 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2798 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2799 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2800 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2801 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2802 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2803 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2804 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2805 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2806 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2807 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2808 |
flag ifTrue:[self showCursor] |
121 | 2809 |
! |
2810 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2811 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2812 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2813 |
|
2815 | 2814 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2815 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2816 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2817 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2818 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2819 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2820 |
|
3303 | 2821 |
"/ self assert:(lineNr notNil). |
2822 |
||
2823 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2824 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2825 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2826 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2827 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2828 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2829 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2830 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2831 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2832 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2833 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2834 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2835 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2836 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2837 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2838 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2839 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2840 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2841 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2842 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2843 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2844 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2845 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2846 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2847 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2848 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2849 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2850 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2851 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2852 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2853 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2854 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2855 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2856 |
|
1833 | 2857 |
^ self cursorShown:true |
2858 |
||
2859 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2860 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2861 |
|
5761 | 2862 |
singleQuoteSelection |
2863 |
"place single quotes around the selected text" |
|
2864 |
||
2865 |
|line1 col1 line2 col2| |
|
2866 |
||
2867 |
line1 := self selectionStartLine. |
|
2868 |
col1 := self selectionStartCol. |
|
2869 |
line2 := self selectionEndLine. |
|
2870 |
col2 := self selectionEndCol. |
|
2871 |
(line1 notNil |
|
6152 | 2872 |
and:[ col1 notNil |
2873 |
and:[ line2 notNil |
|
2874 |
and:[ col2 notNil ]]]) |
|
5761 | 2875 |
ifTrue:[ |
6152 | 2876 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
2877 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2878 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
5761 | 2879 |
] ifFalse:[ |
6262 | 2880 |
self beepInEditor. |
5761 | 2881 |
] |
2882 |
||
2883 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2884 |
! |
|
2885 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2886 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2887 |
"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
|
2888 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2889 |
|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
|
2890 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2891 |
cursorVisibleLine notNil ifTrue:[ |
6031 | 2892 |
prevCol := cursorCol - 1. |
2893 |
||
2894 |
"/ if there is any italic stuff in the cursor line, |
|
2895 |
"/ redraw it completely (because characters overlap). |
|
2896 |
cursorCol > 1 ifTrue:[ |
|
2897 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2898 |
line hasChangeOfEmphasis ifTrue:[ |
|
2899 |
line size >= (cursorCol-1) ifTrue:[ |
|
2900 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2901 |
line size >= (cursorCol) ifTrue:[ |
|
2902 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2903 |
line size >= (cursorCol+1) ifTrue:[ |
|
2904 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2905 |
]. |
|
2906 |
]. |
|
2907 |
]. |
|
2908 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2909 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2910 |
] |
|
2911 |
] |
|
2912 |
] |
|
2913 |
]. |
|
2914 |
||
2915 |
((cursorType == #caret) |
|
2916 |
or:[cursorType == #solidCaret |
|
2917 |
or:[cursorType == #bigSolidCaret |
|
2918 |
or:[cursorType == #bigCaret |
|
2919 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2920 |
"caret-cursor touches 4 characters" |
|
2921 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2922 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2923 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2924 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2925 |
] ifFalse:[ |
|
2926 |
"care for left margin" |
|
2927 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2928 |
]. |
|
2929 |
^ self |
|
2930 |
]. |
|
2931 |
||
2932 |
cursorType == #ibeam ifTrue:[ |
|
2933 |
"ibeam-cursor touches 2 characters" |
|
2934 |
cursorCol > 1 ifTrue:[ |
|
2935 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2936 |
] ifFalse:[ |
|
2937 |
"care for left margin" |
|
2938 |
super redrawVisibleLine:cursorVisibleLine. |
|
2939 |
]. |
|
2940 |
^ self |
|
2941 |
]. |
|
2942 |
||
2943 |
"block cursor is simple - just one character under cursor" |
|
2944 |
||
2945 |
"/ however, if italic characters are involved, we must care |
|
2946 |
"/ for the chars before/after the cursor. |
|
2947 |
"/ We redraw the part of the previous character which got |
|
2948 |
"/ detroyed by the block cursor. |
|
2949 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2950 |
||
2951 |
line := self visibleAt:cursorVisibleLine. |
|
2952 |
(line notNil and:[line isText]) ifTrue:[ |
|
2953 |
cursorCol > 1 ifTrue:[ |
|
2954 |
oldClip := self clippingBoundsOrNil. |
|
2955 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2956 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2957 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
|
2958 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2959 |
self clippingBounds:oldClip. |
|
2960 |
^ self. |
|
2961 |
]. |
|
2962 |
]. |
|
2963 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2964 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2965 |
|
2088 | 2966 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2967 |
! |
2968 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2969 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2970 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2971 |
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
|
2972 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2973 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2974 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2975 |
|
672 | 2976 |
validateCursorCol:col inLine:line |
674 | 2977 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2978 |
Here, no limits are enforced (and col is returned), |
5593 | 2979 |
but it may be redefined in EditFields or views which don't like the |
674 | 2980 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2981 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2982 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2983 |
|
1419 | 2984 |
"/ in ST80 mode, |
2707 | 2985 |
"/ the cursor may not be positioned beyond the |
2986 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2987 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2988 |
self st80EditMode ifTrue:[ |
6152 | 2989 |
l := (self listAt:line). |
2990 |
max := l size + 1. |
|
2991 |
col > max ifTrue:[ |
|
2992 |
^ max |
|
2993 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2994 |
]. |
672 | 2995 |
^ col |
2996 |
||
1419 | 2997 |
"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
|
2998 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2999 |
! |
3000 |
||
3001 |
validateCursorLine:line |
|
6171 | 3002 |
"check if line is a valid cursor line; return a fixed line-nr if not. |
3160 | 3003 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 3004 |
redefined in views which don't like the cursor to be positioned |
674 | 3005 |
behind the end of the text (vi/st-80 behavior), or want to |
3006 |
skip reserved regions" |
|
3007 |
||
1419 | 3008 |
"/ |
3009 |
"/ in st80Mode, the cursor may not be positioned |
|
5787 | 3010 |
"/ beyond the last line |
6091 | 3011 |
"/ (but it must be possible to place it on one line below the last one |
5367 | 3012 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
1419 | 3013 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3014 |
self st80EditMode ifTrue:[ |
6091 | 3015 |
^ (line min:(list size + 1)) max:1 |
1419 | 3016 |
]. |
674 | 3017 |
^ line |
3018 |
||
6091 | 3019 |
"Created: / 22-05-1996 / 18:22:23 / cg" |
3020 |
"Modified: / 20-06-1998 / 18:19:26 / cg" |
|
3021 |
"Modified (comment): / 11-02-2017 / 09:12:37 / cg" |
|
6171 | 3022 |
"Modified (comment): / 19-06-2017 / 16:25:27 / mawalch" |
672 | 3023 |
! |
3024 |
||
121 | 3025 |
withCursorOffDo:aBlock |
3026 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
3027 |
||
3028 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
6152 | 3029 |
^ aBlock value |
121 | 3030 |
]. |
3031 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
3032 |
aBlock ensure:[ |
6152 | 3033 |
self showCursor |
121 | 3034 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3035 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3036 |
|
2589 | 3037 |
!EditTextView methodsFor:'drag & drop'! |
3038 |
||
3039 |
allowDrop:aBoolean |
|
3236 | 3040 |
"enable/disable drop support" |
3041 |
||
2589 | 3042 |
aBoolean ifFalse:[ |
6152 | 3043 |
dropTarget := nil. |
2589 | 3044 |
] ifTrue:[ |
6152 | 3045 |
dropTarget isNil ifTrue:[ |
3046 |
dropTarget := DropTarget |
|
3047 |
receiver:self |
|
3048 |
argument:nil |
|
3049 |
dropSelector:#'drop:' |
|
3050 |
canDropSelector:#'canDrop:' |
|
3051 |
] |
|
3236 | 3052 |
]. |
3053 |
! |
|
3054 |
||
3412 | 3055 |
canDrop:aDropContext |
3056 |
"public from d&d. |
|
3057 |
I accept textObjects and fileObjects only." |
|
3058 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
3059 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 3060 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
3061 |
^ self canDropObjects:aDropContext dropObjects |
|
3062 |
||
3063 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
3064 |
! |
|
3065 |
||
3066 |
canDropObjects:aCollectionOfDropObjects |
|
3067 |
"public from d&d. |
|
3068 |
I accept textObjects and fileObjects only." |
|
2589 | 3069 |
|
3070 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
3071 |
||
3412 | 3072 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
3073 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
3074 |
||
3075 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
3076 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
3077 |
! |
|
3078 |
||
3079 |
drop:aDropContext |
|
3080 |
"public from d&d. |
|
3081 |
drop objects (new API)" |
|
3082 |
||
3083 |
self dropObjects:(aDropContext dropObjects) |
|
3084 |
||
3085 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
3086 |
! |
|
3087 |
||
3088 |
dropFileObject:aDropObject |
|
2589 | 3089 |
"drop objects |
3236 | 3090 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
3091 |
||
4136 | 3092 |
|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
|
3093 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3094 |
pasteWhat := #name. |
3412 | 3095 |
|
3096 |
fn := aDropObject asFilename. |
|
3097 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
6152 | 3098 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
3099 |
(enforcedDropMode notNil |
|
3100 |
and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[ |
|
3101 |
pasteWhat := enforcedDropMode. |
|
3102 |
] ifFalse:[ |
|
3103 |
sensor := self sensor. |
|
3104 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
|
3105 |
pasteWhat := #name. |
|
3106 |
] ifFalse:[ |
|
3107 |
(sensor metaDown) ifTrue:[ |
|
3108 |
pasteWhat := #contents. |
|
3109 |
] ifFalse:[ |
|
3110 |
dontAskAgainHolder := false asValue. |
|
3111 |
answer := Dialog |
|
3112 |
confirmWithCancel:(resources |
|
3113 |
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.' |
|
3114 |
with:fn name allBold) |
|
3115 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
|
3116 |
values:#( nil #name #contents ) |
|
3117 |
default:#contents |
|
3118 |
check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder |
|
3119 |
title:(resources string:'Drop What'). |
|
3120 |
answer isNil ifTrue:[ ^ self ]. |
|
3121 |
||
3122 |
dontAskAgainHolder value ifTrue:[ |
|
3123 |
UserPreferences current enforcedDropModeForFiles:#contents |
|
3124 |
]. |
|
3125 |
pasteWhat := answer. |
|
3126 |
] |
|
3127 |
] |
|
3128 |
]. |
|
3886 | 3129 |
]. |
3130 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3131 |
pasteWhat == #name ifTrue:[ |
6152 | 3132 |
text := fn pathName |
3886 | 3133 |
] ifFalse:[ |
6152 | 3134 |
self withWaitCursorDo:[ |
3135 |
text := fn contentsAsString |
|
3136 |
]. |
|
3137 |
(app := self application) notNil ifTrue:[ |
|
3138 |
app droppedFile:fn in:self |
|
3139 |
]. |
|
5787 | 3140 |
]. |
3141 |
||
3142 |
self |
|
6152 | 3143 |
undoablePaste:text |
3144 |
info:'Drop File'. |
|
3412 | 3145 |
|
3146 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 3147 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 3148 |
! |
3149 |
||
3150 |
dropObject:aDropObject |
|
3151 |
"drop objects |
|
3152 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
3153 |
||
3415 | 3154 |
|text| |
3155 |
||
3412 | 3156 |
(aDropObject isFileObject) ifTrue:[ |
6152 | 3157 |
self dropFileObject:aDropObject |
3412 | 3158 |
] ifFalse:[ |
6152 | 3159 |
aDropObject isTextObject ifTrue:[ |
3160 |
text := aDropObject theObject. |
|
3161 |
text isStringCollection ifTrue:[ |
|
3162 |
text := text asStringWithoutFinalCR |
|
3163 |
]. |
|
3164 |
] ifFalse:[ |
|
3165 |
text := aDropObject theObject asString |
|
3166 |
]. |
|
3167 |
self |
|
3168 |
undoablePaste:text |
|
3169 |
info:'Drop'. |
|
3412 | 3170 |
]. |
3171 |
||
3172 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 3173 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 3174 |
! |
3175 |
||
3176 |
dropObjects:aCollectionOfDropObjects |
|
3177 |
"public from d&d. |
|
3178 |
drop objects (old API)" |
|
3179 |
||
3868 | 3180 |
aCollectionOfDropObjects do:[:el | |
6152 | 3181 |
self dropObject:el |
3412 | 3182 |
]. |
3183 |
||
3184 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
3185 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 3186 |
! ! |
3187 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3188 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3189 |
|
5761 | 3190 |
applyConverterToSelection:converter |
3191 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3192 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3193 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3194 |
|
6226 | 3195 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
3196 |
||
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3197 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3198 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3199 |
line1 isNil ifTrue:[ |
6152 | 3200 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
3201 |
line1 notNil ifTrue:[ |
|
3202 |
line2 := line1 |
|
3203 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3204 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3205 |
line1 notNil ifTrue:[ |
6152 | 3206 |
line1 to:line2 do:[:lineNr | |
3207 |
|line col1 col2 newLine| |
|
3208 |
||
3209 |
line := (self listAt:lineNr) copy. |
|
6548 | 3210 |
line size ~~ 0 ifTrue:[ |
6152 | 3211 |
lineNr == line1 ifTrue:[ |
3212 |
col1 := selectionStartCol. |
|
3213 |
] ifFalse:[ |
|
3214 |
col1 := 1. |
|
3215 |
]. |
|
3216 |
lineNr == line2 ifTrue:[ |
|
3217 |
col2 := selectionEndCol. |
|
3218 |
] ifFalse:[ |
|
3219 |
col2 := (self listAt:lineNr) size. |
|
3220 |
]. |
|
3221 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
|
3222 |
self withoutRedrawAt:lineNr put:newLine. |
|
3223 |
self invalidateLine:lineNr. |
|
3224 |
]. |
|
3225 |
]. |
|
5761 | 3226 |
] |
3227 |
||
3228 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
6226 | 3229 |
"Modified: / 11-11-2017 / 12:55:25 / cg" |
6548 | 3230 |
"Modified: / 01-03-2019 / 14:54:42 / Claus Gittinger" |
5761 | 3231 |
! |
3232 |
||
3233 |
convertSelectionToLowercase |
|
3234 |
"to-lower selected text" |
|
3235 |
||
3236 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3237 |
col1 to:col2 do:[:col | |
3238 |
|ch| |
|
3239 |
||
3240 |
ch := line at:col. |
|
3241 |
line at:col put:ch asLowercase. |
|
3242 |
]. |
|
3243 |
line. |
|
5761 | 3244 |
]. |
3245 |
||
3246 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
3247 |
! |
|
3248 |
||
3249 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
3250 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
3251 |
||
3252 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
6152 | 3253 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
3254 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
3255 |
||
3256 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
3257 |
col1 to:col2 do:[:col | |
|
3258 |
|ch| |
|
3259 |
||
3260 |
ch := line at:col. |
|
3261 |
ch isUppercase ifTrue:[ |
|
3262 |
isAllLower := false. |
|
3263 |
col == col1 ifTrue:[ |
|
3264 |
isLowerFirst := false. |
|
3265 |
]. |
|
3266 |
] ifFalse:[ |
|
3267 |
ch isLowercase ifTrue:[ |
|
3268 |
isAllUpper := false. |
|
3269 |
col == col1 ifTrue:[ |
|
3270 |
isUpperFirst := false. |
|
3271 |
]. |
|
3272 |
] |
|
3273 |
]. |
|
3274 |
]. |
|
3275 |
||
3276 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
3277 |
isLowerFirst ifTrue:[ |
|
3278 |
makeUppercaseFirst := true. |
|
3279 |
] ifFalse:[ |
|
3280 |
"/ must remember where we come from - otherwise, we end up |
|
3281 |
"/ in upperFirst - lowerFirst cycle. |
|
3282 |
"/ think about a good place to store this state |
|
3283 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
3284 |
makeLowercaseFirst := true. |
|
3285 |
] ifFalse:[ |
|
3286 |
isAllUpper ifTrue:[ |
|
3287 |
makeLowercase := true. |
|
3288 |
] ifFalse:[ |
|
3289 |
makeUppercase := true. |
|
3290 |
] |
|
3291 |
] |
|
3292 |
]. |
|
3293 |
makeUppercaseFirst ifTrue:[ |
|
3294 |
line at:col1 put:(line at:col1) asUppercase. |
|
3295 |
] ifFalse:[ |
|
3296 |
makeLowercaseFirst ifTrue:[ |
|
3297 |
line at:col1 put:(line at:col1) asLowercase. |
|
3298 |
] ifFalse:[ |
|
3299 |
col1 to:col2 do:[:col | |
|
3300 |
|ch| |
|
3301 |
||
3302 |
ch := line at:col. |
|
3303 |
ch := makeLowercase |
|
3304 |
ifTrue:[ ch asLowercase ] |
|
3305 |
ifFalse:[ |
|
3306 |
makeUppercase |
|
3307 |
ifTrue:[ ch asUppercase ] |
|
3308 |
ifFalse:[ |
|
3309 |
col == col1 |
|
3310 |
ifTrue:[ ch asUppercase ] |
|
3311 |
ifFalse:[ ch asLowercase ] |
|
3312 |
] |
|
3313 |
]. |
|
3314 |
line at:col put:ch. |
|
3315 |
]. |
|
3316 |
]. |
|
3317 |
]. |
|
3318 |
line |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3319 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3320 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3321 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 3322 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
3323 |
! |
|
3324 |
||
3325 |
convertSelectionToUppercase |
|
3326 |
"to-upper selected text" |
|
3327 |
||
3328 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3329 |
col1 to:col2 do:[:col | |
3330 |
|ch| |
|
3331 |
||
3332 |
ch := line at:col. |
|
3333 |
line at:col put:ch asUppercase. |
|
3334 |
]. |
|
3335 |
line. |
|
5761 | 3336 |
]. |
3337 |
||
3338 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
3339 |
! |
|
3340 |
||
3341 |
convertSelectionToUppercaseFirst |
|
3342 |
"to-upperFirst selected text" |
|
3343 |
||
3344 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3345 |
|state| |
3346 |
||
3347 |
state := #first. |
|
3348 |
col1 to:col2 do:[:col | |
|
3349 |
|ch| |
|
3350 |
||
3351 |
ch := line at:col. |
|
3352 |
ch isSeparator ifFalse:[ |
|
3353 |
state == #first ifTrue:[ |
|
3354 |
line at:col put:ch asUppercase. |
|
3355 |
state := #skipRest |
|
3356 |
] |
|
3357 |
] ifTrue:[ |
|
3358 |
state := #first |
|
3359 |
] |
|
3360 |
]. |
|
3361 |
line. |
|
5761 | 3362 |
]. |
3363 |
||
3364 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3365 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3366 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3367 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3368 |
"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
|
3369 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3370 |
selectionStartLine notNil ifTrue:[ |
6152 | 3371 |
self setClipboardText:(self selection). |
3372 |
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
|
3373 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3374 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3375 |
"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
|
3376 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3377 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3378 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3379 |
"delete single character under cursor; does not merge lines" |
121 | 3380 |
|
3381 |
|wasOn| |
|
3382 |
||
3383 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3384 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3385 |
wasOn ifTrue:[self showCursor] |
3386 |
! |
|
3387 |
||
827 | 3388 |
deleteCharAtLine:lineNr col:colNr |
3389 |
"delete a single character at colNr in line lineNr" |
|
3390 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3391 |
self st80EditMode ifTrue:[ |
6152 | 3392 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3393 |
| wasOn | |
|
3394 |
wasOn := self hideCursor. |
|
3395 |
self |
|
3396 |
cursorReturn; |
|
3397 |
cursorCol:1; |
|
3398 |
deleteCharBeforeCursor. |
|
3399 |
wasOn ifTrue:[ self showCursor]. |
|
3400 |
^ self. |
|
3401 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3402 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3403 |
|
827 | 3404 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3405 |
! |
|
3406 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3407 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3408 |
"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
|
3409 |
|
4592 | 3410 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3411 |
|
6050 | 3412 |
list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete. |
3413 |
||
121 | 3414 |
wasOn := self hideCursor. |
4814 | 3415 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
6050 | 3416 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
3417 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
|
3418 |
ln size < prevTab ifTrue:[ |
|
6567 | 3419 |
ln := ln , (String new:prevTab). |
6050 | 3420 |
]. |
3421 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3422 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3423 |
cursorCol > prevTab ifTrue:[ |
|
3424 |
self st80EditMode ifTrue:[ |
|
3425 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3426 |
"/ not allow a cursor position beyond the end of line, |
|
3427 |
"/ so ensure that cursorLine:col: will force us to the beginning of the line |
|
3428 |
originalLine size < prevTab ifTrue:[ |
|
3429 |
self checkForExistingLine:cursorLine. |
|
3430 |
self basicListAt:cursorLine put:ln |
|
3431 |
] |
|
3432 |
]. |
|
3433 |
self cursorLine:cursorLine col:prevTab. |
|
3434 |
wasOn ifTrue:[ self showCursor ]. |
|
3435 |
^ self |
|
3436 |
]. |
|
3437 |
] ifFalse:[ |
|
3438 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
3439 |
self cursorLine:cursorLine col:prevTab. |
|
3440 |
wasOn ifTrue:[ self showCursor ]. |
|
3441 |
^ self. |
|
3442 |
] |
|
3443 |
]. |
|
827 | 3444 |
]. |
3445 |
||
2491 | 3446 |
"/ (autoIndent |
3447 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3448 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3449 |
"/ ifTrue:[ |
3450 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3451 |
"/ |
|
3452 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3453 |
"/ ln := list at:cursorLine. |
|
3454 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3455 |
"/ soCol := 1 |
|
3456 |
"/ ] |
|
3457 |
"/ ] |
|
3458 |
"/ ] ifFalse:[ |
|
6050 | 3459 |
soCol := 1. |
2491 | 3460 |
"/ ]. |
3461 |
||
1419 | 3462 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
6050 | 3463 |
" |
3464 |
somewhere in the middle of a line |
|
3465 |
" |
|
3466 |
self cursorLeft. |
|
3467 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3468 |
] ifFalse:[ |
6050 | 3469 |
" |
3470 |
at begin of line - merge with previous line; |
|
3471 |
except for the very first line. |
|
3472 |
" |
|
3473 |
(cursorLine == 1) ifFalse:[ |
|
3474 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3475 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3476 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3477 |
"/ we are beyond the end of the text. |
|
3478 |
"/ move the cursor to the previous line. |
|
3479 |
self cursorLine:lineNrAboveCursor col:1. |
|
3480 |
] ifFalse:[ |
|
3481 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3482 |
] |
|
3483 |
] |
|
3484 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3485 |
]. |
827 | 3486 |
wasOn ifTrue:[ self showCursor ] |
3487 |
||
6567 | 3488 |
"Modified: / 16-01-1998 / 22:33:04 / cg" |
3489 |
"Modified: / 24-03-2019 / 09:57:57 / Claus Gittinger" |
|
827 | 3490 |
! |
3491 |
||
3492 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3493 |
"delete characters from colNr up to the end in line lineNr" |
|
3494 |
||
3495 |
|line| |
|
3496 |
||
3497 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
6152 | 3498 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3499 |
] |
3500 |
||
3501 |
! |
|
3502 |
||
4458 | 3503 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3504 |
"delete characters from startCol to endCol in line lineNr" |
|
3505 |
||
3506 |
|deleted| |
|
3507 |
||
3508 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3509 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3510 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3511 |
! |
|
3512 |
||
827 | 3513 |
deleteCharsAtLine:lineNr toCol:colNr |
3514 |
"delete characters from start up to colNr in line lineNr" |
|
3515 |
||
3516 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3517 |
||
3518 |
||
121 | 3519 |
! |
3520 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3521 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3522 |
"delete the line where the cursor sits" |
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 |
self deleteLine:cursorLine |
121 | 3525 |
! |
3526 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3527 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3528 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3529 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3530 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3531 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3532 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3533 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3534 |
col1 == 0 ifTrue:[ |
6152 | 3535 |
line1 := line1 - 1. |
3536 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3537 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3538 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3539 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3540 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3541 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3542 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3543 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3544 |
|
2954 | 3545 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3546 |
"delete all text from startLine/startCol to endLine/endCol - |
|
6163 | 3547 |
joining lines if necessary" |
2954 | 3548 |
|
3549 |
|line newLine lineSize nMore| |
|
3550 |
||
3551 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3552 |
list isNil ifTrue:[^ self]. |
|
3553 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3554 |
||
3555 |
(startLine == endLine) ifTrue:[ |
|
6152 | 3556 |
"/ delete chars within a line |
3557 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3558 |
^ self |
|
2954 | 3559 |
]. |
3560 |
||
3561 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
6152 | 3562 |
"/ delete full lines only |
3563 |
endLine > startLine ifTrue:[ |
|
3564 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3565 |
]. |
|
3566 |
^ self |
|
2954 | 3567 |
]. |
3568 |
||
3569 |
"/ delete right rest of 1st line |
|
4786 | 3570 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3571 |
|
3572 |
"/ delete the inner lines ... |
|
3573 |
endLine > (startLine + 1) ifTrue:[ |
|
6152 | 3574 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3575 |
]. |
3576 |
||
3577 |
(endCol ~~ 0) ifTrue:[ |
|
6152 | 3578 |
"/ delete the left rest of the last line |
3579 |
||
3580 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3581 |
||
3582 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3583 |
startLine <= list size ifTrue:[ |
|
3584 |
line := list at:startLine. |
|
3585 |
lineSize := line size. |
|
3586 |
(startCol > lineSize) ifTrue:[ |
|
3587 |
newLine := line. |
|
3588 |
line isNil ifTrue:[ |
|
3589 |
newLine := String new:(startCol - 1) |
|
3590 |
] ifFalse:[ |
|
3591 |
nMore := startCol - 1 - lineSize. |
|
3592 |
nMore > 0 ifTrue:[ |
|
3593 |
newLine := line , (line species new:nMore) |
|
3594 |
] |
|
3595 |
]. |
|
3596 |
newLine ~~ line ifTrue:[ |
|
3597 |
self basicListAt:startLine put:newLine. |
|
3598 |
]. |
|
3599 |
"/ TODO: remember old maxwidth of linerange, |
|
3600 |
"/ only clear widthOfWidestLine, if this max |
|
3601 |
"/ length was (one of) the longest. |
|
3602 |
"/ avoids slow delete with huge texts. |
|
3603 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3604 |
self textChanged. |
|
3605 |
] |
|
3606 |
] |
|
2954 | 3607 |
]. |
3608 |
||
3609 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3610 |
self mergeLine:startLine removeBlanks:false |
|
3611 |
||
4225 | 3612 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3613 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
6163 | 3614 |
"Modified (comment): / 30-05-2017 / 17:34:03 / mawalch" |
2954 | 3615 |
! |
3616 |
||
4458 | 3617 |
deleteFromLine:startLineNr toLine:endLineNr |
3618 |
"delete some lines" |
|
3619 |
||
3620 |
|deleted| |
|
3621 |
||
3622 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3623 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3624 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3625 |
! |
|
3626 |
||
827 | 3627 |
deleteLine:lineNr |
3628 |
"delete line" |
|
3629 |
||
3630 |
self deleteFromLine:lineNr toLine:lineNr |
|
3631 |
||
3632 |
||
3633 |
! |
|
3634 |
||
4458 | 3635 |
deleteLineWithoutRedraw:lineNr |
3636 |
"delete line - no redraw; |
|
3637 |
return true, if something was really deleted" |
|
3638 |
||
3639 |
|deleted ret| |
|
3640 |
||
3641 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3642 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3643 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3644 |
^ ret. |
|
3645 |
! |
|
3646 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3647 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3648 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3649 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3650 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3651 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3652 |
|
4771 | 3653 |
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
|
3654 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3655 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3656 |
(endLine > list size) ifTrue:[ |
6152 | 3657 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3658 |
] ifFalse:[ |
6152 | 3659 |
lastLine := endLine |
4771 | 3660 |
]. |
3661 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3662 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3663 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3664 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3665 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3666 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3667 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3668 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3669 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3670 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3671 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3672 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3673 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3674 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3675 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3676 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3677 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3678 |
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
|
3679 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3680 |
selectionStartLine notNil ifTrue:[ |
6152 | 3681 |
wasOn := self hideCursor. |
3682 |
||
3683 |
startLine := selectionStartLine. |
|
3684 |
startCol := selectionStartCol. |
|
3685 |
endLine := selectionEndLine. |
|
3686 |
endCol := selectionEndCol. |
|
3687 |
self unselectWithoutRedraw. |
|
3688 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3689 |
self setCursorLine:startLine col:startCol. |
|
3690 |
||
3691 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3692 |
] |
121 | 3693 |
! |
3694 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3695 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3696 |
"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
|
3697 |
|
2952 | 3698 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3699 |
|
3799 | 3700 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3701 |
cursorCol <= 1 ifTrue:[ |
6152 | 3702 |
self deleteCharBeforeCursor. |
3703 |
^ self |
|
5361 | 3704 |
]. |
3799 | 3705 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3706 |
wasOn := self hideCursor. |
5787 | 3707 |
self |
6152 | 3708 |
undoableDo:[ |
3709 |
endCol := cursorCol-1. |
|
3710 |
endLine := cursorLine. |
|
3711 |
self cursorToPreviousWord. |
|
3712 |
beginCol := cursorCol. |
|
3713 |
beginLine := cursorLine. |
|
3714 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3715 |
self cursorLine:cursorLine col:beginCol. |
|
3716 |
] |
|
3717 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3718 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3719 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3720 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3721 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3722 |
|
5761 | 3723 |
indentSelectionBy1 |
3724 |
"indent selected line-range |
|
3725 |
by 1 space (i.e. to the right)" |
|
3726 |
||
3727 |
self indentBy:1 |
|
3728 |
||
3729 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3730 |
! |
|
3731 |
||
4458 | 3732 |
insert:aCharacter atLine:lineNr col:colNr |
3733 |
"insert a single character at lineNr/colNr; |
|
3734 |
set emphasis to character at current position" |
|
3735 |
||
3736 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3737 |
aCharacter ~~ Character cr ifTrue:[ |
|
6152 | 3738 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3739 |
] |
3740 |
! |
|
3741 |
||
121 | 3742 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3743 |
"insert a single character at cursor-position - advance cursor." |
121 | 3744 |
|
3745 |
|wasOn| |
|
3746 |
||
3747 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3748 |
aCharacter == Character tab ifTrue:[ |
6152 | 3749 |
"/ needs special care to advance cursor correctly |
3750 |
self insertTabAtCursor |
|
121 | 3751 |
] ifFalse:[ |
6152 | 3752 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3753 |
aCharacter == (Character cr) ifTrue:[ |
|
3754 |
self basicCursorReturn |
|
3755 |
] ifFalse:[ |
|
3756 |
self cursorRight. |
|
3757 |
]. |
|
121 | 3758 |
]. |
3759 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3760 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3761 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3762 |
! |
3763 |
||
641 | 3764 |
insertLine:aString before:lineNr |
3765 |
"insert the line aString before line lineNr" |
|
3766 |
||
3767 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3768 |
||
3769 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3770 |
! |
|
3771 |
||
155 | 3772 |
insertLines:aStringCollection before:lineNr |
3773 |
"insert a bunch before line lineNr" |
|
3774 |
||
3775 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3776 |
||
3777 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3778 |
! |
|
3779 |
||
4771 | 3780 |
insertLines:someText from:start to:end before:lineNr |
3781 |
"insert a bunch of lines before line lineNr. |
|
3782 |
The cursor position is left unchanged." |
|
3783 |
||
3784 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3785 |
srcY "{ Class: SmallInteger }" |
|
3786 |
dstY "{ Class: SmallInteger }" | |
|
3787 |
||
5357 | 3788 |
"wrong when pasting multiple lines" |
3789 |
false "autoIndent" ifTrue:[ |
|
6152 | 3790 |
indent := self leftIndentForLine:lineNr. |
3791 |
||
3792 |
text := someText |
|
3793 |
collect:[:ln||line| |
|
3794 |
ln notNil ifTrue:[ |
|
3795 |
line := ln withoutLeadingSeparators. |
|
3796 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3797 |
line := (String new:indent), line |
|
3798 |
]. |
|
3799 |
line |
|
3800 |
] ifFalse:[ |
|
3801 |
nil |
|
3802 |
] |
|
3803 |
]. |
|
4771 | 3804 |
] ifFalse:[ |
6152 | 3805 |
text := someText |
4771 | 3806 |
]. |
3807 |
||
3808 |
visLine := self listLineToVisibleLine:lineNr. |
|
3809 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
6152 | 3810 |
self withoutRedrawInsertLines:text |
3811 |
from:start to:end |
|
3812 |
before:lineNr. |
|
4771 | 3813 |
] ifFalse:[ |
6152 | 3814 |
nLines := end - start + 1. |
3815 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3816 |
self withoutRedrawInsertLines:text |
|
3817 |
from:start to:end |
|
3818 |
before:lineNr. |
|
3819 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3820 |
] ifFalse:[ |
|
3821 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3822 |
and:(firstLineShown + nLines + nLinesShown). |
|
3823 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3824 |
dstY := srcY + (nLines * fontHeight). |
|
3825 |
||
3826 |
"/ |
|
3827 |
"/ scroll ... |
|
3828 |
"/ |
|
3829 |
" |
|
3830 |
stupid: must catchExpose before inserting new |
|
3831 |
stuff - since catchExpose may perform redraws |
|
3832 |
" |
|
3833 |
self catchExpose. |
|
3834 |
self withoutRedrawInsertLines:text |
|
3835 |
from:start to:end |
|
3836 |
before:lineNr. |
|
3837 |
self |
|
3838 |
copyFrom:self |
|
3839 |
x:textStartLeft y:srcY |
|
3840 |
toX:textStartLeft y:dstY |
|
3841 |
width:w |
|
3842 |
height:(height - dstY) |
|
3843 |
async:true. |
|
3844 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3845 |
self waitForExpose |
|
3846 |
]. |
|
4771 | 3847 |
]. |
3848 |
widthOfWidestLine notNil ifTrue:[ |
|
6152 | 3849 |
text do:[:line | |
3850 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3851 |
] |
|
4771 | 3852 |
]. |
3853 |
self textChanged. |
|
3854 |
||
3855 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3856 |
! |
|
3857 |
||
654 | 3858 |
insertLines:lines withCR:withCr |
3160 | 3859 |
"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
|
3860 |
Cursor is moved behind insertion. |
641 | 3861 |
If withCr is true, append cr after last line" |
3862 |
||
3863 |
|start end nLines wasOn| |
|
3864 |
||
3865 |
lines notNil ifTrue:[ |
|
6152 | 3866 |
nLines := lines size. |
3867 |
(nLines == 1) ifTrue:[ |
|
3868 |
self insertStringAtCursor:(lines at:1). |
|
3869 |
withCr ifTrue:[ |
|
3870 |
self insertCharAtCursor:(Character cr) |
|
3871 |
] |
|
3872 |
] ifFalse:[ |
|
3873 |
(cursorCol ~~ 1) ifTrue:[ |
|
3874 |
self insertStringAtCursor:(lines at:1). |
|
3875 |
self insertCharAtCursor:(Character cr). |
|
3876 |
start := 2 |
|
3877 |
] ifFalse:[ |
|
3878 |
start := 1 |
|
3879 |
]. |
|
3880 |
withCr ifTrue:[ |
|
3881 |
end := nLines |
|
3882 |
] ifFalse:[ |
|
3883 |
end := nLines - 1 |
|
3884 |
]. |
|
3885 |
(start <= nLines) ifTrue:[ |
|
3886 |
(end >= start) ifTrue:[ |
|
3887 |
wasOn := self hideCursor. |
|
3888 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3889 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3890 |
wasOn ifTrue:[self showCursor]. |
|
3891 |
] |
|
3892 |
]. |
|
3893 |
withCr ifFalse:[ |
|
3894 |
"last line without cr" |
|
3895 |
self insertStringAtCursor:(lines at:nLines) |
|
3896 |
] |
|
3897 |
] |
|
641 | 3898 |
] |
654 | 3899 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3900 |
"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
|
3901 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3902 |
! |
3903 |
||
3904 |
insertLines:lines withCr:withCr |
|
3905 |
"insert a bunch of lines at cursor position. Cursor |
|
3906 |
is moved behind insertion. |
|
3907 |
If withCr is true, append cr after last line" |
|
3908 |
||
2363 | 3909 |
<resource:#obsolete> |
3910 |
||
1292 | 3911 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3912 |
self insertLines:lines withCR:withCr. |
|
3913 |
||
3914 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3915 |
! |
3916 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3917 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3918 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3919 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3920 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3921 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3922 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3923 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3924 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3925 |
self selectFromLine:startLine col:startCol |
6152 | 3926 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3927 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3928 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3929 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3930 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3931 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3932 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3933 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3934 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3935 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3936 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3937 |
col == 0 ifTrue:[ |
6152 | 3938 |
line > 1 ifTrue:[ |
3939 |
line := line - 1. |
|
3940 |
col := (self listAt:line) size + 1. |
|
3941 |
] ifFalse:[ |
|
3942 |
col := 1. |
|
3943 |
] |
|
5060 | 3944 |
]. |
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3945 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3946 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3947 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3948 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3949 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3950 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3952 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3953 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3954 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3955 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3956 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3957 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3958 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3959 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 3960 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3961 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3962 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3963 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3964 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3965 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3966 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3967 |
[start <= end] whileTrue:[ |
6152 | 3968 |
stop := aString indexOf:(Character cr) startingAt:start. |
3969 |
stop == 0 ifTrue:[ |
|
3970 |
stop := end + 1 |
|
3971 |
]. |
|
3972 |
subString := aString copyFrom:start to:(stop - 1). |
|
3973 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3974 |
(stop <= end) ifTrue:[ |
|
3975 |
c := c + subString size. |
|
3976 |
self insert:(Character cr) atLine:l col:c. |
|
3977 |
l := l + 1. |
|
3978 |
c := 1 |
|
3979 |
]. |
|
3980 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3981 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3982 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3983 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3984 |
! |
3985 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3986 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3987 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3988 |
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
|
3989 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3990 |
aString isNil ifTrue:[ |
6152 | 3991 |
"new:" |
3992 |
self insertCharAtCursor:(Character cr). |
|
3993 |
^ self |
|
105 | 3994 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3995 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 3996 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3997 |
]. |
3998 |
||
654 | 3999 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4000 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
4001 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 4002 |
! |
4003 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4004 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4005 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4006 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4007 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 4008 |
shown ifTrue:[ |
6152 | 4009 |
gc font hasOverlappingCharacters ifTrue:[ |
4010 |
self invalidateLine:lineNr. |
|
4011 |
] ifFalse:[ |
|
4012 |
self redrawLine:lineNr from:colNr |
|
4013 |
] |
|
4190 | 4014 |
] |
4015 |
||
4191 | 4016 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 4017 |
! |
4018 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4019 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4020 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4021 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4022 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4023 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4024 |
|
6548 | 4025 |
aString size ~~ 0 ifTrue:[ |
6152 | 4026 |
wasOn := self hideCursor. |
4027 |
(aString includes:Character tab) ifTrue:[ |
|
4028 |
self checkForExistingLine:cursorLine. |
|
4029 |
oldLen := (list at:cursorLine) size. |
|
4030 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
4031 |
newLen := (list at:cursorLine) size. |
|
4032 |
deltaLen := newLen - oldLen. |
|
4033 |
] ifFalse:[ |
|
4034 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
4035 |
deltaLen := aString size. |
|
4036 |
]. |
|
4037 |
self setCursorCol:(cursorCol + deltaLen). |
|
4038 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4039 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
4040 |
|
6548 | 4041 |
"Modified: / 10-06-1998 / 20:43:52 / cg" |
4042 |
"Modified: / 01-03-2019 / 14:54:49 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4043 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4044 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4045 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4046 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4047 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4048 |
|wasOn nextTab| |
105 | 4049 |
|
121 | 4050 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4051 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4052 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4053 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 4054 |
! |
4055 |
||
3542 | 4056 |
joinLines |
3890 | 4057 |
"join lines (remove line-break)" |
4058 |
||
3583 | 4059 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
4060 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
4061 |
self |
6152 | 4062 |
undoableDo:[ |
4063 |
|line col lineLen| |
|
4064 |
||
4065 |
line := cursorLine. |
|
4066 |
col := cursorCol. |
|
4067 |
lineLen := (list at:line) size. |
|
4068 |
col > lineLen ifTrue:[ |
|
4069 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
4070 |
] ifFalse:[ |
|
4071 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
4072 |
]. |
|
4073 |
self mergeLine:line removeBlanks:true. |
|
4074 |
self cursorLine:line col:col. |
|
4075 |
] |
|
4076 |
info:'Join' |
|
3542 | 4077 |
! |
4078 |
||
2952 | 4079 |
mergeLine:lineNr |
4080 |
"merge line lineNr with line lineNr+1" |
|
4081 |
||
4082 |
self mergeLine:lineNr removeBlanks:true |
|
4083 |
||
4084 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
4085 |
! |
|
4086 |
||
4458 | 4087 |
mergeLine:lineNr removeBlanks:removeBlanks |
4088 |
"merge line lineNr with line lineNr+1" |
|
4089 |
||
4090 |
|len| |
|
4091 |
||
4092 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4093 |
||
4094 |
len := (self listAt:lineNr) size. |
|
4095 |
self nonUndoableDo:[ |
|
6152 | 4096 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 4097 |
]. |
4098 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
4099 |
! |
|
4100 |
||
5761 | 4101 |
parenthizeSelection |
6198 | 4102 |
"place parentheses around the selected text. |
5761 | 4103 |
if already parenthized, de-parenthize it" |
4104 |
||
4105 |
self parenthizeSelectionWith:$( and:$) |
|
4106 |
||
4107 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
6198 | 4108 |
"Modified (comment): / 30-08-2017 / 20:17:46 / cg" |
5761 | 4109 |
! |
4110 |
||
2506 | 4111 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 4112 |
"if already parenthized, de-parenthize it" |
4113 |
||
5560 | 4114 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4115 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4116 |
self hasSelection ifFalse:[^ self]. |
5560 | 4117 |
startLine := selectionStartLine. |
4118 |
endLine := selectionEndLine. |
|
4119 |
startCol := selectionStartCol. |
|
4120 |
endCol := selectionEndCol. |
|
5787 | 4121 |
|
5560 | 4122 |
newSelectionEnd := endCol. |
5787 | 4123 |
|
5560 | 4124 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
6152 | 4125 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
4126 |
self deleteCharAtLine:endLine col:endCol. |
|
4127 |
newSelectionEnd := newSelectionEnd-1. |
|
4128 |
]. |
|
4129 |
self deleteCharAtLine:startLine col:startCol. |
|
4130 |
startLine == endLine ifTrue:[ |
|
4131 |
newSelectionEnd := newSelectionEnd-1. |
|
4132 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4133 |
] ifFalse:[ |
6152 | 4134 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4135 |
newSelectionEnd := newSelectionEnd+1. |
|
4136 |
self insert:openingCharacter atLine:startLine col:startCol. |
|
4137 |
startLine == endLine ifTrue:[ |
|
4138 |
newSelectionEnd := newSelectionEnd+1. |
|
4139 |
] |
|
3160 | 4140 |
]. |
4141 |
self |
|
6152 | 4142 |
selectFromLine:startLine col:startCol |
4143 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 4144 |
|
4145 |
"Modified (comment): / 06-06-2016 / 11:00:37 / cg" |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4146 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4147 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4148 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4149 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4150 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4151 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4152 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4153 |
|
5114 | 4154 |
NoModificationError handle:[:ex | |
6152 | 4155 |
^ self |
5114 | 4156 |
] do:[ |
6152 | 4157 |
lastLine := list size. |
4158 |
finished := false. |
|
4159 |
[finished] whileFalse:[ |
|
6469 | 4160 |
((lastLine <= 1) or:[lastLine = cursorLine]) ifTrue:[ |
6152 | 4161 |
finished := true |
4162 |
] ifFalse:[ |
|
4163 |
line := list at:lastLine. |
|
4164 |
line notNil ifTrue:[ |
|
4165 |
line isBlank ifTrue:[ |
|
4166 |
self basicListAt:lastLine put:nil. |
|
4167 |
line := nil |
|
4168 |
] |
|
4169 |
]. |
|
4170 |
line notNil ifTrue:[ |
|
4171 |
finished := true |
|
4172 |
] ifFalse:[ |
|
4173 |
lastLine := lastLine - 1 |
|
4174 |
] |
|
4175 |
] |
|
4176 |
]. |
|
4177 |
(lastLine ~~ list size) ifTrue:[ |
|
4178 |
list grow:lastLine. |
|
4179 |
"/ self textChanged |
|
4180 |
] |
|
118 | 4181 |
]. |
6469 | 4182 |
|
4183 |
"Modified: / 26-10-2018 / 18:22:26 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4184 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4185 |
|
4458 | 4186 |
replace:aCharacter atLine:lineNr col:colNr |
4187 |
"replace a single character at lineNr/colNr" |
|
4188 |
||
4189 |
|originalChar| |
|
4190 |
||
4191 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
4192 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
4193 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
4194 |
! |
|
4195 |
||
4713 | 4196 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 4197 |
|pattern replacePattern| |
4198 |
||
4199 |
pattern := patternArg string. |
|
4200 |
replacePattern := replacePatternArg string. |
|
4630 | 4201 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
6152 | 4202 |
self rememberSearchPattern:pattern. |
4203 |
self rememberSearchPattern:replacePattern. |
|
4204 |
LastSearchIgnoredCase := ignoreCase. |
|
4205 |
self |
|
4206 |
undoableDo:[ |
|
4207 |
all ifTrue:[ |
|
4208 |
self |
|
4209 |
replaceString:pattern |
|
4210 |
to:replacePattern |
|
4211 |
ignoreCase:ignoreCase |
|
4212 |
] ifFalse:[ |
|
4213 |
(self selectionAsString notNil |
|
4214 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
|
4215 |
ifTrue:[ |
|
4216 |
self replaceSelectionBy:replacePattern. |
|
4217 |
self |
|
4218 |
search:pattern |
|
4219 |
ignoreCase:ignoreCase |
|
4220 |
forward:(lastSearchDirection = #forward). |
|
4221 |
]. |
|
4222 |
] |
|
4223 |
] |
|
4224 |
info:'Replace' |
|
3430 | 4225 |
] |
4226 |
||
4227 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
4228 |
! |
|
4229 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4230 |
replaceCharAtCursor:aCharacter |
5413 | 4231 |
"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
|
4232 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4233 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4234 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4235 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4236 |
aCharacter == (Character cr) ifTrue:[ |
6152 | 4237 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4238 |
] ifFalse:[ |
6152 | 4239 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
4240 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4241 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4242 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4243 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4244 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4245 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4246 |
|
4458 | 4247 |
replaceContentsWith:newContents |
5413 | 4248 |
"undoably replace everything" |
4458 | 4249 |
|
4250 |
|originalContents| |
|
4251 |
||
4252 |
originalContents := self contents. |
|
4253 |
self contents:newContents keepUndoHistory:true. |
|
4254 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
4255 |
! |
|
4256 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4257 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 4258 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4259 |
|
5216 | 4260 |
"/ 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
|
4261 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4262 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4263 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4264 |
|
4458 | 4265 |
replaceLine:lineNr with:newText |
5413 | 4266 |
"undoably replace a line at lineNr" |
4458 | 4267 |
|
4268 |
|originalLine| |
|
4269 |
||
4270 |
originalLine := self listAt:lineNr. |
|
4271 |
originalLine isNil ifTrue:[ |
|
6152 | 4272 |
self checkForExistingLine:lineNr |
4458 | 4273 |
]. |
4274 |
self list at:lineNr put:newText. |
|
4275 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4276 |
self invalidateLine:lineNr. |
|
4277 |
||
4278 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
4279 |
! |
|
4280 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4281 |
replaceLines:lines withCR:withCr |
5413 | 4282 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4283 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4284 |
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
|
4285 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4286 |
|
1809 | 4287 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4288 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4289 |
lines notNil ifTrue:[ |
6152 | 4290 |
wasOn := self hideCursor. |
4291 |
nLines := lines size. |
|
4292 |
line := cursorLine. |
|
4293 |
col := cursorCol. |
|
4294 |
lines keysAndValuesDo:[:i :l | |
|
4295 |
self replaceString:(l ? '') atLine:line col:col. |
|
4296 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
4297 |
line := line + 1. |
|
4298 |
col := 1. |
|
4299 |
] ifFalse:[ |
|
4300 |
col := col + (l size). |
|
4301 |
] |
|
4302 |
]. |
|
4303 |
self cursorLine:line col:col. |
|
4304 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
4305 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4306 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4307 |
|
4661 | 4308 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
4309 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4310 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4311 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4312 |
replaceSelectionBy:something |
5413 | 4313 |
"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
|
4314 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4315 |
|
4666 | 4316 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 4317 |
! |
4318 |
||
4319 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 4320 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 4321 |
leave cursor after insertion or leave it, depending on keep" |
4322 |
||
4666 | 4323 |
self replaceSelectionBy:something keepCursor:keep select:false |
4324 |
||
4325 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
4326 |
! |
|
4327 |
||
4328 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 4329 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 4330 |
leave cursor after insertion or leave it, depending on keep. |
4331 |
If selectNewText is true, select the new text; otherwise deselect" |
|
4332 |
||
4333 |
|sel l c selStartLine selStartCol| |
|
105 | 4334 |
|
4335 |
l := cursorLine. |
|
4336 |
c := cursorCol. |
|
4337 |
||
4818 | 4338 |
sel := self selectionAsString. |
4666 | 4339 |
sel isNil ifTrue:[ |
6152 | 4340 |
selStartLine := l. |
4341 |
selStartCol := c. |
|
4666 | 4342 |
] ifFalse:[ |
6152 | 4343 |
selStartLine := selectionStartLine. |
4344 |
selStartCol := selectionStartCol. |
|
4345 |
||
4346 |
self setLastStringToReplace: sel. |
|
4347 |
||
4348 |
self deleteSelection. |
|
4349 |
replacing := true. |
|
4350 |
lastReplacementInfo rememberReplacement. |
|
4351 |
lastReplacementInfo lastReplacement: ''. |
|
4352 |
lastReplacementInfo stillCollectingInput:true. |
|
4353 |
undoSupport actionInfo:'replace'. |
|
3161 | 4354 |
]. |
4355 |
||
4356 |
something isCharacter ifTrue:[ |
|
6152 | 4357 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4358 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
|
4359 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
|
4360 |
]. |
|
4361 |
]. |
|
4362 |
self isInInsertMode ifTrue:[ |
|
4363 |
self insertCharAtCursor:something |
|
4364 |
] ifFalse:[ |
|
4365 |
self replaceCharAtCursor:something |
|
4366 |
] |
|
105 | 4367 |
] ifFalse:[ |
6152 | 4368 |
something isString ifTrue:[ |
4369 |
lastReplacementInfo lastReplacement: something. |
|
4370 |
self isInInsertMode ifTrue:[ |
|
4371 |
self insertStringAtCursor:something |
|
4372 |
] ifFalse:[ |
|
4373 |
self replaceStringAtCursor:something |
|
4374 |
] |
|
4375 |
] ifFalse:[ |
|
4376 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4377 |
]. |
|
105 | 4378 |
]. |
4379 |
keep ifTrue:[ |
|
6152 | 4380 |
self cursorLine:l col:c |
4666 | 4381 |
]. |
4382 |
selectNewText ifTrue:[ |
|
6152 | 4383 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
105 | 4384 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4385 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4386 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4387 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4388 |
|
4458 | 4389 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4390 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4391 |
This is not prepared to encounter special chars (except TAB) in the string." |
4392 |
||
4393 |
|originalString| |
|
4394 |
||
4395 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4396 |
||
4397 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4398 |
||
4399 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4400 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4401 |
! |
|
4402 |
||
4713 | 4403 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4404 |
|continue count| |
4405 |
||
4406 |
self cursorToTop. |
|
4407 |
self selectFromBeginning. |
|
4408 |
count := 0. |
|
4409 |
continue := true. |
|
4410 |
[ continue ] whileTrue:[ |
|
6152 | 4411 |
(self selectionAsString notNil |
4412 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4413 |
ifTrue:[ |
|
4414 |
self replaceSelectionBy:aNewString. |
|
4415 |
count := count + 1. |
|
4416 |
]. |
|
4417 |
self |
|
4418 |
searchFwd:aString |
|
4419 |
ignoreCase:ignoreCase |
|
4420 |
ifAbsent:[ |
|
4421 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4422 |
bindWith:aString with:aNewString with:count). |
|
4423 |
continue := false. |
|
4424 |
]. |
|
3549 | 4425 |
]. |
3430 | 4426 |
|
4427 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4428 |
! |
|
4429 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4430 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4431 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4432 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4433 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4434 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4435 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4436 |
(aString includes:Character tab) ifTrue:[ |
6152 | 4437 |
"/ need special care for TAB (to move cursor correctly) |
4438 |
i1 := 1. |
|
4439 |
[i1 ~~ 0] whileTrue:[ |
|
4440 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4441 |
i2 ~~ 0 ifTrue:[ |
|
4442 |
i1 ~~ i2 ifTrue:[ |
|
4443 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4444 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4445 |
]. |
|
4446 |
self replaceTABAtCursor. |
|
4447 |
i2 := i2 + 1. |
|
4448 |
] ifFalse:[ |
|
4449 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4450 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4451 |
]. |
|
4452 |
i1 := i2. |
|
4453 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4454 |
] ifFalse:[ |
6152 | 4455 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
4456 |
self setValidatedCursorCol:(cursorCol + aString size). |
|
4457 |
"/ self cursorCol:(cursorCol + aString size). |
|
5325 | 4458 |
]. |
4459 |
wasOn ifTrue:[ |
|
6152 | 4460 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
4461 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
5325 | 4462 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4463 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4464 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4465 |
"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
|
4466 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4467 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4468 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4469 |
"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
|
4470 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4471 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4472 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4473 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4474 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4475 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4476 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4477 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4478 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4479 |
! |
4480 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4481 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4482 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4483 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4484 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4485 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4486 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4487 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4488 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4489 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4490 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4491 |
self cursorToPreviousWord. |
5787 | 4492 |
beginCol := cursorCol. |
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4493 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4494 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4495 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4496 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4497 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4498 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4499 |
|
4458 | 4500 |
splitLine:lineNr before:colNr |
4501 |
"split the line linNr before colNr; the right part (from colNr) |
|
4502 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4503 |
||
4504 |
self basicSplitLine:lineNr before:colNr. |
|
4505 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4506 |
! |
|
4507 |
||
5761 | 4508 |
toggleTabSetting |
4509 |
"toggle between 4-col |
|
4510 |
and 8-col tabs" |
|
4511 |
||
4512 |
(tabPositions == self class tab4Positions) |
|
6152 | 4513 |
ifTrue:[self setTab8] |
4514 |
ifFalse:[self setTab4] |
|
5761 | 4515 |
|
4516 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4517 |
! |
|
4518 |
||
4519 |
undentSelectionBy1 |
|
4520 |
"undent selected line-range |
|
4521 |
by 1 space (i.e. to the left)" |
|
4522 |
||
4523 |
self undentBy:1 |
|
4524 |
||
4525 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4526 |
! |
|
4527 |
||
5146 | 4528 |
withAutoIndent:aBoolean do:aBlock |
4529 |
|sav| |
|
4530 |
||
4531 |
sav := autoIndent. |
|
4532 |
autoIndent := aBoolean. |
|
4533 |
aBlock ensure:[ autoIndent := sav ]. |
|
4534 |
! |
|
4535 |
||
4458 | 4536 |
withoutRedrawAt:lineNr put:aString |
4537 |
"replace a line at lineNr" |
|
4538 |
||
4539 |
|originalLine| |
|
4540 |
||
4541 |
originalLine := self listAt:lineNr. |
|
4542 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4543 |
super withoutRedrawAt:lineNr put:aString. |
|
4544 |
! |
|
4545 |
||
4546 |
withoutRedrawInsertLine:aString before:lineNr |
|
4547 |
"insert the argument, aString before line lineNr; the string |
|
4548 |
becomes line lineNr; everything else is moved down; the view |
|
4549 |
is not redrawn" |
|
4550 |
||
4771 | 4551 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4552 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4553 |
! |
|
4554 |
||
4555 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4556 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4557 |
||
4558 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4559 |
self isReadOnly ifFalse:[ |
|
6152 | 4560 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4561 |
]. |
4562 |
! |
|
4563 |
||
4564 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4565 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4566 |
||
4567 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4568 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4569 |
! |
|
4570 |
||
3890 | 4571 |
wrapLines |
4572 |
"wrap lines (insert line-break)" |
|
4573 |
||
4574 |
|lineLength answerString string| |
|
4575 |
||
4576 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4577 |
||
4578 |
self hasSelection ifFalse:[ |
|
6152 | 4579 |
self selectLine:cursorLine. |
3890 | 4580 |
]. |
4581 |
string := self selectionAsString. |
|
4582 |
string isEmptyOrNil ifTrue:[ |
|
6152 | 4583 |
Dialog information:(resources string:'Nothing selected.'). |
4584 |
^ self. |
|
3890 | 4585 |
]. |
4586 |
||
4587 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4588 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4589 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4590 |
lineLength < 1 ifTrue:[ |
6152 | 4591 |
lineLength := 1. |
3890 | 4592 |
]. |
4593 |
||
4594 |
self |
|
6152 | 4595 |
undoableDo:[ |
4596 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4597 |
||
4598 |
line := selectionStartLine. |
|
4599 |
col := selectionStartCol. |
|
4600 |
||
4601 |
self cutSelection. |
|
4602 |
self cursorLine:line col:col. |
|
4603 |
||
4604 |
lastGoodCol := col. |
|
4605 |
||
4606 |
inStream := string readStream. |
|
4607 |
[ inStream atEnd ] whileFalse:[ |
|
4608 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4609 |
word := CharacterWriteStream new. |
|
4610 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4611 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4612 |
self insertCharAtCursor:(Character cr). |
|
4613 |
col := 1. |
|
4614 |
] ifFalse:[ |
|
4615 |
col ~~ 1 ifTrue:[ |
|
4616 |
self insertStringAtCursor:' '. |
|
4617 |
col := col + 1. |
|
4618 |
] |
|
4619 |
]. |
|
4620 |
self insertStringAtCursor:word contents. |
|
4621 |
col := col + word size. |
|
4622 |
]. |
|
4623 |
] |
|
4624 |
info:'Wrap' |
|
4388 | 4625 |
|
4626 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4627 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4628 |
|
2752 | 4629 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4630 |
|
2952 | 4631 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4632 |
"delete characters from startCol to endCol in line lineNr" |
4633 |
||
6232 | 4634 |
|line lineSize newLine start stop |
6207 | 4635 |
prevWidth newWidth newCol| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4636 |
|
4673 | 4637 |
self unselect. |
4638 |
||
4639 |
cursorLine == lineNr ifTrue:[ |
|
5909 | 4640 |
cursorCol >= startCol ifTrue:[ |
4641 |
cursorCol >= endCol ifTrue:[ |
|
6207 | 4642 |
newCol := startCol. |
5909 | 4643 |
] ifFalse:[ |
6207 | 4644 |
newCol := cursorCol - (endCol - startCol + 1). |
5909 | 4645 |
"/ self assert:(cursorCol >= 0). |
6207 | 4646 |
newCol := newCol max:1. |
4647 |
]. |
|
4648 |
self setCursorCol:newCol. |
|
5909 | 4649 |
]. |
4673 | 4650 |
]. |
4651 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4652 |
line := self listAt:lineNr. |
827 | 4653 |
|
4673 | 4654 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4655 |
||
4656 |
lineSize := line size. |
|
4657 |
||
4658 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4659 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4660 |
||
4661 |
stop >= start ifTrue:[ |
|
5909 | 4662 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
4663 |
ifFalse:[ newLine := '' ]. |
|
4664 |
||
4665 |
stop == lineSize ifFalse:[ |
|
4666 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4667 |
newLine := line string species fromString:newLine. |
|
4668 |
]. |
|
4669 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
4670 |
]. |
|
4671 |
||
4672 |
(self trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4673 |
newLine := nil |
|
4674 |
]. |
|
4675 |
||
4676 |
prevWidth := self widthOfLine:lineNr. |
|
4677 |
||
4678 |
self basicListAt:lineNr put:newLine. |
|
4679 |
||
4680 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4681 |
"/ remember old width of this line, |
|
4682 |
"/ only clear widthOfWidestLine, if this lines |
|
4683 |
"/ length was (one of) the longest. |
|
4684 |
"/ avoids slow delete with huge texts. |
|
4685 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4686 |
||
6232 | 4687 |
"/ scroll left if required |
5909 | 4688 |
viewOrigin x > 0 ifTrue:[ |
4689 |
newWidth := self widthOfLine:lineNr. |
|
4690 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4691 |
self scrollHorizontalTo:(newWidth |
|
4692 |
- width |
|
4693 |
+ margin + margin |
|
4694 |
+ (gc font widthOf:' ')) |
|
4695 |
] |
|
4696 |
]. |
|
4697 |
self textChanged. |
|
4698 |
] ifFalse:[ |
|
4699 |
self textChanged "/ textChangedButNoSizeChange |
|
4700 |
]. |
|
4701 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4702 |
self invalidateLine:lineNr. |
|
4703 |
] ifFalse:[ |
|
4704 |
self redrawLine:lineNr from:start. |
|
4705 |
]. |
|
4673 | 4706 |
]. |
827 | 4707 |
|
4191 | 4708 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
6232 | 4709 |
"Modified (format): / 20-11-2017 / 20:17:55 / mawalch" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4710 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4711 |
|
2952 | 4712 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4713 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4714 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4715 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4716 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4717 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4718 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4719 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4720 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4721 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4722 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4723 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4724 |
startLineNr <= list size ifTrue:[ |
6152 | 4725 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4726 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4727 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4728 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4729 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4730 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4731 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4732 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4733 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4734 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4735 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4736 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4737 |
(firstLineShown >= nLines) ifTrue:[ |
6152 | 4738 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4739 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4740 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4741 |
|
4226 | 4742 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4743 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4744 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4745 |
|
2952 | 4746 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4747 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4748 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4749 |
|
2952 | 4750 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4751 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4752 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4753 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4754 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4755 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4756 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4757 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4758 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4759 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4760 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4761 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4762 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4763 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4764 |
|
2952 | 4765 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4766 |
"insert a single character at lineNr/colNr; |
827 | 4767 |
set emphasis to character at current position" |
4768 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4769 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4770 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4771 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4772 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4773 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4774 |
self splitLine:lineNr before:colNr. |
4775 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4776 |
]. |
827 | 4777 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4778 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4779 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4780 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4781 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4782 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4783 |
self st80EditMode ifFalse:[ |
5909 | 4784 |
(self trimBlankLines |
6469 | 4785 |
and:[colNr > (lineSize + 1) |
5909 | 4786 |
and:[aCharacter == Character space]]) ifTrue:[ |
4787 |
^ self |
|
4788 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4789 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4790 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4791 |
(lineSize == 0) ifTrue:[ |
5909 | 4792 |
newLine := aCharacter asString species new:colNr. |
4793 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4794 |
] ifFalse: [ |
5909 | 4795 |
(colNr > lineSize) ifTrue: [ |
4796 |
colNr == (lineSize +1) ifTrue:[ |
|
4797 |
attribute := line emphasisAt:lineSize |
|
4798 |
]. |
|
4799 |
newLine := line species new:colNr. |
|
4800 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4801 |
drawCharacterOnly := true |
|
4802 |
] ifFalse: [ |
|
4803 |
attribute := line emphasisAt:colNr. |
|
4804 |
newLine := line species new:(lineSize + 1). |
|
4805 |
||
4806 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4807 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
4808 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4809 |
]. |
827 | 4810 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4811 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
5909 | 4812 |
newLine := aCharacter asString species fromString:newLine. |
4813 |
line isText ifTrue:[ |
|
4814 |
newLine := newLine asText |
|
4815 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4816 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4817 |
newLine at:colNr put:aCharacter. |
827 | 4818 |
|
4819 |
attribute notNil ifTrue:[ |
|
5909 | 4820 |
newLine emphasisAt:colNr put:attribute. |
827 | 4821 |
]. |
4822 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4823 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4824 |
newLine := self withTabsExpanded:newLine. |
4825 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4826 |
]. |
827 | 4827 |
|
4771 | 4828 |
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
|
4829 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4830 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4831 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4832 |
self textChanged. |
6399 | 4833 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4834 |
shown ifTrue:[ |
5909 | 4835 |
"/ care for italic text - in this case, we must also |
4836 |
"/ redraw the character before the insertion in order |
|
4837 |
"/ to fix the slanted piece of the character. |
|
4838 |
"/ (but we must clip, to avoid destoying the character before) |
|
4839 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
4840 |
colNr > 1 ifTrue:[ |
|
4841 |
cursorVisibleLine notNil ifTrue:[ |
|
6031 | 4842 |
oldClip := self clippingBoundsOrNil. |
5909 | 4843 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
4844 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4845 |
||
4846 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4847 |
self invalidateLine:lineNr. |
|
4848 |
] ifFalse:[ |
|
4849 |
drawCharacterOnly ifTrue:[ |
|
6031 | 4850 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
5909 | 4851 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4852 |
] ifFalse:[ |
|
6031 | 4853 |
self clippingBounds:(x@y extent:((width - x) @ fontHeight)). |
5909 | 4854 |
self redrawLine:lineNr from:colNr-1 |
4855 |
]. |
|
6031 | 4856 |
self clippingBounds:oldClip. |
5909 | 4857 |
]. |
4858 |
]. |
|
4859 |
^ self. |
|
4860 |
]. |
|
4861 |
]. |
|
4862 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4863 |
self invalidateLine:lineNr. |
|
4864 |
] ifFalse:[ |
|
4865 |
drawCharacterOnly ifTrue:[ |
|
4866 |
self redrawLine:lineNr col:colNr |
|
4867 |
] ifFalse:[ |
|
4868 |
self redrawLine:lineNr from:colNr |
|
4869 |
] |
|
4870 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4871 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4872 |
|
4191 | 4873 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
6469 | 4874 |
"Modified: / 26-10-2018 / 18:18:17 / Claus Gittinger" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4875 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4876 |
|
4771 | 4877 |
basicListAt:lineNr put:newLine |
4878 |
"redefinable for special subclasses (with virtual list)" |
|
4879 |
||
4880 |
list at:lineNr put:newLine. |
|
4881 |
! |
|
4882 |
||
4883 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4884 |
"redefinable for special subclasses (with virtual list)" |
|
4885 |
||
4886 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4887 |
! |
|
4888 |
||
2952 | 4889 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4890 |
"merge line lineNr with line lineNr+1" |
4891 |
||
827 | 4892 |
|leftPart rightPart bothParts nextLineNr i| |
4893 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4894 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
5909 | 4895 |
"/ empty list or beyond end of text |
4896 |
^ self |
|
827 | 4897 |
]. |
4898 |
leftPart := self listAt:lineNr. |
|
4899 |
||
4900 |
leftPart isNil ifTrue:[ |
|
5909 | 4901 |
leftPart := ''. |
4902 |
autoIndent ifTrue:[ |
|
6147 | 4903 |
"/ cg: only do this, if the second line has no indent |
4904 |
(i := self leftIndentOfLine:(lineNr+1)) == 0 ifTrue:[ |
|
4905 |
leftPart := String new:(self leftIndentForLine:lineNr) |
|
5909 | 4906 |
] |
4907 |
] |
|
827 | 4908 |
]. |
4909 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4910 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4911 |
||
4912 |
nextLineNr > (list size) ifFalse:[ |
|
5909 | 4913 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4914 |
rightPart := '' |
|
4915 |
] ifFalse:[ |
|
4916 |
removeBlanks ifTrue:[ |
|
4917 |
rightPart := rightPart withoutLeadingSeparators. |
|
4918 |
] |
|
4919 |
]. |
|
4920 |
||
4921 |
bothParts := leftPart , rightPart. |
|
4922 |
(self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4923 |
self basicListAt:lineNr put:bothParts. |
|
4924 |
self redrawLine:lineNr. |
|
4925 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4926 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4927 |
|
6147 | 4928 |
"Created: / 09-09-1997 / 09:27:38 / cg" |
4929 |
"Modified: / 25-04-2017 / 12:41:20 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4930 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4931 |
|
2952 | 4932 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4933 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4934 |
|
5045 | 4935 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4936 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4937 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4938 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4939 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4940 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4941 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4942 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4943 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4944 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4945 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4946 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4947 |
|
5909 | 4948 |
(self trimBlankLines |
6469 | 4949 |
and:[colNr > (lineSize + 1) |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4950 |
and:[aCharacter == Character space]]) ifTrue:[ |
5909 | 4951 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4952 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4953 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4954 |
(lineSize == 0) ifTrue:[ |
5909 | 4955 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4956 |
] ifFalse: [ |
5909 | 4957 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4958 |
newLineSpecies := aCharacter stringSpecies |
|
4959 |
] ifFalse:[ |
|
4960 |
newLineSpecies := line species |
|
4961 |
]. |
|
4962 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4963 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4964 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4965 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4966 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4967 |
newLine := self withTabsExpanded:newLine. |
4968 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4969 |
]. |
4771 | 4970 |
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
|
4971 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4972 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4973 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4974 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4975 |
shown ifTrue:[ |
5909 | 4976 |
gc font hasOverlappingCharacters ifTrue:[ |
4977 |
self invalidateLine:lineNr. |
|
4978 |
] ifFalse:[ |
|
4979 |
drawCharacterOnly ifTrue:[ |
|
4980 |
self redrawLine:lineNr col:colNr |
|
4981 |
] ifFalse:[ |
|
4982 |
self redrawLine:lineNr from:colNr |
|
4983 |
] |
|
4984 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4985 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4986 |
|
4190 | 4987 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4988 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
6469 | 4989 |
"Modified: / 26-10-2018 / 18:21:21 / Claus Gittinger" |
105 | 4990 |
! |
4991 |
||
3235 | 4992 |
basicReplaceString:aString atLine:lineNr col:colNr |
4993 |
"replace multiple characters starting at lineNr/colNr. |
|
4994 |
This is not prepared to encounter special chars (except TAB) |
|
4995 |
in the string." |
|
4996 |
||
5045 | 4997 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4998 |
|
4999 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
5000 |
||
5001 |
self checkForExistingLine:lineNr. |
|
5002 |
line := list at:lineNr. |
|
5003 |
lineSize := line size. |
|
5004 |
||
5005 |
endCol := colNr + aString size - 1. |
|
5006 |
(lineSize == 0) ifTrue:[ |
|
6152 | 5007 |
newLine := aString species new:endCol. |
3235 | 5008 |
] ifFalse: [ |
6152 | 5009 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5010 |
newLineSpecies := aString stringSpecies |
|
5011 |
] ifFalse:[ |
|
5012 |
newLineSpecies := line species |
|
5013 |
]. |
|
5014 |
||
5015 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
5016 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 5017 |
]. |
5018 |
newLine replaceFrom:colNr with:aString. |
|
5019 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 5020 |
newLine := self withTabsExpanded:newLine. |
3235 | 5021 |
]. |
4771 | 5022 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 5023 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 5024 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 5025 |
]. |
5026 |
self textChanged. |
|
5027 |
shown ifTrue:[ |
|
6152 | 5028 |
gc font hasOverlappingCharacters ifTrue:[ |
5029 |
self invalidateLine:lineNr. |
|
5030 |
] ifFalse:[ |
|
5031 |
self redrawLine:lineNr from:colNr |
|
5032 |
] |
|
3235 | 5033 |
] |
5034 |
||
4190 | 5035 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 5036 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 5037 |
! |
5038 |
||
2952 | 5039 |
basicSplitLine:lineNr before:colNr |
5040 |
"split the line linNr before colNr; the right part (from colNr) |
|
5041 |
is cut off and inserted after lineNr; the view is redrawn" |
|
5042 |
||
3160 | 5043 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 5044 |
srcY "{ Class: SmallInteger }" | |
5045 |
||
3027 | 5046 |
list isNil ifTrue:[ ^ self ]. |
5047 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
5048 |
||
5049 |
(colNr == 1) ifTrue:[ |
|
5909 | 5050 |
self nonUndoableDo:[ |
5051 |
self insertLine:nil before:lineNr. |
|
5052 |
]. |
|
5053 |
^ self |
|
3027 | 5054 |
]. |
5055 |
||
5056 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5057 |
line notNil ifTrue:[ |
5909 | 5058 |
lineSize := line size. |
5059 |
(colNr <= lineSize) ifTrue:[ |
|
5060 |
rightRest := line copyFrom:colNr to:lineSize. |
|
5061 |
(colNr > 1) ifTrue:[ |
|
5062 |
leftRest := line copyTo:(colNr - 1) |
|
5063 |
] |
|
5064 |
] ifFalse:[ |
|
5065 |
leftRest := line |
|
5066 |
] |
|
3027 | 5067 |
]. |
6400 | 5068 |
"/ -- debug: self windowGroup sensor hasDamage ifTrue:[self halt]. |
5069 |
||
3027 | 5070 |
leftRest notNil ifTrue:[ |
6400 | 5071 |
(self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]. |
5072 |
]. |
|
5073 |
leftRest = (self listAt:lineNr) ifFalse:[ |
|
5074 |
self basicListAt:lineNr put:leftRest. |
|
5075 |
]. |
|
5076 |
"/ -- debug: (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt]. |
|
5077 |
||
5078 |
"/ -- debug: TraceDamage := self. |
|
5079 |
||
3027 | 5080 |
self nonUndoableDo:[ |
5909 | 5081 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 5082 |
]. |
6400 | 5083 |
|
5084 |
"/ Delay waitForSeconds:1. |
|
5085 |
"/ (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt]. |
|
5086 |
"/ TraceDamage := nil. |
|
5087 |
||
3027 | 5088 |
visLine := self listLineToVisibleLine:(lineNr). |
5089 |
visLine notNil ifTrue:[ |
|
5909 | 5090 |
w := self widthForScrollBetween:lineNr |
5091 |
and:(firstLineShown + nLinesShown). |
|
5092 |
srcY := topMargin + (visLine * fontHeight). |
|
5093 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
5094 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
6306 | 5095 |
mustWait := self catchExpose. |
5909 | 5096 |
self |
5097 |
copyFrom:self |
|
5098 |
x:textStartLeft y:srcY |
|
5099 |
toX:textStartLeft y:(srcY + fontHeight) |
|
5100 |
width:w |
|
5101 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
5102 |
async:true. |
|
5103 |
]. |
|
5104 |
self redrawLine:lineNr. |
|
5105 |
self redrawLine:(lineNr + 1). |
|
6400 | 5106 |
mustWait ifTrue:[self waitForExpose]. |
3027 | 5107 |
]. |
5108 |
widthOfWidestLine := nil. "/ unknown |
|
5109 |
self textChanged. |
|
2952 | 5110 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5111 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
6306 | 5112 |
"Modified: / 19-04-2018 / 12:21:52 / stefan" |
6400 | 5113 |
"Modified: / 22-08-2018 / 12:56:24 / Claus Gittinger" |
2952 | 5114 |
! |
5115 |
||
2954 | 5116 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 5117 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
5118 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5119 |
because the text might have been pasted from an alien view." |
|
2954 | 5120 |
|
5121 |
|newLine newLines nLines| |
|
5122 |
||
5123 |
nLines := end - start + 1. |
|
5124 |
newLines := Array new:(lines size). |
|
5125 |
start to:end do:[:index | |
|
6152 | 5126 |
newLine := lines at:index. |
5127 |
newLine notNil ifTrue:[ |
|
5128 |
newLine isString ifTrue:[ |
|
5129 |
newLine isBlank ifTrue:[ |
|
5130 |
newLine := nil |
|
5131 |
] ifFalse:[ |
|
5132 |
(newLine includes:(Character tab)) ifTrue:[ |
|
5133 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
5134 |
] |
|
5135 |
] |
|
5136 |
] |
|
5137 |
]. |
|
5138 |
newLines at:index put:newLine |
|
2954 | 5139 |
]. |
5140 |
list isNil ifTrue: [ |
|
6152 | 5141 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 5142 |
] ifFalse: [ |
6152 | 5143 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 5144 |
]. |
5145 |
||
5146 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 5147 |
overlapping copy - if it didn't, we had to use:" |
5148 |
" |
|
5149 |
index := list size. |
|
5150 |
[index > lineNr] whileTrue: [ |
|
6152 | 5151 |
pIndex := index - 1. |
5152 |
list at:index put:(list at:pIndex). |
|
5153 |
index := pIndex |
|
2954 | 5154 |
]. |
5155 |
" |
|
5156 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
5157 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
5158 |
self contentsChanged |
|
5159 |
||
4328 | 5160 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 5161 |
! |
5162 |
||
5163 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 5164 |
"insert aString (which has no crs) at lineNr/colNr. |
5165 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5166 |
because the text might have been pasted from an alien view." |
|
2954 | 5167 |
|
4360 | 5168 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 5169 |
|
4623 | 5170 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 5171 |
|
5172 |
strLen := aString size. |
|
5173 |
self checkForExistingLine:lineNr. |
|
5174 |
||
5175 |
stringType := aString string species. |
|
5176 |
isText := aString isText. |
|
5177 |
line := list at:lineNr. |
|
5178 |
||
5179 |
line notNil ifTrue:[ |
|
6152 | 5180 |
lineSize := line size. |
5181 |
line isString ifFalse:[ |
|
5182 |
stringType := line species |
|
5183 |
] ifTrue:[ |
|
5184 |
lineCharWidth := line bitsPerCharacter. |
|
5185 |
stringCharWidth := aString bitsPerCharacter. |
|
5186 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
5187 |
stringType := line string species |
|
5188 |
] ifFalse:[ |
|
5189 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
5190 |
stringType := aString string species |
|
5191 |
] |
|
5192 |
]. |
|
5193 |
line isText ifTrue:[ isText := true ] |
|
5194 |
]. |
|
2954 | 5195 |
] ifFalse:[ |
6152 | 5196 |
lineSize := 0 |
2954 | 5197 |
]. |
5198 |
||
5199 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
6152 | 5200 |
newLine := aString |
2954 | 5201 |
] ifFalse:[ |
6152 | 5202 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
5203 |
sz := colNr + strLen - 1 |
|
5204 |
] ifFalse:[ |
|
5205 |
sz := lineSize + strLen |
|
5206 |
]. |
|
5207 |
||
5208 |
newLine := stringType new:sz. |
|
5209 |
isText ifTrue:[ |
|
5210 |
newLine := Text string:newLine |
|
5211 |
]. |
|
5212 |
||
5213 |
(lineSize ~~ 0) ifTrue: [ |
|
5214 |
(colNr > lineSize) ifTrue: [ |
|
5215 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
5216 |
] ifFalse: [ |
|
5217 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
5218 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
5219 |
] |
|
5220 |
]. |
|
5221 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 5222 |
]. |
5223 |
||
5224 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 5225 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 5226 |
]. |
5227 |
||
4771 | 5228 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 5229 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 5230 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 5231 |
]. |
5232 |
self textChanged. |
|
5233 |
||
4360 | 5234 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5235 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5236 |
|
2752 | 5237 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5238 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5239 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5240 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5241 |
|
5216 | 5242 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 5243 |
dragIsActive := false. |
5244 |
||
5787 | 5245 |
completionSupport notNil ifTrue:[ |
6152 | 5246 |
"/ also give that guy a chance to close its popup view |
5247 |
completionSupport buttonPress:button x:x y:y |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5248 |
]. |
4609 | 5249 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
5250 |
cursorShown ifTrue: [ |
6152 | 5251 |
self drawCursor |
5787 | 5252 |
]. |
5253 |
||
5254 |
"On X11, be nice and paste PRIMARY when middle click. |
|
4420 | 5255 |
Note, that middle button on X11 is translated to button |
5256 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 5257 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
6313 | 5258 |
"change the cursor position..." |
5259 |
super buttonPress:1 x:x y:y. |
|
5260 |
self buttonRelease:1 x:x y:y. |
|
6152 | 5261 |
self undoableDo:[ |
5262 |
self paste: (self getClipboardText:#selection). |
|
5263 |
]. |
|
6313 | 5264 |
^ self. |
4420 | 5265 |
]. |
5266 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5267 |
(button == 1) ifTrue:[ |
6152 | 5268 |
self hideCursor |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5269 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5270 |
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
|
5271 |
|
4420 | 5272 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
5273 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6313 | 5274 |
"Modified (format): / 27-04-2018 / 13:35:09 / stefan" |
121 | 5275 |
! |
5276 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5277 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5278 |
"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
|
5279 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
5280 |
|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
|
5281 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5282 |
(button == 1) ifTrue:[ |
5882 | 5283 |
typeOfSelection := nil. |
5284 |
||
5285 |
dragIsActive ifTrue:[ |
|
5286 |
self unselect |
|
5287 |
]. |
|
5288 |
selectionStartLine isNil ifTrue:[ |
|
5289 |
clickCol notNil ifTrue:[ |
|
5290 |
self cursorMovementAllowed ifTrue:[ |
|
5291 |
newCursorCol := clickCol. |
|
5292 |
||
5293 |
cursorType ~~ #block ifTrue:[ |
|
5294 |
clickPos notNil ifTrue:[ |
|
5295 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
6096 | 5296 |
"/ (i.e. if it's an ibeam). |
5882 | 5297 |
"/ adjust clickCol if the user clicked in the right third of a character. |
5298 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
5299 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
5300 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
5301 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
5302 |
]. |
|
5303 |
]. |
|
5304 |
"/ the following fixes the ugly select behavior when double clicking on |
|
5305 |
"/ a partially visible last line (where the first click used to |
|
5306 |
"/ scroll the text so that the second click was handled on another |
|
5307 |
"/ line. An alternative (possibly better) solution would be to |
|
5308 |
"/ remember the last click position and adjust in the double click |
|
5309 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
5310 |
"/ Time will show, if this hack works. |
|
5311 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
|
5312 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
5313 |
Processor |
|
5314 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
5315 |
after:0.3 seconds. |
|
5316 |
] ifFalse:[ |
|
5317 |
self cursorLine:clickLine col:newCursorCol. |
|
5318 |
]. |
|
5319 |
]. |
|
5320 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
|
5321 |
list notEmptyOrNil ifTrue:[ |
|
5322 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
|
5323 |
(clickLine >= list size) ifTrue:[ |
|
5324 |
(clickLine > (self list size + 2) |
|
5325 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
|
5326 |
self selectAll |
|
5327 |
]. |
|
5328 |
]. |
|
5329 |
] |
|
5330 |
] |
|
5331 |
] |
|
5332 |
] |
|
5333 |
] ifFalse:[ |
|
5334 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
|
5335 |
]. |
|
5336 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5337 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5338 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
5339 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5340 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
6096 | 5341 |
"Modified (format): / 13-02-2017 / 20:10:18 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5342 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5343 |
|
2580 | 5344 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5345 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5346 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5347 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5348 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5349 |
self changeTypeOfSelectionTo:nil. |
2580 | 5350 |
|
5351 |
(key == #CursorRight) ifTrue:[ |
|
6137 | 5352 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5353 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5354 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
5355 |
expandingTop := false. |
|
5356 |
self validateNewSelection. |
|
5357 |
self setPrimarySelection. |
|
5358 |
self selectionChanged. |
|
5359 |
self redrawLine:selectionStartLine. |
|
5360 |
^ self. |
|
5361 |
]. |
|
5362 |
||
5363 |
selectionStartLine notNil ifTrue:[ |
|
5364 |
self cursorMovementAllowed ifTrue:[ |
|
5365 |
"/ |
|
5366 |
"/ treat the whole selection as cursor |
|
5367 |
"/ |
|
5368 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5369 |
selectionEndCol == 0 ifTrue:[ |
|
5370 |
selectionEndCol := 1. |
|
5371 |
]. |
|
5372 |
self setCursorCol:selectionEndCol. |
|
5373 |
shifted ifTrue:[ |
|
5374 |
self expandSelectionRight. |
|
5375 |
^ self |
|
5376 |
]. |
|
5377 |
self unselect; makeCursorVisible. |
|
5378 |
"/ cursorCol == 1 ifTrue:[^ self]. |
|
5379 |
]. |
|
5380 |
]. |
|
5381 |
self cursorRight. |
|
5382 |
^ self |
|
2580 | 5383 |
]. |
5384 |
(key == #CursorDown) ifTrue:[ |
|
6137 | 5385 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5386 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
5387 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
5388 |
selectionEndCol == 1 ifTrue:[ |
|
5389 |
selectionEndCol := 0. |
|
5390 |
]. |
|
5391 |
self validateNewSelection. |
|
5392 |
self selectionChanged. |
|
5393 |
self redrawLine:selectionStartLine. |
|
5394 |
expandingTop := false. |
|
5395 |
self redrawLine:selectionEndLine. |
|
5396 |
^ self |
|
5397 |
]. |
|
5398 |
||
5399 |
selectionStartLine notNil ifTrue:[ |
|
5400 |
self cursorMovementAllowed ifTrue:[ |
|
5401 |
"/ |
|
5402 |
"/ treat the whole selection as cursor |
|
5403 |
"/ |
|
5404 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5405 |
self setCursorCol:selectionStartCol. |
|
5406 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
|
5407 |
self setCursorCol:1. |
|
5408 |
self setCursorLine:(cursorLine - 1). |
|
5409 |
]. |
|
5410 |
self makeCursorVisible. |
|
5411 |
||
5412 |
shifted ifTrue:[ |
|
5413 |
clickLine := cursorLine. |
|
5414 |
clickCol := cursorCol. |
|
5415 |
self expandSelectionDown. |
|
5416 |
^ self |
|
5417 |
]. |
|
5418 |
self unselect. |
|
5419 |
]. |
|
5420 |
]. |
|
5421 |
||
5422 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
|
5423 |
self cursorDown:n. |
|
5424 |
"/ |
|
5425 |
"/ flush keyboard to avoid runaway cursor |
|
5426 |
"/ |
|
5427 |
self sensor flushKeyboardFor:self. |
|
5428 |
^ self |
|
2580 | 5429 |
]. |
5430 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
6137 | 5431 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5432 |
expandingTop := true. |
|
5433 |
key == #CursorLeft ifTrue:[ |
|
5434 |
cursorCol > 1 ifTrue:[ |
|
5435 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5436 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
5437 |
selectionStartCol := cursorCol-1. |
|
5438 |
self validateNewSelection. |
|
5439 |
self selectionChanged. |
|
5440 |
self redrawLine:selectionStartLine. |
|
5441 |
^ self |
|
5442 |
] |
|
5443 |
] ifFalse:[ |
|
5444 |
cursorLine > 1 ifTrue:[ |
|
5445 |
selectionEndLine := clickStartLine := cursorLine. |
|
5446 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
5447 |
selectionStartLine := cursorLine - 1. |
|
5448 |
selectionEndCol == 1 ifTrue:[ |
|
5449 |
selectionEndCol := 0. |
|
5450 |
]. |
|
5451 |
self validateNewSelection. |
|
5452 |
self selectionChanged. |
|
5453 |
self redrawFromLine:selectionStartLine to:cursorLine. |
|
5454 |
^ self |
|
5455 |
] |
|
5456 |
] |
|
5457 |
]. |
|
5458 |
||
5459 |
selectionStartLine notNil ifTrue:[ |
|
5460 |
self cursorMovementAllowed ifTrue:[ |
|
5461 |
"/ |
|
5462 |
"/ treat the whole selection as cursor |
|
5463 |
"/ |
|
5464 |
self setCursorLine:selectionStartLine. |
|
5465 |
self setCursorCol:selectionStartCol. |
|
5466 |
(key == #CursorLeft) ifTrue:[ |
|
5467 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
5468 |
]. |
|
5469 |
self makeCursorVisible. |
|
5470 |
||
5471 |
shifted ifTrue:[ |
|
5472 |
(key == #CursorUp) ifTrue:[ |
|
5473 |
clickLine := cursorLine. |
|
5474 |
self expandSelectionUp. |
|
5475 |
] ifFalse:[ |
|
5476 |
self expandSelectionLeft. |
|
5477 |
]. |
|
5478 |
^ self |
|
5479 |
]. |
|
5480 |
self unselect. |
|
5481 |
]. |
|
5482 |
]. |
|
5483 |
(key == #CursorLeft) ifTrue:[ |
|
5484 |
self cursorLeft. ^self |
|
5485 |
]. |
|
5486 |
(key == #CursorUp) ifTrue:[ |
|
5487 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
|
5488 |
self cursorUp:n. |
|
5489 |
"/ |
|
5490 |
"/ flush keyboard to avoid runaway cursor |
|
5491 |
"/ |
|
5492 |
self sensor flushKeyboardFor:self. |
|
5493 |
^ self |
|
5494 |
]. |
|
2580 | 5495 |
]. |
4420 | 5496 |
|
5497 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6137 | 5498 |
"Modified: / 19-03-2017 / 10:08:54 / cg" |
2580 | 5499 |
! |
5500 |
||
2952 | 5501 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5502 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5503 |
|
4521 | 5504 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
6147 | 5505 |
#Replace #Undo #Redo #Accept |
5506 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
|
5507 |
#DeleteSpaces #Join |
|
5508 |
#SearchMatchingParent #SelectMatchingParents |
|
5509 |
#SelectWord #ExpandSelectionByWord |
|
5510 |
#SelectToEnd #SelectFromBeginning |
|
5511 |
#SelectLine #ExpandSelectionByLine |
|
5512 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
5513 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5514 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5515 |
#GotoLine #BeginOfText #EndOfText |
|
5516 |
#InsertLine #DeleteLine |
|
6354 | 5517 |
#SelectLineFromBeginning #SelectToLineEnd |
6147 | 5518 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
5519 |
#OpenSpecialCharacterWindow #InsertUUID |
|
5520 |
#'F*' #'f*')> |
|
2017 | 5521 |
|
4730 | 5522 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5523 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5524 |
|
5525 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5526 |
|
4701 | 5527 |
"/ experimental |
4818 | 5528 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
5787 | 5529 |
(immediateCompletion |
4818 | 5530 |
or:[currentUserPrefs codeCompletionOnControlKey |
5531 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
6147 | 5532 |
completionSupport isNil ifTrue:[ |
5533 |
self initializeCompletionSupport. |
|
5534 |
]. |
|
5787 | 5535 |
]. |
5536 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5537 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5538 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5539 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5540 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5541 |
completionSupport notNil ifTrue:[ |
6147 | 5542 |
completionSupport stopCompletionProcess. |
5543 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5544 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5545 |
|
4818 | 5546 |
key isSymbol ifTrue:[ |
6147 | 5547 |
(device modifierKeys includes:key) ifFalse:[ |
5548 |
lastReplacementInfo stillCollectingInput:false. |
|
5549 |
] |
|
4818 | 5550 |
]. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5551 |
(key == #LearnKeyboardMacro) ifTrue:[ |
6147 | 5552 |
lastReplacementInfo stillCollectingInput:false. |
5553 |
self toggleLearnMode. |
|
5554 |
^ self |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5555 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5556 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
6147 | 5557 |
lastReplacementInfo stillCollectingInput:false. |
5558 |
self executeLearnedKeyboardMacro. |
|
5559 |
^ self. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5560 |
]. |
3799 | 5561 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5562 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5563 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5564 |
self learnMode ifTrue:[ |
6390 | 5565 |
event := WindowGroup lastEvent. |
6147 | 5566 |
learnedMacro add:event. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5567 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5568 |
|
4238 | 5569 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
6147 | 5570 |
"the macro named key exists" |
5571 |
^ self |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5572 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5573 |
|
4482 | 5574 |
key isSymbol ifFalse:[ |
6147 | 5575 |
"the usual case: key is a character, but maybe a string also (in X11)" |
5576 |
self handleNonCommandKey:key. |
|
5577 |
^ self |
|
4482 | 5578 |
]. |
5579 |
||
5580 |
event isNil ifTrue:[ |
|
6390 | 5581 |
event := WindowGroup lastEvent. |
4482 | 5582 |
]. |
5583 |
shiftPressed := event hasShift. |
|
5584 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5585 |
rawKey := event rawKey. |
4482 | 5586 |
|
5133 | 5587 |
key == #InsertUUID ifTrue:[ |
6147 | 5588 |
self insertUUID. |
5589 |
^ self. |
|
5133 | 5590 |
]. |
5591 |
||
4253 | 5592 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
6147 | 5593 |
self deleteWordBeforeCursor. |
5594 |
^ self. |
|
4253 | 5595 |
]. |
5596 |
||
5119 | 5597 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
6147 | 5598 |
selectionStartLine notNil ifTrue:[ |
5599 |
((key == #BasicBackspace) |
|
5600 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
|
5601 |
ifTrue:[ |
|
5602 |
self deleteSelection. |
|
5603 |
] ifFalse: [ |
|
5604 |
self copyAndDeleteSelection. |
|
5605 |
]. |
|
5606 |
] ifFalse:[ |
|
5607 |
self makeCursorVisible. |
|
4609 | 5608 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
5609 |
"/ self deleteWordBeforeCursor. |
|
5610 |
"/ ] ifFalse:[ |
|
6147 | 5611 |
self deleteCharBeforeCursor. |
6399 | 5612 |
|
5613 |
self maybeShowMatchingParenthesisFor:(self characterBeforeCursor). |
|
5614 |
||
4609 | 5615 |
"/ ]. |
6147 | 5616 |
]. |
5617 |
true "immediateCompletion" ifTrue:[ |
|
5618 |
completionSupport notNil ifTrue:[ |
|
5619 |
completionSupport postKeyPress:key |
|
5620 |
]. |
|
5621 |
]. |
|
5622 |
^ self |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5623 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5624 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5625 |
(key == #ToggleAutoIndent) ifTrue:[ |
6147 | 5626 |
self autoIndent:(autoIndent not). |
5627 |
^ self. |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5628 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5629 |
|
3235 | 5630 |
key == #ToggleInsertMode ifTrue:[ |
6147 | 5631 |
self insertMode:(editMode value == EditMode insertMode) not. |
5632 |
^ self. |
|
3160 | 5633 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5634 |
|
4162 | 5635 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
6147 | 5636 |
CharacterSetView notNil ifTrue:[ |
5637 |
self specialCharacters. |
|
5638 |
^ self. |
|
5639 |
] |
|
4162 | 5640 |
]. |
5641 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5642 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5643 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5644 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5645 |
Fn pastes a key-sequence (but only if not overlayed with |
6147 | 5646 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5647 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5648 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5649 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5650 |
(key at:1) asLowercase == $f ifTrue:[ |
6147 | 5651 |
(('[fF][0-9]' match:key) |
5652 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5653 |
shiftPressed ifFalse:[ |
|
5654 |
fKeyMacros := currentUserPrefs functionKeySequences. |
|
5655 |
fKeyMacros notNil ifTrue:[ |
|
5656 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5657 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5658 |
^ self |
|
5659 |
] |
|
5660 |
] |
|
5661 |
] |
|
5662 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5663 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5664 |
|
2506 | 5665 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
6147 | 5666 |
self parenthizeSelectionWith:$( and:$). |
5667 |
^ self. |
|
2506 | 5668 |
]. |
5669 |
(key == #'Ctrl2') ifTrue:[ |
|
6147 | 5670 |
self parenthizeSelectionWith:$" and:$". |
5671 |
^ self. |
|
2506 | 5672 |
]. |
5673 |
(key == #'Ctrl#') ifTrue:[ |
|
6147 | 5674 |
self parenthizeSelectionWith:$' and:$'. |
5675 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5676 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5677 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
6147 | 5678 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
5679 |
^ self. |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5680 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5681 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5682 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5683 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5684 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5685 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5686 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5687 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5688 |
|
3542 | 5689 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5690 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5691 |
(key == #ExpandSelectionByWord) ifTrue:[ |
6147 | 5692 |
self makeCursorVisible. |
5693 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5694 |
^ self |
|
4707 | 5695 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5696 |
(key == #SelectWord) ifTrue:[ |
6147 | 5697 |
self makeCursorVisible. |
5698 |
self selectWordUnderCursor. |
|
5699 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5700 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5701 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5702 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5703 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5704 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5705 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5706 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5707 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5708 |
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
|
5709 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5710 |
(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
|
5711 |
(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
|
5712 |
(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
|
5713 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5714 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5715 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5716 |
(key == #BeginOfLine) ifTrue:[ |
6147 | 5717 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5718 |
"/ some shifted key to selectFromBeginOfLine |
|
5719 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5720 |
"/ see code below. |
|
5721 |
false "shiftPressed" ifTrue: [ |
|
5722 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5723 |
"/ self unselect. |
|
5724 |
"/ self cursorHome. |
|
5725 |
"Jan's modification" |
|
5726 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
|
5727 |
"/ Jan's modification modified by his own request ;-)) |
|
5728 |
self selectFromBeginOfLine. |
|
5729 |
] ifFalse: [ |
|
5730 |
self unselect. |
|
5731 |
ctrlPressed ifTrue:[ |
|
5732 |
self cursorHome. |
|
5733 |
] ifFalse:[ |
|
5734 |
self cursorToBeginOfLine. |
|
5735 |
] |
|
5736 |
]. |
|
5737 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5738 |
]. |
5226 | 5739 |
(key == #BSelectFromeginOfLine) ifTrue:[ |
6147 | 5740 |
self selectFromBeginOfLine. |
5741 |
^ self |
|
5226 | 5742 |
]. |
5743 |
||
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5744 |
(key == #EndOfLine) ifTrue:[ |
6147 | 5745 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5746 |
"/ some shifted key to selectFromBeginOfLine |
|
5747 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5748 |
"/ see code below. |
|
5749 |
false "shiftPressed" ifTrue:[ |
|
5750 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5751 |
"/ self unselect. |
|
5752 |
"/ self cursorToBottom |
|
5753 |
" Jan's modification" |
|
5754 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5755 |
"/ Jan's modification modified by his own request ;-)) |
|
5756 |
self selectToEndOfLine. |
|
5757 |
] ifFalse:[ |
|
5758 |
self unselect. |
|
5759 |
ctrlPressed ifTrue:[ |
|
5760 |
self cursorToBottom |
|
5761 |
] ifFalse:[ |
|
5762 |
self cursorToEndOfLine. |
|
5763 |
] |
|
5764 |
]. |
|
5765 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5766 |
]. |
5226 | 5767 |
|
5768 |
(key == #SelectToEndOfLine) ifTrue:[ |
|
6147 | 5769 |
self selectToEndOfLine. |
5770 |
^ self |
|
5226 | 5771 |
]. |
5772 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5773 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5774 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5775 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5776 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5777 |
|
5119 | 5778 |
(rawKey == #CursorRight |
5779 |
or:[rawKey == #CursorDown |
|
5780 |
or:[rawKey == #CursorLeft |
|
5781 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
6147 | 5782 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
5783 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5784 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5785 |
|
5119 | 5786 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
6147 | 5787 |
self unselect. self cursorReturn. |
5788 |
^ self |
|
3257 | 5789 |
]. |
5790 |
||
5791 |
(key == #Return) ifTrue:[ |
|
6147 | 5792 |
shiftPressed ifTrue:[ |
5793 |
self unselect. self cursorReturn. |
|
5794 |
^ self |
|
5795 |
]. |
|
5796 |
||
5797 |
self isReadOnly ifTrue:[ |
|
5798 |
self unselect; makeCursorVisible. |
|
5799 |
self cursorReturn |
|
5800 |
] ifFalse:[ |
|
5801 |
self isInInsertMode ifFalse:[ |
|
5802 |
self cursorReturn:true. |
|
5803 |
autoIndent == true ifTrue:[ |
|
5804 |
i := self leftIndentForLine:(cursorLine + 1). |
|
5805 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
|
5806 |
self cursorCol:(i+1 max:1) |
|
5807 |
] |
|
5808 |
] |
|
5809 |
] ifTrue:[ |
|
5810 |
|left right oldIndent| |
|
5811 |
||
5812 |
"/ old version just unselected ... |
|
5813 |
"/ self unselect; makeCursorVisible. |
|
5814 |
||
5815 |
"/ new version deletes ... |
|
5816 |
typeOfSelection == #paste ifTrue:[ |
|
5817 |
self unselect; makeCursorVisible. |
|
5818 |
] ifFalse:[ |
|
5819 |
self copyAndDeleteSelection. |
|
5820 |
]. |
|
5821 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
|
5822 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
5823 |
self insertCharAtCursor:(Character cr). |
|
5824 |
||
5825 |
autoIndent == true ifTrue:[ |
|
5826 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
|
5827 |
"/ nothing to do. |
|
5828 |
] ifFalse:[ |
|
5829 |
((self listAt:cursorLine) isEmptyOrNil |
|
5830 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
|
5831 |
i := (self leftIndentForLine:cursorLine). |
|
5832 |
left := left withoutSeparators. |
|
5833 |
right := right withoutSeparators. |
|
5834 |
(left endsWith:'[') ifTrue:[ |
|
4823 | 5835 |
"/ i := i + 4. |
6147 | 5836 |
] ifFalse:[ |
5837 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
|
5838 |
i := i - 4. |
|
5839 |
]. |
|
5840 |
]. |
|
5841 |
oldIndent := self leftIndentOfLine:cursorLine. |
|
5842 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5843 |
self st80EditMode ifTrue:[ |
|
5844 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5845 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5846 |
]. |
|
5847 |
]. |
|
5848 |
self cursorCol:(i+1 max:1) |
|
5849 |
]. |
|
5850 |
] |
|
5851 |
]. |
|
5852 |
]. |
|
5853 |
]. |
|
5854 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5855 |
]. |
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
|
5856 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5857 |
(key == #NonInsertingTab) ifTrue:[ |
6150 | 5858 |
((rawKey == #ShiftTab) |
5859 |
and:[self hasSelection |
|
5860 |
and:[selectStyle == #line]] |
|
5861 |
) ifTrue:[ |
|
5862 |
self executekeyboardMacroNamed:#UndentBy4. |
|
5863 |
^ self. |
|
5864 |
]. |
|
6147 | 5865 |
self unselect. self cursorTab. |
5866 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5867 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5868 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
6147 | 5869 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5870 |
||
5871 |
self hasSelection ifTrue:[ |
|
5872 |
selectStyle == #line ifTrue:[ |
|
5873 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
|
5874 |
macroName := #IndentBy4. |
|
5875 |
] ifFalse:[ |
|
5876 |
macroName := #UndentBy4. |
|
5877 |
]. |
|
5878 |
macroName notNil ifTrue:[ |
|
5879 |
self executekeyboardMacroNamed:macroName. |
|
6150 | 5880 |
^ self. |
6147 | 5881 |
]. |
5882 |
] |
|
5883 |
]. |
|
5884 |
||
5885 |
self unselect. |
|
5886 |
(key == #Tab) ifTrue:[ |
|
5887 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5888 |
self cursorTab. |
|
5889 |
^ self |
|
5890 |
]. |
|
5891 |
self insertTabAtCursor. |
|
5892 |
^ self |
|
5893 |
]. |
|
5894 |
self cursorBacktab. |
|
5895 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5896 |
]. |
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
|
5897 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5898 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5899 |
(rawKey == #Delete) ifTrue:[ |
6147 | 5900 |
shiftPressed ifTrue:[ |
5901 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5902 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5903 |
self makeCursorVisible. |
|
5904 |
self deleteCharAtCursor. |
|
5905 |
]. |
|
5906 |
^ self |
|
5907 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5908 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5909 |
|
5119 | 5910 |
(rawKey == #Delete |
870 | 5911 |
or:[key == #BasicDelete]) ifTrue:[ |
6147 | 5912 |
selectionStartLine notNil ifTrue:[ |
4130 | 5913 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5914 |
"/ To remove text repetetively, use Cut instead. |
|
5915 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5916 |
"/ lastReplacementInfo lastReplacement: nil. |
|
6147 | 5917 |
((key == #BasicDelete) |
5918 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
|
5919 |
self deleteSelection. |
|
5920 |
] ifFalse:[ |
|
5921 |
self copyAndDeleteSelection. |
|
5922 |
]. |
|
5923 |
^ self |
|
5924 |
]. |
|
5925 |
self makeCursorVisible. |
|
5926 |
self deleteCharAtCursor. |
|
5927 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5928 |
]. |
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
|
5929 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5930 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
6147 | 5931 |
self unselect. |
5932 |
cursorVisibleLine == 1 ifTrue:[ |
|
5933 |
self cursorHome. |
|
5934 |
] ifFalse:[ |
|
5935 |
self cursorToFirstVisibleLine |
|
5936 |
]. |
|
5937 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5938 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5939 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
6147 | 5940 |
self unselect. |
5941 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5942 |
self cursorToBottom. |
|
5943 |
] ifFalse:[ |
|
5944 |
self cursorToLastVisibleLine |
|
5945 |
]. |
|
5946 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5947 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5948 |
((key == #Escape) |
3257 | 5949 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
6147 | 5950 |
self makeCursorVisible. |
5951 |
self unselect. self selectCursorLineFromBeginning. |
|
5952 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5953 |
]. |
6354 | 5954 |
(key == #SelectToLineEnd) ifTrue:[ |
5955 |
self makeCursorVisible. |
|
5956 |
self unselect. self selectCursorLineToEnd. |
|
5957 |
^ self |
|
5958 |
]. |
|
3257 | 5959 |
(key == #SelectLine) ifTrue:[ |
6147 | 5960 |
self makeCursorVisible. |
5961 |
self unselect. self selectCursorLine. |
|
5962 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5963 |
]. |
3257 | 5964 |
(key == #ExpandSelectionByLine) ifTrue:[ |
6147 | 5965 |
"/ self makeCursorVisible. |
5966 |
self selectExpandCursorLine. |
|
5967 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5968 |
]. |
3257 | 5969 |
(key == #DeleteLine) ifTrue:[ |
6147 | 5970 |
self makeCursorVisible. |
5971 |
self unselect. self deleteCursorLine. |
|
5972 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5973 |
]. |
3257 | 5974 |
(key == #InsertLine) ifTrue:[ |
6147 | 5975 |
self makeCursorVisible. |
5976 |
self unselect. self insertLine:nil before:cursorLine. |
|
5977 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5978 |
]. |
3781 | 5979 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5980 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5981 |
|
3310 | 5982 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5983 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6152 | 5984 |
"Modified: / 28-04-2017 / 09:25:22 / cg" |
6399 | 5985 |
"Modified: / 22-08-2018 / 08:36:19 / Claus Gittinger" |
121 | 5986 |
! |
5987 |
||
2952 | 5988 |
executeKeyboardMacro:cmdMacro |
5989 |
Error handle:[:ex | |
|
6152 | 5990 |
self warn:'Error in keyboard macro: ' , ex description. |
5991 |
ex return. |
|
2952 | 5992 |
] do:[ |
6152 | 5993 |
AbortOperationRequest handle:[:ex | |
5994 |
self warn:'Keyboard macro aborted'. |
|
5995 |
ex return. |
|
5996 |
] do:[ |
|
5997 |
Parser |
|
5998 |
evaluate:cmdMacro asString |
|
5999 |
receiver:self |
|
6000 |
notifying:nil |
|
6001 |
compile:false. |
|
6002 |
]. |
|
2952 | 6003 |
]. |
6004 |
! |
|
6005 |
||
6006 |
handleNonCommandKey:keyArg |
|
4700 | 6007 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 6008 |
|
6226 | 6009 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
2952 | 6010 |
|
6011 |
key := keyArg. |
|
6012 |
||
6013 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 6014 |
"pasted selection will NOT be replaced by keystroke" |
6015 |
self unselect |
|
2952 | 6016 |
]. |
6017 |
||
4700 | 6018 |
selStartLineBefore := selectionStartLine. |
6019 |
selStartColBefore := self selectionStartCol. |
|
6020 |
selEndLineBefore := selectionEndLine. |
|
6021 |
selEndColBefore := self selectionEndCol. |
|
2952 | 6022 |
|
6270 | 6023 |
gc characterEncoding ~~ #'iso10646-1' ifTrue:[ |
6024 |
key := CharacterEncoder encodeString:key asString from:#'iso10646-1' into:gc characterEncoding. |
|
2952 | 6025 |
]. |
6026 |
||
6027 |
"replace selection by what is typed in - |
|
3235 | 6028 |
if word was selected with a space, keep it. |
4700 | 6029 |
if there was no selection, the key's character is inserted" |
3235 | 6030 |
|
6031 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
6152 | 6032 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 6033 |
]. |
2952 | 6034 |
|
6035 |
(selectStyle == #wordLeft) ifTrue:[ |
|
6152 | 6036 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 6037 |
] ifFalse:[ |
6152 | 6038 |
(selectStyle == #wordRight) ifTrue:[ |
6039 |
self replaceSelectionBy:(key asString , ' '). |
|
6040 |
self cursorLeft |
|
6041 |
] ifFalse:[ |
|
6042 |
self replaceSelectionBy:key |
|
6043 |
] |
|
3160 | 6044 |
]. |
2952 | 6045 |
selectStyle := nil. |
6046 |
||
3235 | 6047 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 6048 |
selectionStartLine := selStartLineBefore. |
6049 |
selectionStartCol := selStartColBefore. |
|
6050 |
selectionEndLine := selEndLineBefore. |
|
6051 |
selectionEndCol := selEndColBefore. |
|
3235 | 6052 |
]. |
6053 |
||
6399 | 6054 |
self maybeShowMatchingParenthesisFor:key. |
2952 | 6055 |
|
6056 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
6057 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
6058 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
6059 |
"/ |
|
6060 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
6061 |
"/ self selection. |
|
6062 |
"/ typeOfSelection := #paste. |
|
3160 | 6063 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6064 |
"/ ]. |
3235 | 6065 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 6066 |
selectionStartLine isNil ifTrue:[ |
6067 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
|
6068 |
] ifFalse:[ |
|
6069 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
|
6070 |
]. |
|
3235 | 6071 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6072 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 6073 |
|
6226 | 6074 |
"Modified: / 11-11-2017 / 12:54:01 / cg" |
6270 | 6075 |
"Modified: / 19-01-2018 / 12:23:41 / stefan" |
6399 | 6076 |
"Modified: / 22-08-2018 / 08:34:25 / Claus Gittinger" |
2952 | 6077 |
! |
6078 |
||
6079 |
keyPress:key x:x y:y |
|
6080 |
"handle keyboard input" |
|
6081 |
||
4771 | 6082 |
|wasOn| |
6083 |
||
6084 |
wasOn := cursorShown. |
|
6085 |
||
5787 | 6086 |
NoModificationError |
6152 | 6087 |
handle:[:ex | |
6088 |
self flashReadOnly. |
|
6089 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
6090 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6091 |
]. |
|
6092 |
] |
|
6093 |
do:[ |
|
6094 |
self undoableDo:[ |
|
6095 |
self doKeyPress:key x:x y:y |
|
6096 |
]. |
|
6097 |
]. |
|
5689 | 6098 |
|
4242 | 6099 |
self repairDamage |
6100 |
||
6101 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 6102 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 6103 |
! |
6104 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6105 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6106 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6107 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6108 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6109 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6110 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6111 |
|
6399 | 6112 |
maybeShowMatchingParenthesisFor:characterBeforeCursor |
6113 |
showMatchingParenthesis ifTrue:[ |
|
6114 |
"emacs style parenthesis shower" |
|
6115 |
"claus: only do it for closing parenthesis - otherwise its too anoying." |
|
6116 |
("'()[]{}'" ')]}' includes:characterBeforeCursor) ifTrue:[ |
|
6117 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
|
6118 |
self |
|
6119 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
6120 |
ifFound:[:line :col | self showMatchingParenthesisAtLine:line col:col ] |
|
6121 |
ifNotFound:[self showNotFound] |
|
6122 |
onError:[self beepInEditor] |
|
6123 |
]. |
|
6124 |
] |
|
6125 |
]. |
|
6126 |
||
6127 |
"Created: / 22-08-2018 / 08:34:04 / Claus Gittinger" |
|
6128 |
! |
|
6129 |
||
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6130 |
requestAutoAccept |
5068 | 6131 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
6132 |
This forces my value to be accepted into my model. |
|
6133 |
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
|
6134 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6135 |
acceptEnabled == false ifTrue:[ |
6152 | 6136 |
"/ nope - |
6137 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6138 |
]. |
5404 | 6139 |
"/ cg: only do this if modified. |
6140 |
"/ otherwise, users would have to make sure that the contents is |
|
6141 |
"/ always correct (which they don't). If you change this back, |
|
6142 |
"/ please check the expecco file-save or file-reimport dialog, |
|
6143 |
"/ which has a problem with that behavior. |
|
6144 |
self modified ifTrue:[ |
|
6152 | 6145 |
self accept. |
5404 | 6146 |
]. |
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6147 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6148 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6149 |
|
6399 | 6150 |
showMatchingParenthesisAtLine:line col:col |
6151 |
self withCursor:Cursor eye do:[ |
|
6152 |
|savLine savCol sensor| |
|
6153 |
||
6154 |
savLine := cursorLine. |
|
6155 |
savCol := cursorCol. |
|
6156 |
self cursorLine:line col:col. |
|
6157 |
self flush. |
|
6158 |
||
6159 |
"/ want to wait 240ms, but not if another keyPress |
|
6160 |
"/ arrives in the meantime ... |
|
6161 |
||
6162 |
sensor := self sensor. |
|
6163 |
6 timesRepeat:[ |
|
6164 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
6165 |
Processor activeProcess millisecondDelay:40. |
|
6166 |
] |
|
6167 |
]. |
|
6168 |
self cursorLine:savLine col:savCol |
|
6169 |
] |
|
6170 |
||
6171 |
"Created: / 22-08-2018 / 08:22:13 / Claus Gittinger" |
|
6172 |
! |
|
6173 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6174 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6175 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6176 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6177 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6178 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6179 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6180 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6181 |
cv notNil ifTrue:[ |
6152 | 6182 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6183 |
] |
4967 | 6184 |
! |
6185 |
||
6186 |
unmapped |
|
6187 |
super unmapped. |
|
6188 |
||
6189 |
completionSupport notNil ifTrue:[ |
|
6152 | 6190 |
completionSupport release. |
4967 | 6191 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6192 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6193 |
|
1807 | 6194 |
!EditTextView methodsFor:'focus handling'! |
6195 |
||
4818 | 6196 |
focusOut |
6197 |
super focusOut. |
|
6198 |
||
6199 |
completionSupport notNil ifTrue:[ |
|
6152 | 6200 |
completionSupport release. |
4818 | 6201 |
]. |
6202 |
! |
|
6203 |
||
1807 | 6204 |
hasKeyboardFocus:aBoolean |
6205 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
6206 |
(otherwise, I would not know about this)" |
|
6207 |
||
6208 |
hasKeyboardFocus := aBoolean. |
|
4609 | 6209 |
|
3160 | 6210 |
(cursorShown |
6211 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6212 |
and:[self isReadOnly not]]) ifTrue:[ |
5890 | 6213 |
self drawCursor |
4609 | 6214 |
]. |
6215 |
||
6216 |
hasKeyboardFocus ifFalse:[ |
|
5890 | 6217 |
completionSupport notNil ifTrue:[ |
6218 |
"/ this is a hack for Windows: |
|
6219 |
"/ on windows, an activate:false event is first sent to my textView, |
|
6220 |
"/ then an activate is sent to the completion popup. |
|
6221 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
6222 |
"/ therefore, allow for the activate of the completionMenu and its button event to be processed. |
|
6223 |
"/ before forcing it to be closed... |
|
6224 |
completionSupport startTimeoutForEditViewLostFocus. |
|
6225 |
]. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6226 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6227 |
|
4821 | 6228 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 6229 |
! |
6230 |
||
6231 |
showFocus:explicit |
|
6232 |
"in addition to however my superclass thinks how a focusView is to be |
|
6233 |
displayed, show the cursor when I got the focus" |
|
6234 |
||
5239 | 6235 |
self hasKeyboardFocus:true. |
1807 | 6236 |
self showCursor. |
6237 |
super showFocus:explicit |
|
6238 |
||
6239 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6240 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6241 |
|
4967 | 6242 |
showNoFocus:explicit |
5787 | 6243 |
"the view lost the keyboard focus |
4967 | 6244 |
(either explicit, via tabbing; or implicit, by pointer movement) |
6245 |
- change any display attributes as req'd." |
|
6246 |
||
6247 |
super showNoFocus:explicit. |
|
5149 | 6248 |
|
6249 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
6250 |
"/ not when the focus is lost normally (because this also happens when |
|
6251 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
6252 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
6253 |
explicit ifTrue:[ |
|
6152 | 6254 |
completionSupport notNil ifTrue:[ |
6255 |
completionSupport release. |
|
6256 |
]. |
|
4818 | 6257 |
]. |
6258 |
! |
|
6259 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6260 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6261 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6262 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6263 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6264 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6265 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6266 |
and:[self enabled |
4781 | 6267 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6268 |
) ifTrue:[ |
6152 | 6269 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6270 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6271 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6272 |
^ false |
1807 | 6273 |
! ! |
6274 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6275 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6276 |
|
4237 | 6277 |
executekeyboardMacroNamed:macroName |
5787 | 6278 |
"try to execute the keyboard macro; |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6279 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6280 |
|
4482 | 6281 |
|cmdMacro| |
6282 |
||
6283 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6284 |
self |
6152 | 6285 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
6286 |
info: macroName. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6287 |
^ true |
4238 | 6288 |
|
6289 |
" |
|
4483 | 6290 |
EditTextView open |
6152 | 6291 |
contents:'bla'; |
6292 |
selectAll; |
|
6293 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6294 |
EditTextView open |
6152 | 6295 |
contents:'bla'; |
6296 |
selectAll; |
|
6297 |
executekeyboardMacroNamed:#blabla. |
|
4238 | 6298 |
" |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6299 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6300 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6301 |
! |
6302 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6303 |
indent |
3221 | 6304 |
"indent a line-range - this is done by searching for the |
6305 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6306 |
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
|
6307 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6308 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6309 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6310 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6311 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6312 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6313 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6314 |
(selectionEndCol == 0) ifTrue:[ |
6152 | 6315 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6316 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6317 |
self unselect. |
3160 | 6318 |
self |
6152 | 6319 |
undoableDo:[self indentFromLine:start toLine:end] |
6320 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6321 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6322 |
|
4237 | 6323 |
indentBy4 |
5050 | 6324 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6325 |
||
6326 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6327 |
! |
|
6328 |
||
6329 |
indentBy8 |
|
6330 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6331 |
|
6332 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6333 |
! |
|
6334 |
||
5050 | 6335 |
indentBy:n |
6336 |
|line1 line2| |
|
6337 |
||
6338 |
line1 := self selectionStartLine. |
|
6339 |
line2 := self selectionEndLine. |
|
6340 |
line1 isNil ifTrue:[ |
|
5833 | 6341 |
line1 := self cursorLine. |
6342 |
line1 notNil ifTrue:[ |
|
6343 |
line2 := line1 |
|
6344 |
] |
|
5769 | 6345 |
] ifFalse:[ |
5833 | 6346 |
line2 notNil ifTrue:[ |
6347 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
6348 |
]. |
|
5787 | 6349 |
]. |
5050 | 6350 |
line1 notNil ifTrue:[ |
5833 | 6351 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6352 |
] |
6353 |
! |
|
6354 |
||
6355 |
indentByTab |
|
6356 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6357 |
! |
|
6358 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6359 |
indentFromLine:start toLine:end |
3221 | 6360 |
"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
|
6361 |
last non-empty line before start, and change the indent |
4742 | 6362 |
of the selected line-range based on that line's indent." |
6363 |
||
4811 | 6364 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6365 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6366 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6367 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6368 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6369 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6370 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6371 |
self indentFromLine:start toLine:end by:delta |
6372 |
! |
|
6373 |
||
6374 |
indentFromLine:start toLine:end by:delta |
|
6375 |
"indent a line-range - this is done by searching for the |
|
6376 |
last non-empty line before start, and change the indent |
|
6377 |
of the selected line-range based on that line's indent." |
|
6378 |
||
6379 |
|d line spaces anyChange| |
|
6380 |
||
6381 |
(delta == 0) ifTrue:[^ self]. |
|
6226 | 6382 |
|
6383 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[ ^ self]. |
|
6384 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6385 |
(delta > 0) ifTrue:[ |
6152 | 6386 |
spaces := String new:delta |
4742 | 6387 |
]. |
6388 |
||
6389 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6390 |
start to:end do:[:lineNr | |
6152 | 6391 |
line := self listAt:lineNr. |
6392 |
line notNil ifTrue:[ |
|
6393 |
line isBlank ifTrue:[ |
|
6394 |
self basicListAt:lineNr put:nil |
|
6395 |
] ifFalse:[ |
|
6396 |
(delta > 0) ifTrue:[ |
|
6397 |
line := spaces , line. |
|
6398 |
widthOfWidestLine notNil ifTrue:[ |
|
6399 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6400 |
] |
|
6401 |
] ifFalse:[ |
|
6402 |
"check if deletion is ok" |
|
6249 | 6403 |
d := delta negated. |
6152 | 6404 |
|
6405 |
line size > d ifTrue:[ |
|
6249 | 6406 |
(line copyTo:d) withoutSeparators isEmpty ifTrue:[ |
6407 |
line := line copyFrom:(d+1) |
|
6152 | 6408 |
] |
6409 |
]. |
|
6410 |
widthOfWidestLine := nil |
|
6411 |
]. |
|
6412 |
self replaceLine:lineNr with:line. |
|
6413 |
anyChange := true. |
|
6414 |
] |
|
6415 |
] |
|
4742 | 6416 |
]. |
6417 |
||
6418 |
anyChange ifTrue:[ self textChanged ]. |
|
6419 |
||
3221 | 6420 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6421 |
|
6226 | 6422 |
"Modified: / 11-11-2017 / 12:54:33 / cg" |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6423 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6424 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6425 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6426 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6427 |
this is done by searching for the last non-empty line before it |
4823 | 6428 |
and returning its indent. |
6429 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6430 |
|
827 | 6431 |
"SHOULD GO TO ListView" |
6432 |
||
6433 |
|line lnr indent| |
|
6434 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6435 |
lnr := lineNr. |
6147 | 6436 |
[lnr > 1] whileTrue:[ |
6437 |
lnr := lnr - 1. |
|
6438 |
line := self listAt:lnr. |
|
6439 |
||
6440 |
line notEmptyOrNil ifTrue:[ |
|
6441 |
indent := (line indexOfNonSeparatorStartingAt:1) - 1. |
|
6442 |
indent >= 0 ifTrue:[ |
|
6443 |
(self editedLanguage isNil or:[self editedLanguage isSmalltalk]) ifTrue:[ |
|
6444 |
(line endsWith:$[) ifTrue:[ |
|
6445 |
^ indent + 4 |
|
6446 |
]. |
|
6447 |
(line endsWith:']') ifTrue:[ |
|
6448 |
^ indent - 4 |
|
6449 |
]. |
|
6450 |
]. |
|
6451 |
^ indent |
|
6452 |
] |
|
6453 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6454 |
]. |
827 | 6455 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6456 |
|
6147 | 6457 |
"Created: / 05-03-1996 / 14:58:53 / cg" |
6458 |
"Modified (format): / 25-04-2017 / 12:57:44 / cg" |
|
4237 | 6459 |
! |
6460 |
||
6461 |
undentBy4 |
|
5050 | 6462 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6463 |
||
6464 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6465 |
! |
|
6466 |
||
6467 |
undentBy8 |
|
6468 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6469 |
|
6470 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6471 |
! |
6472 |
||
6473 |
undentBy:n |
|
6474 |
self indentBy:(n negated) |
|
6475 |
! |
|
6476 |
||
6477 |
undentByTab |
|
6478 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6479 |
! ! |
6480 |
||
0 | 6481 |
!EditTextView methodsFor:'initialization'! |
6482 |
||
941 | 6483 |
fetchDeviceResources |
6484 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6485 |
||
6486 |
super fetchDeviceResources. |
|
6487 |
||
5643 | 6488 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6489 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6490 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6491 |
|
6492 |
"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
|
6493 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6494 |
! |
6495 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6496 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6497 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6498 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6499 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6500 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6501 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6502 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6503 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6504 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6505 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6506 |
super initStyle. |
4576 | 6507 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6508 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6509 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6510 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6511 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6512 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6513 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6514 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6515 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6152 | 6516 |
cursorTypeNoFocus := cursorType. |
6517 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6518 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6519 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6520 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6521 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6522 |
cursorNoFocusFgColor isNil ifTrue:[ |
6152 | 6523 |
cursorType ~~ #block ifTrue:[ |
6524 |
cursorNoFocusFgColor := cursorBgColor |
|
6525 |
] ifFalse:[ |
|
6526 |
cursorNoFocusFgColor := cursorFgColor |
|
6527 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6528 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6529 |
|
2088 | 6530 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6531 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6532 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6533 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6534 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6535 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6536 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6537 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6538 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6539 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6540 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6541 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6542 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6543 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6544 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6545 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6546 |
cursorCol := 1. |
5251 | 6547 |
cursorLineHolder := ValueHolder with:1. |
6548 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6549 |
modifiedChannel := ValueHolder with:false. |
6550 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6551 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6552 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6553 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6554 |
tabMeansNextField := false. |
5106 | 6555 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6556 |
autoIndent := false. |
|
5251 | 6557 |
editMode := ValueHolder with:EditMode insertMode. |
6558 |
learnMode := ValueHolder with:false. |
|
2131 | 6559 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6560 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6561 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6562 |
"/ enable drop by default |
2589 | 6563 |
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
|
6564 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6565 |
undoSupport := UndoSupport for:self. |
5251 | 6566 |
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
|
6567 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6568 |
"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
|
6569 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6570 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6571 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6572 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6573 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6574 |
completionSupport isNil ifTrue:[ |
6152 | 6575 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
6576 |
completionSupport := supportClass for:self. |
|
6577 |
]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6578 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6579 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6580 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6581 |
! |
6582 |
||
6583 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6584 |
completionSupport notNil ifTrue:[ |
6152 | 6585 |
completionSupport release |
4771 | 6586 |
]. |
6517 | 6587 |
CharacterInputViewSingleton notNil ifTrue:[ |
6588 |
CharacterInputViewSingleton consumingView == self ifTrue:[ |
|
6589 |
CharacterInputViewSingleton closeRequest. |
|
6590 |
CharacterInputViewSingleton := nil |
|
6591 |
] |
|
6592 |
]. |
|
6593 |
||
4771 | 6594 |
super release |
6517 | 6595 |
|
6596 |
"Modified: / 08-01-2019 / 18:16:31 / Claus Gittinger" |
|
0 | 6597 |
! ! |
6598 |
||
2580 | 6599 |
!EditTextView methodsFor:'macros'! |
6600 |
||
6601 |
executeLearnedKeyboardMacro |
|
4673 | 6602 |
"replay the characters as learned previously" |
6603 |
||
6548 | 6604 |
(self learnMode not and:[learnedMacro size ~~ 0]) ifTrue:[ |
6152 | 6605 |
ExecutingMacroQuery |
6606 |
answer:true |
|
6607 |
do:[ |
|
6608 |
learnedMacro do:[:event | |
|
6436 | 6609 |
self |
6610 |
dispatchEvent:event |
|
6611 |
withFocusOn:nil |
|
6612 |
delegate:false |
|
6152 | 6613 |
] |
6614 |
]. |
|
2580 | 6615 |
] ifFalse:[ |
6152 | 6616 |
self flash:'no macro'. |
2580 | 6617 |
]. |
6436 | 6618 |
|
6548 | 6619 |
"Modified: / 01-03-2019 / 14:54:46 / Claus Gittinger" |
2580 | 6620 |
! |
6621 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6622 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6623 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6624 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6625 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6626 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6627 |
|
2580 | 6628 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6629 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6630 |
|
2580 | 6631 |
|fg bg| |
6632 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6633 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6634 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6635 |
aBoolean ifTrue:[ |
5795 | 6636 |
learnedMacro := OrderedCollection new. |
6637 |
fg := self whiteColor. |
|
6638 |
bg := self blackColor. |
|
2580 | 6639 |
] ifFalse:[ |
5795 | 6640 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6641 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6642 |
]. |
6643 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6644 |
! |
|
6645 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6646 |
learnModeHolder |
4673 | 6647 |
"a holder returning true, if in learn mode" |
6648 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6649 |
learnMode isNil ifTrue:[ |
6152 | 6650 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6651 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6652 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6653 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6654 |
|
4673 | 6655 |
rememberLearnedMacroAs: nameString |
6656 |
Macros isNil ifTrue:[ |
|
6152 | 6657 |
Macros := Dictionary new. |
4673 | 6658 |
]. |
6659 |
Macros at:nameString put:learnedMacro |
|
6660 |
! |
|
6661 |
||
2580 | 6662 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6663 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6664 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6665 |
self learnMode:(self learnMode not). |
2580 | 6666 |
! ! |
6667 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6668 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6669 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6670 |
babelFishTranslate:fromToModeString |
5962 | 6671 |
"translate the selected text and paste it after the selection. |
6672 |
This is now obsolete, as that web service no longer exists (sigh)" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6673 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6674 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6675 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6676 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6677 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6678 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6679 |
self withWaitCursorDo:[ |
5962 | 6680 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
6681 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
6682 |
] do:[ |
|
6683 |
translated := SOAP::BabelFishClient new |
|
6684 |
translate:original mode:fromToModeString. |
|
6685 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6686 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6687 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6688 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6689 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6690 |
self unselect. |
5787 | 6691 |
self |
5962 | 6692 |
undoablePaste:translated |
6693 |
info:'Translate' |
|
3495 | 6694 |
|
6695 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6696 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6697 |
|
5689 | 6698 |
copySelection |
6699 |
"copy contents into smalltalk copybuffer. |
|
6700 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6701 |
||
6702 |
self hasSelection ifTrue:[ |
|
6152 | 6703 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
5689 | 6704 |
]. |
6705 |
super copySelection. |
|
6706 |
||
6707 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6708 |
! |
|
6709 |
||
121 | 6710 |
cut |
6711 |
"cut selection into copybuffer" |
|
6712 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6713 |
self deleteCopyToClipboard:true |
121 | 6714 |
! |
6715 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6716 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6717 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6718 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6719 |
cursorLine notNil ifTrue:[ |
6152 | 6720 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6721 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6722 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6723 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6724 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6725 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6726 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6727 |
|
4129 | 6728 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6729 |
|
6226 | 6730 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6731 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6732 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6733 |
sel notNil ifTrue:[ |
6152 | 6734 |
self setLastStringToReplace: sel. |
6735 |
||
6736 |
line := selectionStartLine. |
|
6737 |
col := selectionStartCol. |
|
6738 |
||
6739 |
toClipboard ifTrue:[ |
|
6740 |
" |
|
6741 |
remember in CopyBuffer |
|
6742 |
" |
|
6743 |
self setClipboardText:sel. "/ lastString. |
|
6744 |
]. |
|
6745 |
||
6746 |
" |
|
6747 |
append to DeleteHistory (if there is one) |
|
6748 |
" |
|
6749 |
history := Smalltalk at:#DeleteHistory. |
|
6750 |
history notNil ifTrue:[ |
|
6751 |
history addAll:(sel asStringCollection). |
|
6752 |
history size > 1000 ifTrue:[ |
|
6753 |
history := history copyFrom:(history size - 1000) |
|
6754 |
]. |
|
6755 |
]. |
|
6756 |
||
6757 |
" |
|
6758 |
now, delete it |
|
6759 |
" |
|
6760 |
self |
|
6761 |
undoableDo:[self deleteSelection] |
|
6762 |
info:'Delete'. |
|
6763 |
lastReplacementInfo lastReplacement: nil |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6764 |
] ifFalse:[ |
6152 | 6765 |
" |
6766 |
a cut without selection will search&cut again |
|
6767 |
" |
|
6768 |
self undoableDo:[ |
|
6769 |
self again |
|
6770 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6771 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6772 |
|
6226 | 6773 |
"Modified: / 11-11-2017 / 12:53:45 / cg" |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6774 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6775 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6776 |
editMenu |
5977 | 6777 |
"return the view's middleButtonMenu" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6778 |
|
5787 | 6779 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 6780 |
#Find #GotoLine #SaveAs #Print |
6781 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
|
6782 |
#ToggleAutoIndent #ToggleInsertMode |
|
6783 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6784 |
<resource: #programMenu> |
1054 | 6785 |
|
6241 | 6786 |
|items m sub translateItems sortItems miscItems toolItems convertItems subSubMenu toolSubMenu |
6787 |
transSubMenu sortSubMenu convertSubMenu what undoIdx redoIdx sensor main mainItems| |
|
1515 | 6788 |
|
2460 | 6789 |
items := #( |
5826 | 6790 |
('Redo' redo Redo ) |
6791 |
('Again (for All)' multipleAgain AgainForAll ) |
|
6792 |
('-' ) |
|
6793 |
('Search...' search Find ) |
|
6794 |
('Goto Line...' gotoLine GotoLine ) |
|
6795 |
('-' ) |
|
6796 |
('Tools' tools ) |
|
6797 |
('Font...' changeFont ) |
|
6798 |
('Insert Unicode...' insertUnicode ) |
|
6799 |
). |
|
4213 | 6800 |
CharacterSetView notNil ifTrue:[ |
5826 | 6801 |
items := items , |
6802 |
#( |
|
6803 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6804 |
). |
|
4213 | 6805 |
]. |
6806 |
items := items , #( |
|
5826 | 6807 |
('-' ) |
6808 |
('Save As...' save SaveAs ) |
|
6809 |
('Print' doPrint Print ) |
|
6810 |
('=' ) |
|
6811 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 6812 |
|
2866 | 6813 |
miscItems := #( |
5826 | 6814 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6815 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
6816 |
('-' ) |
|
6134 | 6817 |
('Copy Box' copySelectionBox CopyBox ) |
6818 |
('Paste Box' pasteOrReplaceBox PasteBox ) |
|
5826 | 6819 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
6820 |
('Join Lines' joinLines Join ) |
|
6821 |
('Wrap Lines...' wrapLines Wrap ) |
|
6822 |
('-' ) |
|
6823 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
6824 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
6825 |
('-' ) |
|
6826 |
('Insert File...' insertFile ) |
|
6827 |
('Insert URL Contents...' insertURL ) |
|
6828 |
('Insert new UUID' insertUUID ) |
|
6829 |
('Insert Date && Time' insertDateAndTime ) |
|
6830 |
('-' ) |
|
6831 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6832 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
6833 |
). |
|
4213 | 6834 |
"/ CharacterSetView notNil ifTrue:[ |
6835 |
"/ miscItems := miscItems , |
|
6836 |
"/ #( |
|
5529 | 6837 |
"/ ('-' ) |
4213 | 6838 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6839 |
"/ ('Font...' changeFont ) |
4213 | 6840 |
"/ ). |
5529 | 6841 |
"/ ] ifFalse:[ |
6842 |
"/ miscItems := miscItems , |
|
6843 |
"/ #( |
|
6844 |
"/ ('Font...' changeFont ) |
|
6845 |
"/"/ ('Encoding...' changeEncoding ) |
|
6846 |
"/ ). |
|
5787 | 6847 |
"/ ]. |
2866 | 6848 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6849 |
translateItems := #( |
5826 | 6850 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6851 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6852 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6853 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6854 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6855 |
('-' ) |
|
6856 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6857 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6858 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6859 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6860 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6861 |
). |
|
3221 | 6862 |
|
6863 |
sortItems := #( |
|
5826 | 6864 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6865 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
6866 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
6867 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6868 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
6869 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
6870 |
('-' ) |
|
6871 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
6872 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6873 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6874 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
6875 |
('-' ) |
|
6876 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6877 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
6878 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6879 |
|
2762 | 6880 |
toolItems := #( |
5826 | 6881 |
('Indent' indent ) |
6882 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6241 | 6883 |
('Sort' sortMenu ) |
5826 | 6884 |
('Split...' splitLinesAtCharacterOrString ) |
6241 | 6885 |
('Convert...' convertMenu ) |
5826 | 6886 |
('-' ) |
6887 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6241 | 6888 |
('Builtin Spell Check' internalSpellingSuggestion ) |
6889 |
('Translate' babelFishTranslateMenu ) |
|
5826 | 6890 |
('Compare with Clipboard...' compareWithClipboard ) |
6891 |
('Compare with File...' compareWithFile ) |
|
6892 |
). |
|
2762 | 6893 |
|
6241 | 6894 |
convertItems := #( |
6895 |
('Base64 Decode' selectionDecodeBase64 ) |
|
6896 |
('Base64 Encode' selectionEncodeBase64 ) |
|
6897 |
('Rot13' selectionRot13 ) |
|
6898 |
). |
|
6899 |
||
6359 | 6900 |
toolItems := toolItems , #( |
6901 |
('-' ) |
|
6902 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6903 |
('Open WebBrowser on It' openWebBrowserOnIt ) |
|
6904 |
). |
|
6905 |
||
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6906 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 6907 |
toolItems := toolItems , #( |
6908 |
('-' ) |
|
6564 | 6909 |
('Open Workspace with It' openWorkspaceWithIt OpenWorkspaceOnIt) |
5826 | 6910 |
('Inspect Selected String' inspectSelectedString ) |
6911 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6912 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6913 |
|
2460 | 6914 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6915 |
sub receiver:self. |
2460 | 6916 |
|
6241 | 6917 |
toolSubMenu := PopUpMenu itemList:toolItems resources:resources performer:model. |
6918 |
toolSubMenu receiver:self. |
|
6919 |
sub subMenuAt:#tools put:toolSubMenu. |
|
6920 |
||
6921 |
transSubMenu := PopUpMenu itemList:translateItems resources:resources performer:model. |
|
6922 |
transSubMenu receiver:self. |
|
6923 |
toolSubMenu subMenuAt:#babelFishTranslateMenu put:transSubMenu. |
|
6924 |
||
6925 |
sortSubMenu := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6926 |
sortSubMenu receiver:self. |
|
6927 |
toolSubMenu subMenuAt:#sortMenu put:sortSubMenu. |
|
6928 |
||
6929 |
convertSubMenu := PopUpMenu itemList:convertItems resources:resources performer:model. |
|
6930 |
convertSubMenu receiver:self. |
|
6931 |
toolSubMenu subMenuAt:#convertMenu put:convertSubMenu. |
|
6932 |
||
6933 |
subSubMenu := PopUpMenu itemList:miscItems resources:resources performer:model. |
|
6934 |
subSubMenu receiver:self. |
|
6935 |
subSubMenu checkToggleAt:#autoIndent: put:autoIndent. |
|
6936 |
subSubMenu checkToggleAt:#insertMode: put:(self isInInsertMode). |
|
6937 |
subSubMenu checkToggleAt:#learnMode: put:(self learnModeHolder value). |
|
6938 |
||
6939 |
sub subMenuAt:#misc put:subSubMenu. |
|
2866 | 6940 |
|
3495 | 6941 |
mainItems := #( |
5826 | 6942 |
('Undo' undo Undo ) |
6943 |
('Again' again Again ) |
|
6944 |
('-' ) |
|
6134 | 6945 |
('Cut' cut Cut )). |
6946 |
self sensor metaDown ifTrue:[ |
|
6947 |
mainItems := mainItems , #( |
|
6948 |
('Copy Box' copySelectionBox CopyBox ) |
|
6949 |
('Paste Box' pasteOrReplaceBox PasteBox )) |
|
6950 |
] ifFalse:[ |
|
6951 |
mainItems := mainItems , #( |
|
6477
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
6952 |
('Copy' copySelection Copy ) |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
6953 |
('Paste' pasteOrReplace Paste ) |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
6954 |
('Paste...' pasteOrReplaceFromHistory PasteFromHistory )) |
6134 | 6955 |
]. |
6956 |
mainItems := mainItems , #( |
|
5826 | 6957 |
('-' ) |
6958 |
('Accept' accept Accept ) |
|
6959 |
('=' ) |
|
6134 | 6960 |
('More' others Ctrl )). |
6961 |
||
3495 | 6962 |
main := PopUpMenu itemList:mainItems resources:resources. |
6963 |
main subMenuAt:#others put:sub. |
|
6964 |
||
6965 |
sensor := self sensor. |
|
6966 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6967 |
sensor shiftDown ifTrue:[ |
|
6241 | 6968 |
m := subSubMenu |
5826 | 6969 |
] ifFalse:[ |
6970 |
m := sub |
|
6971 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6972 |
] ifFalse:[ |
5826 | 6973 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6974 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6975 |
|
4742 | 6976 |
"/ the 'Smalltalk at:' code is here to |
6977 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6978 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 6979 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6980 |
m disable:#googleSpellingSuggestion |
|
2676 | 6981 |
]. |
4742 | 6982 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 6983 |
m disable:#internalSpellingSuggestion |
4742 | 6984 |
]. |
2676 | 6985 |
|
3811 | 6986 |
HTTPInterface isNil ifTrue:[ |
5826 | 6987 |
m disableAll:#(insertURL) |
3811 | 6988 |
]. |
6989 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6990 |
self isReadOnly ifTrue:[ |
5826 | 6991 |
m disableAll:#(accept undo again multipleAgain redo |
6134 | 6992 |
paste pasteOrReplace pasteOrReplaceBox pasteOrReplaceFromHistory |
5826 | 6993 |
cut indent autoIndent: insertMode: |
6994 |
insertFile insertFileAsStringLiteral insertURL |
|
6241 | 6995 |
babelFishTranslateMenu googleSpellingSuggestion sortMenu |
5826 | 6996 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
6228 | 6997 |
splitLinesAtCharacterOrString |
5826 | 6998 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
6241 | 6999 |
insertUnicode specialCharacters convertMenu) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7000 |
]. |
2817 | 7001 |
self hasSelectionForCopy ifFalse:[ |
5826 | 7002 |
m disable:#copySelection. |
6134 | 7003 |
m disable:#copySelectionBox. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7004 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
7005 |
self hasSelection ifFalse:[ |
6241 | 7006 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslateMenu openFileBrowserOnIt |
6359 | 7007 |
openWebBrowserOnIt |
6241 | 7008 |
openWorkspaceWithIt sortMenu indent splitLinesAtCharacterOrString inspectSelectedString |
7009 |
convertMenu). |
|
2762 | 7010 |
] ifTrue:[ |
5826 | 7011 |
(Error handle:[:ex | |
7012 |
ex return:false |
|
7013 |
] do:[ |
|
7014 |
|fn| |
|
6374 | 7015 |
fn := self selectionAsString withoutSeparators. |
7016 |
fn asFilename exists or:[ fn withoutQuotes asFilename exists ] |
|
5826 | 7017 |
]) ifFalse:[ |
7018 |
m disableAll:#(openFileBrowserOnIt). |
|
6359 | 7019 |
]. |
7020 |
(Error handle:[:ex | |
|
7021 |
ex return:false |
|
7022 |
] do:[ |
|
6374 | 7023 |
|url| |
7024 |
url := self selectionAsString withoutSeparators. |
|
7025 |
#('http' 'https' 'ftp') includes:url asURL method |
|
6359 | 7026 |
]) ifFalse:[ |
7027 |
m disableAll:#(openWebBrowserOnIt). |
|
5826 | 7028 |
] |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7029 |
]. |
2569 | 7030 |
self hasUndoAction ifFalse:[ |
5826 | 7031 |
m disable:#undo. |
3115 | 7032 |
] ifTrue:[ |
5826 | 7033 |
what := undoSupport undoActionInfo. |
7034 |
what notNil ifTrue:[ |
|
7035 |
undoIdx := m indexOf:#undo. |
|
7036 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
7037 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
7038 |
]. |
2952 | 7039 |
self hasRedoAction ifFalse:[ |
5826 | 7040 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
7041 |
] ifTrue:[ |
5826 | 7042 |
what := undoSupport redoActionInfo. |
7043 |
what notNil ifTrue:[ |
|
7044 |
redoIdx := sub indexOf:#redo. |
|
7045 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
7046 |
] |
|
2952 | 7047 |
]. |
5216 | 7048 |
self canAccept ifFalse:[ |
5826 | 7049 |
m disable:#accept |
1108 | 7050 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7051 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7052 |
|
6241 | 7053 |
"Modified: / 30-11-2017 / 15:06:03 / cg" |
6564 | 7054 |
"Modified: / 22-03-2019 / 14:29:01 / Claus Gittinger" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7055 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7056 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7057 |
getTextSelectionFromHistory |
6328 | 7058 |
"present the copyBufferHistory as a shortened list (first line of each), |
7059 |
and let user select from it. |
|
7060 |
Return the corresponding copyBuffer text or nil. |
|
7061 |
Used with 'Paste Previous' menu function" |
|
7062 |
||
7063 |
|sel listOfPasteTextLines box history| |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7064 |
|
5643 | 7065 |
history := device getCopyBufferHistory copy. |
6452 | 7066 |
|
7067 |
"/ the list presents each first line only |
|
6328 | 7068 |
listOfPasteTextLines := |
7069 |
history collect:[:entry | |
|
7070 |
|text shown| |
|
7071 |
||
7072 |
text := entry asString string asCollectionOfLines. |
|
7073 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
|
7074 |
text size > 1 ifTrue:[ |
|
7075 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
|
6152 | 7076 |
]. |
6328 | 7077 |
shown |
7078 |
]. |
|
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7079 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7080 |
box := ListSelectionBox |
6152 | 7081 |
title:(resources string:'Clipboard History') |
7082 |
okText:(resources string:'Paste') |
|
7083 |
abortText:(resources string:'Cancel') |
|
6328 | 7084 |
list:listOfPasteTextLines |
6152 | 7085 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7086 |
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
|
7087 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7088 |
box show. |
3160 | 7089 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7090 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7091 |
"Modified: / 25-08-2010 / 22:02:14 / cg" |
6328 | 7092 |
"Modified (format): / 27-05-2018 / 10:24:58 / Claus Gittinger" |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7093 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7094 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7095 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7096 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7097 |
self sensor shiftDown ifTrue:[ |
6152 | 7098 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7099 |
]. |
2724 | 7100 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7101 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7102 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7103 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7104 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7105 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7106 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7107 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7108 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7109 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7110 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7111 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7112 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7113 |
"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
|
7114 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7115 |
|
2676 | 7116 |
googleSpellingSuggestion |
7117 |
"insert the google-spelling suggestion for the selected text. |
|
7118 |
Requires that the SOAP stuff is loaded and working." |
|
7119 |
||
2677 | 7120 |
|text suggestion| |
2676 | 7121 |
|
7122 |
self withWaitCursorDo:[ |
|
6152 | 7123 |
text := self selection asString string withoutSeparators. |
7124 |
text size == 0 ifTrue:[^ self]. |
|
7125 |
||
7126 |
"/ the 'Smalltalk at:' code is here to |
|
7127 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
7128 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
7129 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
7130 |
^ self. |
|
7131 |
] do:[ |
|
7132 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
|
7133 |
]. |
|
7134 |
suggestion size == 0 ifTrue:[ |
|
7135 |
self information:('No spelling suggestion from Google for: ' , text). |
|
7136 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
7137 |
^ self. |
|
7138 |
]. |
|
5787 | 7139 |
]. |
7140 |
self |
|
6152 | 7141 |
undoablePaste:suggestion |
7142 |
info:'Spelling Suggestion'. |
|
3495 | 7143 |
|
7144 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 7145 |
! |
7146 |
||
3595 | 7147 |
insertDateAndTime |
6274 | 7148 |
"insert the current date and time string" |
3595 | 7149 |
|
7150 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7151 |
self |
6152 | 7152 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
7153 |
info:'Paste Date and Time' |
|
6274 | 7154 |
|
7155 |
"Modified (comment): / 25-01-2018 / 19:10:40 / mawalch" |
|
3595 | 7156 |
! |
7157 |
||
2676 | 7158 |
insertFile |
3160 | 7159 |
"insert contents of a file |
2676 | 7160 |
- ask user for filename using a fileSelectionBox." |
7161 |
||
3731 | 7162 |
self insertFileAsStringLiteral:false |
7163 |
! |
|
7164 |
||
7165 |
insertFileAsStringLiteral |
|
7166 |
"insert a file's contents as a string literal. |
|
7167 |
Almost the same as the insert file, but single-quotes are doubled, |
|
7168 |
to make it a legal string literal" |
|
7169 |
||
7170 |
self insertFileAsStringLiteral:true |
|
7171 |
! |
|
7172 |
||
7173 |
insertFileAsStringLiteral:asStringLiteral |
|
7174 |
"insert contents of a file; either as-is or as a string literal. |
|
7175 |
- ask user for filename using a fileSelectionBox." |
|
7176 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7177 |
|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
|
7178 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7179 |
((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
|
7180 |
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
|
7181 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7182 |
ifTrue:[ |
6152 | 7183 |
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
|
7184 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7185 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7186 |
[ |
6152 | 7187 |
|why| |
7188 |
||
7189 |
file := Dialog |
|
7190 |
requestFileName:(resources string:'Insert Contents Of:') |
|
7191 |
default:initial |
|
7192 |
ok:(resources string:'Insert') |
|
7193 |
abort:(resources string:'Cancel') |
|
7194 |
pattern:nil |
|
7195 |
fromDirectory:directoryForFileDialog. |
|
7196 |
file isNil ifTrue:[ |
|
7197 |
"cancel" |
|
7198 |
^ self. |
|
7199 |
]. |
|
7200 |
file := file asFilename. |
|
7201 |
directoryForFileDialog := file. |
|
7202 |
||
7203 |
ok := file isReadable and:[file isDirectory not]. |
|
7204 |
ok ifFalse:[ |
|
7205 |
file isReadable ifFalse:[ |
|
6543 | 7206 |
why := '"%1" is unreadable.\\Please try again.' |
6152 | 7207 |
] ifTrue:[ |
6543 | 7208 |
why := '"%1" is a directory.\\Please try again.' |
6152 | 7209 |
]. |
7210 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
7211 |
]. |
|
2909 | 7212 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7213 |
|
5063 | 7214 |
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
|
7215 |
self |
6152 | 7216 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
7217 |
info:'Paste File' |
|
3495 | 7218 |
|
7219 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6543 | 7220 |
"Modified: / 21-02-2019 / 17:42:47 / Claus Gittinger" |
3495 | 7221 |
! |
7222 |
||
3811 | 7223 |
insertURL |
7224 |
"insert contents of a URL |
|
7225 |
- ask user for URL using a dialog." |
|
7226 |
||
7227 |
self insertURLAsStringLiteral:false |
|
7228 |
! |
|
7229 |
||
7230 |
insertURLAsStringLiteral:asStringLiteral |
|
7231 |
"insert contents of a file; either as-is or as a string literal. |
|
7232 |
- ask user for filename using a fileSelectionBox." |
|
7233 |
||
7234 |
|sel url text response initial| |
|
7235 |
||
7236 |
(sel := self selectionAsString) notEmptyOrNil |
|
7237 |
ifTrue:[ |
|
6152 | 7238 |
initial := sel. |
3811 | 7239 |
]. |
7240 |
||
7241 |
url := Dialog |
|
6152 | 7242 |
request:(resources string:'Insert Contents of URL:') |
7243 |
initialAnswer:initial |
|
7244 |
okLabel:(resources string:'Insert') |
|
7245 |
title:(resources string:'URL'). |
|
3811 | 7246 |
url isNil ifTrue:[ |
6152 | 7247 |
"cancel" |
7248 |
^ self. |
|
3811 | 7249 |
]. |
6514 | 7250 |
|
7251 |
self withWaitCursorDo:[ |
|
7252 |
response := HTTPInterface get:url. |
|
7253 |
]. |
|
3811 | 7254 |
response isErrorResponse ifTrue:[ |
6152 | 7255 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
7256 |
^ self. |
|
3811 | 7257 |
]. |
7258 |
text := response data asString. |
|
7259 |
||
7260 |
self |
|
6152 | 7261 |
undoableDo:[ |
7262 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
7263 |
] |
|
7264 |
info:'Insert Contents of URL' |
|
6514 | 7265 |
|
7266 |
"Modified: / 20-12-2018 / 10:27:46 / Claus Gittinger" |
|
3811 | 7267 |
! |
7268 |
||
3495 | 7269 |
insertUUID |
7270 |
"insert a new UUID's string" |
|
7271 |
||
7272 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7273 |
self |
6152 | 7274 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
7275 |
info:'Paste New UUID' |
|
3495 | 7276 |
|
7277 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 7278 |
! |
7279 |
||
4940 | 7280 |
insertUnicode |
7281 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
7282 |
||
7283 |
|unicodePoint unicodeChar unicodeString| |
|
7284 |
||
5904 | 7285 |
unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):'). |
4940 | 7286 |
unicodeString size < 2 ifTrue:[ |
5904 | 7287 |
^ self. |
4940 | 7288 |
]. |
7289 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
5904 | 7290 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
4940 | 7291 |
] ifFalse:[ |
5904 | 7292 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
5787 | 7293 |
]. |
7294 |
||
4940 | 7295 |
unicodeChar := Character value:unicodePoint. |
7296 |
self keyPress:unicodeChar x:0 y:0. |
|
7297 |
self keyRelease:unicodeChar x:0 y:0. |
|
7298 |
! |
|
7299 |
||
5331 | 7300 |
inspectSelectedString |
7301 |
"inspect the selected text" |
|
7302 |
||
7303 |
self selectionAsString inspect. |
|
7304 |
! |
|
7305 |
||
4742 | 7306 |
internalSpellingSuggestion |
7307 |
"insert the internal-spelling suggestion for the selected text. |
|
7308 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7309 |
||
7310 |
|text suggestions best| |
|
7311 |
||
7312 |
self withWaitCursorDo:[ |
|
6152 | 7313 |
text := self selection asString string withoutSeparators. |
7314 |
text size == 0 ifTrue:[^ self]. |
|
7315 |
||
7316 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7317 |
suggestions size == 0 ifTrue:[ |
|
7318 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7319 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7320 |
^ self. |
|
7321 |
]. |
|
7322 |
Transcript showCR:suggestions. |
|
7323 |
best := suggestions first. |
|
5787 | 7324 |
]. |
7325 |
self |
|
6152 | 7326 |
undoablePaste:best |
7327 |
info:'Spelling Suggestion'. |
|
4742 | 7328 |
! |
7329 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7330 |
paste |
1289 | 7331 |
"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
|
7332 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7333 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7334 |
self checkModificationsAllowed ifTrue:[ |
6152 | 7335 |
self withSelfAndTextForPasteDo:[:me :text | |
7336 |
me unselect. |
|
7337 |
me undoablePaste:text |
|
7338 |
] |
|
2952 | 7339 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7340 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7341 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7342 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7343 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7344 |
|
3825 | 7345 |
self paste:someText withCR:false |
7346 |
! |
|
7347 |
||
7348 |
paste:someText withCR:withCR |
|
7349 |
"paste someText at cursor" |
|
7350 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7351 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7352 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7353 |
self checkModificationsAllowed ifFalse:[^ self]. |
6399 | 7354 |
someText isEmptyOrNil ifTrue:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7355 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7356 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7357 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7358 |
CharacterEncoderError handle:[:ex | |
6152 | 7359 |
|code msg| |
7360 |
||
7361 |
code := ex parameter. |
|
7362 |
codingErrorReported ifFalse:[ |
|
6399 | 7363 |
msg := 'Cannot represent pasted string in this view''s encoding (',gc characterEncoding,').'. |
6152 | 7364 |
code notNil ifTrue:[ |
7365 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7366 |
]. |
|
7367 |
Dialog warn:(resources stringWithCRs:msg). |
|
7368 |
codingErrorReported := true. |
|
7369 |
]. |
|
7370 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7371 |
] do:[ |
6152 | 7372 |
s isString ifTrue:[ |
7373 |
s encoding ~~ gc characterEncoding ifTrue:[ |
|
7374 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7375 |
]. |
|
7376 |
||
7377 |
s := s asStringCollection. |
|
7378 |
(someText endsWith:Character cr) ifTrue:[ |
|
7379 |
"/ s := s copyWith:nil. |
|
7380 |
s := s copyWith:'' "/ an empty line at the end |
|
7381 |
||
7382 |
] |
|
7383 |
] ifFalse:[ |
|
7384 |
s isStringCollection ifTrue:[ |
|
7385 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7386 |
] ifFalse:[ |
|
7387 |
(self |
|
7388 |
confirm:(resources |
|
7389 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7390 |
with:s class name)) ifFalse:[^ self]. |
|
7391 |
s := StringCollection with:s storeString . |
|
7392 |
"/ ^ self |
|
7393 |
]. |
|
7394 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7395 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7396 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7397 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7398 |
(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
|
7399 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7400 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7401 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7402 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7403 |
startCol := c1 := cursorCol. |
3180 | 7404 |
|
5787 | 7405 |
"do not autoindent here. |
7406 |
It does make things very ugly, in the inspector |
|
5194 | 7407 |
(try inspecting a multiline string)..." |
7408 |
self withAutoIndent:false do:[ |
|
6152 | 7409 |
"do not expand tabs into spaces here - |
7410 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7411 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7412 |
||
7413 |
self insertLines:s withCR:withCR. |
|
5194 | 7414 |
]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7415 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7416 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7417 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7418 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7419 |
|
4328 | 7420 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7421 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
6399 | 7422 |
"Modified: / 22-08-2018 / 08:29:13 / Claus Gittinger" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7423 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7424 |
|
3731 | 7425 |
pasteAsStringLiteral |
7426 |
"insert clipboard string as a string literal. |
|
7427 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7428 |
to make it a legal string literal" |
|
7429 |
||
7430 |
typeOfSelection := nil. |
|
7431 |
self |
|
6152 | 7432 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
7433 |
info:'Paste as String Literal' |
|
3731 | 7434 |
! |
7435 |
||
6134 | 7436 |
pasteBox |
7437 |
"paste the copybuffer as a box; |
|
7438 |
if there is a selection, unselect first. |
|
7439 |
Then paste at cursor position." |
|
7440 |
||
7441 |
self checkModificationsAllowed ifTrue:[ |
|
7442 |
self withSelfAndTextForPasteDo:[:me :text | |
|
7443 |
me unselect. |
|
7444 |
me undoablePasteBox:text |
|
7445 |
] |
|
7446 |
] |
|
7447 |
||
7448 |
"Created: / 14-03-2017 / 16:34:16 / cg" |
|
7449 |
! |
|
7450 |
||
7451 |
pasteBox:someText |
|
7452 |
"paste someText at cursor" |
|
7453 |
||
7454 |
self pasteBox:someText withCR:false |
|
7455 |
||
7456 |
"Created: / 14-03-2017 / 16:35:08 / cg" |
|
7457 |
! |
|
7458 |
||
7459 |
pasteBox:someText withCR:withCR |
|
7460 |
"paste someText at cursor" |
|
7461 |
||
7462 |
|lines nLines startLine startCol l1 l2 c1 c2| |
|
7463 |
||
7464 |
self checkModificationsAllowed ifFalse:[^ self]. |
|
7465 |
||
7466 |
lines := someText asStringCollection. |
|
7467 |
||
7468 |
(nLines := lines size) == 0 ifTrue:[^ self]. |
|
7469 |
(nLines == 1 and:[(lines at:1) size == 0]) ifTrue:[^ self]. |
|
7470 |
||
7471 |
typeOfSelection := #paste. |
|
7472 |
||
7473 |
startLine := l1 := cursorLine. |
|
7474 |
startCol := c1 := cursorCol. |
|
7475 |
||
7476 |
"do not autoindent here. |
|
7477 |
It does make things very ugly, in the inspector |
|
7478 |
(try inspecting a multiline string)..." |
|
7479 |
self withAutoIndent:false do:[ |
|
7480 |
"do not expand tabs into spaces here - |
|
7481 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7482 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7483 |
||
7484 |
lines do:[:eachLine | |
|
7485 |
self insertString:eachLine atLine:l1 col:startCol. |
|
7486 |
l1 := l1 + 1. |
|
7487 |
]. |
|
7488 |
]. |
|
7489 |
l2 := cursorLine. |
|
7490 |
c2 := (cursorCol - 1). |
|
7491 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
|
7492 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
|
7493 |
||
7494 |
"Created: / 14-03-2017 / 16:39:11 / cg" |
|
7495 |
! |
|
7496 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7497 |
pasteOrReplace |
1289 | 7498 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7499 |
otherwise paste at cursor position. |
7500 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7501 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7502 |
|
2724 | 7503 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7504 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7505 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7506 |
pasteOrReplace:someText |
1289 | 7507 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7508 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7509 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7510 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7511 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7512 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7513 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7514 |
self undoableDo:[ |
6152 | 7515 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7516 |
self replace:someText |
|
7517 |
] ifFalse:[ |
|
7518 |
self paste:someText. |
|
7519 |
] |
|
3542 | 7520 |
] info:'Paste/Replace'. |
1289 | 7521 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7522 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7523 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7524 |
|
6134 | 7525 |
pasteOrReplaceBox |
7526 |
"paste the copybuffer as a box; |
|
7527 |
if there is a selection, unselect first. |
|
7528 |
Then paste at cursor position." |
|
7529 |
||
7530 |
self pasteBox |
|
7531 |
||
7532 |
"Created: / 14-03-2017 / 16:40:08 / cg" |
|
7533 |
! |
|
7534 |
||
5387 | 7535 |
pasteOrReplaceByKeyPress |
7536 |
"paste a previous item from the copybuffer history. |
|
7537 |
(i.e. repaste some previously deleted or copied text)" |
|
7538 |
||
7539 |
|text| |
|
7540 |
||
6226 | 7541 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
7542 |
||
5387 | 7543 |
text := self getClipboardText:#clipboard. |
7544 |
text notNil ifTrue:[ |
|
6152 | 7545 |
self pasteOrReplace:text |
5387 | 7546 |
] |
6226 | 7547 |
|
7548 |
"Modified: / 11-11-2017 / 12:52:54 / cg" |
|
5387 | 7549 |
! |
7550 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7551 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7552 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7553 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7554 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7555 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7556 |
|
6226 | 7557 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
7558 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7559 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7560 |
text notNil ifTrue:[ |
6452 | 7561 |
"/ move to top of list. |
7562 |
device rememberInCopyBufferHistory:text. |
|
6152 | 7563 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7564 |
] |
6226 | 7565 |
|
7566 |
"Modified: / 11-11-2017 / 12:52:42 / cg" |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7567 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7568 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7569 |
replace |
1289 | 7570 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7571 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7572 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7573 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7574 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7575 |
self withSelfAndTextForPasteDo:[:me :text | |
6152 | 7576 |
me undoableDo:[ me replace:text ] |
7577 |
info:'Replace' |
|
2952 | 7578 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7579 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7580 |
|
121 | 7581 |
replace:someText |
1289 | 7582 |
"replace the selection by someText" |
121 | 7583 |
|
3160 | 7584 |
|selected selectedString |
7585 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7586 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7587 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7588 |
|
3130 | 7589 |
self undoableDo:[ |
6152 | 7590 |
selected := self selection. |
7591 |
selected isNil ifTrue:[ |
|
7592 |
^ self paste:someText |
|
7593 |
]. |
|
7594 |
||
7595 |
self deleteSelection. |
|
7596 |
||
7597 |
"take care, if we replace a selection without space by a word selected |
|
7598 |
with one - in this case we usually do not want the space. |
|
7599 |
But, if we replace a word-selected selection by something without a |
|
7600 |
space, we DO want the space added." |
|
7601 |
||
7602 |
selected size == 1 ifTrue:[ |
|
7603 |
selectedString := selected at:1. |
|
7604 |
]. |
|
7605 |
||
7606 |
someText size == 1 ifTrue:[ |
|
7607 |
|cutOffSpace addSpace replacement replacementString| |
|
7608 |
||
7609 |
cutOffSpace := false. |
|
7610 |
addSpace := false. |
|
7611 |
replacement := someText copyFrom:1. |
|
7612 |
||
7613 |
selectedString notNil ifTrue:[ |
|
7614 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7615 |
"selection has no space" |
|
7616 |
||
7617 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7618 |
cutOffSpace := true |
|
7619 |
] |
|
7620 |
] ifTrue:[ |
|
7621 |
addSpace := true |
|
7622 |
] |
|
7623 |
]. |
|
7624 |
replacementString := replacement at:1. |
|
7625 |
cutOffSpace ifTrue:[ |
|
7626 |
(replacementString startsWith:' ') ifTrue:[ |
|
7627 |
replacementString := replacementString withoutSpaces |
|
7628 |
]. |
|
7629 |
] ifFalse:[ |
|
7630 |
selectStyle == #wordLeft ifTrue:[ |
|
7631 |
"want a space at left" |
|
7632 |
(replacementString startsWith:' ') ifFalse:[ |
|
7633 |
replacementString := replacementString withoutSpaces. |
|
7634 |
replacementString := ' ' , replacementString |
|
7635 |
] |
|
7636 |
]. |
|
7637 |
selectStyle == #wordRight ifTrue:[ |
|
7638 |
"want a space at right" |
|
7639 |
||
7640 |
(replacementString endsWith:' ') ifFalse:[ |
|
7641 |
replacementString := replacementString withoutSpaces. |
|
7642 |
replacementString := replacementString , ' ' |
|
7643 |
] |
|
7644 |
]. |
|
7645 |
]. |
|
7646 |
replacement at:1 put: replacementString. |
|
7647 |
self paste:replacement. |
|
7648 |
] ifFalse:[ |
|
7649 |
self paste:someText |
|
7650 |
]. |
|
7651 |
self setLastStringToReplace: selectedString. |
|
7652 |
||
7653 |
lastReplacementInfo lastReplacement: someText. |
|
7654 |
||
7655 |
selStartLine := selectionStartLine. |
|
7656 |
selStartCol := self selectionStartCol. |
|
7657 |
selEndLine := selectionEndLine. |
|
7658 |
selEndCol := self selectionEndCol. |
|
3130 | 7659 |
] |
3542 | 7660 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7661 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7662 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7663 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7664 |
! |
7665 |
||
3430 | 7666 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7667 |
"search for a string - show a box to enter searchpattern |
3430 | 7668 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7669 |
- 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
|
7670 |
|
3430 | 7671 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7672 |
||
7673 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7674 |
lastSearchDirection := #forward. |
|
7675 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7676 |
caseHolder := ValueHolder with:ign. |
7677 |
patternHolder := ValueHolder with:''. |
|
7678 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7679 |
lastSearchPattern notNil ifTrue:[ |
6152 | 7680 |
initialString := lastSearchPattern |
3430 | 7681 |
]. |
7682 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
6152 | 7683 |
initialString := self selectionAsString |
3430 | 7684 |
]. |
7685 |
initialString isNil ifTrue:[ |
|
6548 | 7686 |
LastSearchPatterns size ~~ 0 ifTrue:[ |
6152 | 7687 |
initialString := LastSearchPatterns first |
7688 |
] |
|
3430 | 7689 |
]. |
7690 |
initialString notNil ifTrue:[ |
|
6152 | 7691 |
patternHolder value:initialString. |
7692 |
replacePatternHolder value:initialString. |
|
3430 | 7693 |
]. |
7694 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7695 |
search := [:fwd | |
6152 | 7696 |
self |
7697 |
search:patternHolder value |
|
7698 |
ignoreCase:caseHolder value |
|
7699 |
forward:fwd. |
|
7700 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7701 |
replace := [:all | |
6152 | 7702 |
self |
7703 |
replace:patternHolder value |
|
7704 |
by:replacePatternHolder value |
|
7705 |
all:all |
|
7706 |
ignoreCase:caseHolder value |
|
7707 |
]. |
|
3430 | 7708 |
bindings := IdentityDictionary new. |
7709 |
bindings at:#searchPattern put:patternHolder. |
|
7710 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7711 |
modal ifTrue:[ |
|
6152 | 7712 |
bindings at:#nextAction |
7713 |
put:[ |
|
7714 |
flag := true. |
|
7715 |
action := search. |
|
7716 |
searchBox doAccept. |
|
7717 |
]. |
|
7718 |
bindings at:#prevAction |
|
7719 |
put:[ |
|
7720 |
flag := false. |
|
7721 |
action := search. |
|
7722 |
searchBox doAccept. |
|
7723 |
]. |
|
7724 |
bindings at:#replaceAction |
|
7725 |
put:[ |
|
7726 |
flag := false. |
|
7727 |
action := replace. |
|
7728 |
searchBox doAccept. |
|
7729 |
]. |
|
7730 |
bindings at:#replaceAllAction |
|
7731 |
put:[ |
|
7732 |
flag := true. |
|
7733 |
action := replace. |
|
7734 |
searchBox doAccept. |
|
7735 |
]. |
|
3430 | 7736 |
] ifFalse:[ |
6152 | 7737 |
bindings at:#nextAction put:[ search value:true. ]. |
7738 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7739 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7740 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7741 |
]. |
7742 |
bindings at:#ignoreCase put:caseHolder. |
|
7743 |
bindings at:#patternList put:LastSearchPatterns. |
|
7744 |
modal ifTrue:[ |
|
6152 | 7745 |
searchBox := SimpleDialog new. |
3430 | 7746 |
] ifFalse:[ |
6152 | 7747 |
searchBox := ApplicationModel new. |
7748 |
searchBox createBuilder. |
|
3430 | 7749 |
]. |
7750 |
searchBox resources:(self resources). |
|
7751 |
bldr := searchBox builder. |
|
7752 |
bldr addBindings:bindings. |
|
7753 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7754 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7755 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7756 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7757 |
modal ifTrue:[ |
|
6152 | 7758 |
searchBox openDialog. |
7759 |
searchBox accepted ifTrue:[ |
|
7760 |
action value:flag |
|
7761 |
]. |
|
3430 | 7762 |
] ifFalse:[ |
6152 | 7763 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7764 |
(bldr componentAt:#cancelButton) |
|
7765 |
label:(resources string:'Close'); |
|
7766 |
action:[ searchBox closeRequest ]. |
|
7767 |
||
7768 |
"/ searchBox masterApplication:self application. |
|
7769 |
||
7770 |
self topView beMaster. |
|
7771 |
(searchBox window) |
|
7772 |
beSlave; |
|
7773 |
openInGroup:(self windowGroup). |
|
7774 |
||
7775 |
"/ searchBox window open. |
|
7776 |
||
7777 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
|
3430 | 7778 |
] |
7779 |
||
7780 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
6548 | 7781 |
"Modified: / 01-03-2019 / 14:55:01 / Claus Gittinger" |
3430 | 7782 |
! |
7783 |
||
6241 | 7784 |
selectionDecodeBase64 |
7785 |
self paste:(Base64Coder decode:self selectionAsString) asString |
|
7786 |
||
7787 |
"Created: / 30-11-2017 / 15:07:31 / cg" |
|
7788 |
! |
|
7789 |
||
7790 |
selectionEncodeBase64 |
|
7791 |
self paste:(Base64Coder encode:self selectionAsString) |
|
7792 |
||
7793 |
"Created: / 30-11-2017 / 15:07:34 / cg" |
|
7794 |
! |
|
7795 |
||
7796 |
selectionRot13 |
|
7797 |
"a naive caesar cypher" |
|
7798 |
||
7799 |
self paste:(self selectionAsString rot13) |
|
7800 |
||
7801 |
"Created: / 30-11-2017 / 15:07:50 / cg" |
|
7802 |
! |
|
7803 |
||
121 | 7804 |
showDeleted |
7805 |
"open a readonly editor on all deleted text" |
|
7806 |
||
7807 |
|v| |
|
7808 |
||
7809 |
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
|
7810 |
v readOnly:true. |
121 | 7811 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7812 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7813 |
|
3221 | 7814 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7815 |
"sort/reorder the selected lines. |
7816 |
how: |
|
6152 | 7817 |
#lines |
7818 |
#linesByFirstWord |
|
7819 |
#linesByNthWord |
|
7820 |
#linesByNthNumber |
|
7821 |
#linesByNthHexNumber |
|
7822 |
#words |
|
7823 |
#linesByLength |
|
7824 |
#reverse |
|
4763 | 7825 |
" |
7826 |
||
7827 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7828 |
|
7829 |
lineWise := true. |
|
7830 |
||
4763 | 7831 |
how == #reverse ifTrue:[ |
6152 | 7832 |
operation := [:lines | lines reverse]. |
4763 | 7833 |
] ifFalse:[ |
6152 | 7834 |
operation := [:linesOrWords | |
7835 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7836 |
]. |
|
7837 |
||
7838 |
how == #linesByLength ifTrue:[ |
|
7839 |
fetcher := [:l | l size]. |
|
7840 |
] ifFalse:[ |
|
7841 |
how == #lines ifTrue:[ |
|
7842 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7843 |
] ifFalse:[ |
|
7844 |
how == #linesByFirstWord ifTrue:[ |
|
7845 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7846 |
] ifFalse:[ |
|
7847 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7848 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7849 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7850 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7851 |
LastColumnNumberForSort := n. |
|
7852 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7853 |
how == #linesByNthNumber ifTrue:[ |
|
7854 |
innerExtractor := extractor. |
|
7855 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7856 |
] ifFalse:[ |
|
7857 |
how == #linesByNthHexNumber ifTrue:[ |
|
7858 |
innerExtractor := extractor. |
|
7859 |
extractor := [:l | |
|
7860 |
|s| |
|
7861 |
s := innerExtractor value:l. |
|
7862 |
(s startsWith:'16r') ifTrue:[ |
|
7863 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7864 |
] ifFalse:[ |
|
7865 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7866 |
] |
|
7867 |
] |
|
7868 |
] |
|
7869 |
]. |
|
7870 |
] ifFalse:[ |
|
7871 |
how == #words ifTrue:[ |
|
7872 |
lineWise := false. |
|
7873 |
extractor := [:w | w]. |
|
7874 |
] ifFalse:[ |
|
7875 |
self error:'unknown sort criteria: ', how printString. |
|
7876 |
] |
|
7877 |
] |
|
7878 |
] |
|
7879 |
]. |
|
7880 |
ignoreCase ifTrue:[ |
|
7881 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7882 |
] ifFalse:[ |
|
7883 |
fetcher := extractor. |
|
7884 |
]. |
|
7885 |
]. |
|
3221 | 7886 |
]. |
7887 |
||
7888 |
lineWise ifTrue:[ |
|
6152 | 7889 |
"process the lines of the selection (aka a collection of lines)" |
7890 |
start == end ifTrue:[^ self ]. |
|
7891 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
7892 |
lines := operation value:lines. |
|
7893 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
4763 | 7894 |
] ifFalse:[ |
6152 | 7895 |
"process the whole selection as a string" |
7896 |
s := self selectionAsString. |
|
7897 |
words := s asCollectionOfWords. |
|
7898 |
words := operation value:words. |
|
7899 |
s := words asStringCollection asStringWith:Character space. |
|
7900 |
self replace:s. |
|
4763 | 7901 |
]. |
3221 | 7902 |
self textChanged. |
4373 | 7903 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7904 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7905 |
! |
7906 |
||
7907 |
sortSelection:how ignoreCase:ignoreCase |
|
7908 |
"sort the selected lines" |
|
7909 |
||
7910 |
|start end| |
|
7911 |
||
7912 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7913 |
||
7914 |
start := selectionStartLine. |
|
7915 |
end := selectionEndLine. |
|
7916 |
(selectionEndCol == 0) ifTrue:[ |
|
6152 | 7917 |
end := end - 1 |
3221 | 7918 |
]. |
7919 |
||
7920 |
self |
|
6152 | 7921 |
undoableDo:[ |
7922 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7923 |
] |
|
7924 |
info:'Sort' |
|
4373 | 7925 |
|
7926 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7927 |
! |
7928 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7929 |
specialCharacters |
6517 | 7930 |
"open the special characters input window" |
7931 |
||
7932 |
"CharacterInputViewSingleton := nil" |
|
7933 |
||
7934 |
(CharacterInputViewSingleton notNil and:[CharacterInputViewSingleton isOpen]) ifTrue:[ |
|
7935 |
CharacterInputViewSingleton consumingView:self. |
|
7936 |
CharacterInputViewSingleton topView raiseDeiconified. |
|
7937 |
] ifFalse:[ |
|
7938 |
CharacterInputViewSingleton := |
|
7939 |
CharacterSetView |
|
7940 |
openAsInputFor:self |
|
7941 |
label:(resources string:'Special Character Input') |
|
7942 |
clickLabel:(resources string:'Click to Insert Character'). |
|
7943 |
]. |
|
7944 |
||
7945 |
"Modified (comment): / 08-01-2019 / 18:24:13 / Claus Gittinger" |
|
2866 | 7946 |
! |
7947 |
||
5370 | 7948 |
splitLinesAtCharacterOrString |
7949 |
"ask user for the character and split after it" |
|
7950 |
||
7951 |
|sel in out separator record| |
|
7952 |
||
7953 |
selectionStartLine isNil ifTrue:[^ self]. |
|
6227 | 7954 |
self checkModificationsAllowed ifFalse:[^ self]. |
5370 | 7955 |
|
7956 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7957 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7958 |
||
7959 |
sel := self selectionAsString. |
|
7960 |
in := sel readStream. |
|
5887 | 7961 |
out := CharacterWriteStream on:''. |
5370 | 7962 |
[in atEnd] whileFalse:[ |
5887 | 7963 |
record := in throughAll:separator. |
7964 |
out nextPutLine:record. |
|
5370 | 7965 |
]. |
7966 |
self |
|
5887 | 7967 |
undoableDo:[ |
7968 |
self replaceSelectionBy:(out contents). |
|
7969 |
] |
|
7970 |
info:'Split Selection' |
|
6227 | 7971 |
|
7972 |
"Modified: / 15-11-2017 / 11:56:45 / cg" |
|
5370 | 7973 |
! |
7974 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7975 |
undoablePaste:someText |
3495 | 7976 |
self undoablePaste:someText info:nil. |
7977 |
||
7978 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7979 |
! |
|
7980 |
||
7981 |
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
|
7982 |
self |
6152 | 7983 |
undoableDo:[ |
7984 |
self paste:someText. |
|
7985 |
] |
|
7986 |
info:infoOrNil |
|
3495 | 7987 |
|
7988 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7989 |
! |
|
7990 |
||
6134 | 7991 |
undoablePasteBox:someText |
7992 |
self undoablePasteBox:someText info:nil. |
|
7993 |
||
7994 |
"Created: / 14-03-2017 / 16:34:31 / cg" |
|
7995 |
! |
|
7996 |
||
7997 |
undoablePasteBox:someText info:infoOrNil |
|
7998 |
self |
|
7999 |
undoableDo:[ |
|
8000 |
self pasteBox:someText. |
|
8001 |
] |
|
8002 |
info:infoOrNil |
|
8003 |
||
8004 |
"Created: / 14-03-2017 / 16:34:55 / cg" |
|
8005 |
! |
|
8006 |
||
3495 | 8007 |
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
|
8008 |
self |
6152 | 8009 |
undoableDo:[ |
8010 |
self pasteOrReplace:someText. |
|
8011 |
] |
|
8012 |
info:infoOrNil |
|
3495 | 8013 |
|
8014 |
"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
|
8015 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8016 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8017 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8018 |
self |
6152 | 8019 |
undoableDo:[ |
8020 |
self selectAll. |
|
8021 |
self pasteOrReplace:someText. |
|
8022 |
] |
|
8023 |
info:infoOrNil |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8024 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8025 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8026 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8027 |
|
2724 | 8028 |
withSelfAndTextForPasteDo:aBlock |
8029 |
"common code for paste/replace of the copybuffer" |
|
8030 |
||
8031 |
|sel| |
|
8032 |
||
6226 | 8033 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
2724 | 8034 |
|
8035 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
8036 |
sel notNil ifTrue:[ |
|
6152 | 8037 |
aBlock value:self value:sel. |
2724 | 8038 |
] |
6226 | 8039 |
|
8040 |
"Modified: / 11-11-2017 / 12:52:31 / cg" |
|
6477
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8041 |
! |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8042 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8043 |
withSelfAndTextForPasteFromHistoryDo:aBlock |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8044 |
"common code for paste/replace from the copyBuffer history" |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8045 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8046 |
|sel| |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8047 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8048 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8049 |
sel := self getTextSelectionFromHistory. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8050 |
sel notNil ifTrue:[ |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8051 |
aBlock value:self value:sel. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8052 |
] |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8053 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8054 |
"Modified: / 11-11-2017 / 12:52:31 / cg" |
105 | 8055 |
! ! |
8056 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8057 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8058 |
|
3880 | 8059 |
beep |
5244 | 8060 |
"output an audible beep or bell on my screen device" |
8061 |
||
6262 | 8062 |
super beepInEditor |
3880 | 8063 |
! |
8064 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8065 |
checkModificationsAllowed |
6226 | 8066 |
"check if the text can be modified (i.e. is not readOnly), return true or false. |
8067 |
If not, and an exceptionBlock has been defined, evaluate it. |
|
8068 |
The exceptionBlock can be provided by the application or user of the textView, |
|
8069 |
and may show a warnBox or whatever, or ask again. |
|
8070 |
It can return true to allow the modification" |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8071 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8072 |
self isReadOnly ifTrue: [ |
6152 | 8073 |
exceptionBlock isNil ifTrue:[ |
8074 |
^ false |
|
8075 |
]. |
|
8076 |
||
8077 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
8078 |
^ false |
|
8079 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8080 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8081 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8082 |
|
6226 | 8083 |
"Modified: / 17-06-1998 / 15:51:10 / cg" |
8084 |
"Modified (comment): / 11-11-2017 / 12:49:29 / cg" |
|
8085 |
! |
|
8086 |
||
8087 |
checkModificationsAllowedFlashIfNot:doFlashIfNot |
|
8088 |
"check if the text can be modified (i.e. is not readOnly), return true or false. |
|
8089 |
If not, and an exceptionBlock has been defined, evaluate it. |
|
8090 |
The exceptionBlock can be provided by the application or user of the textView, |
|
8091 |
and may show a warnBox or whatever, or ask again. |
|
8092 |
It can return true to allow the modification. |
|
8093 |
If either no exceptionBlock was defined or it returned false, |
|
8094 |
and doFlashIfNot is true then flash the view to tell the user." |
|
8095 |
||
8096 |
self isReadOnly ifTrue: [ |
|
8097 |
(exceptionBlock isNil |
|
8098 |
or:[(exceptionBlock value:'Text may not be modified') ~~ true]) ifTrue:[ |
|
8099 |
doFlashIfNot ifTrue:[ |
|
8100 |
self flashReadOnly |
|
8101 |
]. |
|
8102 |
^ false |
|
8103 |
]. |
|
8104 |
]. |
|
8105 |
^ true |
|
8106 |
||
8107 |
"Created: / 11-11-2017 / 12:52:00 / cg" |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8108 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8109 |
|
2596 | 8110 |
currentSelectionBgColor |
8111 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 8112 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
5787 | 8113 |
]. |
8114 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
|
2596 | 8115 |
^ super currentSelectionBgColor |
8116 |
||
8117 |
" |
|
8118 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
8119 |
" |
|
8120 |
! |
|
8121 |
||
8122 |
currentSelectionFgColor |
|
8123 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 8124 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 8125 |
]. |
8126 |
^ super currentSelectionFgColor |
|
8127 |
! |
|
8128 |
||
3996 | 8129 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8130 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 8131 |
|
8132 |
super resetVariablesBeforeNewSearch. |
|
8133 |
||
8134 |
"/ new search invalidates remembered string |
|
4048 | 8135 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8136 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8137 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 8138 |
! |
8139 |
||
4053 | 8140 |
setLastStringToReplace: aString |
8141 |
||
8142 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
8143 |
||
8144 |
|lastReplaceIgnoredCase| |
|
8145 |
||
4064 | 8146 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
8147 |
self clearSearchAction. |
|
8148 |
||
4053 | 8149 |
lastReplacementInfo lastStringToReplace: aString. |
8150 |
lastStringFromReplaceForNextSearch := aString. |
|
8151 |
||
8152 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
5787 | 8153 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
6152 | 8154 |
ifTrue: [lastSearchIgnoredCase] |
8155 |
ifFalse: [nil]. |
|
4053 | 8156 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
8157 |
! |
|
8158 |
||
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8159 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8160 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8161 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8162 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8163 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8164 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8165 |
textChanged |
522 | 8166 |
"my text was modified (internally). |
8167 |
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
|
8168 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 8169 |
is used to notify scrollers, other views etc.). |
8170 |
||
5979 | 8171 |
As some authors of this code have been very sloppy in the past |
4635 | 8172 |
(not sending contentsChanged, but textChanged), |
8173 |
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
|
8174 |
|
641 | 8175 |
self contentsChanged. |
1015 | 8176 |
self modified:true. |
5774 | 8177 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8178 |
contentsWasSaved := false |
641 | 8179 |
|
1015 | 8180 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 8181 |
! |
8182 |
||
2617 | 8183 |
textChangedButNoSizeChange |
2207 | 8184 |
"my text was modified (internally). |
8185 |
Sent whenever text has been edited (not to confuse with |
|
8186 |
contentsChanged, which is triggered when the size has changed, and |
|
8187 |
is used to notify scrollers, other views etc.)" |
|
8188 |
||
8189 |
self modified:true. |
|
8190 |
contentsWasSaved := false |
|
8191 |
||
8192 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8193 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8194 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8195 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8196 |
|
5216 | 8197 |
canAccept |
8198 |
"true if text can be accepts. |
|
8199 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8200 |
||
8201 |
^ acceptEnabled ~~ false |
|
8202 |
! |
|
8203 |
||
8204 |
canCut |
|
8205 |
"true if there is a selection possibly to be cut. |
|
8206 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8207 |
||
8208 |
self isReadOnly ifTrue:[ ^ false ]. |
|
8209 |
^ self hasSelection |
|
8210 |
! |
|
8211 |
||
8212 |
canDoAgain |
|
8213 |
"true if there is a possible repeat last edit operation. |
|
8214 |
Used to disable the menu if there is nothing" |
|
8215 |
||
8216 |
self isReadOnly ifTrue:[ ^ false ]. |
|
5972 | 8217 |
^ lastReplacementInfo lastStringToReplace notNil |
8218 |
||
8219 |
"Modified: / 19-11-2016 / 20:19:02 / cg" |
|
5216 | 8220 |
! |
8221 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8222 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8223 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8224 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8225 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8226 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8227 |
"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
|
8228 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8229 |
|
4064 | 8230 |
hasSearchActionSelection |
8231 |
||
8232 |
^ typeOfSelection == #searchAction |
|
8233 |
! |
|
8234 |
||
1878 | 8235 |
isKeyboardConsumer |
8236 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 8237 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 8238 |
|
3476 | 8239 |
^ self isReadOnly not |
1878 | 8240 |
! |
8241 |
||
997 | 8242 |
specClass |
1390 | 8243 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
8244 |
||
997 | 8245 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 8246 |
^ super specClass |
8247 |
||
1390 | 8248 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 8249 |
! |
8250 |
||
324 | 8251 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
8252 |
"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
|
8253 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8254 |
"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
|
8255 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8256 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 8257 |
|
8258 |
"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
|
8259 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8260 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8261 |
widthOfContents |
6230 | 8262 |
"return the width of the contents in pixels. |
8263 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8264 |
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
|
8265 |
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
|
8266 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8267 |
|
697 | 8268 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8269 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8270 |
w := super widthOfContents. |
5643 | 8271 |
(dev := device ) isNil ifTrue:[ |
6152 | 8272 |
"/ really don't know ... |
8273 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
8274 |
]. |
6230 | 8275 |
"/ add width of a space (so cursor is always seen) |
4889 | 8276 |
^ w + (gc font widthOn:dev) |
697 | 8277 |
|
6230 | 8278 |
"Modified: / 28-05-1996 / 19:32:25 / cg" |
8279 |
"Modified (comment): / 19-11-2017 / 14:05:16 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8280 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8281 |
|
1588 | 8282 |
!EditTextView methodsFor:'realization'! |
8283 |
||
8284 |
realize |
|
8285 |
"make the view visible - scroll to make the cursor visible." |
|
8286 |
||
8287 |
super realize. |
|
8288 |
||
8289 |
self makeCursorVisible. |
|
5643 | 8290 |
cursorFgColor := cursorFgColor onDevice:device. |
8291 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 8292 |
|
8293 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
8294 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
8295 |
! ! |
|
8296 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8297 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8298 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8299 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8300 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8301 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8302 |
cursorShown ifTrue:[ |
6152 | 8303 |
cursorVisibleLine notNil ifTrue:[ |
8304 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
8305 |
self drawCursorCharacter |
|
8306 |
] |
|
8307 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8308 |
] |
105 | 8309 |
! |
8310 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8311 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8312 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8313 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8314 |
cursorShown ifTrue:[ |
6152 | 8315 |
(visLine == cursorVisibleLine) ifTrue:[ |
8316 |
self drawCursorCharacter |
|
8317 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8318 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8319 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8320 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8321 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8322 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8323 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8324 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8325 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8326 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8327 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8328 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8329 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8330 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8331 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8332 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8333 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8334 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8335 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8336 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8337 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8338 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8339 |
cursorShown ifTrue:[ |
6152 | 8340 |
(visLine == cursorVisibleLine) ifTrue:[ |
8341 |
(colNr == cursorCol) ifTrue:[ |
|
8342 |
self drawCursorCharacter. |
|
8343 |
^ self |
|
8344 |
] |
|
8345 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8346 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8347 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8348 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8349 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8350 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8351 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8352 |
"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
|
8353 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8354 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 8355 |
cursorShown ifTrue:[ |
6152 | 8356 |
self redrawCursorIfInVisibleLine:visLine |
4494 | 8357 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8358 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8359 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8360 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8361 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8362 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8363 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8364 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8365 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8366 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8367 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8368 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8369 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8370 |
"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
|
8371 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8372 |
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
|
8373 |
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
|
8374 |
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
|
8375 |
|
4889 | 8376 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8377 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8378 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8379 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8380 |
"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
|
8381 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8383 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8384 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8385 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8386 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8387 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8388 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8389 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8390 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8391 |
"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
|
8392 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8393 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8394 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8395 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8396 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8397 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8398 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8399 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8400 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8401 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8402 |
"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
|
8403 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8404 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8405 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8406 |
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
|
8407 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
8408 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8409 |
prevCursorState ifTrue:[ |
6152 | 8410 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8411 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8412 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8413 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8414 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8415 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8416 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8417 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8418 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8419 |
prevCursorState := cursorShown. |
1601 | 8420 |
"/ cursorShown := false. |
1591 | 8421 |
cursorShown ifTrue:[ |
6152 | 8422 |
self hideCursor |
1591 | 8423 |
] |
8424 |
||
1601 | 8425 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8426 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8427 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8428 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8429 |
"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
|
8430 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8431 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8432 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8433 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8434 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8435 |
super pageDown. |
6184 | 8436 |
prevCursorLine notNil ifTrue:[ |
8437 |
"https://expeccoalm.exept.de/D204551" |
|
8438 |
self cursorVisibleLine:prevCursorLine col:cursorCol. |
|
8439 |
]. |
|
8440 |
||
8441 |
"Modified: / 18-07-2017 / 12:31:47 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8442 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8443 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8444 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8445 |
"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
|
8446 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8447 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8448 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8449 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8450 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8451 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8452 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8453 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8454 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8455 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8456 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8457 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8458 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8459 |
|
2822 | 8460 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8461 |
! |
8462 |
||
8463 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8464 |
"do a backward search" |
|
8465 |
||
8466 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8467 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8468 |
! |
8469 |
||
8470 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8471 |
"do a backward search" |
|
8472 |
||
8473 |
cursorLine isNil ifTrue:[^ self]. |
|
8474 |
||
3160 | 8475 |
self |
6152 | 8476 |
searchBackwardFor:pattern |
8477 |
ignoreCase:ign |
|
8478 |
startingAtLine:startLine col:startCol |
|
8479 |
ifFound:[:line :col :endColOrNil | |
|
8480 |
self cursorMovementAllowed ifTrue:[ |
|
8481 |
self cursorLine:line col:col. |
|
8482 |
]. |
|
8483 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
|
1339 | 8484 |
"/ self makeLineVisible:cursorLine |
6152 | 8485 |
typeOfSelection := #search] |
8486 |
ifAbsent:aBlock |
|
1339 | 8487 |
|
8488 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8489 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8490 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8491 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8492 |
"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
|
8493 |
|
2554 | 8494 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8495 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8496 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8497 |
searchForMatchingParenthesis |
3160 | 8498 |
"search for a matching parenthesis starting at cursor position. |
6096 | 8499 |
Search for the corresponding character is done forward if it's an opening, |
8500 |
backwards if it's a closing parenthesis. |
|
8501 |
Positions the cursor if found, beeps if not" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8502 |
|
2822 | 8503 |
self cursorMovementAllowed ifFalse:[^ self]. |
8504 |
||
3160 | 8505 |
self |
6096 | 8506 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8507 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8508 |
ifNotFound:[self showNotFound] |
|
6262 | 8509 |
onError:[self beepInEditor] |
6096 | 8510 |
|
8511 |
"Modified: / 09-10-1997 / 12:56:30 / cg" |
|
8512 |
"Modified (comment): / 13-02-2017 / 20:10:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8513 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8514 |
|
3967 | 8515 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8516 |
"do a forward search" |
8517 |
||
8518 |
cursorLine isNil ifTrue:[^ self]. |
|
5787 | 8519 |
self |
6152 | 8520 |
searchForwardFor:pattern |
8521 |
ignoreCase:ign |
|
8522 |
match: match |
|
8523 |
startingAtLine:startLine col:startCol |
|
8524 |
ifFound:[:line :col :endColOrNil| |
|
8525 |
self cursorMovementAllowed ifTrue:[ |
|
8526 |
self cursorLine:line col:col. |
|
8527 |
]. |
|
8528 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
|
1339 | 8529 |
"/ self makeLineVisible:cursorLine |
6152 | 8530 |
typeOfSelection := #search |
8531 |
] |
|
8532 |
ifAbsent:aBlock |
|
1339 | 8533 |
|
8534 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8535 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8536 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8537 |
|
3967 | 8538 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8539 |
"do a forward search" |
|
8540 |
||
8541 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8542 |
! |
|
8543 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8544 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8545 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8546 |
|
2822 | 8547 |
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
|
8548 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8549 |
|
3982 | 8550 |
searchPatternForSearchBar |
8551 |
||
8552 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8553 |
||
8554 |
|searchPattern| |
|
8555 |
||
4138 | 8556 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
5787 | 8557 |
searchPattern isNil |
6152 | 8558 |
ifTrue: [searchPattern := lastSearchPattern] |
8559 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
3982 | 8560 |
^ searchPattern |
8561 |
! |
|
8562 |
||
3578 | 8563 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8564 |
"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
|
8565 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8566 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8567 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8568 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8569 |
"/ |
3967 | 8570 |
"/ 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
|
8571 |
"/ original string (for search after again) |
4121 | 8572 |
"/ 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
|
8573 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8574 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8575 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8576 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8577 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8578 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8579 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8580 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8581 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8582 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8583 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8584 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8585 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8586 |
"/ 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
|
8587 |
"/ if there was a previous search, only take the selection if |
3967 | 8588 |
"/ 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
|
8589 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8590 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8591 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8592 |
sel notNil ifTrue:[ |
6152 | 8593 |
(lastSearchPattern isNil |
8594 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
|
8595 |
) ifTrue:[ |
|
8596 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8597 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8598 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8599 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8600 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8601 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8602 |
"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
|
8603 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8604 |
|
5717 | 8605 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8606 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8607 |
typeOfSelection := #search. |
8608 |
! |
|
8609 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8610 |
startPositionForSearchBackward |
2822 | 8611 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8612 |
! |
|
8613 |
||
8614 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8615 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8616 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8617 |
selectionStartLine notNil ifTrue:[ |
6152 | 8618 |
startLine := selectionStartLine. |
8619 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8620 |
] ifFalse:[ |
6152 | 8621 |
cursorLine isNil ifTrue:[ |
8622 |
startLine := list size. |
|
8623 |
startCol := self listAt:startLine size. |
|
8624 |
] ifFalse:[ |
|
8625 |
startLine := cursorLine min:list size. |
|
8626 |
startCol := cursorCol |
|
8627 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8628 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8629 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8630 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8631 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8632 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8633 |
startPositionForSearchForward |
2822 | 8634 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8635 |
! |
|
8636 |
||
8637 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8638 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8639 |
|
3160 | 8640 |
"/ 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
|
8641 |
"/ 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
|
8642 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8643 |
self hasSelection ifTrue:[ |
6152 | 8644 |
^ selectionEndCol @ selectionEndLine. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8645 |
] ifFalse:[ |
6152 | 8646 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8647 |
startCol := 0 |
|
8648 |
]. |
|
8649 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8650 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8651 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8652 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8653 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8654 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8655 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8656 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8657 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8658 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8659 |
addToSelectionAfter:aBlock |
5145 | 8660 |
<resource: #obsolete> |
8661 |
||
8662 |
"evaluate aBlock while unselected. |
|
8663 |
Restore the previous selection afterwards. |
|
8664 |
CG: I am not sure, if this is a leftover and is still used at all. |
|
6152 | 8665 |
It is therefore temporarily marked as obsolete. Please check |
8666 |
and let me know." |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8667 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8668 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8669 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8670 |
self hasSelection ifTrue: [ |
6152 | 8671 |
startLine := selectionStartLine . |
8672 |
startCol := selectionStartCol . |
|
8673 |
endLine := selectionEndLine . |
|
8674 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8675 |
] ifFalse: [ |
6152 | 8676 |
startLine := endLine := cursorLine . |
8677 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8678 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8679 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8680 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8681 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8682 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8683 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8684 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8685 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
6152 | 8686 |
ifTrue: [ |
8687 |
startCol := cursorCol. |
|
8688 |
] ifFalse: [ |
|
8689 |
endCol := cursorCol - 1. |
|
8690 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8691 |
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
|
8692 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8693 |
|
1850 | 8694 |
autoMoveCursorToEndOfSelection |
8695 |
"return true, if the cursor should be automatically moved to the |
|
8696 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8697 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8698 |
not be affected by selecting" |
8699 |
||
8700 |
^ true |
|
8701 |
! |
|
8702 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8703 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8704 |
typeOfSelection ~~ newType ifTrue:[ |
6152 | 8705 |
typeOfSelection := newType. |
8706 |
selectionStartLine notNil ifTrue:[ |
|
8707 |
self |
|
8708 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8709 |
toLine:selectionEndLine col:selectionEndCol |
|
8710 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8711 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8712 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8713 |
|
4707 | 8714 |
findNextWordAfterSelectionAndAddToSelection |
8715 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8716 |
||
8717 |
selectionStartCol isNil ifTrue:[ |
|
6152 | 8718 |
self selectWordUnderCursor. |
8719 |
^ self |
|
4707 | 8720 |
]. |
8721 |
||
8722 |
selStartCol := selectionStartCol. |
|
8723 |
selEndCol := selectionEndCol. |
|
8724 |
selStartLine := selectionStartLine. |
|
8725 |
selEndLine := selectionEndLine. |
|
8726 |
||
8727 |
self cursorToNextWord. |
|
8728 |
self selectWordUnderCursor. |
|
8729 |
||
8730 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8731 |
! |
|
8732 |
||
4138 | 8733 |
searchPatternFromUserSelectionOrReplace |
8734 |
||
8735 |
|sel searchPattern| |
|
8736 |
||
8737 |
"/ |
|
8738 |
"/ if the last operation was a replace, set pattern to last |
|
8739 |
"/ original string (for search after again) |
|
8740 |
"/ |
|
8741 |
(lastStringFromReplaceForNextSearch notNil |
|
8742 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
6152 | 8743 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
8744 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8745 |
] ifFalse:[ |
|
8746 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8747 |
]. |
|
8748 |
^ searchPattern |
|
4138 | 8749 |
]. |
8750 |
||
8751 |
"/ |
|
8752 |
"/ if there is a selection: |
|
8753 |
"/ if there was no previous search, take it as search pattern. |
|
8754 |
"/ if there was a previous search, only take the selection if |
|
8755 |
"/ it did not result from a paste. |
|
8756 |
"/ (to allow search-paste to be repeated) |
|
8757 |
"/ |
|
8758 |
sel := self selection. |
|
8759 |
sel notNil ifTrue:[ |
|
6152 | 8760 |
typeOfSelection ~~ #search ifTrue:[ |
8761 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8762 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8763 |
searchPattern := sel asStringWithoutFinalCR. |
|
8764 |
] |
|
8765 |
]. |
|
4138 | 8766 |
]. |
8767 |
||
8768 |
^ searchPattern |
|
8769 |
! |
|
8770 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8771 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8772 |
"select the whole text. |
5593 | 8773 |
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
|
8774 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8775 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8776 |
list isNil ifTrue:[ |
6152 | 8777 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8778 |
] ifFalse:[ |
6152 | 8779 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8780 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8781 |
] |
1082 | 8782 |
|
8783 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8784 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8785 |
|
4117 | 8786 |
selectAllInitially |
8787 |
"select the whole text. This is called only once during the initialization |
|
8788 |
for editFields which are shown in a table or tree. |
|
8789 |
The selectAll is called via this method to allow for easier redefinition and |
|
8790 |
to distinguish auto-select from user-initiated selects." |
|
8791 |
||
8792 |
self selectAll |
|
8793 |
! |
|
8794 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8795 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8796 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8797 |
|
3160 | 8798 |
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
|
8799 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8800 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8801 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8802 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8803 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8804 |
cursorCol > 1 ifTrue:[ |
6152 | 8805 |
self selectFromLine:cursorLine col:1 |
8806 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8807 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8808 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8809 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8810 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8811 |
|
6354 | 8812 |
selectCursorLineToEnd |
8813 |
"select cursorline from cursor position to the end" |
|
8814 |
||
8815 |
self selectFromLine:cursorLine col:cursorCol |
|
8816 |
toLine:(cursorLine+1) col:0 |
|
8817 |
||
8818 |
"Created: / 16-06-2018 / 00:46:21 / Claus Gittinger" |
|
8819 |
! |
|
8820 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8821 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8822 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8823 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8824 |
selectionStartLine isNil ifTrue:[ |
6152 | 8825 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8826 |
] ifFalse:[ |
6152 | 8827 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8828 |
toLine:cursorLine+1 col:0. |
|
8829 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8830 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8831 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8832 |
|
4257 | 8833 |
selectFromBeginOfLine |
8834 |
"select the text from the beginning of the current line to the current cursor position." |
|
8835 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8836 |
| newCursorCol ln | |
4271 | 8837 |
|
4257 | 8838 |
list isNil ifTrue:[ |
6152 | 8839 |
self unselect |
4257 | 8840 |
] ifFalse:[ |
6152 | 8841 |
cursorCol > 1 ifTrue:[ |
8842 |
ln := list at: cursorLine. |
|
8843 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
|
8844 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
|
6207 | 8845 |
"/ cursorCol := newCursorCol. |
8846 |
self setCursorCol:newCursorCol. |
|
6152 | 8847 |
typeOfSelection := nil |
8848 |
] |
|
4257 | 8849 |
] |
8850 |
||
8851 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8852 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8853 |
! |
8854 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8855 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8856 |
"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
|
8857 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8858 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8859 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8860 |
list isNil ifTrue:[ |
6152 | 8861 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8862 |
] ifFalse:[ |
6152 | 8863 |
cursorCol == 0 ifTrue:[ |
8864 |
col := 0 |
|
8865 |
] ifFalse:[ |
|
8866 |
col := cursorCol - 1 |
|
8867 |
]. |
|
8868 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8869 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8870 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8871 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8872 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8873 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8874 |
"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
|
8875 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8876 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8877 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 8878 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
6152 | 8879 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 8880 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8881 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8882 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8883 |
|
4257 | 8884 |
selectToEndOfLine |
8885 |
"select the text from the current cursor position to the end of the current line" |
|
8886 |
||
4271 | 8887 |
| newCursorCol line | |
8888 |
||
4257 | 8889 |
list isNil ifTrue:[ |
6152 | 8890 |
self unselect |
4257 | 8891 |
] ifFalse:[ |
6152 | 8892 |
cursorCol >= 1 ifTrue:[ |
8893 |
line := list at: cursorLine. |
|
8894 |
newCursorCol := line size. |
|
8895 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8896 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8897 |
||
8898 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
6207 | 8899 |
"/ cursorCol := newCursorCol. |
8900 |
self setCursorCol:newCursorCol. |
|
6152 | 8901 |
typeOfSelection := nil |
8902 |
] |
|
4257 | 8903 |
] |
8904 |
||
8905 |
"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
|
8906 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8907 |
! |
8908 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8909 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8910 |
"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
|
8911 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8912 |
list isNil ifTrue:[ |
6152 | 8913 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8914 |
] ifFalse:[ |
6152 | 8915 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8916 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8917 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8918 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8919 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8920 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8921 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8922 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8923 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8924 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8925 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8926 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8927 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8928 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8929 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8930 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8931 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8932 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8933 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8934 |
wasOn ifTrue:[self showCursor] |
105 | 8935 |
! ! |
8936 |
||
8937 |
!EditTextView methodsFor:'undo & again'! |
|
8938 |
||
2952 | 8939 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8940 |
^ undoSupport addUndo:action. |
2952 | 8941 |
! |
8942 |
||
105 | 8943 |
again |
8944 |
"repeat the last action (which was a cut or replace). |
|
8945 |
If current selection is not last string, search forward to |
|
3160 | 8946 |
next occurrence of it before repeating the last operation." |
105 | 8947 |
|
5787 | 8948 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8949 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8950 |
|
8951 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8952 |
lastStringToReplace isNil ifTrue:[ |
6152 | 8953 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8954 |
]. |
4048 | 8955 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8956 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8957 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8958 |
self undoableDo:[ |
6152 | 8959 |
s := lastStringToReplace asString. |
8960 |
"remove final cr" |
|
8961 |
(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
|
8962 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8963 |
|
6152 | 8964 |
"set lastStringToReplace as the next search string |
8965 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
8966 |
lastStringFromReplaceForNextSearch := s. |
|
8967 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
|
8968 |
||
8969 |
savedSelectStyle := selectStyle. |
|
8970 |
selectStyle := nil. |
|
8971 |
||
8972 |
sel := self selection. |
|
8973 |
||
6156 | 8974 |
"if we are already there (after a find), omit search" |
6152 | 8975 |
|
8976 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
|
8977 |
l := selectionStartLine "cursorLine". |
|
8978 |
c := selectionStartCol "cursorCol". |
|
8979 |
self deleteSelection. |
|
8980 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
8981 |
self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false. |
|
8982 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
|
8983 |
typeOfSelection := #paste |
|
8984 |
]. |
|
8985 |
selectStyle := savedSelectStyle. |
|
8986 |
^ true |
|
8987 |
]. |
|
8988 |
||
8989 |
sel isEmptyOrNil ifTrue:[ |
|
8990 |
startColForSearch := cursorCol - 1 |
|
8991 |
] ifFalse:[ |
|
8992 |
startColForSearch := selectionEndCol ? (cursorCol - 1) |
|
8993 |
]. |
|
8994 |
self |
|
8995 |
searchForwardFor:s |
|
8996 |
ignoreCase: lastReplaceIgnoredCase |
|
8997 |
match: lastReplaceWasMatch |
|
8998 |
startingAtLine:cursorLine col:startColForSearch |
|
8999 |
ifFound: |
|
9000 |
[ |
|
9001 |
:line :col | |
|
9002 |
||
9003 |
|repl| |
|
9004 |
||
9005 |
self selectFromLine:line col:col |
|
9006 |
toLine:line col:(col + s size - 1). |
|
9007 |
self makeLineVisible:line. |
|
9008 |
||
9009 |
self deleteSelection. |
|
9010 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
9011 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
9012 |
repl := lastReplacementInfo lastReplacement asString "withoutSpaces" |
|
9013 |
] ifTrue:[ |
|
9014 |
repl := lastReplacementInfo lastReplacement "withoutSpaces". |
|
9015 |
]. |
|
9016 |
self insertLines:repl asStringCollection withCR:false. |
|
9017 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
|
9018 |
undoSupport actionInfo:'replace'. |
|
9019 |
]. |
|
9020 |
selectStyle := savedSelectStyle. |
|
9021 |
typeOfSelection := #paste. |
|
9022 |
^ true |
|
9023 |
] |
|
9024 |
ifAbsent: |
|
9025 |
[ |
|
9026 |
self sensor compressKeyPressEventsWithKey:#Again. |
|
9027 |
self showNotFound. |
|
9028 |
selectStyle := savedSelectStyle. |
|
9029 |
^ false |
|
9030 |
]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
9031 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
9032 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
9033 |
^ true. |
501 | 9034 |
|
6156 | 9035 |
"Modified: / 09-10-1996 / 16:14:11 / cg" |
9036 |
"Modified (comment): / 17-05-2017 / 16:19:32 / mawalch" |
|
105 | 9037 |
! |
9038 |
||
2952 | 9039 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9040 |
^ undoSupport hasRedoAction. |
2952 | 9041 |
! |
9042 |
||
9043 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9044 |
^ undoSupport hasUndoAction. |
2952 | 9045 |
! |
9046 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9047 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9048 |
"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
|
9049 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9050 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9051 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9052 |
|
2952 | 9053 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9054 |
undoSupport nonUndoableDo:aBlock. |
2952 | 9055 |
! |
9056 |
||
9057 |
redo |
|
3780 | 9058 |
"undo the last undo" |
9059 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9060 |
undoSupport hasRedoAction ifFalse:[ |
6262 | 9061 |
self beepInEditor |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9062 |
] ifTrue:[ |
6152 | 9063 |
undoSupport redo. |
2952 | 9064 |
] |
9065 |
! |
|
9066 |
||
121 | 9067 |
undo |
3780 | 9068 |
"undo the last edit operation" |
9069 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9070 |
undoSupport hasUndoAction ifFalse:[ |
6262 | 9071 |
self beepInEditor |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9072 |
] ifTrue:[ |
5834 | 9073 |
undoSupport undo. |
9074 |
self makeSelectionVisible. |
|
9075 |
self makeCursorVisible. |
|
121 | 9076 |
] |
2952 | 9077 |
! |
9078 |
||
9079 |
undoableDo:aBlock |
|
3495 | 9080 |
self undoableDo:aBlock info:nil. |
9081 |
||
9082 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 9083 |
! |
9084 |
||
9085 |
undoableDo:aBlock info:aString |
|
5689 | 9086 |
|selectionRestore| |
9087 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9088 |
self checkModificationsAllowed ifFalse:[ |
6152 | 9089 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
9090 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9091 |
] ifTrue:[ |
6152 | 9092 |
undoSupport isInTransaction ifFalse:[ |
9093 |
selectionRestore := RestoreSelectionAndCursor new |
|
9094 |
cursorLine:cursorLine cursorCol:cursorCol |
|
9095 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
9096 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
9097 |
info:nil. |
|
9098 |
]. |
|
9099 |
undoSupport |
|
9100 |
undoableDo:[ |
|
9101 |
aBlock value. |
|
9102 |
selectionRestore notNil ifTrue:[ |
|
9103 |
undoSupport transactionNotEmpty ifTrue:[ |
|
9104 |
undoSupport addUndoFirst:selectionRestore |
|
9105 |
]. |
|
9106 |
]. |
|
9107 |
] |
|
9108 |
info:aString. |
|
5689 | 9109 |
]. |
9110 |
||
9111 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 9112 |
! ! |
9113 |
||
9114 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
9115 |
||
9116 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9117 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9118 |
! |
|
9119 |
||
3115 | 9120 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 9121 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 9122 |
! |
9123 |
||
2952 | 9124 |
line:arg1 col:arg2 character:arg3 |
9125 |
^ self new line:arg1 col:arg2 character:arg3 |
|
9126 |
! |
|
9127 |
||
3115 | 9128 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 9129 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 9130 |
! |
9131 |
||
3235 | 9132 |
line:arg1 col:arg2 characters:arg3 info:info |
9133 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
9134 |
! |
|
9135 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9136 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9137 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9138 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9139 |
|
2952 | 9140 |
line:arg1 col:arg2 string:arg3 |
9141 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 9142 |
! |
9143 |
||
9144 |
line:arg1 col:arg2 string:arg3 info:info |
|
9145 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 9146 |
! |
9147 |
||
9148 |
line:arg1 string:arg3 info:info |
|
9149 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 9150 |
! |
9151 |
||
9152 |
text:arg info:info |
|
9153 |
^ (self new text:arg) info:info |
|
3115 | 9154 |
! ! |
9155 |
||
9156 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
9157 |
||
9158 |
info |
|
9159 |
^ userFriendlyInfo |
|
9160 |
! |
|
9161 |
||
9162 |
info:aString |
|
9163 |
userFriendlyInfo := aString |
|
2952 | 9164 |
! ! |
9165 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9166 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9167 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9168 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9169 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9170 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9171 |
"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
|
9172 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9173 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9174 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9175 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9176 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9177 |
^ false |
5710 | 9178 |
! |
9179 |
||
9180 |
isRestoreSelectionAndCursor |
|
9181 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9182 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9183 |
|
2952 | 9184 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
9185 |
||
3160 | 9186 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 9187 |
"set instance variables (automatically generated)" |
9188 |
||
9189 |
self assert:(line1Arg notNil). |
|
9190 |
self assert:(col1Arg notNil). |
|
9191 |
self assert:(line2Arg notNil). |
|
9192 |
self assert:(col2Arg notNil). |
|
9193 |
||
9194 |
line1 := line1Arg. |
|
9195 |
col1 := col1Arg. |
|
9196 |
line2 := line2Arg. |
|
9197 |
col2 := col2Arg. |
|
9198 |
! ! |
|
9199 |
||
9200 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
9201 |
||
3160 | 9202 |
executeIn:editor |
2952 | 9203 |
editor unselect. |
3160 | 9204 |
editor |
6152 | 9205 |
deleteFromLine:line1 |
9206 |
col:col1 |
|
9207 |
toLine:line2 |
|
9208 |
col:col2. |
|
2952 | 9209 |
editor cursorLine:line1 col:col1. |
9210 |
! ! |
|
9211 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9212 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9213 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9214 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9215 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9216 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9217 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9218 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9219 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9220 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9221 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9222 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9223 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9224 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9225 |
|
3160 | 9226 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9227 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9228 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9229 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9230 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9231 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9232 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9233 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9234 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9235 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9236 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9237 |
|
3160 | 9238 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9239 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9240 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9241 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9242 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9243 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9244 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9245 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9246 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9247 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9248 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9249 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9250 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9251 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9252 |
|
3160 | 9253 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9254 |
"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
|
9255 |
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
|
9256 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9257 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9258 |
previousDeleteAction line == line ifTrue:[ |
6152 | 9259 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
9260 |
^ true |
|
9261 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9262 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9263 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9264 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9265 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9266 |
|
3160 | 9267 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9268 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9269 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9270 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9271 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9272 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9273 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9274 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9275 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9276 |
|
3160 | 9277 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9278 |
editor unselect. |
3160 | 9279 |
editor |
6152 | 9280 |
deleteFromLine:line |
9281 |
col:col1 |
|
9282 |
toLine:line |
|
9283 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9284 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9285 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9286 |
|
3235 | 9287 |
!EditTextView::EditMode class methodsFor:'constants'! |
9288 |
||
9289 |
insertAndSelectMode |
|
9290 |
^ InsertAndSelectMode |
|
9291 |
! |
|
9292 |
||
9293 |
insertMode |
|
9294 |
^ InsertMode |
|
9295 |
! |
|
9296 |
||
9297 |
overwriteMode |
|
9298 |
^ OverwriteMode |
|
9299 |
! ! |
|
9300 |
||
9301 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
9302 |
||
9303 |
isInsertAndSelectMode |
|
9304 |
^ false |
|
9305 |
! |
|
9306 |
||
9307 |
isInsertMode |
|
9308 |
^ false |
|
9309 |
! |
|
9310 |
||
9311 |
symbolicName |
|
9312 |
self subclassResponsibility |
|
9313 |
! ! |
|
9314 |
||
9315 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
9316 |
||
9317 |
infoPrintString |
|
9318 |
^ 'IS' |
|
9319 |
! ! |
|
9320 |
||
9321 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
9322 |
||
9323 |
isInsertAndSelectMode |
|
9324 |
^ true |
|
9325 |
! |
|
9326 |
||
9327 |
isInsertMode |
|
9328 |
^ true |
|
9329 |
! ! |
|
9330 |
||
9331 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
9332 |
||
9333 |
infoPrintString |
|
9334 |
^ 'I' |
|
9335 |
! ! |
|
9336 |
||
9337 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
9338 |
||
9339 |
isInsertMode |
|
9340 |
^ true |
|
9341 |
! ! |
|
9342 |
||
9343 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
9344 |
||
9345 |
infoPrintString |
|
9346 |
^ 'O' |
|
9347 |
! ! |
|
9348 |
||
4048 | 9349 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
9350 |
||
9351 |
lastReplaceIgnoredCase |
|
9352 |
^ lastReplaceIgnoredCase ? false |
|
9353 |
! |
|
9354 |
||
9355 |
lastReplaceIgnoredCase:something |
|
9356 |
lastReplaceIgnoredCase := something. |
|
9357 |
! |
|
9358 |
||
9359 |
lastReplaceWasMatch |
|
9360 |
^ lastReplaceWasMatch ? false |
|
9361 |
! |
|
9362 |
||
9363 |
lastReplaceWasMatch:something |
|
9364 |
lastReplaceWasMatch := something. |
|
9365 |
! |
|
9366 |
||
9367 |
lastReplacement |
|
9368 |
^ lastReplacement |
|
9369 |
! |
|
9370 |
||
9371 |
lastReplacement:something |
|
4053 | 9372 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 9373 |
lastReplacement := something. |
9374 |
! |
|
9375 |
||
9376 |
lastStringToReplace |
|
9377 |
^ lastStringToReplace |
|
9378 |
! |
|
9379 |
||
9380 |
lastStringToReplace:something |
|
9381 |
lastStringToReplace := something. |
|
4818 | 9382 |
! |
9383 |
||
9384 |
previousReplacements |
|
9385 |
^ previousReplacements ? #() |
|
9386 |
! |
|
9387 |
||
9388 |
stillCollectingInput |
|
9389 |
^ stillCollectingInput |
|
9390 |
! |
|
9391 |
||
9392 |
stillCollectingInput:aBoolean |
|
9393 |
stillCollectingInput := aBoolean. |
|
9394 |
! ! |
|
9395 |
||
9396 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9397 |
||
9398 |
rememberReplacement |
|
9399 |
"remember the previous replacement (called when a new one appears). |
|
9400 |
Mostly for the benefit of the code completion..." |
|
9401 |
||
9402 |
|oldString newString| |
|
9403 |
||
9404 |
oldString := lastStringToReplace. |
|
9405 |
newString := lastReplacement. |
|
9406 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
6152 | 9407 |
previousReplacements isNil ifTrue:[ |
9408 |
previousReplacements := OrderedCollection new. |
|
9409 |
]. |
|
9410 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9411 |
previousReplacements addFirst:(oldString -> newString). |
|
9412 |
previousReplacements size > 20 ifTrue:[ |
|
9413 |
previousReplacements removeLast. |
|
9414 |
] |
|
4818 | 9415 |
]. |
4048 | 9416 |
! ! |
9417 |
||
2952 | 9418 |
!EditTextView::PasteString methodsFor:'accessing'! |
9419 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9420 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9421 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9422 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9423 |
"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
|
9424 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9425 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9426 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9427 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9428 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9429 |
"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
|
9430 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9431 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9432 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9433 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9434 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9435 |
"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
|
9436 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9437 |
|
3160 | 9438 |
line:lineArg col:colArg string:stringArg |
2952 | 9439 |
self assert:(lineArg notNil). |
9440 |
self assert:(colArg notNil). |
|
9441 |
self assert:(stringArg notNil). |
|
9442 |
||
9443 |
line := lineArg. |
|
9444 |
col := colArg. |
|
9445 |
string := stringArg. |
|
9446 |
! |
|
9447 |
||
9448 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9449 |
self assert:(lineArg notNil). |
|
9450 |
self assert:(colArg notNil). |
|
9451 |
self assert:(stringArg notNil). |
|
9452 |
||
9453 |
line := lineArg. |
|
9454 |
col := colArg. |
|
9455 |
string := stringArg. |
|
9456 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9457 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9458 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9459 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9460 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9461 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9462 |
"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
|
9463 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9464 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9465 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9466 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9467 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9468 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9469 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9470 |
"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
|
9471 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9472 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9473 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9474 |
"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
|
9475 |
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
|
9476 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9477 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9478 |
previousPasteAction line == line ifTrue:[ |
6152 | 9479 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9480 |
^ true |
|
9481 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9482 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9483 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9484 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9485 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9486 |
"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
|
9487 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9488 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9489 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9490 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9491 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9492 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9493 |
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
|
9494 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9495 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9496 |
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
|
9497 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9498 |
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
|
9499 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9500 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9501 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9502 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9503 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9504 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9505 |
! ! |
9506 |
||
9507 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9508 |
||
3160 | 9509 |
executeIn:editor |
2952 | 9510 |
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
|
9511 |
editor paste:string. |
2952 | 9512 |
selected ~~ true ifTrue:[ |
6152 | 9513 |
editor unselect |
2952 | 9514 |
]. |
9515 |
! ! |
|
9516 |
||
9517 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9518 |
||
3235 | 9519 |
col |
9520 |
^ col |
|
9521 |
! |
|
9522 |
||
9523 |
col1 |
|
9524 |
^ col |
|
9525 |
! |
|
9526 |
||
9527 |
col2 |
|
9528 |
^ col |
|
9529 |
! |
|
9530 |
||
9531 |
line |
|
9532 |
^ line |
|
9533 |
! |
|
9534 |
||
3160 | 9535 |
line:lineArg col:colArg character:characterArg |
2952 | 9536 |
line := lineArg. |
9537 |
col := colArg. |
|
9538 |
character := characterArg. |
|
9539 |
! ! |
|
9540 |
||
9541 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9542 |
||
3160 | 9543 |
executeIn:editor |
9544 |
editor |
|
6152 | 9545 |
replace:character |
9546 |
atLine:line |
|
9547 |
col:col. |
|
2952 | 9548 |
editor cursorLine:line col:col. |
105 | 9549 |
! ! |
9550 |
||
3235 | 9551 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9552 |
||
9553 |
characters |
|
9554 |
^ characters |
|
9555 |
! |
|
9556 |
||
9557 |
col1 |
|
9558 |
^ col1 |
|
9559 |
! |
|
9560 |
||
9561 |
col2 |
|
9562 |
^ col2 |
|
9563 |
! |
|
9564 |
||
9565 |
line |
|
9566 |
^ line |
|
9567 |
! |
|
9568 |
||
9569 |
line:lineArg col:colArg character:characterArg |
|
9570 |
line := lineArg. |
|
9571 |
col1 := col2 := colArg. |
|
9572 |
characters := characterArg asString. |
|
9573 |
! |
|
9574 |
||
9575 |
line:lineArg col:colArg characters:charactersArg |
|
9576 |
line := lineArg. |
|
9577 |
col1 := colArg. |
|
9578 |
characters := charactersArg asString. |
|
9579 |
col2 := col1 + charactersArg size - 1 |
|
9580 |
! ! |
|
9581 |
||
9582 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9583 |
||
9584 |
canCombineWithNext:anotherAction |
|
9585 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9586 |
! |
|
9587 |
||
9588 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9589 |
"I will combine only if we both are single character deletes, |
|
9590 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9591 |
(i.e. single-character typing)" |
|
9592 |
||
9593 |
previousReplaceAction line == line ifTrue:[ |
|
6152 | 9594 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9595 |
^ true |
|
9596 |
]. |
|
3235 | 9597 |
]. |
9598 |
||
9599 |
^ false |
|
9600 |
! |
|
9601 |
||
9602 |
combineWithNext:nextReplaceAction |
|
9603 |
self assert:(line == nextReplaceAction line). |
|
9604 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9605 |
||
9606 |
col2 := nextReplaceAction col2. |
|
9607 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9608 |
characters := characters , nextReplaceAction characters. |
|
9609 |
! ! |
|
9610 |
||
9611 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9612 |
||
9613 |
executeIn:editor |
|
9614 |
editor |
|
6152 | 9615 |
replaceString:characters |
9616 |
atLine:line |
|
9617 |
col:col1. |
|
3235 | 9618 |
editor cursorLine:line col:col1. |
9619 |
! ! |
|
9620 |
||
3131 | 9621 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9622 |
||
9623 |
text:something |
|
9624 |
text := something. |
|
9625 |
! ! |
|
9626 |
||
9627 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9628 |
||
3160 | 9629 |
executeIn:editor |
3131 | 9630 |
editor contents:text |
9631 |
! ! |
|
9632 |
||
3130 | 9633 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9634 |
||
3160 | 9635 |
line:lineArg string:stringArg |
3130 | 9636 |
line := lineArg. |
9637 |
text := stringArg. |
|
9638 |
! ! |
|
9639 |
||
9640 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9641 |
||
3160 | 9642 |
executeIn:editor |
3130 | 9643 |
editor list at:line put:text. |
9644 |
editor invalidateLine:line |
|
9645 |
! ! |
|
9646 |
||
3402 | 9647 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9648 |
||
9649 |
line:lineArg lines:lineCollectionArg |
|
9650 |
line := lineArg. |
|
9651 |
text := lineCollectionArg. |
|
9652 |
||
9653 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9654 |
! ! |
|
9655 |
||
9656 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9657 |
||
9658 |
executeIn:editor |
|
9659 |
|lnr| |
|
9660 |
||
9661 |
lnr := line. |
|
9662 |
text do:[:eachLine | |
|
6152 | 9663 |
editor list at:lnr put:eachLine. |
9664 |
editor invalidateLine:lnr. |
|
9665 |
lnr := lnr + 1. |
|
3402 | 9666 |
]. |
9667 |
||
9668 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9669 |
! ! |
|
9670 |
||
5689 | 9671 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9672 |
||
5787 | 9673 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
5689 | 9674 |
cursorLine := cursorLineArg. |
9675 |
cursorCol := cursorColArg. |
|
9676 |
selectionStartLine := selectionStartLineArg. |
|
9677 |
selectionStartCol := selectionStartColArg. |
|
9678 |
selectionEndLine := selectionEndLineArg. |
|
9679 |
selectionEndCol := selectionEndColArg. |
|
9680 |
! |
|
9681 |
||
5787 | 9682 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
6152 | 9683 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
9684 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9685 |
info:info |
|
5689 | 9686 |
|
9687 |
cursorLine := cursorLineArg. |
|
9688 |
cursorCol := cursorColArg. |
|
9689 |
selectionStartLine := selectionStartLineArg. |
|
9690 |
selectionStartCol := selectionStartColArg. |
|
9691 |
selectionEndLine := selectionEndLineArg. |
|
9692 |
selectionEndCol := selectionEndColArg. |
|
9693 |
userFriendlyInfo := info. |
|
9694 |
||
9695 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9696 |
! ! |
|
9697 |
||
9698 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9699 |
||
9700 |
executeIn:editor |
|
9701 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9702 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
6152 | 9703 |
editor setCursorLine:cursorLine col:cursorCol. |
9704 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
5689 | 9705 |
] ifFalse:[ |
6152 | 9706 |
editor cursorLine:cursorLine col:cursorCol. |
5689 | 9707 |
]. |
9708 |
||
9709 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9710 |
! ! |
|
9711 |
||
5710 | 9712 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9713 |
||
9714 |
isRestoreSelectionAndCursor |
|
9715 |
^ true |
|
9716 |
! ! |
|
9717 |
||
865 | 9718 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9719 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9720 |
version |
5361 | 9721 |
^ '$Header$' |
3945 | 9722 |
! |
9723 |
||
9724 |
version_CVS |
|
5361 | 9725 |
^ '$Header$' |
0 | 9726 |
! ! |
4481 | 9727 |