author | Claus Gittinger <cg@exept.de> |
Tue, 12 Mar 2019 16:40:50 +0100 | |
changeset 6556 | 2b8c8e4fbfcb |
parent 6548 | 59a6fdf4dd26 |
child 6563 | 3cbb78c9dc1f |
permissions | -rw-r--r-- |
6517 | 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 |
1439 |
"return the contents as a String (i.e. without emphasis)" |
|
1440 |
||
1441 |
list isNil ifTrue:[^ '']. |
|
1442 |
self removeTrailingBlankLines. |
|
6412 | 1443 |
^ (list collect:[:each | |
1444 |
each isNil |
|
1445 |
ifTrue:[''] |
|
1446 |
ifFalse:[each string] |
|
1447 |
]) asStringWithCRs |
|
1448 |
||
1449 |
"Modified (format): / 29-08-2018 / 09:24:29 / Claus Gittinger" |
|
2213 | 1450 |
! |
1451 |
||
5067 | 1452 |
contentsAsStringWithTabs |
1453 |
"return the contents as a String (i.e. without emphasis) |
|
1454 |
and with leading spaces replaced by tab characters |
|
1455 |
(i.e. as would be written to a file)" |
|
1456 |
||
1457 |
list isNil ifTrue:[^ '']. |
|
1458 |
self removeTrailingBlankLines. |
|
5787 | 1459 |
^ (list collect:[:each | |
6152 | 1460 |
each isNil |
1461 |
ifTrue:[''] |
|
1462 |
ifFalse:[each string withTabs] |
|
5067 | 1463 |
]) asStringWithCRs |
1464 |
! |
|
1465 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1466 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1467 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1468 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1469 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1470 |
^ cursorCol |
125 | 1471 |
! |
1472 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1473 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1474 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1475 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1476 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1477 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1478 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1479 |
cursorLine |
3160 | 1480 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1481 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1482 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1483 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1484 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1485 |
|
6295 | 1486 |
cursorLineAndColumnHolder |
1487 |
"return a valueHolder for the cursors line and column as an |
|
1488 |
array of the form { lineNr . col } |
|
1489 |
This can be used directly as a model to react on cursor movement" |
|
1490 |
||
1491 |
^ BlockValue |
|
1492 |
with:[:l :c | (Array with:l with:c) ] |
|
1493 |
argument:self cursorLineHolder |
|
1494 |
argument:self cursorColHolder |
|
1495 |
! |
|
1496 |
||
5400 | 1497 |
cursorLineAndColumnLabelHolder |
5399 | 1498 |
"return a valueHolder for the cursors line and column as an info string |
5787 | 1499 |
of the form 'line : col'. |
5399 | 1500 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
1501 |
||
1502 |
^ BlockValue |
|
6152 | 1503 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
1504 |
argument:self cursorLineHolder |
|
1505 |
argument:self cursorColHolder |
|
5399 | 1506 |
! |
1507 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1508 |
cursorLineHolder |
3160 | 1509 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1510 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1511 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1512 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1513 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1514 |
|
4713 | 1515 |
lineStringBeforeCursor |
1516 |
"return the line's string before the cursor. |
|
1517 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1518 |
||
1519 |
|line| |
|
1520 |
||
1521 |
line := ((self at:cursorLine) ? '') string. |
|
1522 |
line size < (cursorCol-1) ifTrue:[ |
|
6152 | 1523 |
^ line paddedTo:(cursorCol-1) |
4713 | 1524 |
]. |
1525 |
^ line copyTo:(cursorCol-1) |
|
1526 |
! |
|
1527 |
||
6289 | 1528 |
list:newCollectionOfLinesOrNil |
5413 | 1529 |
"replace the whole contents by something new. |
1530 |
this is not undoably, unless you care for yourself. |
|
6289 | 1531 |
Positions the cursor as defined in cursorMovementWhenUpdating |
1532 |
(which defaults to: home)" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1533 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1534 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1535 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1536 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1537 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1538 |
|
6289 | 1539 |
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
|
1540 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1541 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1542 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
6152 | 1543 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1544 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1545 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1546 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
6152 | 1547 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1548 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1549 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1550 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1551 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
6152 | 1552 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1553 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1554 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
6152 | 1555 |
^ 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
|
1556 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1557 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1558 |
"/ 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
|
1559 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1560 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1561 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1562 |
setContents:something |
5787 | 1563 |
"replace the whole contents by something new |
5413 | 1564 |
AND clear the remembered undo actions" |
1565 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1566 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1567 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1568 |
undoSupport resetHistories. |
2955 | 1569 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1570 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1571 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1572 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1573 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1574 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1575 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1576 |
|
4609 | 1577 |
!EditTextView methodsFor:'accessing-dimensions'! |
1578 |
||
1579 |
xOfCursor |
|
4728 | 1580 |
|point| |
1581 |
||
1582 |
cursorVisibleLine isNil ifTrue:[ |
|
6152 | 1583 |
"/ take the end of the selection, if any |
1584 |
(selectionStartLine notNil |
|
1585 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1586 |
ifTrue:[ |
|
1587 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1588 |
]. |
|
5787 | 1589 |
|
1590 |
"/ point := device |
|
4728 | 1591 |
"/ translatePoint:(device pointerPosition) |
1592 |
"/ fromView:nil |
|
1593 |
"/ toView:self. |
|
1594 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1595 |
"/ ^ point x |
|
1596 |
"/ ]. |
|
1597 |
"/ ^ 0 |
|
6152 | 1598 |
^ nil |
4728 | 1599 |
]. |
4609 | 1600 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1601 |
||
1602 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1603 |
! ! |
|
4590 | 1604 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1605 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1606 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1607 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1608 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1609 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1610 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1611 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1612 |
wasOn := self hideCursor. |
5643 | 1613 |
cursorFgColor := color1 onDevice:device. |
1614 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1615 |
wasOn ifTrue:[self showCursor] |
1333 | 1616 |
! |
1617 |
||
1899 | 1618 |
cursorType |
1619 |
"return the style of the text cursor. |
|
4721 | 1620 |
Currently, supported are: #none |
6152 | 1621 |
#block, #frame, #ibeam, #caret, #solidCaret |
1622 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1623 |
|
1624 |
^ cursorType |
|
1625 |
||
1626 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1627 |
! |
|
1628 |
||
1333 | 1629 |
cursorType:aCursorTypeSymbol |
1630 |
"set the style of the text cursor. |
|
4721 | 1631 |
Currently, supported are: #none |
6152 | 1632 |
#block, #frame, #ibeam, #caret, #solidCaret |
1633 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1634 |
|
1334 | 1635 |
cursorType := aCursorTypeSymbol. |
1333 | 1636 |
|
1637 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1638 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1639 |
! |
1640 |
||
1899 | 1641 |
cursorTypeNoFocus |
1642 |
"return the style of the text cursor when the view has no focus. |
|
1643 |
If left unspecified, this is the same as the regular cursorType." |
|
1644 |
||
1645 |
^ cursorTypeNoFocus |
|
1646 |
||
1647 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1648 |
! |
|
1649 |
||
1334 | 1650 |
cursorTypeNoFocus:aCursorTypeSymbol |
1651 |
"set the style of the text cursor when the view has no focus. |
|
1652 |
If left unspecified, this is the same as the regular cursorType." |
|
1653 |
||
1654 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1655 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1656 |
|
4048 | 1657 |
!EditTextView methodsFor:'accessing-replace'! |
1658 |
||
4746 | 1659 |
lastReplacementInfo |
1660 |
^ lastReplacementInfo |
|
1661 |
! |
|
1662 |
||
4048 | 1663 |
lastStringToReplace: aString |
4818 | 1664 |
! |
1665 |
||
1666 |
previousReplacements |
|
1667 |
"accessor for the code completion" |
|
1668 |
||
1669 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1670 |
! ! |
1671 |
||
2119 | 1672 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1673 |
|
125 | 1674 |
accept |
1675 |
"accept the current contents by executing the accept-action and/or |
|
5937 | 1676 |
changeMessage. |
1677 |
Historically, ST/X used a callBack (acceptAction); |
|
1678 |
and ST80/VW used the model, into which the text is stored. |
|
1679 |
We support both; if there is a mode, it gets a value: message, |
|
1680 |
If there is an acceptAction, it is called." |
|
125 | 1681 |
|
1108 | 1682 |
acceptEnabled == false ifTrue:[ |
6262 | 1683 |
self beepInEditor. |
5937 | 1684 |
^ self |
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1685 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1686 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
5937 | 1687 |
^ self |
1108 | 1688 |
]. |
1689 |
||
125 | 1690 |
lockUpdates := true. |
1013 | 1691 |
|
1692 |
"/ |
|
1693 |
"/ ST-80 way of doing it |
|
1694 |
"/ |
|
1695 |
model notNil ifTrue:[ |
|
5937 | 1696 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
1697 |
acceptChannel notNil ifTrue:[ |
|
1698 |
acceptChannel value:true withoutNotifying:self. |
|
1699 |
]. |
|
2999 | 1700 |
]. |
1701 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1702 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1703 |
"/ ST/X way of doing things |
5937 | 1704 |
"/ as a historic leftover, |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1705 |
"/ 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
|
1706 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1707 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1708 |
acceptAction notNil ifTrue:[ |
5937 | 1709 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1710 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1711 |
|
125 | 1712 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1713 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1714 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1715 |
! |
1716 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1717 |
argForChangeMessage |
597 | 1718 |
"return the argument to be passed with the change notification. |
1719 |
Defined as separate method for easier subclassability." |
|
1720 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1721 |
^ self contents |
597 | 1722 |
|
1723 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1724 |
! |
1725 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1726 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1727 |
"get my contents from the model. |
597 | 1728 |
Redefined to ignore updates resulting from my own changes |
1729 |
(i.e. if lockUpdates is true)." |
|
121 | 1730 |
|
1731 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1732 |
ignore updates from my own change |
121 | 1733 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1734 |
lockUpdates ifTrue:[ |
6152 | 1735 |
lockUpdates := false. |
1736 |
^ self |
|
121 | 1737 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1738 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1739 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1740 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1741 |
"/ validate the cursorLine |
3160 | 1742 |
(cursorLine notNil |
2310 | 1743 |
and:[ cursorLine > list size ]) ifTrue:[ |
6152 | 1744 |
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
|
1745 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1746 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1747 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1748 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1749 |
changedObject == acceptChannel ifTrue:[ |
6152 | 1750 |
acceptChannel value == true ifTrue:[ |
1751 |
self accept. |
|
1752 |
]. |
|
1753 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1754 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1755 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1756 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1757 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1758 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1759 |
! ! |
1760 |
||
6015 | 1761 |
!EditTextView methodsFor:'commenting'! |
1762 |
||
1763 |
commentFrom:line1 to:line2 commentStrings:commentStrings |
|
1764 |
"helper function to comment out a block. |
|
1765 |
All lines from line1 to line2 get an end-of-line comment |
|
1766 |
in the first col |
|
1767 |
(if no eol comment is available, a bracketing comment is used)." |
|
1768 |
||
1769 |
|eolComment opening closing| |
|
1770 |
||
1771 |
eolComment := commentStrings at:1. |
|
1772 |
eolComment isNil ifTrue:[ |
|
1773 |
opening := (commentStrings at:2) at:1. |
|
1774 |
closing := (commentStrings at:2) at:2. |
|
1775 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1776 |
]. |
|
1777 |
||
1778 |
line1 to:line2 do:[:lineNr | |
|
1779 |
|l| |
|
1780 |
||
1781 |
l := self listAt:lineNr. |
|
1782 |
l isNil ifTrue:[l := '']. |
|
1783 |
eolComment notNil ifTrue:[ |
|
1784 |
l := eolComment , l |
|
1785 |
] ifFalse:[ |
|
1786 |
l := opening , l , closing |
|
1787 |
]. |
|
1788 |
self replaceLine:lineNr with:l. |
|
1789 |
widthOfWidestLine notNil ifTrue:[ |
|
1790 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1791 |
]. |
|
1792 |
]. |
|
1793 |
self textChanged. |
|
1794 |
||
1795 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
|
1796 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1797 |
! |
|
1798 |
||
1799 |
commentSelection:commentStrings |
|
1800 |
"convenient function to comment out a block. |
|
1801 |
All lines from line1 to line2 get an end-of-line comment |
|
1802 |
in the first col." |
|
1803 |
||
1804 |
|e commentPair opening closing| |
|
1805 |
||
1806 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
6301 | 1807 |
commentStrings isEmptyOrNil ifTrue:[ self beepInEditor. ^ self]. |
6015 | 1808 |
|
1809 |
self |
|
1810 |
undoableDo:[ |
|
1811 |
selectionStartLine isNil ifTrue:[ |
|
1812 |
self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1813 |
] ifFalse:[ |
|
1814 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1815 |
self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1816 |
] ifFalse:[ |
|
1817 |
commentPair := commentStrings at:2 ifAbsent:nil. |
|
1818 |
commentPair isNil ifTrue:[ |
|
1819 |
self beep. |
|
1820 |
] ifFalse:[ |
|
1821 |
opening := commentPair at:1. |
|
1822 |
closing := commentPair at:2. |
|
1823 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1824 |
||
1825 |
e := selectionEndCol. |
|
1826 |
||
1827 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1828 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
1829 |
||
1830 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
|
1831 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1832 |
toLine:selectionEndLine col:e+closing size. |
|
1833 |
] |
|
1834 |
] |
|
1835 |
]. |
|
1836 |
] |
|
1837 |
info:'Comment'. |
|
1838 |
||
1839 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
|
1840 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
|
1841 |
! |
|
1842 |
||
1843 |
uncommentFrom:line1 to:line2 commentStrings:commentStrings |
|
1844 |
"helper function to comment out a block. |
|
1845 |
All lines from line1 to line2 get an end-of-line comment |
|
1846 |
in the first col. |
|
1847 |
(if no eol comment is available, a bracketing comment is removed)." |
|
1848 |
||
1849 |
|eolComment opening closing rest| |
|
1850 |
||
1851 |
eolComment := commentStrings at:1. |
|
1852 |
eolComment isNil ifTrue:[ |
|
1853 |
opening := (commentStrings at:2) at:1. |
|
1854 |
closing := (commentStrings at:2) at:2. |
|
1855 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1856 |
] ifFalse:[ |
|
1857 |
rest := eolComment size + 1. |
|
1858 |
]. |
|
1859 |
||
1860 |
line1 to:line2 do:[:lineNr | |
|
1861 |
|l| |
|
1862 |
||
1863 |
l := self listAt:lineNr. |
|
1864 |
l notNil ifTrue:[ |
|
1865 |
eolComment notNil ifTrue:[ |
|
1866 |
(l startsWith:eolComment) ifTrue:[ |
|
1867 |
l := l copyFrom:rest |
|
1868 |
] ifFalse:[ |
|
1869 |
(l withoutLeadingSeparators startsWith:eolComment) ifTrue:[ |
|
1870 |
"/ only for single lines? |
|
1871 |
true "line1 = line2" ifTrue:[ |
|
1872 |
|numSpaces| |
|
1873 |
||
1874 |
numSpaces := l indexOfNonSeparator - 1. |
|
1875 |
l := l copyFrom:numSpaces+1+rest. |
|
1876 |
l := (String new:numSpaces),l |
|
1877 |
]. |
|
1878 |
]. |
|
1879 |
] |
|
1880 |
] ifFalse:[ |
|
1881 |
((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[ |
|
1882 |
l := l copyFrom:opening size + 1. |
|
1883 |
l := l copyButLast:closing size. |
|
1884 |
]. |
|
1885 |
]. |
|
1886 |
self replaceLine:lineNr with:l. |
|
1887 |
] |
|
1888 |
]. |
|
1889 |
||
1890 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
1891 |
self textChanged. |
|
1892 |
! |
|
1893 |
||
1894 |
uncommentSelection:commentStrings |
|
1895 |
"convenient function to comment out a block. |
|
1896 |
All lines from line1 to line2 get an end-of-line comment |
|
1897 |
in the first col." |
|
1898 |
||
1899 |
|e commentPair opening closing sz1 sz2 l1 l2 c1 c2| |
|
1900 |
||
1901 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
6262 | 1902 |
commentStrings isNil ifTrue:[ self beepInEditor. ^ self]. |
6015 | 1903 |
|
1904 |
self |
|
1905 |
undoableDo:[ |
|
1906 |
selectionStartLine isNil ifTrue:[ |
|
1907 |
self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1908 |
] ifFalse:[ |
|
1909 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1910 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1911 |
] ifFalse:[ |
|
1912 |
commentPair := commentStrings at:2. |
|
1913 |
opening := commentPair at:1. |
|
1914 |
closing := commentPair at:2. |
|
1915 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1916 |
||
1917 |
sz1 := opening size. |
|
1918 |
sz2 := closing size. |
|
1919 |
||
1920 |
((self |
|
1921 |
stringAtLine:selectionStartLine |
|
1922 |
from:selectionStartCol |
|
1923 |
to:selectionStartCol+sz1 - 1) = opening |
|
1924 |
and:[(self |
|
1925 |
stringAtLine:selectionEndLine |
|
1926 |
from:selectionEndCol - sz2 + 1 |
|
1927 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1928 |
||
1929 |
l2 := selectionEndLine. c2 := selectionEndCol. |
|
1930 |
l1 := selectionStartLine. c1 := selectionStartCol. |
|
1931 |
self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2. |
|
1932 |
self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1. |
|
1933 |
||
1934 |
e := c2 - sz2. |
|
1935 |
l1 == l2 ifTrue:[e := e - sz1]. |
|
1936 |
self selectFromLine:l1 col:c1 toLine:l2 col:e. |
|
1937 |
] |
|
1938 |
] |
|
1939 |
]. |
|
1940 |
] |
|
1941 |
info:'Uncomment'. |
|
1942 |
||
1943 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
|
1944 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
|
1945 |
! ! |
|
1946 |
||
121 | 1947 |
!EditTextView methodsFor:'cursor handling'! |
1948 |
||
4820 | 1949 |
basicCursorReturn |
1950 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1951 |
||
1952 |
|wasOn| |
|
1953 |
||
1954 |
self checkForExistingLine:(cursorLine + 1). |
|
1955 |
cursorVisibleLine notNil ifTrue:[ |
|
6152 | 1956 |
nFullLinesShown notNil ifTrue:[ |
6339 | 1957 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDownLines:1] |
6152 | 1958 |
] |
4820 | 1959 |
]. |
1960 |
||
1961 |
wasOn := self hideCursor. |
|
1962 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1963 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1964 |
||
6339 | 1965 |
"Modified: / 22-05-1996 / 18:27:34 / cg" |
1966 |
"Modified: / 13-06-2018 / 22:14:31 / Claus Gittinger" |
|
4820 | 1967 |
! |
1968 |
||
2406 | 1969 |
characterPositionOfCursor |
1970 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1971 |
! |
|
1972 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1973 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1974 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1975 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1976 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1977 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1978 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1979 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1980 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1981 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1982 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
|
2822 | 1984 |
(cursorCol == newCol) ifTrue:[^ self]. |
1985 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1986 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1987 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1988 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1989 |
|
1990 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1991 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1992 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1993 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1994 |
"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
|
1995 |
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
|
1996 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1997 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1998 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1999 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2000 |
|
2707 | 2001 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2002 |
cursorLine > list size ifTrue:[ |
6152 | 2003 |
wasOn := self hideCursor. |
2004 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
2005 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6262 | 2006 |
self beepInEditor. |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2007 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2008 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2009 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2010 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2011 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2012 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2013 |
"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
|
2014 |
|
5857 | 2015 |
|inLastLine wasOn nv nL cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2016 |
|
4595 | 2017 |
(nL := cursorLine) isNil ifTrue:[ |
5857 | 2018 |
nL := firstLineShown |
2019 |
]. |
|
2020 |
||
2021 |
inLastLine := (nL == list size). |
|
5890 | 2022 |
|
5857 | 2023 |
inLastLine ifTrue:[ |
5858 | 2024 |
|generateTextAfterEndHook| |
5857 | 2025 |
|
2026 |
cursorColBefore := cursorCol. |
|
5858 | 2027 |
(generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[ |
5860 | 2028 |
wasOn := self hideCursor. |
2029 |
nL := generateTextAfterEndHook value:(nL + n). |
|
2030 |
self setValidatedCursorLine:nL col:cursorColBefore. |
|
2031 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2032 |
^ self. |
|
5890 | 2033 |
]. |
4595 | 2034 |
]. |
2035 |
||
2036 |
self st80EditMode ifTrue:[ |
|
5857 | 2037 |
nL == list size ifTrue:[ |
2038 |
wasOn := self hideCursor. |
|
2039 |
self setValidatedCursorLine:nL col:(self listAt:nL) size + 1. |
|
2040 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6262 | 2041 |
self beepInEditor. |
5857 | 2042 |
^ self. |
2043 |
] |
|
4595 | 2044 |
]. |
2045 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2046 |
cursorVisibleLine notNil ifTrue:[ |
5857 | 2047 |
wasOn := self hideCursor. |
2048 |
nv := cursorVisibleLine + n - 1. |
|
2049 |
(nv >= nFullLinesShown) ifTrue:[ |
|
6339 | 2050 |
self scrollDownLines:(nv - nFullLinesShown + 1) |
5857 | 2051 |
]. |
2052 |
self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol). |
|
2053 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2054 |
] ifFalse:[ |
5857 | 2055 |
self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol). |
2056 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2057 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2058 |
|
6339 | 2059 |
"Modified: / 10-06-1998 / 16:59:17 / cg" |
2060 |
"Modified: / 13-06-2018 / 22:08:21 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2061 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2062 |
|
121 | 2063 |
cursorHome |
597 | 2064 |
"scroll to top AND move cursor to first line of text." |
121 | 2065 |
|
674 | 2066 |
self cursorLine:1 col:1 |
2067 |
||
2068 |
"/ |wasOn| |
|
2069 |
"/ |
|
2070 |
"/ wasOn := self hideCursor. |
|
2071 |
"/ self scrollToTop. |
|
2072 |
"/ cursorLine := cursorVisibleLine := 1. |
|
2073 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
2074 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
2075 |
||
2076 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 2077 |
! |
2078 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2079 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2080 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2081 |
|
6207 | 2082 |
|wasOn| |
2083 |
||
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2084 |
(cursorCol ~~ 1) ifTrue:[ |
6207 | 2085 |
wasOn := self hideCursor. |
2086 |
self setValidatedCursorCol:(cursorCol - 1). |
|
2087 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2088 |
"/ self cursorCol:(cursorCol - 1) |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2089 |
] ifFalse:[ |
6152 | 2090 |
cursorLine ~~ 1 ifTrue:[ |
2091 |
self st80EditMode ifTrue:[ |
|
2092 |
self cursorUp. |
|
2093 |
self cursorToEndOfLine. |
|
2094 |
] |
|
2095 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2096 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2097 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
2098 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2099 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2100 |
|
4126 | 2101 |
cursorLeft:n |
2102 |
"move cursor to left" |
|
2103 |
||
2104 |
n timesRepeat:[ |
|
6152 | 2105 |
self cursorLeft |
4126 | 2106 |
]. |
2107 |
! |
|
2108 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2109 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2110 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2111 |
|
5056 | 2112 |
self cursorLine:line col:col makeVisible:true |
2113 |
! |
|
2114 |
||
2115 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
2116 |
"this positions onto physical - not visible - line" |
|
2117 |
||
676 | 2118 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2119 |
|
2822 | 2120 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
2121 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2122 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2123 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2124 |
|
672 | 2125 |
(col < 1) ifTrue:[ |
6152 | 2126 |
newCol := 1 |
672 | 2127 |
] ifFalse:[ |
6152 | 2128 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2129 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2130 |
self st80EditMode ifTrue:[ |
6152 | 2131 |
(cursorLine == list size |
2132 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
2133 |
newCol := (self listAt:(list size)) size + 1. |
|
2134 |
] |
|
1419 | 2135 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2136 |
self setValidatedCursorCol:newCol. |
5056 | 2137 |
makeVisibleBoolean ifTrue:[ |
6152 | 2138 |
self makeCursorVisibleAndShowCursor:wasOn. |
5056 | 2139 |
] ifFalse:[ |
6152 | 2140 |
wasOn ifTrue:[self showCursor] |
5056 | 2141 |
]. |
672 | 2142 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2143 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2144 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2145 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2146 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2147 |
"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
|
2148 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2149 |
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
|
2150 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2151 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2152 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2153 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2154 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2155 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2156 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2157 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2158 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2159 |
"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
|
2160 |
|
4820 | 2161 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2162 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2163 |
|
5529 | 2164 |
cursorReturn:withPossibleAutoIndent |
2165 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2166 |
||
2167 |
self basicCursorReturn |
|
2168 |
! |
|
2169 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2170 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2171 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2172 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2173 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2174 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2175 |
self st80EditMode ifTrue:[ |
6210 | 2176 |
self isInputField ifFalse:[ |
2177 |
l := (self listAt:cursorLine). |
|
2178 |
cursorCol >= (l size + 1) ifTrue:[ |
|
2179 |
cursorLine <= list size ifTrue:[ |
|
2180 |
self cursorReturn:false. "/ no autoindent |
|
2181 |
]. |
|
2182 |
^ self |
|
2183 |
] |
|
2184 |
]. |
|
3160 | 2185 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2186 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2187 |
|
6210 | 2188 |
"Modified: / 27-09-2017 / 15:38:26 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2189 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2190 |
|
4126 | 2191 |
cursorRight:n |
2192 |
"move cursor to right" |
|
2193 |
||
2194 |
n timesRepeat:[ |
|
6152 | 2195 |
self cursorRight |
4126 | 2196 |
]. |
2197 |
! |
|
2198 |
||
1833 | 2199 |
cursorShown:aBoolean |
2200 |
"change cursor visibility |
|
2201 |
return true if cursor was visible before." |
|
2202 |
||
2203 |
|oldState| |
|
2204 |
||
4494 | 2205 |
aBoolean == cursorShown ifTrue:[ |
6152 | 2206 |
^ cursorShown |
4494 | 2207 |
]. |
1833 | 2208 |
oldState := cursorShown. |
2209 |
||
2210 |
aBoolean ifTrue:[ |
|
6152 | 2211 |
self drawCursor. |
1833 | 2212 |
] ifFalse:[ |
6152 | 2213 |
(cursorShown and:[shown]) ifTrue: [ |
2214 |
self undrawCursor. |
|
2215 |
]. |
|
1833 | 2216 |
]. |
2217 |
cursorShown := aBoolean. |
|
2218 |
||
2219 |
^ oldState |
|
2220 |
||
2221 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
2222 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
2223 |
! |
|
2224 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2225 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2226 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2227 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2228 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2229 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2230 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2231 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2232 |
"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
|
2233 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2234 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2235 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2236 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2237 |
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
|
2238 |
cursorCol > textStart ifTrue:[ |
6152 | 2239 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2240 |
] ifFalse:[ |
6152 | 2241 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2242 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2243 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2244 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2245 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2246 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2247 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2248 |
"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
|
2249 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2250 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2251 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2252 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2253 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2254 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2255 |
(newTop < 1) ifTrue:[ |
6152 | 2256 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2257 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2258 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2259 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2260 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2261 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2262 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2263 |
|
674 | 2264 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2265 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2266 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2267 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2268 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2269 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2270 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2271 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2272 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2273 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2274 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2275 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2276 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2277 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2278 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2279 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2280 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2281 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2282 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2283 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2284 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2285 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2286 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2287 |
cursorLine >= lineNr ifTrue:[ |
6152 | 2288 |
line := self listAt:cursorLine. |
2289 |
(line isEmptyOrNil) ifTrue:[ |
|
2290 |
^ self |
|
2291 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2292 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2293 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2294 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2295 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2296 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2297 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2298 |
(newTop < 1) ifTrue:[ |
6152 | 2299 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2300 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2301 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2302 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2303 |
self setValidatedCursorLine:lineNr 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 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2306 |
|
674 | 2307 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2310 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2311 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2312 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2313 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2314 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2315 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2316 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2317 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2318 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2319 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2320 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2321 |
cursorToEndOfText |
4288 | 2322 |
"move cursor to the end of the text (behind the last character in last line)" |
2323 |
||
2324 |
|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
|
2325 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2326 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2327 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2328 |
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
|
2329 |
(newTop < 1) ifTrue:[ |
6152 | 2330 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2331 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2332 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2333 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2334 |
self setValidatedCursorLine:list size. |
4288 | 2335 |
lastLineLength := (self listAt:cursorLine) size. |
2336 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2337 |
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
|
2338 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2339 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2340 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2341 |
"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
|
2342 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2343 |
|
3310 | 2344 |
cursorToEndOfWord |
2345 |
"move the cursor to the end of the word" |
|
2346 |
||
2347 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2348 |
||
2349 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2350 |
:beginLine :beginCol :endLine :endCol :style | |
2351 |
||
2352 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2353 |
] |
2354 |
||
2355 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2356 |
! |
|
2357 |
||
131 | 2358 |
cursorToFirstVisibleLine |
2359 |
"place cursor into the first visible line; do not scroll." |
|
2360 |
||
2361 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2362 |
! |
|
2363 |
||
2364 |
cursorToLastVisibleLine |
|
2365 |
"place cursor into the first visible line; do not scroll." |
|
2366 |
||
2367 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2368 |
! |
|
2369 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2370 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2371 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2372 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2373 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2374 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2375 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2376 |
|
5787 | 2377 |
self |
6152 | 2378 |
wordAtLine:cursorLine col:cursorCol |
2379 |
do:[ |
|
2380 |
:beginLine :beginCol :endLine :endCol :style | |
|
6154 | 2381 |
|lineSize| |
6152 | 2382 |
|
2383 |
line := endLine. |
|
2384 |
col := endCol + 1. |
|
6154 | 2385 |
lineSize := (self listAt:line) size. |
2386 |
(endCol ~= lineSize or:[lineSize == 0]) ifTrue:[ |
|
2387 |
searching := true. |
|
2388 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
2389 |
self wordAtLine:line col:col do:[ |
|
2390 |
:beginLine :beginCol :endLine :endCol :style | |
|
2391 |
||
2392 |
(line > list size) ifTrue:[ |
|
2393 |
"break out" |
|
2394 |
searching := false |
|
2395 |
] ifFalse:[ |
|
2396 |
line := endLine. |
|
2397 |
col := endCol + 1. |
|
2398 |
] |
|
6152 | 2399 |
] |
6154 | 2400 |
]. |
6152 | 2401 |
]. |
2402 |
self cursorLine:line col:col |
|
4707 | 2403 |
] |
6154 | 2404 |
|
2405 |
"Modified: / 11-05-2017 / 17:50:47 / stefan" |
|
121 | 2406 |
! |
2407 |
||
499 | 2408 |
cursorToPreviousWord |
2409 |
"move the cursor to the beginning of this or the previous word" |
|
2410 |
||
6154 | 2411 |
|col line searching| |
499 | 2412 |
|
2413 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2414 |
:beginLine :beginCol :endLine :endCol :style | |
2415 |
||
2416 |
line := beginLine. |
|
2417 |
col := beginCol. |
|
2418 |
style == #wordLeft ifTrue:[ |
|
2419 |
col := col + 1 |
|
2420 |
]. |
|
2421 |
||
2422 |
(cursorLine == line |
|
2423 |
and:[cursorCol == col]) ifTrue:[ |
|
2424 |
searching := true. |
|
2425 |
||
2426 |
col > 1 ifTrue:[ |
|
2427 |
col := col - 1. |
|
2428 |
]. |
|
2429 |
||
2430 |
[searching] whileTrue:[ |
|
2431 |
(col == 1) ifTrue:[ |
|
2432 |
line == 1 ifTrue:[ |
|
2433 |
searching := false |
|
2434 |
] ifFalse:[ |
|
2435 |
line := line - 1. |
|
6154 | 2436 |
col := (list at:line) size + 1. |
2437 |
col ~~ 1 ifTrue:[ |
|
2438 |
"at end of word in previous line" |
|
2439 |
searching := false. |
|
2440 |
]. |
|
6152 | 2441 |
] |
2442 |
] ifFalse:[ |
|
2443 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2444 |
self wordAtLine:line col:col do:[ |
|
2445 |
:beginLine :beginCol :endLine :endCol :style | |
|
2446 |
||
2447 |
line := beginLine. |
|
2448 |
col := beginCol. |
|
2449 |
style == #wordLeft ifTrue:[ |
|
2450 |
col := col + 1 |
|
2451 |
]. |
|
2452 |
searching := false. |
|
2453 |
] |
|
2454 |
] ifTrue:[ |
|
2455 |
col := col - 1 |
|
2456 |
] |
|
2457 |
] |
|
2458 |
] |
|
2459 |
]. |
|
2460 |
self cursorLine:line col:col |
|
499 | 2461 |
] |
2462 |
||
6154 | 2463 |
"Created: / 08-03-1996 / 21:52:48 / cg" |
2464 |
"Modified (format): / 11-05-2017 / 17:45:11 / stefan" |
|
499 | 2465 |
! |
2466 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2467 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2468 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2469 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2470 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2471 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2472 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2473 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2474 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2475 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2476 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2477 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2478 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2479 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2480 |
"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
|
2481 |
|
5856 | 2482 |
|wasOn nv nl cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2483 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2484 |
cursorLine isNil ifTrue:[ |
5850 | 2485 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2486 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2487 |
nl := cursorLine - n. |
5850 | 2488 |
nl < 1 ifTrue:[ |
5858 | 2489 |
|generateTextBeforeStartHook| |
5890 | 2490 |
|
5856 | 2491 |
cursorColBefore := cursorCol. |
5858 | 2492 |
(generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[ |
2493 |
nl := generateTextBeforeStartHook value:nl |
|
5890 | 2494 |
]. |
5850 | 2495 |
nl := nl max:1 |
2496 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2497 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2498 |
(nl ~~ cursorLine) ifTrue: [ |
5850 | 2499 |
wasOn := self hideCursor. |
2500 |
cursorVisibleLine notNil ifTrue:[ |
|
2501 |
nv := cursorVisibleLine - n. |
|
2502 |
nv < 1 ifTrue:[ |
|
6339 | 2503 |
self scrollUpLines:(nv negated + 1) |
5850 | 2504 |
]. |
2505 |
]. |
|
5856 | 2506 |
self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol). |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2507 |
"/ wasOn ifTrue:[self showCursor]. |
5850 | 2508 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2509 |
] |
672 | 2510 |
|
6339 | 2511 |
"Modified: / 22-05-1996 / 18:28:11 / cg" |
2512 |
"Modified: / 13-06-2018 / 22:45:32 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2513 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2514 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2515 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2516 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2517 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2518 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2519 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2520 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2521 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2522 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2523 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2524 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2525 |
|
676 | 2526 |
newCol := colNr. |
2527 |
(newCol < 1) ifTrue:[ |
|
6152 | 2528 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2529 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2530 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2531 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2532 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2533 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2534 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2535 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2536 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2537 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2538 |
"put cursor to position next to x/y coordinate in view" |
121 | 2539 |
|
2540 |
|line col| |
|
2541 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2542 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2543 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2544 |
self cursorVisibleLine:line col:col. |
121 | 2545 |
! |
2546 |
||
2547 |
drawCursor |
|
2548 |
"draw the cursor if shown and cursor is visible. |
|
2549 |
(but not, if there is a selection - to avoid confusion)" |
|
2550 |
||
2551 |
shown ifTrue:[ |
|
6152 | 2552 |
cursorVisibleLine notNil ifTrue:[ |
2553 |
self hasSelection ifFalse:[ |
|
2554 |
self drawCursorCharacter |
|
2555 |
] |
|
2556 |
] |
|
121 | 2557 |
] |
2558 |
! |
|
2559 |
||
2560 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2561 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2562 |
of cursor should be drawn. |
5787 | 2563 |
Currently, supported are: #none, |
6031 | 2564 |
#block, #frame, #ibeam, #caret, #solidCaret |
2565 |
#bigCaret and #bigSolidCaret" |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2566 |
|
2570 | 2567 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2568 |
|
2569 |
self hasSelection ifTrue:[ |
|
6031 | 2570 |
" |
2571 |
hide cursor, if there is a selection |
|
2572 |
" |
|
2573 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2574 |
]. |
2575 |
||
1334 | 2576 |
cursorType == #none ifTrue:[ |
6031 | 2577 |
^ self |
1334 | 2578 |
]. |
2579 |
||
121 | 2580 |
cursorType == #block ifTrue:[ |
6031 | 2581 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
2582 |
^ self |
|
121 | 2583 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2584 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2585 |
y := self yOfVisibleLine:cursorVisibleLine. |
2586 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2587 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2588 |
cursorType == #frame ifTrue:[ |
6031 | 2589 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2590 |
||
2591 |
char := self characterUnderCursor asString. |
|
6068 | 2592 |
gc paint:bgColor. |
2593 |
gc displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
|
133 | 2594 |
] ifFalse:[ |
6031 | 2595 |
self paint:bgColor. |
2596 |
cursorType == #ibeam ifTrue:[ |
|
2597 |
x1 := x - 1. |
|
2598 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2599 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2600 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
6031 | 2601 |
^ self |
2602 |
]. |
|
2603 |
||
2604 |
cursorType == #Ibeam ifTrue:[ |
|
2605 |
x1 := x - 1. |
|
2606 |
y := y + 1. |
|
2607 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2608 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2609 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
2610 |
gc displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2611 |
gc displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
6031 | 2612 |
^ self |
2613 |
]. |
|
2614 |
||
2615 |
y := y + fontHeight - 3. |
|
2616 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2617 |
w := (fontWidth * 2 // 3) max:4. |
|
2618 |
y2 := y + w + (w//2). |
|
2619 |
] ifFalse:[ |
|
2620 |
w := (fontWidth // 2) max:4. |
|
2621 |
y2 := y + w. |
|
2622 |
]. |
|
2623 |
x1 := x - w. |
|
2624 |
x2 := x + w. |
|
2625 |
||
2626 |
oldClip := self clippingBoundsOrNil. |
|
2627 |
self clippingBounds:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2628 |
||
2629 |
cursorType == #caret ifTrue:[ |
|
6068 | 2630 |
gc lineWidth:2. |
2631 |
gc displayLineFromX:x1 y:y2 toX:x y:y. |
|
2632 |
gc displayLineFromX:x y:y toX:x2 y:y2. |
|
6031 | 2633 |
] ifFalse:[ |
2634 |
"anything else: solidCaret" |
|
2635 |
||
6068 | 2636 |
gc fillPolygon:(Array with:(x1 @ y2) |
2637 |
with:(x @ y) |
|
2638 |
with:(x2 @ y2)) |
|
6031 | 2639 |
]. |
2640 |
||
2641 |
self clippingBounds:oldClip |
|
121 | 2642 |
]. |
6068 | 2643 |
gc paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2644 |
|
2088 | 2645 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2646 |
! |
2647 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2648 |
drawCursorCharacter |
3160 | 2649 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2650 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2651 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2652 |
|
3160 | 2653 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2654 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2655 |
and:[self isReadOnly not]]) ifTrue:[ |
6152 | 2656 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2657 |
] ifFalse:[ |
6152 | 2658 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2659 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2660 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2661 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2662 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2663 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2664 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2665 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2666 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2667 |
self hasSelection ifTrue:[ |
6152 | 2668 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2669 |
]. |
2670 |
cursorType == #none ifTrue:[ |
|
6152 | 2671 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2672 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2673 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2674 |
|
2675 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2676 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2677 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2678 |
drawNoFocusCursor |
3160 | 2679 |
"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
|
2680 |
|
1334 | 2681 |
|cType| |
2682 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2683 |
self hasSelection ifTrue:[ |
6152 | 2684 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2685 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2686 |
|
1334 | 2687 |
cType := cursorTypeNoFocus ? cursorType. |
2688 |
cType == #none ifTrue:[ |
|
6152 | 2689 |
^ self undrawCursor |
1334 | 2690 |
]. |
2691 |
||
2692 |
cType == #block ifTrue:[ |
|
6152 | 2693 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2694 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2695 |
|
1334 | 2696 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2697 |
||
2698 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2699 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2700 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2701 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2702 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2703 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2704 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2705 |
self makeLineVisible:aLineNumber. |
2951 | 2706 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2707 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2708 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2709 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2710 |
hideCursor |
1833 | 2711 |
"make cursor invisible if currently invisible" |
2712 |
||
2713 |
^ self cursorShown:false |
|
2714 |
||
2715 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2716 |
! |
2717 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2718 |
makeCursorVisible |
3160 | 2719 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2720 |
(i.e. to have cursorLine in visible area)" |
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 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2723 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2724 |
cursorLine notNil ifTrue:[ |
6152 | 2725 |
line := cursorLine. |
2726 |
col := cursorCol. |
|
2727 |
" |
|
2728 |
if there is a selection, its better to |
|
2729 |
have its start being visible, instead of the end |
|
2730 |
" |
|
2731 |
(selectionStartLine notNil |
|
2732 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2733 |
expandingTop ~~ false ifTrue:[ |
|
2734 |
line := selectionStartLine. |
|
2735 |
col := selectionStartCol. |
|
2736 |
] ifFalse:[ |
|
2737 |
line := selectionEndLine. |
|
2738 |
col := selectionEndCol |
|
2739 |
] |
|
2740 |
]. |
|
2741 |
self makeLineVisible:line. |
|
2742 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2743 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2744 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2745 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2746 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2747 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2748 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2749 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2750 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2751 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2752 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2753 |
flag ifTrue:[self showCursor] |
121 | 2754 |
! |
2755 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2756 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2757 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2758 |
|
2815 | 2759 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2760 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2761 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2762 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2763 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2764 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2765 |
|
3303 | 2766 |
"/ self assert:(lineNr notNil). |
2767 |
||
2768 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2769 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2770 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2771 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2772 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2773 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2774 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2775 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2776 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2777 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2778 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2779 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2780 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2781 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2782 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2783 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2784 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2785 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2786 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2787 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2788 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2789 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2790 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2791 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2792 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2793 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2794 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2795 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2796 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2797 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2798 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2799 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2800 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2801 |
|
1833 | 2802 |
^ self cursorShown:true |
2803 |
||
2804 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2805 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2806 |
|
5761 | 2807 |
singleQuoteSelection |
2808 |
"place single quotes around the selected text" |
|
2809 |
||
2810 |
|line1 col1 line2 col2| |
|
2811 |
||
2812 |
line1 := self selectionStartLine. |
|
2813 |
col1 := self selectionStartCol. |
|
2814 |
line2 := self selectionEndLine. |
|
2815 |
col2 := self selectionEndCol. |
|
2816 |
(line1 notNil |
|
6152 | 2817 |
and:[ col1 notNil |
2818 |
and:[ line2 notNil |
|
2819 |
and:[ col2 notNil ]]]) |
|
5761 | 2820 |
ifTrue:[ |
6152 | 2821 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
2822 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2823 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
5761 | 2824 |
] ifFalse:[ |
6262 | 2825 |
self beepInEditor. |
5761 | 2826 |
] |
2827 |
||
2828 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2829 |
! |
|
2830 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2831 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2832 |
"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
|
2833 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2834 |
|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
|
2835 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2836 |
cursorVisibleLine notNil ifTrue:[ |
6031 | 2837 |
prevCol := cursorCol - 1. |
2838 |
||
2839 |
"/ if there is any italic stuff in the cursor line, |
|
2840 |
"/ redraw it completely (because characters overlap). |
|
2841 |
cursorCol > 1 ifTrue:[ |
|
2842 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2843 |
line hasChangeOfEmphasis ifTrue:[ |
|
2844 |
line size >= (cursorCol-1) ifTrue:[ |
|
2845 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2846 |
line size >= (cursorCol) ifTrue:[ |
|
2847 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2848 |
line size >= (cursorCol+1) ifTrue:[ |
|
2849 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2850 |
]. |
|
2851 |
]. |
|
2852 |
]. |
|
2853 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2854 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2855 |
] |
|
2856 |
] |
|
2857 |
] |
|
2858 |
]. |
|
2859 |
||
2860 |
((cursorType == #caret) |
|
2861 |
or:[cursorType == #solidCaret |
|
2862 |
or:[cursorType == #bigSolidCaret |
|
2863 |
or:[cursorType == #bigCaret |
|
2864 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2865 |
"caret-cursor touches 4 characters" |
|
2866 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2867 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2868 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2869 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2870 |
] ifFalse:[ |
|
2871 |
"care for left margin" |
|
2872 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2873 |
]. |
|
2874 |
^ self |
|
2875 |
]. |
|
2876 |
||
2877 |
cursorType == #ibeam ifTrue:[ |
|
2878 |
"ibeam-cursor touches 2 characters" |
|
2879 |
cursorCol > 1 ifTrue:[ |
|
2880 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2881 |
] ifFalse:[ |
|
2882 |
"care for left margin" |
|
2883 |
super redrawVisibleLine:cursorVisibleLine. |
|
2884 |
]. |
|
2885 |
^ self |
|
2886 |
]. |
|
2887 |
||
2888 |
"block cursor is simple - just one character under cursor" |
|
2889 |
||
2890 |
"/ however, if italic characters are involved, we must care |
|
2891 |
"/ for the chars before/after the cursor. |
|
2892 |
"/ We redraw the part of the previous character which got |
|
2893 |
"/ detroyed by the block cursor. |
|
2894 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2895 |
||
2896 |
line := self visibleAt:cursorVisibleLine. |
|
2897 |
(line notNil and:[line isText]) ifTrue:[ |
|
2898 |
cursorCol > 1 ifTrue:[ |
|
2899 |
oldClip := self clippingBoundsOrNil. |
|
2900 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2901 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2902 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
|
2903 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2904 |
self clippingBounds:oldClip. |
|
2905 |
^ self. |
|
2906 |
]. |
|
2907 |
]. |
|
2908 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2909 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2910 |
|
2088 | 2911 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2912 |
! |
2913 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2914 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2915 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2916 |
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
|
2917 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2918 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2919 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2920 |
|
672 | 2921 |
validateCursorCol:col inLine:line |
674 | 2922 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2923 |
Here, no limits are enforced (and col is returned), |
5593 | 2924 |
but it may be redefined in EditFields or views which don't like the |
674 | 2925 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2926 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2927 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2928 |
|
1419 | 2929 |
"/ in ST80 mode, |
2707 | 2930 |
"/ the cursor may not be positioned beyond the |
2931 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2932 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2933 |
self st80EditMode ifTrue:[ |
6152 | 2934 |
l := (self listAt:line). |
2935 |
max := l size + 1. |
|
2936 |
col > max ifTrue:[ |
|
2937 |
^ max |
|
2938 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2939 |
]. |
672 | 2940 |
^ col |
2941 |
||
1419 | 2942 |
"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
|
2943 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2944 |
! |
2945 |
||
2946 |
validateCursorLine:line |
|
6171 | 2947 |
"check if line is a valid cursor line; return a fixed line-nr if not. |
3160 | 2948 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2949 |
redefined in views which don't like the cursor to be positioned |
674 | 2950 |
behind the end of the text (vi/st-80 behavior), or want to |
2951 |
skip reserved regions" |
|
2952 |
||
1419 | 2953 |
"/ |
2954 |
"/ in st80Mode, the cursor may not be positioned |
|
5787 | 2955 |
"/ beyond the last line |
6091 | 2956 |
"/ (but it must be possible to place it on one line below the last one |
5367 | 2957 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
1419 | 2958 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2959 |
self st80EditMode ifTrue:[ |
6091 | 2960 |
^ (line min:(list size + 1)) max:1 |
1419 | 2961 |
]. |
674 | 2962 |
^ line |
2963 |
||
6091 | 2964 |
"Created: / 22-05-1996 / 18:22:23 / cg" |
2965 |
"Modified: / 20-06-1998 / 18:19:26 / cg" |
|
2966 |
"Modified (comment): / 11-02-2017 / 09:12:37 / cg" |
|
6171 | 2967 |
"Modified (comment): / 19-06-2017 / 16:25:27 / mawalch" |
672 | 2968 |
! |
2969 |
||
121 | 2970 |
withCursorOffDo:aBlock |
2971 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2972 |
||
2973 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
6152 | 2974 |
^ aBlock value |
121 | 2975 |
]. |
2976 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2977 |
aBlock ensure:[ |
6152 | 2978 |
self showCursor |
121 | 2979 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2980 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2981 |
|
2589 | 2982 |
!EditTextView methodsFor:'drag & drop'! |
2983 |
||
2984 |
allowDrop:aBoolean |
|
3236 | 2985 |
"enable/disable drop support" |
2986 |
||
2589 | 2987 |
aBoolean ifFalse:[ |
6152 | 2988 |
dropTarget := nil. |
2589 | 2989 |
] ifTrue:[ |
6152 | 2990 |
dropTarget isNil ifTrue:[ |
2991 |
dropTarget := DropTarget |
|
2992 |
receiver:self |
|
2993 |
argument:nil |
|
2994 |
dropSelector:#'drop:' |
|
2995 |
canDropSelector:#'canDrop:' |
|
2996 |
] |
|
3236 | 2997 |
]. |
2998 |
! |
|
2999 |
||
3412 | 3000 |
canDrop:aDropContext |
3001 |
"public from d&d. |
|
3002 |
I accept textObjects and fileObjects only." |
|
3003 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
3004 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 3005 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
3006 |
^ self canDropObjects:aDropContext dropObjects |
|
3007 |
||
3008 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
3009 |
! |
|
3010 |
||
3011 |
canDropObjects:aCollectionOfDropObjects |
|
3012 |
"public from d&d. |
|
3013 |
I accept textObjects and fileObjects only." |
|
2589 | 3014 |
|
3015 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
3016 |
||
3412 | 3017 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
3018 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
3019 |
||
3020 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
3021 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
3022 |
! |
|
3023 |
||
3024 |
drop:aDropContext |
|
3025 |
"public from d&d. |
|
3026 |
drop objects (new API)" |
|
3027 |
||
3028 |
self dropObjects:(aDropContext dropObjects) |
|
3029 |
||
3030 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
3031 |
! |
|
3032 |
||
3033 |
dropFileObject:aDropObject |
|
2589 | 3034 |
"drop objects |
3236 | 3035 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
3036 |
||
4136 | 3037 |
|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
|
3038 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3039 |
pasteWhat := #name. |
3412 | 3040 |
|
3041 |
fn := aDropObject asFilename. |
|
3042 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
6152 | 3043 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
3044 |
(enforcedDropMode notNil |
|
3045 |
and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[ |
|
3046 |
pasteWhat := enforcedDropMode. |
|
3047 |
] ifFalse:[ |
|
3048 |
sensor := self sensor. |
|
3049 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
|
3050 |
pasteWhat := #name. |
|
3051 |
] ifFalse:[ |
|
3052 |
(sensor metaDown) ifTrue:[ |
|
3053 |
pasteWhat := #contents. |
|
3054 |
] ifFalse:[ |
|
3055 |
dontAskAgainHolder := false asValue. |
|
3056 |
answer := Dialog |
|
3057 |
confirmWithCancel:(resources |
|
3058 |
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.' |
|
3059 |
with:fn name allBold) |
|
3060 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
|
3061 |
values:#( nil #name #contents ) |
|
3062 |
default:#contents |
|
3063 |
check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder |
|
3064 |
title:(resources string:'Drop What'). |
|
3065 |
answer isNil ifTrue:[ ^ self ]. |
|
3066 |
||
3067 |
dontAskAgainHolder value ifTrue:[ |
|
3068 |
UserPreferences current enforcedDropModeForFiles:#contents |
|
3069 |
]. |
|
3070 |
pasteWhat := answer. |
|
3071 |
] |
|
3072 |
] |
|
3073 |
]. |
|
3886 | 3074 |
]. |
3075 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3076 |
pasteWhat == #name ifTrue:[ |
6152 | 3077 |
text := fn pathName |
3886 | 3078 |
] ifFalse:[ |
6152 | 3079 |
self withWaitCursorDo:[ |
3080 |
text := fn contentsAsString |
|
3081 |
]. |
|
3082 |
(app := self application) notNil ifTrue:[ |
|
3083 |
app droppedFile:fn in:self |
|
3084 |
]. |
|
5787 | 3085 |
]. |
3086 |
||
3087 |
self |
|
6152 | 3088 |
undoablePaste:text |
3089 |
info:'Drop File'. |
|
3412 | 3090 |
|
3091 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 3092 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 3093 |
! |
3094 |
||
3095 |
dropObject:aDropObject |
|
3096 |
"drop objects |
|
3097 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
3098 |
||
3415 | 3099 |
|text| |
3100 |
||
3412 | 3101 |
(aDropObject isFileObject) ifTrue:[ |
6152 | 3102 |
self dropFileObject:aDropObject |
3412 | 3103 |
] ifFalse:[ |
6152 | 3104 |
aDropObject isTextObject ifTrue:[ |
3105 |
text := aDropObject theObject. |
|
3106 |
text isStringCollection ifTrue:[ |
|
3107 |
text := text asStringWithoutFinalCR |
|
3108 |
]. |
|
3109 |
] ifFalse:[ |
|
3110 |
text := aDropObject theObject asString |
|
3111 |
]. |
|
3112 |
self |
|
3113 |
undoablePaste:text |
|
3114 |
info:'Drop'. |
|
3412 | 3115 |
]. |
3116 |
||
3117 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 3118 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 3119 |
! |
3120 |
||
3121 |
dropObjects:aCollectionOfDropObjects |
|
3122 |
"public from d&d. |
|
3123 |
drop objects (old API)" |
|
3124 |
||
3868 | 3125 |
aCollectionOfDropObjects do:[:el | |
6152 | 3126 |
self dropObject:el |
3412 | 3127 |
]. |
3128 |
||
3129 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
3130 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 3131 |
! ! |
3132 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3133 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3134 |
|
5761 | 3135 |
applyConverterToSelection:converter |
3136 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3137 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3138 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3139 |
|
6226 | 3140 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
3141 |
||
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3142 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3143 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3144 |
line1 isNil ifTrue:[ |
6152 | 3145 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
3146 |
line1 notNil ifTrue:[ |
|
3147 |
line2 := line1 |
|
3148 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3149 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3150 |
line1 notNil ifTrue:[ |
6152 | 3151 |
line1 to:line2 do:[:lineNr | |
3152 |
|line col1 col2 newLine| |
|
3153 |
||
3154 |
line := (self listAt:lineNr) copy. |
|
6548 | 3155 |
line size ~~ 0 ifTrue:[ |
6152 | 3156 |
lineNr == line1 ifTrue:[ |
3157 |
col1 := selectionStartCol. |
|
3158 |
] ifFalse:[ |
|
3159 |
col1 := 1. |
|
3160 |
]. |
|
3161 |
lineNr == line2 ifTrue:[ |
|
3162 |
col2 := selectionEndCol. |
|
3163 |
] ifFalse:[ |
|
3164 |
col2 := (self listAt:lineNr) size. |
|
3165 |
]. |
|
3166 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
|
3167 |
self withoutRedrawAt:lineNr put:newLine. |
|
3168 |
self invalidateLine:lineNr. |
|
3169 |
]. |
|
3170 |
]. |
|
5761 | 3171 |
] |
3172 |
||
3173 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
6226 | 3174 |
"Modified: / 11-11-2017 / 12:55:25 / cg" |
6548 | 3175 |
"Modified: / 01-03-2019 / 14:54:42 / Claus Gittinger" |
5761 | 3176 |
! |
3177 |
||
3178 |
convertSelectionToLowercase |
|
3179 |
"to-lower selected text" |
|
3180 |
||
3181 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3182 |
col1 to:col2 do:[:col | |
3183 |
|ch| |
|
3184 |
||
3185 |
ch := line at:col. |
|
3186 |
line at:col put:ch asLowercase. |
|
3187 |
]. |
|
3188 |
line. |
|
5761 | 3189 |
]. |
3190 |
||
3191 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
3192 |
! |
|
3193 |
||
3194 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
3195 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
3196 |
||
3197 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
6152 | 3198 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
3199 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
3200 |
||
3201 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
3202 |
col1 to:col2 do:[:col | |
|
3203 |
|ch| |
|
3204 |
||
3205 |
ch := line at:col. |
|
3206 |
ch isUppercase ifTrue:[ |
|
3207 |
isAllLower := false. |
|
3208 |
col == col1 ifTrue:[ |
|
3209 |
isLowerFirst := false. |
|
3210 |
]. |
|
3211 |
] ifFalse:[ |
|
3212 |
ch isLowercase ifTrue:[ |
|
3213 |
isAllUpper := false. |
|
3214 |
col == col1 ifTrue:[ |
|
3215 |
isUpperFirst := false. |
|
3216 |
]. |
|
3217 |
] |
|
3218 |
]. |
|
3219 |
]. |
|
3220 |
||
3221 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
3222 |
isLowerFirst ifTrue:[ |
|
3223 |
makeUppercaseFirst := true. |
|
3224 |
] ifFalse:[ |
|
3225 |
"/ must remember where we come from - otherwise, we end up |
|
3226 |
"/ in upperFirst - lowerFirst cycle. |
|
3227 |
"/ think about a good place to store this state |
|
3228 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
3229 |
makeLowercaseFirst := true. |
|
3230 |
] ifFalse:[ |
|
3231 |
isAllUpper ifTrue:[ |
|
3232 |
makeLowercase := true. |
|
3233 |
] ifFalse:[ |
|
3234 |
makeUppercase := true. |
|
3235 |
] |
|
3236 |
] |
|
3237 |
]. |
|
3238 |
makeUppercaseFirst ifTrue:[ |
|
3239 |
line at:col1 put:(line at:col1) asUppercase. |
|
3240 |
] ifFalse:[ |
|
3241 |
makeLowercaseFirst ifTrue:[ |
|
3242 |
line at:col1 put:(line at:col1) asLowercase. |
|
3243 |
] ifFalse:[ |
|
3244 |
col1 to:col2 do:[:col | |
|
3245 |
|ch| |
|
3246 |
||
3247 |
ch := line at:col. |
|
3248 |
ch := makeLowercase |
|
3249 |
ifTrue:[ ch asLowercase ] |
|
3250 |
ifFalse:[ |
|
3251 |
makeUppercase |
|
3252 |
ifTrue:[ ch asUppercase ] |
|
3253 |
ifFalse:[ |
|
3254 |
col == col1 |
|
3255 |
ifTrue:[ ch asUppercase ] |
|
3256 |
ifFalse:[ ch asLowercase ] |
|
3257 |
] |
|
3258 |
]. |
|
3259 |
line at:col put:ch. |
|
3260 |
]. |
|
3261 |
]. |
|
3262 |
]. |
|
3263 |
line |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3264 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3265 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3266 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 3267 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
3268 |
! |
|
3269 |
||
3270 |
convertSelectionToUppercase |
|
3271 |
"to-upper selected text" |
|
3272 |
||
3273 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3274 |
col1 to:col2 do:[:col | |
3275 |
|ch| |
|
3276 |
||
3277 |
ch := line at:col. |
|
3278 |
line at:col put:ch asUppercase. |
|
3279 |
]. |
|
3280 |
line. |
|
5761 | 3281 |
]. |
3282 |
||
3283 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
3284 |
! |
|
3285 |
||
3286 |
convertSelectionToUppercaseFirst |
|
3287 |
"to-upperFirst selected text" |
|
3288 |
||
3289 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3290 |
|state| |
3291 |
||
3292 |
state := #first. |
|
3293 |
col1 to:col2 do:[:col | |
|
3294 |
|ch| |
|
3295 |
||
3296 |
ch := line at:col. |
|
3297 |
ch isSeparator ifFalse:[ |
|
3298 |
state == #first ifTrue:[ |
|
3299 |
line at:col put:ch asUppercase. |
|
3300 |
state := #skipRest |
|
3301 |
] |
|
3302 |
] ifTrue:[ |
|
3303 |
state := #first |
|
3304 |
] |
|
3305 |
]. |
|
3306 |
line. |
|
5761 | 3307 |
]. |
3308 |
||
3309 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3310 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3311 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3312 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3313 |
"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
|
3314 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3315 |
selectionStartLine notNil ifTrue:[ |
6152 | 3316 |
self setClipboardText:(self selection). |
3317 |
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
|
3318 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3319 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3320 |
"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
|
3321 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3322 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3323 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3324 |
"delete single character under cursor; does not merge lines" |
121 | 3325 |
|
3326 |
|wasOn| |
|
3327 |
||
3328 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3329 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3330 |
wasOn ifTrue:[self showCursor] |
3331 |
! |
|
3332 |
||
827 | 3333 |
deleteCharAtLine:lineNr col:colNr |
3334 |
"delete a single character at colNr in line lineNr" |
|
3335 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3336 |
self st80EditMode ifTrue:[ |
6152 | 3337 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3338 |
| wasOn | |
|
3339 |
wasOn := self hideCursor. |
|
3340 |
self |
|
3341 |
cursorReturn; |
|
3342 |
cursorCol:1; |
|
3343 |
deleteCharBeforeCursor. |
|
3344 |
wasOn ifTrue:[ self showCursor]. |
|
3345 |
^ self. |
|
3346 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3347 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3348 |
|
827 | 3349 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3350 |
! |
|
3351 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3352 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3353 |
"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
|
3354 |
|
4592 | 3355 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3356 |
|
6050 | 3357 |
list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete. |
3358 |
||
121 | 3359 |
wasOn := self hideCursor. |
4814 | 3360 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
6050 | 3361 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
3362 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
|
3363 |
ln size < prevTab ifTrue:[ |
|
3364 |
ln := ln , (String new:prevTab withAll:Character space). |
|
3365 |
]. |
|
3366 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3367 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3368 |
cursorCol > prevTab ifTrue:[ |
|
3369 |
self st80EditMode ifTrue:[ |
|
3370 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3371 |
"/ not allow a cursor position beyond the end of line, |
|
3372 |
"/ so ensure that cursorLine:col: will force us to the beginning of the line |
|
3373 |
originalLine size < prevTab ifTrue:[ |
|
3374 |
self checkForExistingLine:cursorLine. |
|
3375 |
self basicListAt:cursorLine put:ln |
|
3376 |
] |
|
3377 |
]. |
|
3378 |
self cursorLine:cursorLine col:prevTab. |
|
3379 |
wasOn ifTrue:[ self showCursor ]. |
|
3380 |
^ self |
|
3381 |
]. |
|
3382 |
] ifFalse:[ |
|
3383 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
3384 |
self cursorLine:cursorLine col:prevTab. |
|
3385 |
wasOn ifTrue:[ self showCursor ]. |
|
3386 |
^ self. |
|
3387 |
] |
|
3388 |
]. |
|
827 | 3389 |
]. |
3390 |
||
2491 | 3391 |
"/ (autoIndent |
3392 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3393 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3394 |
"/ ifTrue:[ |
3395 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3396 |
"/ |
|
3397 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3398 |
"/ ln := list at:cursorLine. |
|
3399 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3400 |
"/ soCol := 1 |
|
3401 |
"/ ] |
|
3402 |
"/ ] |
|
3403 |
"/ ] ifFalse:[ |
|
6050 | 3404 |
soCol := 1. |
2491 | 3405 |
"/ ]. |
3406 |
||
1419 | 3407 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
6050 | 3408 |
" |
3409 |
somewhere in the middle of a line |
|
3410 |
" |
|
3411 |
self cursorLeft. |
|
3412 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3413 |
] ifFalse:[ |
6050 | 3414 |
" |
3415 |
at begin of line - merge with previous line; |
|
3416 |
except for the very first line. |
|
3417 |
" |
|
3418 |
(cursorLine == 1) ifFalse:[ |
|
3419 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3420 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3421 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3422 |
"/ we are beyond the end of the text. |
|
3423 |
"/ move the cursor to the previous line. |
|
3424 |
self cursorLine:lineNrAboveCursor col:1. |
|
3425 |
] ifFalse:[ |
|
3426 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3427 |
] |
|
3428 |
] |
|
3429 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3430 |
]. |
827 | 3431 |
wasOn ifTrue:[ self showCursor ] |
3432 |
||
1419 | 3433 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 3434 |
! |
3435 |
||
3436 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3437 |
"delete characters from colNr up to the end in line lineNr" |
|
3438 |
||
3439 |
|line| |
|
3440 |
||
3441 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
6152 | 3442 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3443 |
] |
3444 |
||
3445 |
! |
|
3446 |
||
4458 | 3447 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3448 |
"delete characters from startCol to endCol in line lineNr" |
|
3449 |
||
3450 |
|deleted| |
|
3451 |
||
3452 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3453 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3454 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3455 |
! |
|
3456 |
||
827 | 3457 |
deleteCharsAtLine:lineNr toCol:colNr |
3458 |
"delete characters from start up to colNr in line lineNr" |
|
3459 |
||
3460 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3461 |
||
3462 |
||
121 | 3463 |
! |
3464 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3465 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3466 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3467 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3468 |
self deleteLine:cursorLine |
121 | 3469 |
! |
3470 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3471 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3472 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3473 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3474 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3475 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3476 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3477 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3478 |
col1 == 0 ifTrue:[ |
6152 | 3479 |
line1 := line1 - 1. |
3480 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3481 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3482 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3483 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3484 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3485 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3486 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3487 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3488 |
|
2954 | 3489 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3490 |
"delete all text from startLine/startCol to endLine/endCol - |
|
6163 | 3491 |
joining lines if necessary" |
2954 | 3492 |
|
3493 |
|line newLine lineSize nMore| |
|
3494 |
||
3495 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3496 |
list isNil ifTrue:[^ self]. |
|
3497 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3498 |
||
3499 |
(startLine == endLine) ifTrue:[ |
|
6152 | 3500 |
"/ delete chars within a line |
3501 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3502 |
^ self |
|
2954 | 3503 |
]. |
3504 |
||
3505 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
6152 | 3506 |
"/ delete full lines only |
3507 |
endLine > startLine ifTrue:[ |
|
3508 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3509 |
]. |
|
3510 |
^ self |
|
2954 | 3511 |
]. |
3512 |
||
3513 |
"/ delete right rest of 1st line |
|
4786 | 3514 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3515 |
|
3516 |
"/ delete the inner lines ... |
|
3517 |
endLine > (startLine + 1) ifTrue:[ |
|
6152 | 3518 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3519 |
]. |
3520 |
||
3521 |
(endCol ~~ 0) ifTrue:[ |
|
6152 | 3522 |
"/ delete the left rest of the last line |
3523 |
||
3524 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3525 |
||
3526 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3527 |
startLine <= list size ifTrue:[ |
|
3528 |
line := list at:startLine. |
|
3529 |
lineSize := line size. |
|
3530 |
(startCol > lineSize) ifTrue:[ |
|
3531 |
newLine := line. |
|
3532 |
line isNil ifTrue:[ |
|
3533 |
newLine := String new:(startCol - 1) |
|
3534 |
] ifFalse:[ |
|
3535 |
nMore := startCol - 1 - lineSize. |
|
3536 |
nMore > 0 ifTrue:[ |
|
3537 |
newLine := line , (line species new:nMore) |
|
3538 |
] |
|
3539 |
]. |
|
3540 |
newLine ~~ line ifTrue:[ |
|
3541 |
self basicListAt:startLine put:newLine. |
|
3542 |
]. |
|
3543 |
"/ TODO: remember old maxwidth of linerange, |
|
3544 |
"/ only clear widthOfWidestLine, if this max |
|
3545 |
"/ length was (one of) the longest. |
|
3546 |
"/ avoids slow delete with huge texts. |
|
3547 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3548 |
self textChanged. |
|
3549 |
] |
|
3550 |
] |
|
2954 | 3551 |
]. |
3552 |
||
3553 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3554 |
self mergeLine:startLine removeBlanks:false |
|
3555 |
||
4225 | 3556 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3557 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
6163 | 3558 |
"Modified (comment): / 30-05-2017 / 17:34:03 / mawalch" |
2954 | 3559 |
! |
3560 |
||
4458 | 3561 |
deleteFromLine:startLineNr toLine:endLineNr |
3562 |
"delete some lines" |
|
3563 |
||
3564 |
|deleted| |
|
3565 |
||
3566 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3567 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3568 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3569 |
! |
|
3570 |
||
827 | 3571 |
deleteLine:lineNr |
3572 |
"delete line" |
|
3573 |
||
3574 |
self deleteFromLine:lineNr toLine:lineNr |
|
3575 |
||
3576 |
||
3577 |
! |
|
3578 |
||
4458 | 3579 |
deleteLineWithoutRedraw:lineNr |
3580 |
"delete line - no redraw; |
|
3581 |
return true, if something was really deleted" |
|
3582 |
||
3583 |
|deleted ret| |
|
3584 |
||
3585 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3586 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3587 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3588 |
^ ret. |
|
3589 |
! |
|
3590 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3591 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3592 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3593 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3594 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3595 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3596 |
|
4771 | 3597 |
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
|
3598 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3599 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3600 |
(endLine > list size) ifTrue:[ |
6152 | 3601 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3602 |
] ifFalse:[ |
6152 | 3603 |
lastLine := endLine |
4771 | 3604 |
]. |
3605 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3606 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3607 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3608 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3609 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3610 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3611 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3612 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3613 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3614 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3615 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3616 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3617 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3618 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3619 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3620 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3621 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3622 |
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
|
3623 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3624 |
selectionStartLine notNil ifTrue:[ |
6152 | 3625 |
wasOn := self hideCursor. |
3626 |
||
3627 |
startLine := selectionStartLine. |
|
3628 |
startCol := selectionStartCol. |
|
3629 |
endLine := selectionEndLine. |
|
3630 |
endCol := selectionEndCol. |
|
3631 |
self unselectWithoutRedraw. |
|
3632 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3633 |
self setCursorLine:startLine col:startCol. |
|
3634 |
||
3635 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3636 |
] |
121 | 3637 |
! |
3638 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3639 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3640 |
"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
|
3641 |
|
2952 | 3642 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3643 |
|
3799 | 3644 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3645 |
cursorCol <= 1 ifTrue:[ |
6152 | 3646 |
self deleteCharBeforeCursor. |
3647 |
^ self |
|
5361 | 3648 |
]. |
3799 | 3649 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3650 |
wasOn := self hideCursor. |
5787 | 3651 |
self |
6152 | 3652 |
undoableDo:[ |
3653 |
endCol := cursorCol-1. |
|
3654 |
endLine := cursorLine. |
|
3655 |
self cursorToPreviousWord. |
|
3656 |
beginCol := cursorCol. |
|
3657 |
beginLine := cursorLine. |
|
3658 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3659 |
self cursorLine:cursorLine col:beginCol. |
|
3660 |
] |
|
3661 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3662 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3663 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3664 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3665 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3666 |
|
5761 | 3667 |
indentSelectionBy1 |
3668 |
"indent selected line-range |
|
3669 |
by 1 space (i.e. to the right)" |
|
3670 |
||
3671 |
self indentBy:1 |
|
3672 |
||
3673 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3674 |
! |
|
3675 |
||
4458 | 3676 |
insert:aCharacter atLine:lineNr col:colNr |
3677 |
"insert a single character at lineNr/colNr; |
|
3678 |
set emphasis to character at current position" |
|
3679 |
||
3680 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3681 |
aCharacter ~~ Character cr ifTrue:[ |
|
6152 | 3682 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3683 |
] |
3684 |
! |
|
3685 |
||
121 | 3686 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3687 |
"insert a single character at cursor-position - advance cursor." |
121 | 3688 |
|
3689 |
|wasOn| |
|
3690 |
||
3691 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3692 |
aCharacter == Character tab ifTrue:[ |
6152 | 3693 |
"/ needs special care to advance cursor correctly |
3694 |
self insertTabAtCursor |
|
121 | 3695 |
] ifFalse:[ |
6152 | 3696 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3697 |
aCharacter == (Character cr) ifTrue:[ |
|
3698 |
self basicCursorReturn |
|
3699 |
] ifFalse:[ |
|
3700 |
self cursorRight. |
|
3701 |
]. |
|
121 | 3702 |
]. |
3703 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3704 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3705 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3706 |
! |
3707 |
||
641 | 3708 |
insertLine:aString before:lineNr |
3709 |
"insert the line aString before line lineNr" |
|
3710 |
||
3711 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3712 |
||
3713 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3714 |
! |
|
3715 |
||
155 | 3716 |
insertLines:aStringCollection before:lineNr |
3717 |
"insert a bunch before line lineNr" |
|
3718 |
||
3719 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3720 |
||
3721 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3722 |
! |
|
3723 |
||
4771 | 3724 |
insertLines:someText from:start to:end before:lineNr |
3725 |
"insert a bunch of lines before line lineNr. |
|
3726 |
The cursor position is left unchanged." |
|
3727 |
||
3728 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3729 |
srcY "{ Class: SmallInteger }" |
|
3730 |
dstY "{ Class: SmallInteger }" | |
|
3731 |
||
5357 | 3732 |
"wrong when pasting multiple lines" |
3733 |
false "autoIndent" ifTrue:[ |
|
6152 | 3734 |
indent := self leftIndentForLine:lineNr. |
3735 |
||
3736 |
text := someText |
|
3737 |
collect:[:ln||line| |
|
3738 |
ln notNil ifTrue:[ |
|
3739 |
line := ln withoutLeadingSeparators. |
|
3740 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3741 |
line := (String new:indent), line |
|
3742 |
]. |
|
3743 |
line |
|
3744 |
] ifFalse:[ |
|
3745 |
nil |
|
3746 |
] |
|
3747 |
]. |
|
4771 | 3748 |
] ifFalse:[ |
6152 | 3749 |
text := someText |
4771 | 3750 |
]. |
3751 |
||
3752 |
visLine := self listLineToVisibleLine:lineNr. |
|
3753 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
6152 | 3754 |
self withoutRedrawInsertLines:text |
3755 |
from:start to:end |
|
3756 |
before:lineNr. |
|
4771 | 3757 |
] ifFalse:[ |
6152 | 3758 |
nLines := end - start + 1. |
3759 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3760 |
self withoutRedrawInsertLines:text |
|
3761 |
from:start to:end |
|
3762 |
before:lineNr. |
|
3763 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3764 |
] ifFalse:[ |
|
3765 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3766 |
and:(firstLineShown + nLines + nLinesShown). |
|
3767 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3768 |
dstY := srcY + (nLines * fontHeight). |
|
3769 |
||
3770 |
"/ |
|
3771 |
"/ scroll ... |
|
3772 |
"/ |
|
3773 |
" |
|
3774 |
stupid: must catchExpose before inserting new |
|
3775 |
stuff - since catchExpose may perform redraws |
|
3776 |
" |
|
3777 |
self catchExpose. |
|
3778 |
self withoutRedrawInsertLines:text |
|
3779 |
from:start to:end |
|
3780 |
before:lineNr. |
|
3781 |
self |
|
3782 |
copyFrom:self |
|
3783 |
x:textStartLeft y:srcY |
|
3784 |
toX:textStartLeft y:dstY |
|
3785 |
width:w |
|
3786 |
height:(height - dstY) |
|
3787 |
async:true. |
|
3788 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3789 |
self waitForExpose |
|
3790 |
]. |
|
4771 | 3791 |
]. |
3792 |
widthOfWidestLine notNil ifTrue:[ |
|
6152 | 3793 |
text do:[:line | |
3794 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3795 |
] |
|
4771 | 3796 |
]. |
3797 |
self textChanged. |
|
3798 |
||
3799 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3800 |
! |
|
3801 |
||
654 | 3802 |
insertLines:lines withCR:withCr |
3160 | 3803 |
"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
|
3804 |
Cursor is moved behind insertion. |
641 | 3805 |
If withCr is true, append cr after last line" |
3806 |
||
3807 |
|start end nLines wasOn| |
|
3808 |
||
3809 |
lines notNil ifTrue:[ |
|
6152 | 3810 |
nLines := lines size. |
3811 |
(nLines == 1) ifTrue:[ |
|
3812 |
self insertStringAtCursor:(lines at:1). |
|
3813 |
withCr ifTrue:[ |
|
3814 |
self insertCharAtCursor:(Character cr) |
|
3815 |
] |
|
3816 |
] ifFalse:[ |
|
3817 |
(cursorCol ~~ 1) ifTrue:[ |
|
3818 |
self insertStringAtCursor:(lines at:1). |
|
3819 |
self insertCharAtCursor:(Character cr). |
|
3820 |
start := 2 |
|
3821 |
] ifFalse:[ |
|
3822 |
start := 1 |
|
3823 |
]. |
|
3824 |
withCr ifTrue:[ |
|
3825 |
end := nLines |
|
3826 |
] ifFalse:[ |
|
3827 |
end := nLines - 1 |
|
3828 |
]. |
|
3829 |
(start <= nLines) ifTrue:[ |
|
3830 |
(end >= start) ifTrue:[ |
|
3831 |
wasOn := self hideCursor. |
|
3832 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3833 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3834 |
wasOn ifTrue:[self showCursor]. |
|
3835 |
] |
|
3836 |
]. |
|
3837 |
withCr ifFalse:[ |
|
3838 |
"last line without cr" |
|
3839 |
self insertStringAtCursor:(lines at:nLines) |
|
3840 |
] |
|
3841 |
] |
|
641 | 3842 |
] |
654 | 3843 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3844 |
"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
|
3845 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3846 |
! |
3847 |
||
3848 |
insertLines:lines withCr:withCr |
|
3849 |
"insert a bunch of lines at cursor position. Cursor |
|
3850 |
is moved behind insertion. |
|
3851 |
If withCr is true, append cr after last line" |
|
3852 |
||
2363 | 3853 |
<resource:#obsolete> |
3854 |
||
1292 | 3855 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3856 |
self insertLines:lines withCR:withCr. |
|
3857 |
||
3858 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3859 |
! |
3860 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3861 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3862 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3863 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3864 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3865 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3866 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3867 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3868 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3869 |
self selectFromLine:startLine col:startCol |
6152 | 3870 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3871 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3872 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3873 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3874 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3875 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3876 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3877 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3878 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3879 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3880 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3881 |
col == 0 ifTrue:[ |
6152 | 3882 |
line > 1 ifTrue:[ |
3883 |
line := line - 1. |
|
3884 |
col := (self listAt:line) size + 1. |
|
3885 |
] ifFalse:[ |
|
3886 |
col := 1. |
|
3887 |
] |
|
5060 | 3888 |
]. |
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3889 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3890 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3891 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3892 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3893 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3894 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3895 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3896 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3897 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3898 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3899 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3900 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3901 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3902 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3903 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 3904 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3905 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3906 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3907 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3908 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3909 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3910 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3911 |
[start <= end] whileTrue:[ |
6152 | 3912 |
stop := aString indexOf:(Character cr) startingAt:start. |
3913 |
stop == 0 ifTrue:[ |
|
3914 |
stop := end + 1 |
|
3915 |
]. |
|
3916 |
subString := aString copyFrom:start to:(stop - 1). |
|
3917 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3918 |
(stop <= end) ifTrue:[ |
|
3919 |
c := c + subString size. |
|
3920 |
self insert:(Character cr) atLine:l col:c. |
|
3921 |
l := l + 1. |
|
3922 |
c := 1 |
|
3923 |
]. |
|
3924 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3925 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3926 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3927 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3928 |
! |
3929 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3930 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3931 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3932 |
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
|
3933 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3934 |
aString isNil ifTrue:[ |
6152 | 3935 |
"new:" |
3936 |
self insertCharAtCursor:(Character cr). |
|
3937 |
^ self |
|
105 | 3938 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3939 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 3940 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3941 |
]. |
3942 |
||
654 | 3943 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3944 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3945 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3946 |
! |
3947 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3948 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3949 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3950 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3951 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3952 |
shown ifTrue:[ |
6152 | 3953 |
gc font hasOverlappingCharacters ifTrue:[ |
3954 |
self invalidateLine:lineNr. |
|
3955 |
] ifFalse:[ |
|
3956 |
self redrawLine:lineNr from:colNr |
|
3957 |
] |
|
4190 | 3958 |
] |
3959 |
||
4191 | 3960 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3961 |
! |
3962 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3963 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3964 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3965 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3966 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3967 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3968 |
|
6548 | 3969 |
aString size ~~ 0 ifTrue:[ |
6152 | 3970 |
wasOn := self hideCursor. |
3971 |
(aString includes:Character tab) ifTrue:[ |
|
3972 |
self checkForExistingLine:cursorLine. |
|
3973 |
oldLen := (list at:cursorLine) size. |
|
3974 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3975 |
newLen := (list at:cursorLine) size. |
|
3976 |
deltaLen := newLen - oldLen. |
|
3977 |
] ifFalse:[ |
|
3978 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3979 |
deltaLen := aString size. |
|
3980 |
]. |
|
3981 |
self setCursorCol:(cursorCol + deltaLen). |
|
3982 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3983 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3984 |
|
6548 | 3985 |
"Modified: / 10-06-1998 / 20:43:52 / cg" |
3986 |
"Modified: / 01-03-2019 / 14:54:49 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3987 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3988 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3989 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3990 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3991 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3992 |
|wasOn nextTab| |
105 | 3993 |
|
121 | 3994 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3995 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3996 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3997 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3998 |
! |
3999 |
||
3542 | 4000 |
joinLines |
3890 | 4001 |
"join lines (remove line-break)" |
4002 |
||
3583 | 4003 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
4004 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
4005 |
self |
6152 | 4006 |
undoableDo:[ |
4007 |
|line col lineLen| |
|
4008 |
||
4009 |
line := cursorLine. |
|
4010 |
col := cursorCol. |
|
4011 |
lineLen := (list at:line) size. |
|
4012 |
col > lineLen ifTrue:[ |
|
4013 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
4014 |
] ifFalse:[ |
|
4015 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
4016 |
]. |
|
4017 |
self mergeLine:line removeBlanks:true. |
|
4018 |
self cursorLine:line col:col. |
|
4019 |
] |
|
4020 |
info:'Join' |
|
3542 | 4021 |
! |
4022 |
||
2952 | 4023 |
mergeLine:lineNr |
4024 |
"merge line lineNr with line lineNr+1" |
|
4025 |
||
4026 |
self mergeLine:lineNr removeBlanks:true |
|
4027 |
||
4028 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
4029 |
! |
|
4030 |
||
4458 | 4031 |
mergeLine:lineNr removeBlanks:removeBlanks |
4032 |
"merge line lineNr with line lineNr+1" |
|
4033 |
||
4034 |
|len| |
|
4035 |
||
4036 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4037 |
||
4038 |
len := (self listAt:lineNr) size. |
|
4039 |
self nonUndoableDo:[ |
|
6152 | 4040 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 4041 |
]. |
4042 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
4043 |
! |
|
4044 |
||
5761 | 4045 |
parenthizeSelection |
6198 | 4046 |
"place parentheses around the selected text. |
5761 | 4047 |
if already parenthized, de-parenthize it" |
4048 |
||
4049 |
self parenthizeSelectionWith:$( and:$) |
|
4050 |
||
4051 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
6198 | 4052 |
"Modified (comment): / 30-08-2017 / 20:17:46 / cg" |
5761 | 4053 |
! |
4054 |
||
2506 | 4055 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 4056 |
"if already parenthized, de-parenthize it" |
4057 |
||
5560 | 4058 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4059 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4060 |
self hasSelection ifFalse:[^ self]. |
5560 | 4061 |
startLine := selectionStartLine. |
4062 |
endLine := selectionEndLine. |
|
4063 |
startCol := selectionStartCol. |
|
4064 |
endCol := selectionEndCol. |
|
5787 | 4065 |
|
5560 | 4066 |
newSelectionEnd := endCol. |
5787 | 4067 |
|
5560 | 4068 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
6152 | 4069 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
4070 |
self deleteCharAtLine:endLine col:endCol. |
|
4071 |
newSelectionEnd := newSelectionEnd-1. |
|
4072 |
]. |
|
4073 |
self deleteCharAtLine:startLine col:startCol. |
|
4074 |
startLine == endLine ifTrue:[ |
|
4075 |
newSelectionEnd := newSelectionEnd-1. |
|
4076 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4077 |
] ifFalse:[ |
6152 | 4078 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4079 |
newSelectionEnd := newSelectionEnd+1. |
|
4080 |
self insert:openingCharacter atLine:startLine col:startCol. |
|
4081 |
startLine == endLine ifTrue:[ |
|
4082 |
newSelectionEnd := newSelectionEnd+1. |
|
4083 |
] |
|
3160 | 4084 |
]. |
4085 |
self |
|
6152 | 4086 |
selectFromLine:startLine col:startCol |
4087 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 4088 |
|
4089 |
"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
|
4090 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4091 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4092 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4093 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4094 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4095 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4096 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4097 |
|
5114 | 4098 |
NoModificationError handle:[:ex | |
6152 | 4099 |
^ self |
5114 | 4100 |
] do:[ |
6152 | 4101 |
lastLine := list size. |
4102 |
finished := false. |
|
4103 |
[finished] whileFalse:[ |
|
6469 | 4104 |
((lastLine <= 1) or:[lastLine = cursorLine]) ifTrue:[ |
6152 | 4105 |
finished := true |
4106 |
] ifFalse:[ |
|
4107 |
line := list at:lastLine. |
|
4108 |
line notNil ifTrue:[ |
|
4109 |
line isBlank ifTrue:[ |
|
4110 |
self basicListAt:lastLine put:nil. |
|
4111 |
line := nil |
|
4112 |
] |
|
4113 |
]. |
|
4114 |
line notNil ifTrue:[ |
|
4115 |
finished := true |
|
4116 |
] ifFalse:[ |
|
4117 |
lastLine := lastLine - 1 |
|
4118 |
] |
|
4119 |
] |
|
4120 |
]. |
|
4121 |
(lastLine ~~ list size) ifTrue:[ |
|
4122 |
list grow:lastLine. |
|
4123 |
"/ self textChanged |
|
4124 |
] |
|
118 | 4125 |
]. |
6469 | 4126 |
|
4127 |
"Modified: / 26-10-2018 / 18:22:26 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4128 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4129 |
|
4458 | 4130 |
replace:aCharacter atLine:lineNr col:colNr |
4131 |
"replace a single character at lineNr/colNr" |
|
4132 |
||
4133 |
|originalChar| |
|
4134 |
||
4135 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
4136 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
4137 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
4138 |
! |
|
4139 |
||
4713 | 4140 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 4141 |
|pattern replacePattern| |
4142 |
||
4143 |
pattern := patternArg string. |
|
4144 |
replacePattern := replacePatternArg string. |
|
4630 | 4145 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
6152 | 4146 |
self rememberSearchPattern:pattern. |
4147 |
self rememberSearchPattern:replacePattern. |
|
4148 |
LastSearchIgnoredCase := ignoreCase. |
|
4149 |
self |
|
4150 |
undoableDo:[ |
|
4151 |
all ifTrue:[ |
|
4152 |
self |
|
4153 |
replaceString:pattern |
|
4154 |
to:replacePattern |
|
4155 |
ignoreCase:ignoreCase |
|
4156 |
] ifFalse:[ |
|
4157 |
(self selectionAsString notNil |
|
4158 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
|
4159 |
ifTrue:[ |
|
4160 |
self replaceSelectionBy:replacePattern. |
|
4161 |
self |
|
4162 |
search:pattern |
|
4163 |
ignoreCase:ignoreCase |
|
4164 |
forward:(lastSearchDirection = #forward). |
|
4165 |
]. |
|
4166 |
] |
|
4167 |
] |
|
4168 |
info:'Replace' |
|
3430 | 4169 |
] |
4170 |
||
4171 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
4172 |
! |
|
4173 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4174 |
replaceCharAtCursor:aCharacter |
5413 | 4175 |
"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
|
4176 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4177 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4178 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4179 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4180 |
aCharacter == (Character cr) ifTrue:[ |
6152 | 4181 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4182 |
] ifFalse:[ |
6152 | 4183 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
4184 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4185 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4186 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4187 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4188 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4189 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4190 |
|
4458 | 4191 |
replaceContentsWith:newContents |
5413 | 4192 |
"undoably replace everything" |
4458 | 4193 |
|
4194 |
|originalContents| |
|
4195 |
||
4196 |
originalContents := self contents. |
|
4197 |
self contents:newContents keepUndoHistory:true. |
|
4198 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
4199 |
! |
|
4200 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4201 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 4202 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4203 |
|
5216 | 4204 |
"/ 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
|
4205 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4206 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4207 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4208 |
|
4458 | 4209 |
replaceLine:lineNr with:newText |
5413 | 4210 |
"undoably replace a line at lineNr" |
4458 | 4211 |
|
4212 |
|originalLine| |
|
4213 |
||
4214 |
originalLine := self listAt:lineNr. |
|
4215 |
originalLine isNil ifTrue:[ |
|
6152 | 4216 |
self checkForExistingLine:lineNr |
4458 | 4217 |
]. |
4218 |
self list at:lineNr put:newText. |
|
4219 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4220 |
self invalidateLine:lineNr. |
|
4221 |
||
4222 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
4223 |
! |
|
4224 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4225 |
replaceLines:lines withCR:withCr |
5413 | 4226 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4227 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4228 |
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
|
4229 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4230 |
|
1809 | 4231 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4232 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4233 |
lines notNil ifTrue:[ |
6152 | 4234 |
wasOn := self hideCursor. |
4235 |
nLines := lines size. |
|
4236 |
line := cursorLine. |
|
4237 |
col := cursorCol. |
|
4238 |
lines keysAndValuesDo:[:i :l | |
|
4239 |
self replaceString:(l ? '') atLine:line col:col. |
|
4240 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
4241 |
line := line + 1. |
|
4242 |
col := 1. |
|
4243 |
] ifFalse:[ |
|
4244 |
col := col + (l size). |
|
4245 |
] |
|
4246 |
]. |
|
4247 |
self cursorLine:line col:col. |
|
4248 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
4249 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4250 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4251 |
|
4661 | 4252 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
4253 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4254 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4255 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4256 |
replaceSelectionBy:something |
5413 | 4257 |
"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
|
4258 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4259 |
|
4666 | 4260 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 4261 |
! |
4262 |
||
4263 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 4264 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 4265 |
leave cursor after insertion or leave it, depending on keep" |
4266 |
||
4666 | 4267 |
self replaceSelectionBy:something keepCursor:keep select:false |
4268 |
||
4269 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
4270 |
! |
|
4271 |
||
4272 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 4273 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 4274 |
leave cursor after insertion or leave it, depending on keep. |
4275 |
If selectNewText is true, select the new text; otherwise deselect" |
|
4276 |
||
4277 |
|sel l c selStartLine selStartCol| |
|
105 | 4278 |
|
4279 |
l := cursorLine. |
|
4280 |
c := cursorCol. |
|
4281 |
||
4818 | 4282 |
sel := self selectionAsString. |
4666 | 4283 |
sel isNil ifTrue:[ |
6152 | 4284 |
selStartLine := l. |
4285 |
selStartCol := c. |
|
4666 | 4286 |
] ifFalse:[ |
6152 | 4287 |
selStartLine := selectionStartLine. |
4288 |
selStartCol := selectionStartCol. |
|
4289 |
||
4290 |
self setLastStringToReplace: sel. |
|
4291 |
||
4292 |
self deleteSelection. |
|
4293 |
replacing := true. |
|
4294 |
lastReplacementInfo rememberReplacement. |
|
4295 |
lastReplacementInfo lastReplacement: ''. |
|
4296 |
lastReplacementInfo stillCollectingInput:true. |
|
4297 |
undoSupport actionInfo:'replace'. |
|
3161 | 4298 |
]. |
4299 |
||
4300 |
something isCharacter ifTrue:[ |
|
6152 | 4301 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4302 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
|
4303 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
|
4304 |
]. |
|
4305 |
]. |
|
4306 |
self isInInsertMode ifTrue:[ |
|
4307 |
self insertCharAtCursor:something |
|
4308 |
] ifFalse:[ |
|
4309 |
self replaceCharAtCursor:something |
|
4310 |
] |
|
105 | 4311 |
] ifFalse:[ |
6152 | 4312 |
something isString ifTrue:[ |
4313 |
lastReplacementInfo lastReplacement: something. |
|
4314 |
self isInInsertMode ifTrue:[ |
|
4315 |
self insertStringAtCursor:something |
|
4316 |
] ifFalse:[ |
|
4317 |
self replaceStringAtCursor:something |
|
4318 |
] |
|
4319 |
] ifFalse:[ |
|
4320 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4321 |
]. |
|
105 | 4322 |
]. |
4323 |
keep ifTrue:[ |
|
6152 | 4324 |
self cursorLine:l col:c |
4666 | 4325 |
]. |
4326 |
selectNewText ifTrue:[ |
|
6152 | 4327 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
105 | 4328 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4329 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4330 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4331 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4332 |
|
4458 | 4333 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4334 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4335 |
This is not prepared to encounter special chars (except TAB) in the string." |
4336 |
||
4337 |
|originalString| |
|
4338 |
||
4339 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4340 |
||
4341 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4342 |
||
4343 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4344 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4345 |
! |
|
4346 |
||
4713 | 4347 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4348 |
|continue count| |
4349 |
||
4350 |
self cursorToTop. |
|
4351 |
self selectFromBeginning. |
|
4352 |
count := 0. |
|
4353 |
continue := true. |
|
4354 |
[ continue ] whileTrue:[ |
|
6152 | 4355 |
(self selectionAsString notNil |
4356 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4357 |
ifTrue:[ |
|
4358 |
self replaceSelectionBy:aNewString. |
|
4359 |
count := count + 1. |
|
4360 |
]. |
|
4361 |
self |
|
4362 |
searchFwd:aString |
|
4363 |
ignoreCase:ignoreCase |
|
4364 |
ifAbsent:[ |
|
4365 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4366 |
bindWith:aString with:aNewString with:count). |
|
4367 |
continue := false. |
|
4368 |
]. |
|
3549 | 4369 |
]. |
3430 | 4370 |
|
4371 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4372 |
! |
|
4373 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4374 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4375 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4376 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4377 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4378 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4379 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4380 |
(aString includes:Character tab) ifTrue:[ |
6152 | 4381 |
"/ need special care for TAB (to move cursor correctly) |
4382 |
i1 := 1. |
|
4383 |
[i1 ~~ 0] whileTrue:[ |
|
4384 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4385 |
i2 ~~ 0 ifTrue:[ |
|
4386 |
i1 ~~ i2 ifTrue:[ |
|
4387 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4388 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4389 |
]. |
|
4390 |
self replaceTABAtCursor. |
|
4391 |
i2 := i2 + 1. |
|
4392 |
] ifFalse:[ |
|
4393 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4394 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4395 |
]. |
|
4396 |
i1 := i2. |
|
4397 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4398 |
] ifFalse:[ |
6152 | 4399 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
4400 |
self setValidatedCursorCol:(cursorCol + aString size). |
|
4401 |
"/ self cursorCol:(cursorCol + aString size). |
|
5325 | 4402 |
]. |
4403 |
wasOn ifTrue:[ |
|
6152 | 4404 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
4405 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
5325 | 4406 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4407 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4408 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4409 |
"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
|
4410 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4411 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4412 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4413 |
"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
|
4414 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4415 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4416 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4417 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4418 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4419 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4420 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4421 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4422 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4423 |
! |
4424 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4425 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4426 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4427 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4428 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4429 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4430 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4431 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4432 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4433 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4434 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4435 |
self cursorToPreviousWord. |
5787 | 4436 |
beginCol := cursorCol. |
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4437 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4438 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4439 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4440 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4441 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4442 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4443 |
|
4458 | 4444 |
splitLine:lineNr before:colNr |
4445 |
"split the line linNr before colNr; the right part (from colNr) |
|
4446 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4447 |
||
4448 |
self basicSplitLine:lineNr before:colNr. |
|
4449 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4450 |
! |
|
4451 |
||
5761 | 4452 |
toggleTabSetting |
4453 |
"toggle between 4-col |
|
4454 |
and 8-col tabs" |
|
4455 |
||
4456 |
(tabPositions == self class tab4Positions) |
|
6152 | 4457 |
ifTrue:[self setTab8] |
4458 |
ifFalse:[self setTab4] |
|
5761 | 4459 |
|
4460 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4461 |
! |
|
4462 |
||
4463 |
undentSelectionBy1 |
|
4464 |
"undent selected line-range |
|
4465 |
by 1 space (i.e. to the left)" |
|
4466 |
||
4467 |
self undentBy:1 |
|
4468 |
||
4469 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4470 |
! |
|
4471 |
||
5146 | 4472 |
withAutoIndent:aBoolean do:aBlock |
4473 |
|sav| |
|
4474 |
||
4475 |
sav := autoIndent. |
|
4476 |
autoIndent := aBoolean. |
|
4477 |
aBlock ensure:[ autoIndent := sav ]. |
|
4478 |
! |
|
4479 |
||
4458 | 4480 |
withoutRedrawAt:lineNr put:aString |
4481 |
"replace a line at lineNr" |
|
4482 |
||
4483 |
|originalLine| |
|
4484 |
||
4485 |
originalLine := self listAt:lineNr. |
|
4486 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4487 |
super withoutRedrawAt:lineNr put:aString. |
|
4488 |
! |
|
4489 |
||
4490 |
withoutRedrawInsertLine:aString before:lineNr |
|
4491 |
"insert the argument, aString before line lineNr; the string |
|
4492 |
becomes line lineNr; everything else is moved down; the view |
|
4493 |
is not redrawn" |
|
4494 |
||
4771 | 4495 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4496 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4497 |
! |
|
4498 |
||
4499 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4500 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4501 |
||
4502 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4503 |
self isReadOnly ifFalse:[ |
|
6152 | 4504 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4505 |
]. |
4506 |
! |
|
4507 |
||
4508 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4509 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4510 |
||
4511 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4512 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4513 |
! |
|
4514 |
||
3890 | 4515 |
wrapLines |
4516 |
"wrap lines (insert line-break)" |
|
4517 |
||
4518 |
|lineLength answerString string| |
|
4519 |
||
4520 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4521 |
||
4522 |
self hasSelection ifFalse:[ |
|
6152 | 4523 |
self selectLine:cursorLine. |
3890 | 4524 |
]. |
4525 |
string := self selectionAsString. |
|
4526 |
string isEmptyOrNil ifTrue:[ |
|
6152 | 4527 |
Dialog information:(resources string:'Nothing selected.'). |
4528 |
^ self. |
|
3890 | 4529 |
]. |
4530 |
||
4531 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4532 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4533 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4534 |
lineLength < 1 ifTrue:[ |
6152 | 4535 |
lineLength := 1. |
3890 | 4536 |
]. |
4537 |
||
4538 |
self |
|
6152 | 4539 |
undoableDo:[ |
4540 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4541 |
||
4542 |
line := selectionStartLine. |
|
4543 |
col := selectionStartCol. |
|
4544 |
||
4545 |
self cutSelection. |
|
4546 |
self cursorLine:line col:col. |
|
4547 |
||
4548 |
lastGoodCol := col. |
|
4549 |
||
4550 |
inStream := string readStream. |
|
4551 |
[ inStream atEnd ] whileFalse:[ |
|
4552 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4553 |
word := CharacterWriteStream new. |
|
4554 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4555 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4556 |
self insertCharAtCursor:(Character cr). |
|
4557 |
col := 1. |
|
4558 |
] ifFalse:[ |
|
4559 |
col ~~ 1 ifTrue:[ |
|
4560 |
self insertStringAtCursor:' '. |
|
4561 |
col := col + 1. |
|
4562 |
] |
|
4563 |
]. |
|
4564 |
self insertStringAtCursor:word contents. |
|
4565 |
col := col + word size. |
|
4566 |
]. |
|
4567 |
] |
|
4568 |
info:'Wrap' |
|
4388 | 4569 |
|
4570 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4571 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4572 |
|
2752 | 4573 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4574 |
|
2952 | 4575 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4576 |
"delete characters from startCol to endCol in line lineNr" |
4577 |
||
6232 | 4578 |
|line lineSize newLine start stop |
6207 | 4579 |
prevWidth newWidth newCol| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4580 |
|
4673 | 4581 |
self unselect. |
4582 |
||
4583 |
cursorLine == lineNr ifTrue:[ |
|
5909 | 4584 |
cursorCol >= startCol ifTrue:[ |
4585 |
cursorCol >= endCol ifTrue:[ |
|
6207 | 4586 |
newCol := startCol. |
5909 | 4587 |
] ifFalse:[ |
6207 | 4588 |
newCol := cursorCol - (endCol - startCol + 1). |
5909 | 4589 |
"/ self assert:(cursorCol >= 0). |
6207 | 4590 |
newCol := newCol max:1. |
4591 |
]. |
|
4592 |
self setCursorCol:newCol. |
|
5909 | 4593 |
]. |
4673 | 4594 |
]. |
4595 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4596 |
line := self listAt:lineNr. |
827 | 4597 |
|
4673 | 4598 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4599 |
||
4600 |
lineSize := line size. |
|
4601 |
||
4602 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4603 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4604 |
||
4605 |
stop >= start ifTrue:[ |
|
5909 | 4606 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
4607 |
ifFalse:[ newLine := '' ]. |
|
4608 |
||
4609 |
stop == lineSize ifFalse:[ |
|
4610 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4611 |
newLine := line string species fromString:newLine. |
|
4612 |
]. |
|
4613 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
4614 |
]. |
|
4615 |
||
4616 |
(self trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4617 |
newLine := nil |
|
4618 |
]. |
|
4619 |
||
4620 |
prevWidth := self widthOfLine:lineNr. |
|
4621 |
||
4622 |
self basicListAt:lineNr put:newLine. |
|
4623 |
||
4624 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4625 |
"/ remember old width of this line, |
|
4626 |
"/ only clear widthOfWidestLine, if this lines |
|
4627 |
"/ length was (one of) the longest. |
|
4628 |
"/ avoids slow delete with huge texts. |
|
4629 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4630 |
||
6232 | 4631 |
"/ scroll left if required |
5909 | 4632 |
viewOrigin x > 0 ifTrue:[ |
4633 |
newWidth := self widthOfLine:lineNr. |
|
4634 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4635 |
self scrollHorizontalTo:(newWidth |
|
4636 |
- width |
|
4637 |
+ margin + margin |
|
4638 |
+ (gc font widthOf:' ')) |
|
4639 |
] |
|
4640 |
]. |
|
4641 |
self textChanged. |
|
4642 |
] ifFalse:[ |
|
4643 |
self textChanged "/ textChangedButNoSizeChange |
|
4644 |
]. |
|
4645 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4646 |
self invalidateLine:lineNr. |
|
4647 |
] ifFalse:[ |
|
4648 |
self redrawLine:lineNr from:start. |
|
4649 |
]. |
|
4673 | 4650 |
]. |
827 | 4651 |
|
4191 | 4652 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
6232 | 4653 |
"Modified (format): / 20-11-2017 / 20:17:55 / mawalch" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4654 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4655 |
|
2952 | 4656 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4657 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4658 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4659 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4660 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4661 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4662 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4663 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4664 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4665 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4666 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4667 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4668 |
startLineNr <= list size ifTrue:[ |
6152 | 4669 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4670 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4671 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4672 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4673 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4674 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4675 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4676 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4677 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4678 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4679 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4680 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4681 |
(firstLineShown >= nLines) ifTrue:[ |
6152 | 4682 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4683 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4684 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4685 |
|
4226 | 4686 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4687 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4688 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4689 |
|
2952 | 4690 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4691 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4692 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4693 |
|
2952 | 4694 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4695 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4696 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4697 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4698 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4699 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4700 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4701 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4702 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4703 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4704 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4705 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4706 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4707 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4708 |
|
2952 | 4709 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4710 |
"insert a single character at lineNr/colNr; |
827 | 4711 |
set emphasis to character at current position" |
4712 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4713 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
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 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
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 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4718 |
self splitLine:lineNr before:colNr. |
4719 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4720 |
]. |
827 | 4721 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4722 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4723 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4724 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4725 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4726 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4727 |
self st80EditMode ifFalse:[ |
5909 | 4728 |
(self trimBlankLines |
6469 | 4729 |
and:[colNr > (lineSize + 1) |
5909 | 4730 |
and:[aCharacter == Character space]]) ifTrue:[ |
4731 |
^ self |
|
4732 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4733 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4734 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4735 |
(lineSize == 0) ifTrue:[ |
5909 | 4736 |
newLine := aCharacter asString species new:colNr. |
4737 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4738 |
] ifFalse: [ |
5909 | 4739 |
(colNr > lineSize) ifTrue: [ |
4740 |
colNr == (lineSize +1) ifTrue:[ |
|
4741 |
attribute := line emphasisAt:lineSize |
|
4742 |
]. |
|
4743 |
newLine := line species new:colNr. |
|
4744 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4745 |
drawCharacterOnly := true |
|
4746 |
] ifFalse: [ |
|
4747 |
attribute := line emphasisAt:colNr. |
|
4748 |
newLine := line species new:(lineSize + 1). |
|
4749 |
||
4750 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4751 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
4752 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4753 |
]. |
827 | 4754 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4755 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
5909 | 4756 |
newLine := aCharacter asString species fromString:newLine. |
4757 |
line isText ifTrue:[ |
|
4758 |
newLine := newLine asText |
|
4759 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4760 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4761 |
newLine at:colNr put:aCharacter. |
827 | 4762 |
|
4763 |
attribute notNil ifTrue:[ |
|
5909 | 4764 |
newLine emphasisAt:colNr put:attribute. |
827 | 4765 |
]. |
4766 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4767 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4768 |
newLine := self withTabsExpanded:newLine. |
4769 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4770 |
]. |
827 | 4771 |
|
4771 | 4772 |
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
|
4773 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4774 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4775 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4776 |
self textChanged. |
6399 | 4777 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4778 |
shown ifTrue:[ |
5909 | 4779 |
"/ care for italic text - in this case, we must also |
4780 |
"/ redraw the character before the insertion in order |
|
4781 |
"/ to fix the slanted piece of the character. |
|
4782 |
"/ (but we must clip, to avoid destoying the character before) |
|
4783 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
4784 |
colNr > 1 ifTrue:[ |
|
4785 |
cursorVisibleLine notNil ifTrue:[ |
|
6031 | 4786 |
oldClip := self clippingBoundsOrNil. |
5909 | 4787 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
4788 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4789 |
||
4790 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4791 |
self invalidateLine:lineNr. |
|
4792 |
] ifFalse:[ |
|
4793 |
drawCharacterOnly ifTrue:[ |
|
6031 | 4794 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
5909 | 4795 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4796 |
] ifFalse:[ |
|
6031 | 4797 |
self clippingBounds:(x@y extent:((width - x) @ fontHeight)). |
5909 | 4798 |
self redrawLine:lineNr from:colNr-1 |
4799 |
]. |
|
6031 | 4800 |
self clippingBounds:oldClip. |
5909 | 4801 |
]. |
4802 |
]. |
|
4803 |
^ self. |
|
4804 |
]. |
|
4805 |
]. |
|
4806 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4807 |
self invalidateLine:lineNr. |
|
4808 |
] ifFalse:[ |
|
4809 |
drawCharacterOnly ifTrue:[ |
|
4810 |
self redrawLine:lineNr col:colNr |
|
4811 |
] ifFalse:[ |
|
4812 |
self redrawLine:lineNr from:colNr |
|
4813 |
] |
|
4814 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4815 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4816 |
|
4191 | 4817 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
6469 | 4818 |
"Modified: / 26-10-2018 / 18:18:17 / Claus Gittinger" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4819 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4820 |
|
4771 | 4821 |
basicListAt:lineNr put:newLine |
4822 |
"redefinable for special subclasses (with virtual list)" |
|
4823 |
||
4824 |
list at:lineNr put:newLine. |
|
4825 |
! |
|
4826 |
||
4827 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4828 |
"redefinable for special subclasses (with virtual list)" |
|
4829 |
||
4830 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4831 |
! |
|
4832 |
||
2952 | 4833 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4834 |
"merge line lineNr with line lineNr+1" |
4835 |
||
827 | 4836 |
|leftPart rightPart bothParts nextLineNr i| |
4837 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4838 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
5909 | 4839 |
"/ empty list or beyond end of text |
4840 |
^ self |
|
827 | 4841 |
]. |
4842 |
leftPart := self listAt:lineNr. |
|
4843 |
||
4844 |
leftPart isNil ifTrue:[ |
|
5909 | 4845 |
leftPart := ''. |
4846 |
autoIndent ifTrue:[ |
|
6147 | 4847 |
"/ cg: only do this, if the second line has no indent |
4848 |
(i := self leftIndentOfLine:(lineNr+1)) == 0 ifTrue:[ |
|
4849 |
leftPart := String new:(self leftIndentForLine:lineNr) |
|
5909 | 4850 |
] |
4851 |
] |
|
827 | 4852 |
]. |
4853 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4854 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4855 |
||
4856 |
nextLineNr > (list size) ifFalse:[ |
|
5909 | 4857 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4858 |
rightPart := '' |
|
4859 |
] ifFalse:[ |
|
4860 |
removeBlanks ifTrue:[ |
|
4861 |
rightPart := rightPart withoutLeadingSeparators. |
|
4862 |
] |
|
4863 |
]. |
|
4864 |
||
4865 |
bothParts := leftPart , rightPart. |
|
4866 |
(self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4867 |
self basicListAt:lineNr put:bothParts. |
|
4868 |
self redrawLine:lineNr. |
|
4869 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4870 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4871 |
|
6147 | 4872 |
"Created: / 09-09-1997 / 09:27:38 / cg" |
4873 |
"Modified: / 25-04-2017 / 12:41:20 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4874 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4875 |
|
2952 | 4876 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4877 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4878 |
|
5045 | 4879 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4880 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4881 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4882 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4883 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4884 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4885 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4886 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4887 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4888 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4889 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4890 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4891 |
|
5909 | 4892 |
(self trimBlankLines |
6469 | 4893 |
and:[colNr > (lineSize + 1) |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4894 |
and:[aCharacter == Character space]]) ifTrue:[ |
5909 | 4895 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4896 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4897 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4898 |
(lineSize == 0) ifTrue:[ |
5909 | 4899 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4900 |
] ifFalse: [ |
5909 | 4901 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4902 |
newLineSpecies := aCharacter stringSpecies |
|
4903 |
] ifFalse:[ |
|
4904 |
newLineSpecies := line species |
|
4905 |
]. |
|
4906 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4907 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4908 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4909 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4910 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4911 |
newLine := self withTabsExpanded:newLine. |
4912 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4913 |
]. |
4771 | 4914 |
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
|
4915 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4916 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4917 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4918 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4919 |
shown ifTrue:[ |
5909 | 4920 |
gc font hasOverlappingCharacters ifTrue:[ |
4921 |
self invalidateLine:lineNr. |
|
4922 |
] ifFalse:[ |
|
4923 |
drawCharacterOnly ifTrue:[ |
|
4924 |
self redrawLine:lineNr col:colNr |
|
4925 |
] ifFalse:[ |
|
4926 |
self redrawLine:lineNr from:colNr |
|
4927 |
] |
|
4928 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4929 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4930 |
|
4190 | 4931 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4932 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
6469 | 4933 |
"Modified: / 26-10-2018 / 18:21:21 / Claus Gittinger" |
105 | 4934 |
! |
4935 |
||
3235 | 4936 |
basicReplaceString:aString atLine:lineNr col:colNr |
4937 |
"replace multiple characters starting at lineNr/colNr. |
|
4938 |
This is not prepared to encounter special chars (except TAB) |
|
4939 |
in the string." |
|
4940 |
||
5045 | 4941 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4942 |
|
4943 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4944 |
||
4945 |
self checkForExistingLine:lineNr. |
|
4946 |
line := list at:lineNr. |
|
4947 |
lineSize := line size. |
|
4948 |
||
4949 |
endCol := colNr + aString size - 1. |
|
4950 |
(lineSize == 0) ifTrue:[ |
|
6152 | 4951 |
newLine := aString species new:endCol. |
3235 | 4952 |
] ifFalse: [ |
6152 | 4953 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4954 |
newLineSpecies := aString stringSpecies |
|
4955 |
] ifFalse:[ |
|
4956 |
newLineSpecies := line species |
|
4957 |
]. |
|
4958 |
||
4959 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4960 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4961 |
]. |
4962 |
newLine replaceFrom:colNr with:aString. |
|
4963 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 4964 |
newLine := self withTabsExpanded:newLine. |
3235 | 4965 |
]. |
4771 | 4966 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4967 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 4968 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4969 |
]. |
4970 |
self textChanged. |
|
4971 |
shown ifTrue:[ |
|
6152 | 4972 |
gc font hasOverlappingCharacters ifTrue:[ |
4973 |
self invalidateLine:lineNr. |
|
4974 |
] ifFalse:[ |
|
4975 |
self redrawLine:lineNr from:colNr |
|
4976 |
] |
|
3235 | 4977 |
] |
4978 |
||
4190 | 4979 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4980 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4981 |
! |
4982 |
||
2952 | 4983 |
basicSplitLine:lineNr before:colNr |
4984 |
"split the line linNr before colNr; the right part (from colNr) |
|
4985 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4986 |
||
3160 | 4987 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4988 |
srcY "{ Class: SmallInteger }" | |
4989 |
||
3027 | 4990 |
list isNil ifTrue:[ ^ self ]. |
4991 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4992 |
||
4993 |
(colNr == 1) ifTrue:[ |
|
5909 | 4994 |
self nonUndoableDo:[ |
4995 |
self insertLine:nil before:lineNr. |
|
4996 |
]. |
|
4997 |
^ self |
|
3027 | 4998 |
]. |
4999 |
||
5000 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5001 |
line notNil ifTrue:[ |
5909 | 5002 |
lineSize := line size. |
5003 |
(colNr <= lineSize) ifTrue:[ |
|
5004 |
rightRest := line copyFrom:colNr to:lineSize. |
|
5005 |
(colNr > 1) ifTrue:[ |
|
5006 |
leftRest := line copyTo:(colNr - 1) |
|
5007 |
] |
|
5008 |
] ifFalse:[ |
|
5009 |
leftRest := line |
|
5010 |
] |
|
3027 | 5011 |
]. |
6400 | 5012 |
"/ -- debug: self windowGroup sensor hasDamage ifTrue:[self halt]. |
5013 |
||
3027 | 5014 |
leftRest notNil ifTrue:[ |
6400 | 5015 |
(self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]. |
5016 |
]. |
|
5017 |
leftRest = (self listAt:lineNr) ifFalse:[ |
|
5018 |
self basicListAt:lineNr put:leftRest. |
|
5019 |
]. |
|
5020 |
"/ -- debug: (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt]. |
|
5021 |
||
5022 |
"/ -- debug: TraceDamage := self. |
|
5023 |
||
3027 | 5024 |
self nonUndoableDo:[ |
5909 | 5025 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 5026 |
]. |
6400 | 5027 |
|
5028 |
"/ Delay waitForSeconds:1. |
|
5029 |
"/ (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt]. |
|
5030 |
"/ TraceDamage := nil. |
|
5031 |
||
3027 | 5032 |
visLine := self listLineToVisibleLine:(lineNr). |
5033 |
visLine notNil ifTrue:[ |
|
5909 | 5034 |
w := self widthForScrollBetween:lineNr |
5035 |
and:(firstLineShown + nLinesShown). |
|
5036 |
srcY := topMargin + (visLine * fontHeight). |
|
5037 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
5038 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
6306 | 5039 |
mustWait := self catchExpose. |
5909 | 5040 |
self |
5041 |
copyFrom:self |
|
5042 |
x:textStartLeft y:srcY |
|
5043 |
toX:textStartLeft y:(srcY + fontHeight) |
|
5044 |
width:w |
|
5045 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
5046 |
async:true. |
|
5047 |
]. |
|
5048 |
self redrawLine:lineNr. |
|
5049 |
self redrawLine:(lineNr + 1). |
|
6400 | 5050 |
mustWait ifTrue:[self waitForExpose]. |
3027 | 5051 |
]. |
5052 |
widthOfWidestLine := nil. "/ unknown |
|
5053 |
self textChanged. |
|
2952 | 5054 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5055 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
6306 | 5056 |
"Modified: / 19-04-2018 / 12:21:52 / stefan" |
6400 | 5057 |
"Modified: / 22-08-2018 / 12:56:24 / Claus Gittinger" |
2952 | 5058 |
! |
5059 |
||
2954 | 5060 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 5061 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
5062 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5063 |
because the text might have been pasted from an alien view." |
|
2954 | 5064 |
|
5065 |
|newLine newLines nLines| |
|
5066 |
||
5067 |
nLines := end - start + 1. |
|
5068 |
newLines := Array new:(lines size). |
|
5069 |
start to:end do:[:index | |
|
6152 | 5070 |
newLine := lines at:index. |
5071 |
newLine notNil ifTrue:[ |
|
5072 |
newLine isString ifTrue:[ |
|
5073 |
newLine isBlank ifTrue:[ |
|
5074 |
newLine := nil |
|
5075 |
] ifFalse:[ |
|
5076 |
(newLine includes:(Character tab)) ifTrue:[ |
|
5077 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
5078 |
] |
|
5079 |
] |
|
5080 |
] |
|
5081 |
]. |
|
5082 |
newLines at:index put:newLine |
|
2954 | 5083 |
]. |
5084 |
list isNil ifTrue: [ |
|
6152 | 5085 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 5086 |
] ifFalse: [ |
6152 | 5087 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 5088 |
]. |
5089 |
||
5090 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 5091 |
overlapping copy - if it didn't, we had to use:" |
5092 |
" |
|
5093 |
index := list size. |
|
5094 |
[index > lineNr] whileTrue: [ |
|
6152 | 5095 |
pIndex := index - 1. |
5096 |
list at:index put:(list at:pIndex). |
|
5097 |
index := pIndex |
|
2954 | 5098 |
]. |
5099 |
" |
|
5100 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
5101 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
5102 |
self contentsChanged |
|
5103 |
||
4328 | 5104 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 5105 |
! |
5106 |
||
5107 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 5108 |
"insert aString (which has no crs) at lineNr/colNr. |
5109 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5110 |
because the text might have been pasted from an alien view." |
|
2954 | 5111 |
|
4360 | 5112 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 5113 |
|
4623 | 5114 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 5115 |
|
5116 |
strLen := aString size. |
|
5117 |
self checkForExistingLine:lineNr. |
|
5118 |
||
5119 |
stringType := aString string species. |
|
5120 |
isText := aString isText. |
|
5121 |
line := list at:lineNr. |
|
5122 |
||
5123 |
line notNil ifTrue:[ |
|
6152 | 5124 |
lineSize := line size. |
5125 |
line isString ifFalse:[ |
|
5126 |
stringType := line species |
|
5127 |
] ifTrue:[ |
|
5128 |
lineCharWidth := line bitsPerCharacter. |
|
5129 |
stringCharWidth := aString bitsPerCharacter. |
|
5130 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
5131 |
stringType := line string species |
|
5132 |
] ifFalse:[ |
|
5133 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
5134 |
stringType := aString string species |
|
5135 |
] |
|
5136 |
]. |
|
5137 |
line isText ifTrue:[ isText := true ] |
|
5138 |
]. |
|
2954 | 5139 |
] ifFalse:[ |
6152 | 5140 |
lineSize := 0 |
2954 | 5141 |
]. |
5142 |
||
5143 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
6152 | 5144 |
newLine := aString |
2954 | 5145 |
] ifFalse:[ |
6152 | 5146 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
5147 |
sz := colNr + strLen - 1 |
|
5148 |
] ifFalse:[ |
|
5149 |
sz := lineSize + strLen |
|
5150 |
]. |
|
5151 |
||
5152 |
newLine := stringType new:sz. |
|
5153 |
isText ifTrue:[ |
|
5154 |
newLine := Text string:newLine |
|
5155 |
]. |
|
5156 |
||
5157 |
(lineSize ~~ 0) ifTrue: [ |
|
5158 |
(colNr > lineSize) ifTrue: [ |
|
5159 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
5160 |
] ifFalse: [ |
|
5161 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
5162 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
5163 |
] |
|
5164 |
]. |
|
5165 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 5166 |
]. |
5167 |
||
5168 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 5169 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 5170 |
]. |
5171 |
||
4771 | 5172 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 5173 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 5174 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 5175 |
]. |
5176 |
self textChanged. |
|
5177 |
||
4360 | 5178 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5179 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5180 |
|
2752 | 5181 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5182 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5183 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5184 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5185 |
|
5216 | 5186 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 5187 |
dragIsActive := false. |
5188 |
||
5787 | 5189 |
completionSupport notNil ifTrue:[ |
6152 | 5190 |
"/ also give that guy a chance to close its popup view |
5191 |
completionSupport buttonPress:button x:x y:y |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5192 |
]. |
4609 | 5193 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
5194 |
cursorShown ifTrue: [ |
6152 | 5195 |
self drawCursor |
5787 | 5196 |
]. |
5197 |
||
5198 |
"On X11, be nice and paste PRIMARY when middle click. |
|
4420 | 5199 |
Note, that middle button on X11 is translated to button |
5200 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 5201 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
6313 | 5202 |
"change the cursor position..." |
5203 |
super buttonPress:1 x:x y:y. |
|
5204 |
self buttonRelease:1 x:x y:y. |
|
6152 | 5205 |
self undoableDo:[ |
5206 |
self paste: (self getClipboardText:#selection). |
|
5207 |
]. |
|
6313 | 5208 |
^ self. |
4420 | 5209 |
]. |
5210 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5211 |
(button == 1) ifTrue:[ |
6152 | 5212 |
self hideCursor |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5213 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5214 |
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
|
5215 |
|
4420 | 5216 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
5217 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6313 | 5218 |
"Modified (format): / 27-04-2018 / 13:35:09 / stefan" |
121 | 5219 |
! |
5220 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5221 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5222 |
"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
|
5223 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
5224 |
|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
|
5225 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5226 |
(button == 1) ifTrue:[ |
5882 | 5227 |
typeOfSelection := nil. |
5228 |
||
5229 |
dragIsActive ifTrue:[ |
|
5230 |
self unselect |
|
5231 |
]. |
|
5232 |
selectionStartLine isNil ifTrue:[ |
|
5233 |
clickCol notNil ifTrue:[ |
|
5234 |
self cursorMovementAllowed ifTrue:[ |
|
5235 |
newCursorCol := clickCol. |
|
5236 |
||
5237 |
cursorType ~~ #block ifTrue:[ |
|
5238 |
clickPos notNil ifTrue:[ |
|
5239 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
6096 | 5240 |
"/ (i.e. if it's an ibeam). |
5882 | 5241 |
"/ adjust clickCol if the user clicked in the right third of a character. |
5242 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
5243 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
5244 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
5245 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
5246 |
]. |
|
5247 |
]. |
|
5248 |
"/ the following fixes the ugly select behavior when double clicking on |
|
5249 |
"/ a partially visible last line (where the first click used to |
|
5250 |
"/ scroll the text so that the second click was handled on another |
|
5251 |
"/ line. An alternative (possibly better) solution would be to |
|
5252 |
"/ remember the last click position and adjust in the double click |
|
5253 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
5254 |
"/ Time will show, if this hack works. |
|
5255 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
|
5256 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
5257 |
Processor |
|
5258 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
5259 |
after:0.3 seconds. |
|
5260 |
] ifFalse:[ |
|
5261 |
self cursorLine:clickLine col:newCursorCol. |
|
5262 |
]. |
|
5263 |
]. |
|
5264 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
|
5265 |
list notEmptyOrNil ifTrue:[ |
|
5266 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
|
5267 |
(clickLine >= list size) ifTrue:[ |
|
5268 |
(clickLine > (self list size + 2) |
|
5269 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
|
5270 |
self selectAll |
|
5271 |
]. |
|
5272 |
]. |
|
5273 |
] |
|
5274 |
] |
|
5275 |
] |
|
5276 |
] |
|
5277 |
] ifFalse:[ |
|
5278 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
|
5279 |
]. |
|
5280 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5281 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5282 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
5283 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5284 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
6096 | 5285 |
"Modified (format): / 13-02-2017 / 20:10:18 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5286 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5287 |
|
2580 | 5288 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5289 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5290 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5291 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5292 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5293 |
self changeTypeOfSelectionTo:nil. |
2580 | 5294 |
|
5295 |
(key == #CursorRight) ifTrue:[ |
|
6137 | 5296 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5297 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5298 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
5299 |
expandingTop := false. |
|
5300 |
self validateNewSelection. |
|
5301 |
self setPrimarySelection. |
|
5302 |
self selectionChanged. |
|
5303 |
self redrawLine:selectionStartLine. |
|
5304 |
^ self. |
|
5305 |
]. |
|
5306 |
||
5307 |
selectionStartLine notNil ifTrue:[ |
|
5308 |
self cursorMovementAllowed ifTrue:[ |
|
5309 |
"/ |
|
5310 |
"/ treat the whole selection as cursor |
|
5311 |
"/ |
|
5312 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5313 |
selectionEndCol == 0 ifTrue:[ |
|
5314 |
selectionEndCol := 1. |
|
5315 |
]. |
|
5316 |
self setCursorCol:selectionEndCol. |
|
5317 |
shifted ifTrue:[ |
|
5318 |
self expandSelectionRight. |
|
5319 |
^ self |
|
5320 |
]. |
|
5321 |
self unselect; makeCursorVisible. |
|
5322 |
"/ cursorCol == 1 ifTrue:[^ self]. |
|
5323 |
]. |
|
5324 |
]. |
|
5325 |
self cursorRight. |
|
5326 |
^ self |
|
2580 | 5327 |
]. |
5328 |
(key == #CursorDown) ifTrue:[ |
|
6137 | 5329 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5330 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
5331 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
5332 |
selectionEndCol == 1 ifTrue:[ |
|
5333 |
selectionEndCol := 0. |
|
5334 |
]. |
|
5335 |
self validateNewSelection. |
|
5336 |
self selectionChanged. |
|
5337 |
self redrawLine:selectionStartLine. |
|
5338 |
expandingTop := false. |
|
5339 |
self redrawLine:selectionEndLine. |
|
5340 |
^ self |
|
5341 |
]. |
|
5342 |
||
5343 |
selectionStartLine notNil ifTrue:[ |
|
5344 |
self cursorMovementAllowed ifTrue:[ |
|
5345 |
"/ |
|
5346 |
"/ treat the whole selection as cursor |
|
5347 |
"/ |
|
5348 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5349 |
self setCursorCol:selectionStartCol. |
|
5350 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
|
5351 |
self setCursorCol:1. |
|
5352 |
self setCursorLine:(cursorLine - 1). |
|
5353 |
]. |
|
5354 |
self makeCursorVisible. |
|
5355 |
||
5356 |
shifted ifTrue:[ |
|
5357 |
clickLine := cursorLine. |
|
5358 |
clickCol := cursorCol. |
|
5359 |
self expandSelectionDown. |
|
5360 |
^ self |
|
5361 |
]. |
|
5362 |
self unselect. |
|
5363 |
]. |
|
5364 |
]. |
|
5365 |
||
5366 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
|
5367 |
self cursorDown:n. |
|
5368 |
"/ |
|
5369 |
"/ flush keyboard to avoid runaway cursor |
|
5370 |
"/ |
|
5371 |
self sensor flushKeyboardFor:self. |
|
5372 |
^ self |
|
2580 | 5373 |
]. |
5374 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
6137 | 5375 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5376 |
expandingTop := true. |
|
5377 |
key == #CursorLeft ifTrue:[ |
|
5378 |
cursorCol > 1 ifTrue:[ |
|
5379 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5380 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
5381 |
selectionStartCol := cursorCol-1. |
|
5382 |
self validateNewSelection. |
|
5383 |
self selectionChanged. |
|
5384 |
self redrawLine:selectionStartLine. |
|
5385 |
^ self |
|
5386 |
] |
|
5387 |
] ifFalse:[ |
|
5388 |
cursorLine > 1 ifTrue:[ |
|
5389 |
selectionEndLine := clickStartLine := cursorLine. |
|
5390 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
5391 |
selectionStartLine := cursorLine - 1. |
|
5392 |
selectionEndCol == 1 ifTrue:[ |
|
5393 |
selectionEndCol := 0. |
|
5394 |
]. |
|
5395 |
self validateNewSelection. |
|
5396 |
self selectionChanged. |
|
5397 |
self redrawFromLine:selectionStartLine to:cursorLine. |
|
5398 |
^ self |
|
5399 |
] |
|
5400 |
] |
|
5401 |
]. |
|
5402 |
||
5403 |
selectionStartLine notNil ifTrue:[ |
|
5404 |
self cursorMovementAllowed ifTrue:[ |
|
5405 |
"/ |
|
5406 |
"/ treat the whole selection as cursor |
|
5407 |
"/ |
|
5408 |
self setCursorLine:selectionStartLine. |
|
5409 |
self setCursorCol:selectionStartCol. |
|
5410 |
(key == #CursorLeft) ifTrue:[ |
|
5411 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
5412 |
]. |
|
5413 |
self makeCursorVisible. |
|
5414 |
||
5415 |
shifted ifTrue:[ |
|
5416 |
(key == #CursorUp) ifTrue:[ |
|
5417 |
clickLine := cursorLine. |
|
5418 |
self expandSelectionUp. |
|
5419 |
] ifFalse:[ |
|
5420 |
self expandSelectionLeft. |
|
5421 |
]. |
|
5422 |
^ self |
|
5423 |
]. |
|
5424 |
self unselect. |
|
5425 |
]. |
|
5426 |
]. |
|
5427 |
(key == #CursorLeft) ifTrue:[ |
|
5428 |
self cursorLeft. ^self |
|
5429 |
]. |
|
5430 |
(key == #CursorUp) ifTrue:[ |
|
5431 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
|
5432 |
self cursorUp:n. |
|
5433 |
"/ |
|
5434 |
"/ flush keyboard to avoid runaway cursor |
|
5435 |
"/ |
|
5436 |
self sensor flushKeyboardFor:self. |
|
5437 |
^ self |
|
5438 |
]. |
|
2580 | 5439 |
]. |
4420 | 5440 |
|
5441 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6137 | 5442 |
"Modified: / 19-03-2017 / 10:08:54 / cg" |
2580 | 5443 |
! |
5444 |
||
2952 | 5445 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5446 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5447 |
|
4521 | 5448 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
6147 | 5449 |
#Replace #Undo #Redo #Accept |
5450 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
|
5451 |
#DeleteSpaces #Join |
|
5452 |
#SearchMatchingParent #SelectMatchingParents |
|
5453 |
#SelectWord #ExpandSelectionByWord |
|
5454 |
#SelectToEnd #SelectFromBeginning |
|
5455 |
#SelectLine #ExpandSelectionByLine |
|
5456 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
5457 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5458 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5459 |
#GotoLine #BeginOfText #EndOfText |
|
5460 |
#InsertLine #DeleteLine |
|
6354 | 5461 |
#SelectLineFromBeginning #SelectToLineEnd |
6147 | 5462 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
5463 |
#OpenSpecialCharacterWindow #InsertUUID |
|
5464 |
#'F*' #'f*')> |
|
2017 | 5465 |
|
4730 | 5466 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5467 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5468 |
|
5469 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5470 |
|
4701 | 5471 |
"/ experimental |
4818 | 5472 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
5787 | 5473 |
(immediateCompletion |
4818 | 5474 |
or:[currentUserPrefs codeCompletionOnControlKey |
5475 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
6147 | 5476 |
completionSupport isNil ifTrue:[ |
5477 |
self initializeCompletionSupport. |
|
5478 |
]. |
|
5787 | 5479 |
]. |
5480 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5481 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5482 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5483 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5484 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5485 |
completionSupport notNil ifTrue:[ |
6147 | 5486 |
completionSupport stopCompletionProcess. |
5487 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5488 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5489 |
|
4818 | 5490 |
key isSymbol ifTrue:[ |
6147 | 5491 |
(device modifierKeys includes:key) ifFalse:[ |
5492 |
lastReplacementInfo stillCollectingInput:false. |
|
5493 |
] |
|
4818 | 5494 |
]. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5495 |
(key == #LearnKeyboardMacro) ifTrue:[ |
6147 | 5496 |
lastReplacementInfo stillCollectingInput:false. |
5497 |
self toggleLearnMode. |
|
5498 |
^ self |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5499 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5500 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
6147 | 5501 |
lastReplacementInfo stillCollectingInput:false. |
5502 |
self executeLearnedKeyboardMacro. |
|
5503 |
^ self. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5504 |
]. |
3799 | 5505 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5506 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5507 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5508 |
self learnMode ifTrue:[ |
6390 | 5509 |
event := WindowGroup lastEvent. |
6147 | 5510 |
learnedMacro add:event. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5511 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5512 |
|
4238 | 5513 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
6147 | 5514 |
"the macro named key exists" |
5515 |
^ self |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5516 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5517 |
|
4482 | 5518 |
key isSymbol ifFalse:[ |
6147 | 5519 |
"the usual case: key is a character, but maybe a string also (in X11)" |
5520 |
self handleNonCommandKey:key. |
|
5521 |
^ self |
|
4482 | 5522 |
]. |
5523 |
||
5524 |
event isNil ifTrue:[ |
|
6390 | 5525 |
event := WindowGroup lastEvent. |
4482 | 5526 |
]. |
5527 |
shiftPressed := event hasShift. |
|
5528 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5529 |
rawKey := event rawKey. |
4482 | 5530 |
|
5133 | 5531 |
key == #InsertUUID ifTrue:[ |
6147 | 5532 |
self insertUUID. |
5533 |
^ self. |
|
5133 | 5534 |
]. |
5535 |
||
4253 | 5536 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
6147 | 5537 |
self deleteWordBeforeCursor. |
5538 |
^ self. |
|
4253 | 5539 |
]. |
5540 |
||
5119 | 5541 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
6147 | 5542 |
selectionStartLine notNil ifTrue:[ |
5543 |
((key == #BasicBackspace) |
|
5544 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
|
5545 |
ifTrue:[ |
|
5546 |
self deleteSelection. |
|
5547 |
] ifFalse: [ |
|
5548 |
self copyAndDeleteSelection. |
|
5549 |
]. |
|
5550 |
] ifFalse:[ |
|
5551 |
self makeCursorVisible. |
|
4609 | 5552 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
5553 |
"/ self deleteWordBeforeCursor. |
|
5554 |
"/ ] ifFalse:[ |
|
6147 | 5555 |
self deleteCharBeforeCursor. |
6399 | 5556 |
|
5557 |
self maybeShowMatchingParenthesisFor:(self characterBeforeCursor). |
|
5558 |
||
4609 | 5559 |
"/ ]. |
6147 | 5560 |
]. |
5561 |
true "immediateCompletion" ifTrue:[ |
|
5562 |
completionSupport notNil ifTrue:[ |
|
5563 |
completionSupport postKeyPress:key |
|
5564 |
]. |
|
5565 |
]. |
|
5566 |
^ self |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5567 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5568 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5569 |
(key == #ToggleAutoIndent) ifTrue:[ |
6147 | 5570 |
self autoIndent:(autoIndent not). |
5571 |
^ self. |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5572 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5573 |
|
3235 | 5574 |
key == #ToggleInsertMode ifTrue:[ |
6147 | 5575 |
self insertMode:(editMode value == EditMode insertMode) not. |
5576 |
^ self. |
|
3160 | 5577 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5578 |
|
4162 | 5579 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
6147 | 5580 |
CharacterSetView notNil ifTrue:[ |
5581 |
self specialCharacters. |
|
5582 |
^ self. |
|
5583 |
] |
|
4162 | 5584 |
]. |
5585 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5586 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5587 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5588 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5589 |
Fn pastes a key-sequence (but only if not overlayed with |
6147 | 5590 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5591 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5592 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5593 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5594 |
(key at:1) asLowercase == $f ifTrue:[ |
6147 | 5595 |
(('[fF][0-9]' match:key) |
5596 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5597 |
shiftPressed ifFalse:[ |
|
5598 |
fKeyMacros := currentUserPrefs functionKeySequences. |
|
5599 |
fKeyMacros notNil ifTrue:[ |
|
5600 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5601 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5602 |
^ self |
|
5603 |
] |
|
5604 |
] |
|
5605 |
] |
|
5606 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5607 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5608 |
|
2506 | 5609 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
6147 | 5610 |
self parenthizeSelectionWith:$( and:$). |
5611 |
^ self. |
|
2506 | 5612 |
]. |
5613 |
(key == #'Ctrl2') ifTrue:[ |
|
6147 | 5614 |
self parenthizeSelectionWith:$" and:$". |
5615 |
^ self. |
|
2506 | 5616 |
]. |
5617 |
(key == #'Ctrl#') ifTrue:[ |
|
6147 | 5618 |
self parenthizeSelectionWith:$' and:$'. |
5619 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5620 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5621 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
6147 | 5622 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
5623 |
^ self. |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5624 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5625 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5626 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5627 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5628 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5629 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5630 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5631 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5632 |
|
3542 | 5633 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5634 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5635 |
(key == #ExpandSelectionByWord) ifTrue:[ |
6147 | 5636 |
self makeCursorVisible. |
5637 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5638 |
^ self |
|
4707 | 5639 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5640 |
(key == #SelectWord) ifTrue:[ |
6147 | 5641 |
self makeCursorVisible. |
5642 |
self selectWordUnderCursor. |
|
5643 |
^ self |
|
259
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 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5646 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5647 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5648 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5649 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5650 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5651 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5652 |
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
|
5653 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5654 |
(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
|
5655 |
(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
|
5656 |
(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
|
5657 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5658 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5659 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5660 |
(key == #BeginOfLine) ifTrue:[ |
6147 | 5661 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5662 |
"/ some shifted key to selectFromBeginOfLine |
|
5663 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5664 |
"/ see code below. |
|
5665 |
false "shiftPressed" ifTrue: [ |
|
5666 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5667 |
"/ self unselect. |
|
5668 |
"/ self cursorHome. |
|
5669 |
"Jan's modification" |
|
5670 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
|
5671 |
"/ Jan's modification modified by his own request ;-)) |
|
5672 |
self selectFromBeginOfLine. |
|
5673 |
] ifFalse: [ |
|
5674 |
self unselect. |
|
5675 |
ctrlPressed ifTrue:[ |
|
5676 |
self cursorHome. |
|
5677 |
] ifFalse:[ |
|
5678 |
self cursorToBeginOfLine. |
|
5679 |
] |
|
5680 |
]. |
|
5681 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5682 |
]. |
5226 | 5683 |
(key == #BSelectFromeginOfLine) ifTrue:[ |
6147 | 5684 |
self selectFromBeginOfLine. |
5685 |
^ self |
|
5226 | 5686 |
]. |
5687 |
||
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5688 |
(key == #EndOfLine) ifTrue:[ |
6147 | 5689 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5690 |
"/ some shifted key to selectFromBeginOfLine |
|
5691 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5692 |
"/ see code below. |
|
5693 |
false "shiftPressed" ifTrue:[ |
|
5694 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5695 |
"/ self unselect. |
|
5696 |
"/ self cursorToBottom |
|
5697 |
" Jan's modification" |
|
5698 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5699 |
"/ Jan's modification modified by his own request ;-)) |
|
5700 |
self selectToEndOfLine. |
|
5701 |
] ifFalse:[ |
|
5702 |
self unselect. |
|
5703 |
ctrlPressed ifTrue:[ |
|
5704 |
self cursorToBottom |
|
5705 |
] ifFalse:[ |
|
5706 |
self cursorToEndOfLine. |
|
5707 |
] |
|
5708 |
]. |
|
5709 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5710 |
]. |
5226 | 5711 |
|
5712 |
(key == #SelectToEndOfLine) ifTrue:[ |
|
6147 | 5713 |
self selectToEndOfLine. |
5714 |
^ self |
|
5226 | 5715 |
]. |
5716 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5717 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5718 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5719 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5720 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5721 |
|
5119 | 5722 |
(rawKey == #CursorRight |
5723 |
or:[rawKey == #CursorDown |
|
5724 |
or:[rawKey == #CursorLeft |
|
5725 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
6147 | 5726 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
5727 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5728 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5729 |
|
5119 | 5730 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
6147 | 5731 |
self unselect. self cursorReturn. |
5732 |
^ self |
|
3257 | 5733 |
]. |
5734 |
||
5735 |
(key == #Return) ifTrue:[ |
|
6147 | 5736 |
shiftPressed ifTrue:[ |
5737 |
self unselect. self cursorReturn. |
|
5738 |
^ self |
|
5739 |
]. |
|
5740 |
||
5741 |
self isReadOnly ifTrue:[ |
|
5742 |
self unselect; makeCursorVisible. |
|
5743 |
self cursorReturn |
|
5744 |
] ifFalse:[ |
|
5745 |
self isInInsertMode ifFalse:[ |
|
5746 |
self cursorReturn:true. |
|
5747 |
autoIndent == true ifTrue:[ |
|
5748 |
i := self leftIndentForLine:(cursorLine + 1). |
|
5749 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
|
5750 |
self cursorCol:(i+1 max:1) |
|
5751 |
] |
|
5752 |
] |
|
5753 |
] ifTrue:[ |
|
5754 |
|left right oldIndent| |
|
5755 |
||
5756 |
"/ old version just unselected ... |
|
5757 |
"/ self unselect; makeCursorVisible. |
|
5758 |
||
5759 |
"/ new version deletes ... |
|
5760 |
typeOfSelection == #paste ifTrue:[ |
|
5761 |
self unselect; makeCursorVisible. |
|
5762 |
] ifFalse:[ |
|
5763 |
self copyAndDeleteSelection. |
|
5764 |
]. |
|
5765 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
|
5766 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
5767 |
self insertCharAtCursor:(Character cr). |
|
5768 |
||
5769 |
autoIndent == true ifTrue:[ |
|
5770 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
|
5771 |
"/ nothing to do. |
|
5772 |
] ifFalse:[ |
|
5773 |
((self listAt:cursorLine) isEmptyOrNil |
|
5774 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
|
5775 |
i := (self leftIndentForLine:cursorLine). |
|
5776 |
left := left withoutSeparators. |
|
5777 |
right := right withoutSeparators. |
|
5778 |
(left endsWith:'[') ifTrue:[ |
|
4823 | 5779 |
"/ i := i + 4. |
6147 | 5780 |
] ifFalse:[ |
5781 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
|
5782 |
i := i - 4. |
|
5783 |
]. |
|
5784 |
]. |
|
5785 |
oldIndent := self leftIndentOfLine:cursorLine. |
|
5786 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5787 |
self st80EditMode ifTrue:[ |
|
5788 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5789 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5790 |
]. |
|
5791 |
]. |
|
5792 |
self cursorCol:(i+1 max:1) |
|
5793 |
]. |
|
5794 |
] |
|
5795 |
]. |
|
5796 |
]. |
|
5797 |
]. |
|
5798 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5799 |
]. |
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
|
5800 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5801 |
(key == #NonInsertingTab) ifTrue:[ |
6150 | 5802 |
((rawKey == #ShiftTab) |
5803 |
and:[self hasSelection |
|
5804 |
and:[selectStyle == #line]] |
|
5805 |
) ifTrue:[ |
|
5806 |
self executekeyboardMacroNamed:#UndentBy4. |
|
5807 |
^ self. |
|
5808 |
]. |
|
6147 | 5809 |
self unselect. self cursorTab. |
5810 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5811 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5812 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
6147 | 5813 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5814 |
||
5815 |
self hasSelection ifTrue:[ |
|
5816 |
selectStyle == #line ifTrue:[ |
|
5817 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
|
5818 |
macroName := #IndentBy4. |
|
5819 |
] ifFalse:[ |
|
5820 |
macroName := #UndentBy4. |
|
5821 |
]. |
|
5822 |
macroName notNil ifTrue:[ |
|
5823 |
self executekeyboardMacroNamed:macroName. |
|
6150 | 5824 |
^ self. |
6147 | 5825 |
]. |
5826 |
] |
|
5827 |
]. |
|
5828 |
||
5829 |
self unselect. |
|
5830 |
(key == #Tab) ifTrue:[ |
|
5831 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5832 |
self cursorTab. |
|
5833 |
^ self |
|
5834 |
]. |
|
5835 |
self insertTabAtCursor. |
|
5836 |
^ self |
|
5837 |
]. |
|
5838 |
self cursorBacktab. |
|
5839 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5840 |
]. |
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
|
5841 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5842 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5843 |
(rawKey == #Delete) ifTrue:[ |
6147 | 5844 |
shiftPressed ifTrue:[ |
5845 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5846 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5847 |
self makeCursorVisible. |
|
5848 |
self deleteCharAtCursor. |
|
5849 |
]. |
|
5850 |
^ self |
|
5851 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5852 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5853 |
|
5119 | 5854 |
(rawKey == #Delete |
870 | 5855 |
or:[key == #BasicDelete]) ifTrue:[ |
6147 | 5856 |
selectionStartLine notNil ifTrue:[ |
4130 | 5857 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5858 |
"/ To remove text repetetively, use Cut instead. |
|
5859 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5860 |
"/ lastReplacementInfo lastReplacement: nil. |
|
6147 | 5861 |
((key == #BasicDelete) |
5862 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
|
5863 |
self deleteSelection. |
|
5864 |
] ifFalse:[ |
|
5865 |
self copyAndDeleteSelection. |
|
5866 |
]. |
|
5867 |
^ self |
|
5868 |
]. |
|
5869 |
self makeCursorVisible. |
|
5870 |
self deleteCharAtCursor. |
|
5871 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5872 |
]. |
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
|
5873 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5874 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
6147 | 5875 |
self unselect. |
5876 |
cursorVisibleLine == 1 ifTrue:[ |
|
5877 |
self cursorHome. |
|
5878 |
] ifFalse:[ |
|
5879 |
self cursorToFirstVisibleLine |
|
5880 |
]. |
|
5881 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5882 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5883 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
6147 | 5884 |
self unselect. |
5885 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5886 |
self cursorToBottom. |
|
5887 |
] ifFalse:[ |
|
5888 |
self cursorToLastVisibleLine |
|
5889 |
]. |
|
5890 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5891 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5892 |
((key == #Escape) |
3257 | 5893 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
6147 | 5894 |
self makeCursorVisible. |
5895 |
self unselect. self selectCursorLineFromBeginning. |
|
5896 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5897 |
]. |
6354 | 5898 |
(key == #SelectToLineEnd) ifTrue:[ |
5899 |
self makeCursorVisible. |
|
5900 |
self unselect. self selectCursorLineToEnd. |
|
5901 |
^ self |
|
5902 |
]. |
|
3257 | 5903 |
(key == #SelectLine) ifTrue:[ |
6147 | 5904 |
self makeCursorVisible. |
5905 |
self unselect. self selectCursorLine. |
|
5906 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5907 |
]. |
3257 | 5908 |
(key == #ExpandSelectionByLine) ifTrue:[ |
6147 | 5909 |
"/ self makeCursorVisible. |
5910 |
self selectExpandCursorLine. |
|
5911 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5912 |
]. |
3257 | 5913 |
(key == #DeleteLine) ifTrue:[ |
6147 | 5914 |
self makeCursorVisible. |
5915 |
self unselect. self deleteCursorLine. |
|
5916 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5917 |
]. |
3257 | 5918 |
(key == #InsertLine) ifTrue:[ |
6147 | 5919 |
self makeCursorVisible. |
5920 |
self unselect. self insertLine:nil before:cursorLine. |
|
5921 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5922 |
]. |
3781 | 5923 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5924 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5925 |
|
3310 | 5926 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5927 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6152 | 5928 |
"Modified: / 28-04-2017 / 09:25:22 / cg" |
6399 | 5929 |
"Modified: / 22-08-2018 / 08:36:19 / Claus Gittinger" |
121 | 5930 |
! |
5931 |
||
2952 | 5932 |
executeKeyboardMacro:cmdMacro |
5933 |
Error handle:[:ex | |
|
6152 | 5934 |
self warn:'Error in keyboard macro: ' , ex description. |
5935 |
ex return. |
|
2952 | 5936 |
] do:[ |
6152 | 5937 |
AbortOperationRequest handle:[:ex | |
5938 |
self warn:'Keyboard macro aborted'. |
|
5939 |
ex return. |
|
5940 |
] do:[ |
|
5941 |
Parser |
|
5942 |
evaluate:cmdMacro asString |
|
5943 |
receiver:self |
|
5944 |
notifying:nil |
|
5945 |
compile:false. |
|
5946 |
]. |
|
2952 | 5947 |
]. |
5948 |
! |
|
5949 |
||
5950 |
handleNonCommandKey:keyArg |
|
4700 | 5951 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5952 |
|
6226 | 5953 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
2952 | 5954 |
|
5955 |
key := keyArg. |
|
5956 |
||
5957 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 5958 |
"pasted selection will NOT be replaced by keystroke" |
5959 |
self unselect |
|
2952 | 5960 |
]. |
5961 |
||
4700 | 5962 |
selStartLineBefore := selectionStartLine. |
5963 |
selStartColBefore := self selectionStartCol. |
|
5964 |
selEndLineBefore := selectionEndLine. |
|
5965 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5966 |
|
6270 | 5967 |
gc characterEncoding ~~ #'iso10646-1' ifTrue:[ |
5968 |
key := CharacterEncoder encodeString:key asString from:#'iso10646-1' into:gc characterEncoding. |
|
2952 | 5969 |
]. |
5970 |
||
5971 |
"replace selection by what is typed in - |
|
3235 | 5972 |
if word was selected with a space, keep it. |
4700 | 5973 |
if there was no selection, the key's character is inserted" |
3235 | 5974 |
|
5975 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
6152 | 5976 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5977 |
]. |
2952 | 5978 |
|
5979 |
(selectStyle == #wordLeft) ifTrue:[ |
|
6152 | 5980 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5981 |
] ifFalse:[ |
6152 | 5982 |
(selectStyle == #wordRight) ifTrue:[ |
5983 |
self replaceSelectionBy:(key asString , ' '). |
|
5984 |
self cursorLeft |
|
5985 |
] ifFalse:[ |
|
5986 |
self replaceSelectionBy:key |
|
5987 |
] |
|
3160 | 5988 |
]. |
2952 | 5989 |
selectStyle := nil. |
5990 |
||
3235 | 5991 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 5992 |
selectionStartLine := selStartLineBefore. |
5993 |
selectionStartCol := selStartColBefore. |
|
5994 |
selectionEndLine := selEndLineBefore. |
|
5995 |
selectionEndCol := selEndColBefore. |
|
3235 | 5996 |
]. |
5997 |
||
6399 | 5998 |
self maybeShowMatchingParenthesisFor:key. |
2952 | 5999 |
|
6000 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
6001 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
6002 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
6003 |
"/ |
|
6004 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
6005 |
"/ self selection. |
|
6006 |
"/ typeOfSelection := #paste. |
|
3160 | 6007 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6008 |
"/ ]. |
3235 | 6009 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 6010 |
selectionStartLine isNil ifTrue:[ |
6011 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
|
6012 |
] ifFalse:[ |
|
6013 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
|
6014 |
]. |
|
3235 | 6015 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6016 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 6017 |
|
6226 | 6018 |
"Modified: / 11-11-2017 / 12:54:01 / cg" |
6270 | 6019 |
"Modified: / 19-01-2018 / 12:23:41 / stefan" |
6399 | 6020 |
"Modified: / 22-08-2018 / 08:34:25 / Claus Gittinger" |
2952 | 6021 |
! |
6022 |
||
6023 |
keyPress:key x:x y:y |
|
6024 |
"handle keyboard input" |
|
6025 |
||
4771 | 6026 |
|wasOn| |
6027 |
||
6028 |
wasOn := cursorShown. |
|
6029 |
||
5787 | 6030 |
NoModificationError |
6152 | 6031 |
handle:[:ex | |
6032 |
self flashReadOnly. |
|
6033 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
6034 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6035 |
]. |
|
6036 |
] |
|
6037 |
do:[ |
|
6038 |
self undoableDo:[ |
|
6039 |
self doKeyPress:key x:x y:y |
|
6040 |
]. |
|
6041 |
]. |
|
5689 | 6042 |
|
4242 | 6043 |
self repairDamage |
6044 |
||
6045 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 6046 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 6047 |
! |
6048 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6049 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6050 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6051 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6052 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6053 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6054 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6055 |
|
6399 | 6056 |
maybeShowMatchingParenthesisFor:characterBeforeCursor |
6057 |
showMatchingParenthesis ifTrue:[ |
|
6058 |
"emacs style parenthesis shower" |
|
6059 |
"claus: only do it for closing parenthesis - otherwise its too anoying." |
|
6060 |
("'()[]{}'" ')]}' includes:characterBeforeCursor) ifTrue:[ |
|
6061 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
|
6062 |
self |
|
6063 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
6064 |
ifFound:[:line :col | self showMatchingParenthesisAtLine:line col:col ] |
|
6065 |
ifNotFound:[self showNotFound] |
|
6066 |
onError:[self beepInEditor] |
|
6067 |
]. |
|
6068 |
] |
|
6069 |
]. |
|
6070 |
||
6071 |
"Created: / 22-08-2018 / 08:34:04 / Claus Gittinger" |
|
6072 |
! |
|
6073 |
||
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6074 |
requestAutoAccept |
5068 | 6075 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
6076 |
This forces my value to be accepted into my model. |
|
6077 |
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
|
6078 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6079 |
acceptEnabled == false ifTrue:[ |
6152 | 6080 |
"/ nope - |
6081 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6082 |
]. |
5404 | 6083 |
"/ cg: only do this if modified. |
6084 |
"/ otherwise, users would have to make sure that the contents is |
|
6085 |
"/ always correct (which they don't). If you change this back, |
|
6086 |
"/ please check the expecco file-save or file-reimport dialog, |
|
6087 |
"/ which has a problem with that behavior. |
|
6088 |
self modified ifTrue:[ |
|
6152 | 6089 |
self accept. |
5404 | 6090 |
]. |
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6091 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6092 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6093 |
|
6399 | 6094 |
showMatchingParenthesisAtLine:line col:col |
6095 |
self withCursor:Cursor eye do:[ |
|
6096 |
|savLine savCol sensor| |
|
6097 |
||
6098 |
savLine := cursorLine. |
|
6099 |
savCol := cursorCol. |
|
6100 |
self cursorLine:line col:col. |
|
6101 |
self flush. |
|
6102 |
||
6103 |
"/ want to wait 240ms, but not if another keyPress |
|
6104 |
"/ arrives in the meantime ... |
|
6105 |
||
6106 |
sensor := self sensor. |
|
6107 |
6 timesRepeat:[ |
|
6108 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
6109 |
Processor activeProcess millisecondDelay:40. |
|
6110 |
] |
|
6111 |
]. |
|
6112 |
self cursorLine:savLine col:savCol |
|
6113 |
] |
|
6114 |
||
6115 |
"Created: / 22-08-2018 / 08:22:13 / Claus Gittinger" |
|
6116 |
! |
|
6117 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6118 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6119 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6120 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6121 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6122 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6123 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6124 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6125 |
cv notNil ifTrue:[ |
6152 | 6126 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6127 |
] |
4967 | 6128 |
! |
6129 |
||
6130 |
unmapped |
|
6131 |
super unmapped. |
|
6132 |
||
6133 |
completionSupport notNil ifTrue:[ |
|
6152 | 6134 |
completionSupport release. |
4967 | 6135 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6136 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6137 |
|
1807 | 6138 |
!EditTextView methodsFor:'focus handling'! |
6139 |
||
4818 | 6140 |
focusOut |
6141 |
super focusOut. |
|
6142 |
||
6143 |
completionSupport notNil ifTrue:[ |
|
6152 | 6144 |
completionSupport release. |
4818 | 6145 |
]. |
6146 |
! |
|
6147 |
||
1807 | 6148 |
hasKeyboardFocus:aBoolean |
6149 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
6150 |
(otherwise, I would not know about this)" |
|
6151 |
||
6152 |
hasKeyboardFocus := aBoolean. |
|
4609 | 6153 |
|
3160 | 6154 |
(cursorShown |
6155 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6156 |
and:[self isReadOnly not]]) ifTrue:[ |
5890 | 6157 |
self drawCursor |
4609 | 6158 |
]. |
6159 |
||
6160 |
hasKeyboardFocus ifFalse:[ |
|
5890 | 6161 |
completionSupport notNil ifTrue:[ |
6162 |
"/ this is a hack for Windows: |
|
6163 |
"/ on windows, an activate:false event is first sent to my textView, |
|
6164 |
"/ then an activate is sent to the completion popup. |
|
6165 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
6166 |
"/ therefore, allow for the activate of the completionMenu and its button event to be processed. |
|
6167 |
"/ before forcing it to be closed... |
|
6168 |
completionSupport startTimeoutForEditViewLostFocus. |
|
6169 |
]. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6170 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6171 |
|
4821 | 6172 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 6173 |
! |
6174 |
||
6175 |
showFocus:explicit |
|
6176 |
"in addition to however my superclass thinks how a focusView is to be |
|
6177 |
displayed, show the cursor when I got the focus" |
|
6178 |
||
5239 | 6179 |
self hasKeyboardFocus:true. |
1807 | 6180 |
self showCursor. |
6181 |
super showFocus:explicit |
|
6182 |
||
6183 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6184 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6185 |
|
4967 | 6186 |
showNoFocus:explicit |
5787 | 6187 |
"the view lost the keyboard focus |
4967 | 6188 |
(either explicit, via tabbing; or implicit, by pointer movement) |
6189 |
- change any display attributes as req'd." |
|
6190 |
||
6191 |
super showNoFocus:explicit. |
|
5149 | 6192 |
|
6193 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
6194 |
"/ not when the focus is lost normally (because this also happens when |
|
6195 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
6196 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
6197 |
explicit ifTrue:[ |
|
6152 | 6198 |
completionSupport notNil ifTrue:[ |
6199 |
completionSupport release. |
|
6200 |
]. |
|
4818 | 6201 |
]. |
6202 |
! |
|
6203 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6204 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6205 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6206 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6207 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6208 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6209 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6210 |
and:[self enabled |
4781 | 6211 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6212 |
) ifTrue:[ |
6152 | 6213 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6214 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6215 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6216 |
^ false |
1807 | 6217 |
! ! |
6218 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6219 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6220 |
|
4237 | 6221 |
executekeyboardMacroNamed:macroName |
5787 | 6222 |
"try to execute the keyboard macro; |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6223 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6224 |
|
4482 | 6225 |
|cmdMacro| |
6226 |
||
6227 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6228 |
self |
6152 | 6229 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
6230 |
info: macroName. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6231 |
^ true |
4238 | 6232 |
|
6233 |
" |
|
4483 | 6234 |
EditTextView open |
6152 | 6235 |
contents:'bla'; |
6236 |
selectAll; |
|
6237 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6238 |
EditTextView open |
6152 | 6239 |
contents:'bla'; |
6240 |
selectAll; |
|
6241 |
executekeyboardMacroNamed:#blabla. |
|
4238 | 6242 |
" |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6243 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6244 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6245 |
! |
6246 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6247 |
indent |
3221 | 6248 |
"indent a line-range - this is done by searching for the |
6249 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6250 |
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
|
6251 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6252 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6253 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6254 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6255 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6256 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6257 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6258 |
(selectionEndCol == 0) ifTrue:[ |
6152 | 6259 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6260 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6261 |
self unselect. |
3160 | 6262 |
self |
6152 | 6263 |
undoableDo:[self indentFromLine:start toLine:end] |
6264 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6265 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6266 |
|
4237 | 6267 |
indentBy4 |
5050 | 6268 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6269 |
||
6270 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6271 |
! |
|
6272 |
||
6273 |
indentBy8 |
|
6274 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6275 |
|
6276 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6277 |
! |
|
6278 |
||
5050 | 6279 |
indentBy:n |
6280 |
|line1 line2| |
|
6281 |
||
6282 |
line1 := self selectionStartLine. |
|
6283 |
line2 := self selectionEndLine. |
|
6284 |
line1 isNil ifTrue:[ |
|
5833 | 6285 |
line1 := self cursorLine. |
6286 |
line1 notNil ifTrue:[ |
|
6287 |
line2 := line1 |
|
6288 |
] |
|
5769 | 6289 |
] ifFalse:[ |
5833 | 6290 |
line2 notNil ifTrue:[ |
6291 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
6292 |
]. |
|
5787 | 6293 |
]. |
5050 | 6294 |
line1 notNil ifTrue:[ |
5833 | 6295 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6296 |
] |
6297 |
! |
|
6298 |
||
6299 |
indentByTab |
|
6300 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6301 |
! |
|
6302 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6303 |
indentFromLine:start toLine:end |
3221 | 6304 |
"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
|
6305 |
last non-empty line before start, and change the indent |
4742 | 6306 |
of the selected line-range based on that line's indent." |
6307 |
||
4811 | 6308 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6309 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6310 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6311 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6312 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6313 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6314 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6315 |
self indentFromLine:start toLine:end by:delta |
6316 |
! |
|
6317 |
||
6318 |
indentFromLine:start toLine:end by:delta |
|
6319 |
"indent a line-range - this is done by searching for the |
|
6320 |
last non-empty line before start, and change the indent |
|
6321 |
of the selected line-range based on that line's indent." |
|
6322 |
||
6323 |
|d line spaces anyChange| |
|
6324 |
||
6325 |
(delta == 0) ifTrue:[^ self]. |
|
6226 | 6326 |
|
6327 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[ ^ self]. |
|
6328 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6329 |
(delta > 0) ifTrue:[ |
6152 | 6330 |
spaces := String new:delta |
4742 | 6331 |
]. |
6332 |
||
6333 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6334 |
start to:end do:[:lineNr | |
6152 | 6335 |
line := self listAt:lineNr. |
6336 |
line notNil ifTrue:[ |
|
6337 |
line isBlank ifTrue:[ |
|
6338 |
self basicListAt:lineNr put:nil |
|
6339 |
] ifFalse:[ |
|
6340 |
(delta > 0) ifTrue:[ |
|
6341 |
line := spaces , line. |
|
6342 |
widthOfWidestLine notNil ifTrue:[ |
|
6343 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6344 |
] |
|
6345 |
] ifFalse:[ |
|
6346 |
"check if deletion is ok" |
|
6249 | 6347 |
d := delta negated. |
6152 | 6348 |
|
6349 |
line size > d ifTrue:[ |
|
6249 | 6350 |
(line copyTo:d) withoutSeparators isEmpty ifTrue:[ |
6351 |
line := line copyFrom:(d+1) |
|
6152 | 6352 |
] |
6353 |
]. |
|
6354 |
widthOfWidestLine := nil |
|
6355 |
]. |
|
6356 |
self replaceLine:lineNr with:line. |
|
6357 |
anyChange := true. |
|
6358 |
] |
|
6359 |
] |
|
4742 | 6360 |
]. |
6361 |
||
6362 |
anyChange ifTrue:[ self textChanged ]. |
|
6363 |
||
3221 | 6364 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6365 |
|
6226 | 6366 |
"Modified: / 11-11-2017 / 12:54:33 / cg" |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6367 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6368 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6369 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6370 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6371 |
this is done by searching for the last non-empty line before it |
4823 | 6372 |
and returning its indent. |
6373 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6374 |
|
827 | 6375 |
"SHOULD GO TO ListView" |
6376 |
||
6377 |
|line lnr indent| |
|
6378 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6379 |
lnr := lineNr. |
6147 | 6380 |
[lnr > 1] whileTrue:[ |
6381 |
lnr := lnr - 1. |
|
6382 |
line := self listAt:lnr. |
|
6383 |
||
6384 |
line notEmptyOrNil ifTrue:[ |
|
6385 |
indent := (line indexOfNonSeparatorStartingAt:1) - 1. |
|
6386 |
indent >= 0 ifTrue:[ |
|
6387 |
(self editedLanguage isNil or:[self editedLanguage isSmalltalk]) ifTrue:[ |
|
6388 |
(line endsWith:$[) ifTrue:[ |
|
6389 |
^ indent + 4 |
|
6390 |
]. |
|
6391 |
(line endsWith:']') ifTrue:[ |
|
6392 |
^ indent - 4 |
|
6393 |
]. |
|
6394 |
]. |
|
6395 |
^ indent |
|
6396 |
] |
|
6397 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6398 |
]. |
827 | 6399 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6400 |
|
6147 | 6401 |
"Created: / 05-03-1996 / 14:58:53 / cg" |
6402 |
"Modified (format): / 25-04-2017 / 12:57:44 / cg" |
|
4237 | 6403 |
! |
6404 |
||
6405 |
undentBy4 |
|
5050 | 6406 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6407 |
||
6408 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6409 |
! |
|
6410 |
||
6411 |
undentBy8 |
|
6412 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6413 |
|
6414 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6415 |
! |
6416 |
||
6417 |
undentBy:n |
|
6418 |
self indentBy:(n negated) |
|
6419 |
! |
|
6420 |
||
6421 |
undentByTab |
|
6422 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6423 |
! ! |
6424 |
||
0 | 6425 |
!EditTextView methodsFor:'initialization'! |
6426 |
||
941 | 6427 |
fetchDeviceResources |
6428 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6429 |
||
6430 |
super fetchDeviceResources. |
|
6431 |
||
5643 | 6432 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6433 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6434 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6435 |
|
6436 |
"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
|
6437 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6438 |
! |
6439 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6440 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6441 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6442 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6443 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6444 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6445 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6446 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6447 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6448 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6449 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6450 |
super initStyle. |
4576 | 6451 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6452 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6453 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6454 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6455 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6456 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6457 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6458 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6459 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6152 | 6460 |
cursorTypeNoFocus := cursorType. |
6461 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6462 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6463 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6464 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6465 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6466 |
cursorNoFocusFgColor isNil ifTrue:[ |
6152 | 6467 |
cursorType ~~ #block ifTrue:[ |
6468 |
cursorNoFocusFgColor := cursorBgColor |
|
6469 |
] ifFalse:[ |
|
6470 |
cursorNoFocusFgColor := cursorFgColor |
|
6471 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6472 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6473 |
|
2088 | 6474 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6475 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6476 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6477 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6478 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6479 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6480 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6481 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6482 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6483 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6484 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6485 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6486 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6487 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6488 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6489 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6490 |
cursorCol := 1. |
5251 | 6491 |
cursorLineHolder := ValueHolder with:1. |
6492 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6493 |
modifiedChannel := ValueHolder with:false. |
6494 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6495 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6496 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6497 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6498 |
tabMeansNextField := false. |
5106 | 6499 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6500 |
autoIndent := false. |
|
5251 | 6501 |
editMode := ValueHolder with:EditMode insertMode. |
6502 |
learnMode := ValueHolder with:false. |
|
2131 | 6503 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6504 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6505 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6506 |
"/ enable drop by default |
2589 | 6507 |
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
|
6508 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6509 |
undoSupport := UndoSupport for:self. |
5251 | 6510 |
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
|
6511 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6512 |
"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
|
6513 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6514 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6515 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6516 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6517 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6518 |
completionSupport isNil ifTrue:[ |
6152 | 6519 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
6520 |
completionSupport := supportClass for:self. |
|
6521 |
]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6522 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6523 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6524 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6525 |
! |
6526 |
||
6527 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6528 |
completionSupport notNil ifTrue:[ |
6152 | 6529 |
completionSupport release |
4771 | 6530 |
]. |
6517 | 6531 |
CharacterInputViewSingleton notNil ifTrue:[ |
6532 |
CharacterInputViewSingleton consumingView == self ifTrue:[ |
|
6533 |
CharacterInputViewSingleton closeRequest. |
|
6534 |
CharacterInputViewSingleton := nil |
|
6535 |
] |
|
6536 |
]. |
|
6537 |
||
4771 | 6538 |
super release |
6517 | 6539 |
|
6540 |
"Modified: / 08-01-2019 / 18:16:31 / Claus Gittinger" |
|
0 | 6541 |
! ! |
6542 |
||
2580 | 6543 |
!EditTextView methodsFor:'macros'! |
6544 |
||
6545 |
executeLearnedKeyboardMacro |
|
4673 | 6546 |
"replay the characters as learned previously" |
6547 |
||
6548 | 6548 |
(self learnMode not and:[learnedMacro size ~~ 0]) ifTrue:[ |
6152 | 6549 |
ExecutingMacroQuery |
6550 |
answer:true |
|
6551 |
do:[ |
|
6552 |
learnedMacro do:[:event | |
|
6436 | 6553 |
self |
6554 |
dispatchEvent:event |
|
6555 |
withFocusOn:nil |
|
6556 |
delegate:false |
|
6152 | 6557 |
] |
6558 |
]. |
|
2580 | 6559 |
] ifFalse:[ |
6152 | 6560 |
self flash:'no macro'. |
2580 | 6561 |
]. |
6436 | 6562 |
|
6548 | 6563 |
"Modified: / 01-03-2019 / 14:54:46 / Claus Gittinger" |
2580 | 6564 |
! |
6565 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6566 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6567 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6568 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6569 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6570 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6571 |
|
2580 | 6572 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6573 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6574 |
|
2580 | 6575 |
|fg bg| |
6576 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6577 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6578 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6579 |
aBoolean ifTrue:[ |
5795 | 6580 |
learnedMacro := OrderedCollection new. |
6581 |
fg := self whiteColor. |
|
6582 |
bg := self blackColor. |
|
2580 | 6583 |
] ifFalse:[ |
5795 | 6584 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6585 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6586 |
]. |
6587 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6588 |
! |
|
6589 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6590 |
learnModeHolder |
4673 | 6591 |
"a holder returning true, if in learn mode" |
6592 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6593 |
learnMode isNil ifTrue:[ |
6152 | 6594 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6595 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6596 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6597 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6598 |
|
4673 | 6599 |
rememberLearnedMacroAs: nameString |
6600 |
Macros isNil ifTrue:[ |
|
6152 | 6601 |
Macros := Dictionary new. |
4673 | 6602 |
]. |
6603 |
Macros at:nameString put:learnedMacro |
|
6604 |
! |
|
6605 |
||
2580 | 6606 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6607 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6608 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6609 |
self learnMode:(self learnMode not). |
2580 | 6610 |
! ! |
6611 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6612 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6613 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6614 |
babelFishTranslate:fromToModeString |
5962 | 6615 |
"translate the selected text and paste it after the selection. |
6616 |
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
|
6617 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6618 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6619 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6620 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6621 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6622 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6623 |
self withWaitCursorDo:[ |
5962 | 6624 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
6625 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
6626 |
] do:[ |
|
6627 |
translated := SOAP::BabelFishClient new |
|
6628 |
translate:original mode:fromToModeString. |
|
6629 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6630 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6631 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6632 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6633 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6634 |
self unselect. |
5787 | 6635 |
self |
5962 | 6636 |
undoablePaste:translated |
6637 |
info:'Translate' |
|
3495 | 6638 |
|
6639 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6640 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6641 |
|
5689 | 6642 |
copySelection |
6643 |
"copy contents into smalltalk copybuffer. |
|
6644 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6645 |
||
6646 |
self hasSelection ifTrue:[ |
|
6152 | 6647 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
5689 | 6648 |
]. |
6649 |
super copySelection. |
|
6650 |
||
6651 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6652 |
! |
|
6653 |
||
121 | 6654 |
cut |
6655 |
"cut selection into copybuffer" |
|
6656 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6657 |
self deleteCopyToClipboard:true |
121 | 6658 |
! |
6659 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6660 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6661 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6662 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6663 |
cursorLine notNil ifTrue:[ |
6152 | 6664 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6665 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6666 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6667 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6668 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6669 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6670 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6671 |
|
4129 | 6672 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6673 |
|
6226 | 6674 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6675 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6676 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6677 |
sel notNil ifTrue:[ |
6152 | 6678 |
self setLastStringToReplace: sel. |
6679 |
||
6680 |
line := selectionStartLine. |
|
6681 |
col := selectionStartCol. |
|
6682 |
||
6683 |
toClipboard ifTrue:[ |
|
6684 |
" |
|
6685 |
remember in CopyBuffer |
|
6686 |
" |
|
6687 |
self setClipboardText:sel. "/ lastString. |
|
6688 |
]. |
|
6689 |
||
6690 |
" |
|
6691 |
append to DeleteHistory (if there is one) |
|
6692 |
" |
|
6693 |
history := Smalltalk at:#DeleteHistory. |
|
6694 |
history notNil ifTrue:[ |
|
6695 |
history addAll:(sel asStringCollection). |
|
6696 |
history size > 1000 ifTrue:[ |
|
6697 |
history := history copyFrom:(history size - 1000) |
|
6698 |
]. |
|
6699 |
]. |
|
6700 |
||
6701 |
" |
|
6702 |
now, delete it |
|
6703 |
" |
|
6704 |
self |
|
6705 |
undoableDo:[self deleteSelection] |
|
6706 |
info:'Delete'. |
|
6707 |
lastReplacementInfo lastReplacement: nil |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6708 |
] ifFalse:[ |
6152 | 6709 |
" |
6710 |
a cut without selection will search&cut again |
|
6711 |
" |
|
6712 |
self undoableDo:[ |
|
6713 |
self again |
|
6714 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6715 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6716 |
|
6226 | 6717 |
"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
|
6718 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6719 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6720 |
editMenu |
5977 | 6721 |
"return the view's middleButtonMenu" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6722 |
|
5787 | 6723 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 6724 |
#Find #GotoLine #SaveAs #Print |
6725 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
|
6726 |
#ToggleAutoIndent #ToggleInsertMode |
|
6727 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6728 |
<resource: #programMenu> |
1054 | 6729 |
|
6241 | 6730 |
|items m sub translateItems sortItems miscItems toolItems convertItems subSubMenu toolSubMenu |
6731 |
transSubMenu sortSubMenu convertSubMenu what undoIdx redoIdx sensor main mainItems| |
|
1515 | 6732 |
|
2460 | 6733 |
items := #( |
5826 | 6734 |
('Redo' redo Redo ) |
6735 |
('Again (for All)' multipleAgain AgainForAll ) |
|
6736 |
('-' ) |
|
6737 |
('Search...' search Find ) |
|
6738 |
('Goto Line...' gotoLine GotoLine ) |
|
6739 |
('-' ) |
|
6740 |
('Tools' tools ) |
|
6741 |
('Font...' changeFont ) |
|
6742 |
('Insert Unicode...' insertUnicode ) |
|
6743 |
). |
|
4213 | 6744 |
CharacterSetView notNil ifTrue:[ |
5826 | 6745 |
items := items , |
6746 |
#( |
|
6747 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6748 |
). |
|
4213 | 6749 |
]. |
6750 |
items := items , #( |
|
5826 | 6751 |
('-' ) |
6752 |
('Save As...' save SaveAs ) |
|
6753 |
('Print' doPrint Print ) |
|
6754 |
('=' ) |
|
6755 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 6756 |
|
2866 | 6757 |
miscItems := #( |
5826 | 6758 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6759 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
6760 |
('-' ) |
|
6134 | 6761 |
('Copy Box' copySelectionBox CopyBox ) |
6762 |
('Paste Box' pasteOrReplaceBox PasteBox ) |
|
5826 | 6763 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
6764 |
('Join Lines' joinLines Join ) |
|
6765 |
('Wrap Lines...' wrapLines Wrap ) |
|
6766 |
('-' ) |
|
6767 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
6768 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
6769 |
('-' ) |
|
6770 |
('Insert File...' insertFile ) |
|
6771 |
('Insert URL Contents...' insertURL ) |
|
6772 |
('Insert new UUID' insertUUID ) |
|
6773 |
('Insert Date && Time' insertDateAndTime ) |
|
6774 |
('-' ) |
|
6775 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6776 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
6777 |
). |
|
4213 | 6778 |
"/ CharacterSetView notNil ifTrue:[ |
6779 |
"/ miscItems := miscItems , |
|
6780 |
"/ #( |
|
5529 | 6781 |
"/ ('-' ) |
4213 | 6782 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6783 |
"/ ('Font...' changeFont ) |
4213 | 6784 |
"/ ). |
5529 | 6785 |
"/ ] ifFalse:[ |
6786 |
"/ miscItems := miscItems , |
|
6787 |
"/ #( |
|
6788 |
"/ ('Font...' changeFont ) |
|
6789 |
"/"/ ('Encoding...' changeEncoding ) |
|
6790 |
"/ ). |
|
5787 | 6791 |
"/ ]. |
2866 | 6792 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6793 |
translateItems := #( |
5826 | 6794 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6795 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6796 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6797 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6798 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6799 |
('-' ) |
|
6800 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6801 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6802 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6803 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6804 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6805 |
). |
|
3221 | 6806 |
|
6807 |
sortItems := #( |
|
5826 | 6808 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6809 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
6810 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
6811 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6812 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
6813 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
6814 |
('-' ) |
|
6815 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
6816 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6817 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6818 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
6819 |
('-' ) |
|
6820 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6821 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
6822 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6823 |
|
2762 | 6824 |
toolItems := #( |
5826 | 6825 |
('Indent' indent ) |
6826 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6241 | 6827 |
('Sort' sortMenu ) |
5826 | 6828 |
('Split...' splitLinesAtCharacterOrString ) |
6241 | 6829 |
('Convert...' convertMenu ) |
5826 | 6830 |
('-' ) |
6831 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6241 | 6832 |
('Builtin Spell Check' internalSpellingSuggestion ) |
6833 |
('Translate' babelFishTranslateMenu ) |
|
5826 | 6834 |
('Compare with Clipboard...' compareWithClipboard ) |
6835 |
('Compare with File...' compareWithFile ) |
|
6836 |
). |
|
2762 | 6837 |
|
6241 | 6838 |
convertItems := #( |
6839 |
('Base64 Decode' selectionDecodeBase64 ) |
|
6840 |
('Base64 Encode' selectionEncodeBase64 ) |
|
6841 |
('Rot13' selectionRot13 ) |
|
6842 |
). |
|
6843 |
||
6359 | 6844 |
toolItems := toolItems , #( |
6845 |
('-' ) |
|
6846 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6847 |
('Open WebBrowser on It' openWebBrowserOnIt ) |
|
6848 |
). |
|
6849 |
||
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6850 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 6851 |
toolItems := toolItems , #( |
6852 |
('-' ) |
|
6853 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6854 |
('Inspect Selected String' inspectSelectedString ) |
|
6855 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6856 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6857 |
|
2460 | 6858 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6859 |
sub receiver:self. |
2460 | 6860 |
|
6241 | 6861 |
toolSubMenu := PopUpMenu itemList:toolItems resources:resources performer:model. |
6862 |
toolSubMenu receiver:self. |
|
6863 |
sub subMenuAt:#tools put:toolSubMenu. |
|
6864 |
||
6865 |
transSubMenu := PopUpMenu itemList:translateItems resources:resources performer:model. |
|
6866 |
transSubMenu receiver:self. |
|
6867 |
toolSubMenu subMenuAt:#babelFishTranslateMenu put:transSubMenu. |
|
6868 |
||
6869 |
sortSubMenu := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6870 |
sortSubMenu receiver:self. |
|
6871 |
toolSubMenu subMenuAt:#sortMenu put:sortSubMenu. |
|
6872 |
||
6873 |
convertSubMenu := PopUpMenu itemList:convertItems resources:resources performer:model. |
|
6874 |
convertSubMenu receiver:self. |
|
6875 |
toolSubMenu subMenuAt:#convertMenu put:convertSubMenu. |
|
6876 |
||
6877 |
subSubMenu := PopUpMenu itemList:miscItems resources:resources performer:model. |
|
6878 |
subSubMenu receiver:self. |
|
6879 |
subSubMenu checkToggleAt:#autoIndent: put:autoIndent. |
|
6880 |
subSubMenu checkToggleAt:#insertMode: put:(self isInInsertMode). |
|
6881 |
subSubMenu checkToggleAt:#learnMode: put:(self learnModeHolder value). |
|
6882 |
||
6883 |
sub subMenuAt:#misc put:subSubMenu. |
|
2866 | 6884 |
|
3495 | 6885 |
mainItems := #( |
5826 | 6886 |
('Undo' undo Undo ) |
6887 |
('Again' again Again ) |
|
6888 |
('-' ) |
|
6134 | 6889 |
('Cut' cut Cut )). |
6890 |
self sensor metaDown ifTrue:[ |
|
6891 |
mainItems := mainItems , #( |
|
6892 |
('Copy Box' copySelectionBox CopyBox ) |
|
6893 |
('Paste Box' pasteOrReplaceBox PasteBox )) |
|
6894 |
] ifFalse:[ |
|
6895 |
mainItems := mainItems , #( |
|
6477
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
6896 |
('Copy' copySelection Copy ) |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
6897 |
('Paste' pasteOrReplace Paste ) |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
6898 |
('Paste...' pasteOrReplaceFromHistory PasteFromHistory )) |
6134 | 6899 |
]. |
6900 |
mainItems := mainItems , #( |
|
5826 | 6901 |
('-' ) |
6902 |
('Accept' accept Accept ) |
|
6903 |
('=' ) |
|
6134 | 6904 |
('More' others Ctrl )). |
6905 |
||
3495 | 6906 |
main := PopUpMenu itemList:mainItems resources:resources. |
6907 |
main subMenuAt:#others put:sub. |
|
6908 |
||
6909 |
sensor := self sensor. |
|
6910 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6911 |
sensor shiftDown ifTrue:[ |
|
6241 | 6912 |
m := subSubMenu |
5826 | 6913 |
] ifFalse:[ |
6914 |
m := sub |
|
6915 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6916 |
] ifFalse:[ |
5826 | 6917 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6918 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6919 |
|
4742 | 6920 |
"/ the 'Smalltalk at:' code is here to |
6921 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6922 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 6923 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6924 |
m disable:#googleSpellingSuggestion |
|
2676 | 6925 |
]. |
4742 | 6926 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 6927 |
m disable:#internalSpellingSuggestion |
4742 | 6928 |
]. |
2676 | 6929 |
|
3811 | 6930 |
HTTPInterface isNil ifTrue:[ |
5826 | 6931 |
m disableAll:#(insertURL) |
3811 | 6932 |
]. |
6933 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6934 |
self isReadOnly ifTrue:[ |
5826 | 6935 |
m disableAll:#(accept undo again multipleAgain redo |
6134 | 6936 |
paste pasteOrReplace pasteOrReplaceBox pasteOrReplaceFromHistory |
5826 | 6937 |
cut indent autoIndent: insertMode: |
6938 |
insertFile insertFileAsStringLiteral insertURL |
|
6241 | 6939 |
babelFishTranslateMenu googleSpellingSuggestion sortMenu |
5826 | 6940 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
6228 | 6941 |
splitLinesAtCharacterOrString |
5826 | 6942 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
6241 | 6943 |
insertUnicode specialCharacters convertMenu) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6944 |
]. |
2817 | 6945 |
self hasSelectionForCopy ifFalse:[ |
5826 | 6946 |
m disable:#copySelection. |
6134 | 6947 |
m disable:#copySelectionBox. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6948 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6949 |
self hasSelection ifFalse:[ |
6241 | 6950 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslateMenu openFileBrowserOnIt |
6359 | 6951 |
openWebBrowserOnIt |
6241 | 6952 |
openWorkspaceWithIt sortMenu indent splitLinesAtCharacterOrString inspectSelectedString |
6953 |
convertMenu). |
|
2762 | 6954 |
] ifTrue:[ |
5826 | 6955 |
(Error handle:[:ex | |
6956 |
ex return:false |
|
6957 |
] do:[ |
|
6958 |
|fn| |
|
6374 | 6959 |
fn := self selectionAsString withoutSeparators. |
6960 |
fn asFilename exists or:[ fn withoutQuotes asFilename exists ] |
|
5826 | 6961 |
]) ifFalse:[ |
6962 |
m disableAll:#(openFileBrowserOnIt). |
|
6359 | 6963 |
]. |
6964 |
(Error handle:[:ex | |
|
6965 |
ex return:false |
|
6966 |
] do:[ |
|
6374 | 6967 |
|url| |
6968 |
url := self selectionAsString withoutSeparators. |
|
6969 |
#('http' 'https' 'ftp') includes:url asURL method |
|
6359 | 6970 |
]) ifFalse:[ |
6971 |
m disableAll:#(openWebBrowserOnIt). |
|
5826 | 6972 |
] |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6973 |
]. |
2569 | 6974 |
self hasUndoAction ifFalse:[ |
5826 | 6975 |
m disable:#undo. |
3115 | 6976 |
] ifTrue:[ |
5826 | 6977 |
what := undoSupport undoActionInfo. |
6978 |
what notNil ifTrue:[ |
|
6979 |
undoIdx := m indexOf:#undo. |
|
6980 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6981 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6982 |
]. |
2952 | 6983 |
self hasRedoAction ifFalse:[ |
5826 | 6984 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6985 |
] ifTrue:[ |
5826 | 6986 |
what := undoSupport redoActionInfo. |
6987 |
what notNil ifTrue:[ |
|
6988 |
redoIdx := sub indexOf:#redo. |
|
6989 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6990 |
] |
|
2952 | 6991 |
]. |
5216 | 6992 |
self canAccept ifFalse:[ |
5826 | 6993 |
m disable:#accept |
1108 | 6994 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6995 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6996 |
|
6241 | 6997 |
"Modified: / 30-11-2017 / 15:06:03 / cg" |
6374 | 6998 |
"Modified: / 06-07-2018 / 07:28:32 / Claus Gittinger" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6999 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7000 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7001 |
getTextSelectionFromHistory |
6328 | 7002 |
"present the copyBufferHistory as a shortened list (first line of each), |
7003 |
and let user select from it. |
|
7004 |
Return the corresponding copyBuffer text or nil. |
|
7005 |
Used with 'Paste Previous' menu function" |
|
7006 |
||
7007 |
|sel listOfPasteTextLines box history| |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7008 |
|
5643 | 7009 |
history := device getCopyBufferHistory copy. |
6452 | 7010 |
|
7011 |
"/ the list presents each first line only |
|
6328 | 7012 |
listOfPasteTextLines := |
7013 |
history collect:[:entry | |
|
7014 |
|text shown| |
|
7015 |
||
7016 |
text := entry asString string asCollectionOfLines. |
|
7017 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
|
7018 |
text size > 1 ifTrue:[ |
|
7019 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
|
6152 | 7020 |
]. |
6328 | 7021 |
shown |
7022 |
]. |
|
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7023 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7024 |
box := ListSelectionBox |
6152 | 7025 |
title:(resources string:'Clipboard History') |
7026 |
okText:(resources string:'Paste') |
|
7027 |
abortText:(resources string:'Cancel') |
|
6328 | 7028 |
list:listOfPasteTextLines |
6152 | 7029 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7030 |
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
|
7031 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7032 |
box show. |
3160 | 7033 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7034 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7035 |
"Modified: / 25-08-2010 / 22:02:14 / cg" |
6328 | 7036 |
"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
|
7037 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7038 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7039 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7040 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7041 |
self sensor shiftDown ifTrue:[ |
6152 | 7042 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7043 |
]. |
2724 | 7044 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7045 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7046 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7047 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7048 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7049 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7050 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7051 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7052 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7053 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7054 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7055 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7056 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7057 |
"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
|
7058 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7059 |
|
2676 | 7060 |
googleSpellingSuggestion |
7061 |
"insert the google-spelling suggestion for the selected text. |
|
7062 |
Requires that the SOAP stuff is loaded and working." |
|
7063 |
||
2677 | 7064 |
|text suggestion| |
2676 | 7065 |
|
7066 |
self withWaitCursorDo:[ |
|
6152 | 7067 |
text := self selection asString string withoutSeparators. |
7068 |
text size == 0 ifTrue:[^ self]. |
|
7069 |
||
7070 |
"/ the 'Smalltalk at:' code is here to |
|
7071 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
7072 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
7073 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
7074 |
^ self. |
|
7075 |
] do:[ |
|
7076 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
|
7077 |
]. |
|
7078 |
suggestion size == 0 ifTrue:[ |
|
7079 |
self information:('No spelling suggestion from Google for: ' , text). |
|
7080 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
7081 |
^ self. |
|
7082 |
]. |
|
5787 | 7083 |
]. |
7084 |
self |
|
6152 | 7085 |
undoablePaste:suggestion |
7086 |
info:'Spelling Suggestion'. |
|
3495 | 7087 |
|
7088 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 7089 |
! |
7090 |
||
3595 | 7091 |
insertDateAndTime |
6274 | 7092 |
"insert the current date and time string" |
3595 | 7093 |
|
7094 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7095 |
self |
6152 | 7096 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
7097 |
info:'Paste Date and Time' |
|
6274 | 7098 |
|
7099 |
"Modified (comment): / 25-01-2018 / 19:10:40 / mawalch" |
|
3595 | 7100 |
! |
7101 |
||
2676 | 7102 |
insertFile |
3160 | 7103 |
"insert contents of a file |
2676 | 7104 |
- ask user for filename using a fileSelectionBox." |
7105 |
||
3731 | 7106 |
self insertFileAsStringLiteral:false |
7107 |
! |
|
7108 |
||
7109 |
insertFileAsStringLiteral |
|
7110 |
"insert a file's contents as a string literal. |
|
7111 |
Almost the same as the insert file, but single-quotes are doubled, |
|
7112 |
to make it a legal string literal" |
|
7113 |
||
7114 |
self insertFileAsStringLiteral:true |
|
7115 |
! |
|
7116 |
||
7117 |
insertFileAsStringLiteral:asStringLiteral |
|
7118 |
"insert contents of a file; either as-is or as a string literal. |
|
7119 |
- ask user for filename using a fileSelectionBox." |
|
7120 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7121 |
|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
|
7122 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7123 |
((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
|
7124 |
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
|
7125 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7126 |
ifTrue:[ |
6152 | 7127 |
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
|
7128 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7129 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7130 |
[ |
6152 | 7131 |
|why| |
7132 |
||
7133 |
file := Dialog |
|
7134 |
requestFileName:(resources string:'Insert Contents Of:') |
|
7135 |
default:initial |
|
7136 |
ok:(resources string:'Insert') |
|
7137 |
abort:(resources string:'Cancel') |
|
7138 |
pattern:nil |
|
7139 |
fromDirectory:directoryForFileDialog. |
|
7140 |
file isNil ifTrue:[ |
|
7141 |
"cancel" |
|
7142 |
^ self. |
|
7143 |
]. |
|
7144 |
file := file asFilename. |
|
7145 |
directoryForFileDialog := file. |
|
7146 |
||
7147 |
ok := file isReadable and:[file isDirectory not]. |
|
7148 |
ok ifFalse:[ |
|
7149 |
file isReadable ifFalse:[ |
|
6543 | 7150 |
why := '"%1" is unreadable.\\Please try again.' |
6152 | 7151 |
] ifTrue:[ |
6543 | 7152 |
why := '"%1" is a directory.\\Please try again.' |
6152 | 7153 |
]. |
7154 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
7155 |
]. |
|
2909 | 7156 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7157 |
|
5063 | 7158 |
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
|
7159 |
self |
6152 | 7160 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
7161 |
info:'Paste File' |
|
3495 | 7162 |
|
7163 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6543 | 7164 |
"Modified: / 21-02-2019 / 17:42:47 / Claus Gittinger" |
3495 | 7165 |
! |
7166 |
||
3811 | 7167 |
insertURL |
7168 |
"insert contents of a URL |
|
7169 |
- ask user for URL using a dialog." |
|
7170 |
||
7171 |
self insertURLAsStringLiteral:false |
|
7172 |
! |
|
7173 |
||
7174 |
insertURLAsStringLiteral:asStringLiteral |
|
7175 |
"insert contents of a file; either as-is or as a string literal. |
|
7176 |
- ask user for filename using a fileSelectionBox." |
|
7177 |
||
7178 |
|sel url text response initial| |
|
7179 |
||
7180 |
(sel := self selectionAsString) notEmptyOrNil |
|
7181 |
ifTrue:[ |
|
6152 | 7182 |
initial := sel. |
3811 | 7183 |
]. |
7184 |
||
7185 |
url := Dialog |
|
6152 | 7186 |
request:(resources string:'Insert Contents of URL:') |
7187 |
initialAnswer:initial |
|
7188 |
okLabel:(resources string:'Insert') |
|
7189 |
title:(resources string:'URL'). |
|
3811 | 7190 |
url isNil ifTrue:[ |
6152 | 7191 |
"cancel" |
7192 |
^ self. |
|
3811 | 7193 |
]. |
6514 | 7194 |
|
7195 |
self withWaitCursorDo:[ |
|
7196 |
response := HTTPInterface get:url. |
|
7197 |
]. |
|
3811 | 7198 |
response isErrorResponse ifTrue:[ |
6152 | 7199 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
7200 |
^ self. |
|
3811 | 7201 |
]. |
7202 |
text := response data asString. |
|
7203 |
||
7204 |
self |
|
6152 | 7205 |
undoableDo:[ |
7206 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
7207 |
] |
|
7208 |
info:'Insert Contents of URL' |
|
6514 | 7209 |
|
7210 |
"Modified: / 20-12-2018 / 10:27:46 / Claus Gittinger" |
|
3811 | 7211 |
! |
7212 |
||
3495 | 7213 |
insertUUID |
7214 |
"insert a new UUID's string" |
|
7215 |
||
7216 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7217 |
self |
6152 | 7218 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
7219 |
info:'Paste New UUID' |
|
3495 | 7220 |
|
7221 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 7222 |
! |
7223 |
||
4940 | 7224 |
insertUnicode |
7225 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
7226 |
||
7227 |
|unicodePoint unicodeChar unicodeString| |
|
7228 |
||
5904 | 7229 |
unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):'). |
4940 | 7230 |
unicodeString size < 2 ifTrue:[ |
5904 | 7231 |
^ self. |
4940 | 7232 |
]. |
7233 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
5904 | 7234 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
4940 | 7235 |
] ifFalse:[ |
5904 | 7236 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
5787 | 7237 |
]. |
7238 |
||
4940 | 7239 |
unicodeChar := Character value:unicodePoint. |
7240 |
self keyPress:unicodeChar x:0 y:0. |
|
7241 |
self keyRelease:unicodeChar x:0 y:0. |
|
7242 |
! |
|
7243 |
||
5331 | 7244 |
inspectSelectedString |
7245 |
"inspect the selected text" |
|
7246 |
||
7247 |
self selectionAsString inspect. |
|
7248 |
! |
|
7249 |
||
4742 | 7250 |
internalSpellingSuggestion |
7251 |
"insert the internal-spelling suggestion for the selected text. |
|
7252 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7253 |
||
7254 |
|text suggestions best| |
|
7255 |
||
7256 |
self withWaitCursorDo:[ |
|
6152 | 7257 |
text := self selection asString string withoutSeparators. |
7258 |
text size == 0 ifTrue:[^ self]. |
|
7259 |
||
7260 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7261 |
suggestions size == 0 ifTrue:[ |
|
7262 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7263 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7264 |
^ self. |
|
7265 |
]. |
|
7266 |
Transcript showCR:suggestions. |
|
7267 |
best := suggestions first. |
|
5787 | 7268 |
]. |
7269 |
self |
|
6152 | 7270 |
undoablePaste:best |
7271 |
info:'Spelling Suggestion'. |
|
4742 | 7272 |
! |
7273 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7274 |
paste |
1289 | 7275 |
"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
|
7276 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7277 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7278 |
self checkModificationsAllowed ifTrue:[ |
6152 | 7279 |
self withSelfAndTextForPasteDo:[:me :text | |
7280 |
me unselect. |
|
7281 |
me undoablePaste:text |
|
7282 |
] |
|
2952 | 7283 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7284 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7285 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7286 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7287 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7288 |
|
3825 | 7289 |
self paste:someText withCR:false |
7290 |
! |
|
7291 |
||
7292 |
paste:someText withCR:withCR |
|
7293 |
"paste someText at cursor" |
|
7294 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7295 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7296 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7297 |
self checkModificationsAllowed ifFalse:[^ self]. |
6399 | 7298 |
someText isEmptyOrNil ifTrue:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7299 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7300 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7301 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7302 |
CharacterEncoderError handle:[:ex | |
6152 | 7303 |
|code msg| |
7304 |
||
7305 |
code := ex parameter. |
|
7306 |
codingErrorReported ifFalse:[ |
|
6399 | 7307 |
msg := 'Cannot represent pasted string in this view''s encoding (',gc characterEncoding,').'. |
6152 | 7308 |
code notNil ifTrue:[ |
7309 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7310 |
]. |
|
7311 |
Dialog warn:(resources stringWithCRs:msg). |
|
7312 |
codingErrorReported := true. |
|
7313 |
]. |
|
7314 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7315 |
] do:[ |
6152 | 7316 |
s isString ifTrue:[ |
7317 |
s encoding ~~ gc characterEncoding ifTrue:[ |
|
7318 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7319 |
]. |
|
7320 |
||
7321 |
s := s asStringCollection. |
|
7322 |
(someText endsWith:Character cr) ifTrue:[ |
|
7323 |
"/ s := s copyWith:nil. |
|
7324 |
s := s copyWith:'' "/ an empty line at the end |
|
7325 |
||
7326 |
] |
|
7327 |
] ifFalse:[ |
|
7328 |
s isStringCollection ifTrue:[ |
|
7329 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7330 |
] ifFalse:[ |
|
7331 |
(self |
|
7332 |
confirm:(resources |
|
7333 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7334 |
with:s class name)) ifFalse:[^ self]. |
|
7335 |
s := StringCollection with:s storeString . |
|
7336 |
"/ ^ self |
|
7337 |
]. |
|
7338 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7339 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7340 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7341 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7342 |
(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
|
7343 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7344 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7345 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7346 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7347 |
startCol := c1 := cursorCol. |
3180 | 7348 |
|
5787 | 7349 |
"do not autoindent here. |
7350 |
It does make things very ugly, in the inspector |
|
5194 | 7351 |
(try inspecting a multiline string)..." |
7352 |
self withAutoIndent:false do:[ |
|
6152 | 7353 |
"do not expand tabs into spaces here - |
7354 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7355 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7356 |
||
7357 |
self insertLines:s withCR:withCR. |
|
5194 | 7358 |
]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7359 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7360 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7361 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7362 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7363 |
|
4328 | 7364 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7365 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
6399 | 7366 |
"Modified: / 22-08-2018 / 08:29:13 / Claus Gittinger" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7367 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7368 |
|
3731 | 7369 |
pasteAsStringLiteral |
7370 |
"insert clipboard string as a string literal. |
|
7371 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7372 |
to make it a legal string literal" |
|
7373 |
||
7374 |
typeOfSelection := nil. |
|
7375 |
self |
|
6152 | 7376 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
7377 |
info:'Paste as String Literal' |
|
3731 | 7378 |
! |
7379 |
||
6134 | 7380 |
pasteBox |
7381 |
"paste the copybuffer as a box; |
|
7382 |
if there is a selection, unselect first. |
|
7383 |
Then paste at cursor position." |
|
7384 |
||
7385 |
self checkModificationsAllowed ifTrue:[ |
|
7386 |
self withSelfAndTextForPasteDo:[:me :text | |
|
7387 |
me unselect. |
|
7388 |
me undoablePasteBox:text |
|
7389 |
] |
|
7390 |
] |
|
7391 |
||
7392 |
"Created: / 14-03-2017 / 16:34:16 / cg" |
|
7393 |
! |
|
7394 |
||
7395 |
pasteBox:someText |
|
7396 |
"paste someText at cursor" |
|
7397 |
||
7398 |
self pasteBox:someText withCR:false |
|
7399 |
||
7400 |
"Created: / 14-03-2017 / 16:35:08 / cg" |
|
7401 |
! |
|
7402 |
||
7403 |
pasteBox:someText withCR:withCR |
|
7404 |
"paste someText at cursor" |
|
7405 |
||
7406 |
|lines nLines startLine startCol l1 l2 c1 c2| |
|
7407 |
||
7408 |
self checkModificationsAllowed ifFalse:[^ self]. |
|
7409 |
||
7410 |
lines := someText asStringCollection. |
|
7411 |
||
7412 |
(nLines := lines size) == 0 ifTrue:[^ self]. |
|
7413 |
(nLines == 1 and:[(lines at:1) size == 0]) ifTrue:[^ self]. |
|
7414 |
||
7415 |
typeOfSelection := #paste. |
|
7416 |
||
7417 |
startLine := l1 := cursorLine. |
|
7418 |
startCol := c1 := cursorCol. |
|
7419 |
||
7420 |
"do not autoindent here. |
|
7421 |
It does make things very ugly, in the inspector |
|
7422 |
(try inspecting a multiline string)..." |
|
7423 |
self withAutoIndent:false do:[ |
|
7424 |
"do not expand tabs into spaces here - |
|
7425 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7426 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7427 |
||
7428 |
lines do:[:eachLine | |
|
7429 |
self insertString:eachLine atLine:l1 col:startCol. |
|
7430 |
l1 := l1 + 1. |
|
7431 |
]. |
|
7432 |
]. |
|
7433 |
l2 := cursorLine. |
|
7434 |
c2 := (cursorCol - 1). |
|
7435 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
|
7436 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
|
7437 |
||
7438 |
"Created: / 14-03-2017 / 16:39:11 / cg" |
|
7439 |
! |
|
7440 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7441 |
pasteOrReplace |
1289 | 7442 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7443 |
otherwise paste at cursor position. |
7444 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7445 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7446 |
|
2724 | 7447 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7448 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7449 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7450 |
pasteOrReplace:someText |
1289 | 7451 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7452 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7453 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7454 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7455 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7456 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7457 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7458 |
self undoableDo:[ |
6152 | 7459 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7460 |
self replace:someText |
|
7461 |
] ifFalse:[ |
|
7462 |
self paste:someText. |
|
7463 |
] |
|
3542 | 7464 |
] info:'Paste/Replace'. |
1289 | 7465 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7466 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7467 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7468 |
|
6134 | 7469 |
pasteOrReplaceBox |
7470 |
"paste the copybuffer as a box; |
|
7471 |
if there is a selection, unselect first. |
|
7472 |
Then paste at cursor position." |
|
7473 |
||
7474 |
self pasteBox |
|
7475 |
||
7476 |
"Created: / 14-03-2017 / 16:40:08 / cg" |
|
7477 |
! |
|
7478 |
||
5387 | 7479 |
pasteOrReplaceByKeyPress |
7480 |
"paste a previous item from the copybuffer history. |
|
7481 |
(i.e. repaste some previously deleted or copied text)" |
|
7482 |
||
7483 |
|text| |
|
7484 |
||
6226 | 7485 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
7486 |
||
5387 | 7487 |
text := self getClipboardText:#clipboard. |
7488 |
text notNil ifTrue:[ |
|
6152 | 7489 |
self pasteOrReplace:text |
5387 | 7490 |
] |
6226 | 7491 |
|
7492 |
"Modified: / 11-11-2017 / 12:52:54 / cg" |
|
5387 | 7493 |
! |
7494 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7495 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7496 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7497 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7498 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7499 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7500 |
|
6226 | 7501 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
7502 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7503 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7504 |
text notNil ifTrue:[ |
6452 | 7505 |
"/ move to top of list. |
7506 |
device rememberInCopyBufferHistory:text. |
|
6152 | 7507 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7508 |
] |
6226 | 7509 |
|
7510 |
"Modified: / 11-11-2017 / 12:52:42 / cg" |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7511 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7512 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7513 |
replace |
1289 | 7514 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7515 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7516 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7517 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7518 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7519 |
self withSelfAndTextForPasteDo:[:me :text | |
6152 | 7520 |
me undoableDo:[ me replace:text ] |
7521 |
info:'Replace' |
|
2952 | 7522 |
] |
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 |
|
121 | 7525 |
replace:someText |
1289 | 7526 |
"replace the selection by someText" |
121 | 7527 |
|
3160 | 7528 |
|selected selectedString |
7529 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7530 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7531 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7532 |
|
3130 | 7533 |
self undoableDo:[ |
6152 | 7534 |
selected := self selection. |
7535 |
selected isNil ifTrue:[ |
|
7536 |
^ self paste:someText |
|
7537 |
]. |
|
7538 |
||
7539 |
self deleteSelection. |
|
7540 |
||
7541 |
"take care, if we replace a selection without space by a word selected |
|
7542 |
with one - in this case we usually do not want the space. |
|
7543 |
But, if we replace a word-selected selection by something without a |
|
7544 |
space, we DO want the space added." |
|
7545 |
||
7546 |
selected size == 1 ifTrue:[ |
|
7547 |
selectedString := selected at:1. |
|
7548 |
]. |
|
7549 |
||
7550 |
someText size == 1 ifTrue:[ |
|
7551 |
|cutOffSpace addSpace replacement replacementString| |
|
7552 |
||
7553 |
cutOffSpace := false. |
|
7554 |
addSpace := false. |
|
7555 |
replacement := someText copyFrom:1. |
|
7556 |
||
7557 |
selectedString notNil ifTrue:[ |
|
7558 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7559 |
"selection has no space" |
|
7560 |
||
7561 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7562 |
cutOffSpace := true |
|
7563 |
] |
|
7564 |
] ifTrue:[ |
|
7565 |
addSpace := true |
|
7566 |
] |
|
7567 |
]. |
|
7568 |
replacementString := replacement at:1. |
|
7569 |
cutOffSpace ifTrue:[ |
|
7570 |
(replacementString startsWith:' ') ifTrue:[ |
|
7571 |
replacementString := replacementString withoutSpaces |
|
7572 |
]. |
|
7573 |
] ifFalse:[ |
|
7574 |
selectStyle == #wordLeft ifTrue:[ |
|
7575 |
"want a space at left" |
|
7576 |
(replacementString startsWith:' ') ifFalse:[ |
|
7577 |
replacementString := replacementString withoutSpaces. |
|
7578 |
replacementString := ' ' , replacementString |
|
7579 |
] |
|
7580 |
]. |
|
7581 |
selectStyle == #wordRight ifTrue:[ |
|
7582 |
"want a space at right" |
|
7583 |
||
7584 |
(replacementString endsWith:' ') ifFalse:[ |
|
7585 |
replacementString := replacementString withoutSpaces. |
|
7586 |
replacementString := replacementString , ' ' |
|
7587 |
] |
|
7588 |
]. |
|
7589 |
]. |
|
7590 |
replacement at:1 put: replacementString. |
|
7591 |
self paste:replacement. |
|
7592 |
] ifFalse:[ |
|
7593 |
self paste:someText |
|
7594 |
]. |
|
7595 |
self setLastStringToReplace: selectedString. |
|
7596 |
||
7597 |
lastReplacementInfo lastReplacement: someText. |
|
7598 |
||
7599 |
selStartLine := selectionStartLine. |
|
7600 |
selStartCol := self selectionStartCol. |
|
7601 |
selEndLine := selectionEndLine. |
|
7602 |
selEndCol := self selectionEndCol. |
|
3130 | 7603 |
] |
3542 | 7604 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7605 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7606 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7607 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7608 |
! |
7609 |
||
3430 | 7610 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7611 |
"search for a string - show a box to enter searchpattern |
3430 | 7612 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7613 |
- 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
|
7614 |
|
3430 | 7615 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7616 |
||
7617 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7618 |
lastSearchDirection := #forward. |
|
7619 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7620 |
caseHolder := ValueHolder with:ign. |
7621 |
patternHolder := ValueHolder with:''. |
|
7622 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7623 |
lastSearchPattern notNil ifTrue:[ |
6152 | 7624 |
initialString := lastSearchPattern |
3430 | 7625 |
]. |
7626 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
6152 | 7627 |
initialString := self selectionAsString |
3430 | 7628 |
]. |
7629 |
initialString isNil ifTrue:[ |
|
6548 | 7630 |
LastSearchPatterns size ~~ 0 ifTrue:[ |
6152 | 7631 |
initialString := LastSearchPatterns first |
7632 |
] |
|
3430 | 7633 |
]. |
7634 |
initialString notNil ifTrue:[ |
|
6152 | 7635 |
patternHolder value:initialString. |
7636 |
replacePatternHolder value:initialString. |
|
3430 | 7637 |
]. |
7638 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7639 |
search := [:fwd | |
6152 | 7640 |
self |
7641 |
search:patternHolder value |
|
7642 |
ignoreCase:caseHolder value |
|
7643 |
forward:fwd. |
|
7644 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7645 |
replace := [:all | |
6152 | 7646 |
self |
7647 |
replace:patternHolder value |
|
7648 |
by:replacePatternHolder value |
|
7649 |
all:all |
|
7650 |
ignoreCase:caseHolder value |
|
7651 |
]. |
|
3430 | 7652 |
bindings := IdentityDictionary new. |
7653 |
bindings at:#searchPattern put:patternHolder. |
|
7654 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7655 |
modal ifTrue:[ |
|
6152 | 7656 |
bindings at:#nextAction |
7657 |
put:[ |
|
7658 |
flag := true. |
|
7659 |
action := search. |
|
7660 |
searchBox doAccept. |
|
7661 |
]. |
|
7662 |
bindings at:#prevAction |
|
7663 |
put:[ |
|
7664 |
flag := false. |
|
7665 |
action := search. |
|
7666 |
searchBox doAccept. |
|
7667 |
]. |
|
7668 |
bindings at:#replaceAction |
|
7669 |
put:[ |
|
7670 |
flag := false. |
|
7671 |
action := replace. |
|
7672 |
searchBox doAccept. |
|
7673 |
]. |
|
7674 |
bindings at:#replaceAllAction |
|
7675 |
put:[ |
|
7676 |
flag := true. |
|
7677 |
action := replace. |
|
7678 |
searchBox doAccept. |
|
7679 |
]. |
|
3430 | 7680 |
] ifFalse:[ |
6152 | 7681 |
bindings at:#nextAction put:[ search value:true. ]. |
7682 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7683 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7684 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7685 |
]. |
7686 |
bindings at:#ignoreCase put:caseHolder. |
|
7687 |
bindings at:#patternList put:LastSearchPatterns. |
|
7688 |
modal ifTrue:[ |
|
6152 | 7689 |
searchBox := SimpleDialog new. |
3430 | 7690 |
] ifFalse:[ |
6152 | 7691 |
searchBox := ApplicationModel new. |
7692 |
searchBox createBuilder. |
|
3430 | 7693 |
]. |
7694 |
searchBox resources:(self resources). |
|
7695 |
bldr := searchBox builder. |
|
7696 |
bldr addBindings:bindings. |
|
7697 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7698 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7699 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7700 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7701 |
modal ifTrue:[ |
|
6152 | 7702 |
searchBox openDialog. |
7703 |
searchBox accepted ifTrue:[ |
|
7704 |
action value:flag |
|
7705 |
]. |
|
3430 | 7706 |
] ifFalse:[ |
6152 | 7707 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7708 |
(bldr componentAt:#cancelButton) |
|
7709 |
label:(resources string:'Close'); |
|
7710 |
action:[ searchBox closeRequest ]. |
|
7711 |
||
7712 |
"/ searchBox masterApplication:self application. |
|
7713 |
||
7714 |
self topView beMaster. |
|
7715 |
(searchBox window) |
|
7716 |
beSlave; |
|
7717 |
openInGroup:(self windowGroup). |
|
7718 |
||
7719 |
"/ searchBox window open. |
|
7720 |
||
7721 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
|
3430 | 7722 |
] |
7723 |
||
7724 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
6548 | 7725 |
"Modified: / 01-03-2019 / 14:55:01 / Claus Gittinger" |
3430 | 7726 |
! |
7727 |
||
6241 | 7728 |
selectionDecodeBase64 |
7729 |
self paste:(Base64Coder decode:self selectionAsString) asString |
|
7730 |
||
7731 |
"Created: / 30-11-2017 / 15:07:31 / cg" |
|
7732 |
! |
|
7733 |
||
7734 |
selectionEncodeBase64 |
|
7735 |
self paste:(Base64Coder encode:self selectionAsString) |
|
7736 |
||
7737 |
"Created: / 30-11-2017 / 15:07:34 / cg" |
|
7738 |
! |
|
7739 |
||
7740 |
selectionRot13 |
|
7741 |
"a naive caesar cypher" |
|
7742 |
||
7743 |
self paste:(self selectionAsString rot13) |
|
7744 |
||
7745 |
"Created: / 30-11-2017 / 15:07:50 / cg" |
|
7746 |
! |
|
7747 |
||
121 | 7748 |
showDeleted |
7749 |
"open a readonly editor on all deleted text" |
|
7750 |
||
7751 |
|v| |
|
7752 |
||
7753 |
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
|
7754 |
v readOnly:true. |
121 | 7755 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7756 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7757 |
|
3221 | 7758 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7759 |
"sort/reorder the selected lines. |
7760 |
how: |
|
6152 | 7761 |
#lines |
7762 |
#linesByFirstWord |
|
7763 |
#linesByNthWord |
|
7764 |
#linesByNthNumber |
|
7765 |
#linesByNthHexNumber |
|
7766 |
#words |
|
7767 |
#linesByLength |
|
7768 |
#reverse |
|
4763 | 7769 |
" |
7770 |
||
7771 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7772 |
|
7773 |
lineWise := true. |
|
7774 |
||
4763 | 7775 |
how == #reverse ifTrue:[ |
6152 | 7776 |
operation := [:lines | lines reverse]. |
4763 | 7777 |
] ifFalse:[ |
6152 | 7778 |
operation := [:linesOrWords | |
7779 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7780 |
]. |
|
7781 |
||
7782 |
how == #linesByLength ifTrue:[ |
|
7783 |
fetcher := [:l | l size]. |
|
7784 |
] ifFalse:[ |
|
7785 |
how == #lines ifTrue:[ |
|
7786 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7787 |
] ifFalse:[ |
|
7788 |
how == #linesByFirstWord ifTrue:[ |
|
7789 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7790 |
] ifFalse:[ |
|
7791 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7792 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7793 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7794 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7795 |
LastColumnNumberForSort := n. |
|
7796 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7797 |
how == #linesByNthNumber ifTrue:[ |
|
7798 |
innerExtractor := extractor. |
|
7799 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7800 |
] ifFalse:[ |
|
7801 |
how == #linesByNthHexNumber ifTrue:[ |
|
7802 |
innerExtractor := extractor. |
|
7803 |
extractor := [:l | |
|
7804 |
|s| |
|
7805 |
s := innerExtractor value:l. |
|
7806 |
(s startsWith:'16r') ifTrue:[ |
|
7807 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7808 |
] ifFalse:[ |
|
7809 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7810 |
] |
|
7811 |
] |
|
7812 |
] |
|
7813 |
]. |
|
7814 |
] ifFalse:[ |
|
7815 |
how == #words ifTrue:[ |
|
7816 |
lineWise := false. |
|
7817 |
extractor := [:w | w]. |
|
7818 |
] ifFalse:[ |
|
7819 |
self error:'unknown sort criteria: ', how printString. |
|
7820 |
] |
|
7821 |
] |
|
7822 |
] |
|
7823 |
]. |
|
7824 |
ignoreCase ifTrue:[ |
|
7825 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7826 |
] ifFalse:[ |
|
7827 |
fetcher := extractor. |
|
7828 |
]. |
|
7829 |
]. |
|
3221 | 7830 |
]. |
7831 |
||
7832 |
lineWise ifTrue:[ |
|
6152 | 7833 |
"process the lines of the selection (aka a collection of lines)" |
7834 |
start == end ifTrue:[^ self ]. |
|
7835 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
7836 |
lines := operation value:lines. |
|
7837 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
4763 | 7838 |
] ifFalse:[ |
6152 | 7839 |
"process the whole selection as a string" |
7840 |
s := self selectionAsString. |
|
7841 |
words := s asCollectionOfWords. |
|
7842 |
words := operation value:words. |
|
7843 |
s := words asStringCollection asStringWith:Character space. |
|
7844 |
self replace:s. |
|
4763 | 7845 |
]. |
3221 | 7846 |
self textChanged. |
4373 | 7847 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7848 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7849 |
! |
7850 |
||
7851 |
sortSelection:how ignoreCase:ignoreCase |
|
7852 |
"sort the selected lines" |
|
7853 |
||
7854 |
|start end| |
|
7855 |
||
7856 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7857 |
||
7858 |
start := selectionStartLine. |
|
7859 |
end := selectionEndLine. |
|
7860 |
(selectionEndCol == 0) ifTrue:[ |
|
6152 | 7861 |
end := end - 1 |
3221 | 7862 |
]. |
7863 |
||
7864 |
self |
|
6152 | 7865 |
undoableDo:[ |
7866 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7867 |
] |
|
7868 |
info:'Sort' |
|
4373 | 7869 |
|
7870 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7871 |
! |
7872 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7873 |
specialCharacters |
6517 | 7874 |
"open the special characters input window" |
7875 |
||
7876 |
"CharacterInputViewSingleton := nil" |
|
7877 |
||
7878 |
(CharacterInputViewSingleton notNil and:[CharacterInputViewSingleton isOpen]) ifTrue:[ |
|
7879 |
CharacterInputViewSingleton consumingView:self. |
|
7880 |
CharacterInputViewSingleton topView raiseDeiconified. |
|
7881 |
] ifFalse:[ |
|
7882 |
CharacterInputViewSingleton := |
|
7883 |
CharacterSetView |
|
7884 |
openAsInputFor:self |
|
7885 |
label:(resources string:'Special Character Input') |
|
7886 |
clickLabel:(resources string:'Click to Insert Character'). |
|
7887 |
]. |
|
7888 |
||
7889 |
"Modified (comment): / 08-01-2019 / 18:24:13 / Claus Gittinger" |
|
2866 | 7890 |
! |
7891 |
||
5370 | 7892 |
splitLinesAtCharacterOrString |
7893 |
"ask user for the character and split after it" |
|
7894 |
||
7895 |
|sel in out separator record| |
|
7896 |
||
7897 |
selectionStartLine isNil ifTrue:[^ self]. |
|
6227 | 7898 |
self checkModificationsAllowed ifFalse:[^ self]. |
5370 | 7899 |
|
7900 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7901 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7902 |
||
7903 |
sel := self selectionAsString. |
|
7904 |
in := sel readStream. |
|
5887 | 7905 |
out := CharacterWriteStream on:''. |
5370 | 7906 |
[in atEnd] whileFalse:[ |
5887 | 7907 |
record := in throughAll:separator. |
7908 |
out nextPutLine:record. |
|
5370 | 7909 |
]. |
7910 |
self |
|
5887 | 7911 |
undoableDo:[ |
7912 |
self replaceSelectionBy:(out contents). |
|
7913 |
] |
|
7914 |
info:'Split Selection' |
|
6227 | 7915 |
|
7916 |
"Modified: / 15-11-2017 / 11:56:45 / cg" |
|
5370 | 7917 |
! |
7918 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7919 |
undoablePaste:someText |
3495 | 7920 |
self undoablePaste:someText info:nil. |
7921 |
||
7922 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7923 |
! |
|
7924 |
||
7925 |
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
|
7926 |
self |
6152 | 7927 |
undoableDo:[ |
7928 |
self paste:someText. |
|
7929 |
] |
|
7930 |
info:infoOrNil |
|
3495 | 7931 |
|
7932 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7933 |
! |
|
7934 |
||
6134 | 7935 |
undoablePasteBox:someText |
7936 |
self undoablePasteBox:someText info:nil. |
|
7937 |
||
7938 |
"Created: / 14-03-2017 / 16:34:31 / cg" |
|
7939 |
! |
|
7940 |
||
7941 |
undoablePasteBox:someText info:infoOrNil |
|
7942 |
self |
|
7943 |
undoableDo:[ |
|
7944 |
self pasteBox:someText. |
|
7945 |
] |
|
7946 |
info:infoOrNil |
|
7947 |
||
7948 |
"Created: / 14-03-2017 / 16:34:55 / cg" |
|
7949 |
! |
|
7950 |
||
3495 | 7951 |
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
|
7952 |
self |
6152 | 7953 |
undoableDo:[ |
7954 |
self pasteOrReplace:someText. |
|
7955 |
] |
|
7956 |
info:infoOrNil |
|
3495 | 7957 |
|
7958 |
"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
|
7959 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7960 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7961 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7962 |
self |
6152 | 7963 |
undoableDo:[ |
7964 |
self selectAll. |
|
7965 |
self pasteOrReplace:someText. |
|
7966 |
] |
|
7967 |
info:infoOrNil |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7968 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7969 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7970 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7971 |
|
2724 | 7972 |
withSelfAndTextForPasteDo:aBlock |
7973 |
"common code for paste/replace of the copybuffer" |
|
7974 |
||
7975 |
|sel| |
|
7976 |
||
6226 | 7977 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
2724 | 7978 |
|
7979 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7980 |
sel notNil ifTrue:[ |
|
6152 | 7981 |
aBlock value:self value:sel. |
2724 | 7982 |
] |
6226 | 7983 |
|
7984 |
"Modified: / 11-11-2017 / 12:52:31 / cg" |
|
6477
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7985 |
! |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7986 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7987 |
withSelfAndTextForPasteFromHistoryDo:aBlock |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7988 |
"common code for paste/replace from the copyBuffer history" |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7989 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7990 |
|sel| |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7991 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7992 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7993 |
sel := self getTextSelectionFromHistory. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7994 |
sel notNil ifTrue:[ |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7995 |
aBlock value:self value:sel. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7996 |
] |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7997 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7998 |
"Modified: / 11-11-2017 / 12:52:31 / cg" |
105 | 7999 |
! ! |
8000 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8001 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8002 |
|
3880 | 8003 |
beep |
5244 | 8004 |
"output an audible beep or bell on my screen device" |
8005 |
||
6262 | 8006 |
super beepInEditor |
3880 | 8007 |
! |
8008 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8009 |
checkModificationsAllowed |
6226 | 8010 |
"check if the text can be modified (i.e. is not readOnly), return true or false. |
8011 |
If not, and an exceptionBlock has been defined, evaluate it. |
|
8012 |
The exceptionBlock can be provided by the application or user of the textView, |
|
8013 |
and may show a warnBox or whatever, or ask again. |
|
8014 |
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
|
8015 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8016 |
self isReadOnly ifTrue: [ |
6152 | 8017 |
exceptionBlock isNil ifTrue:[ |
8018 |
^ false |
|
8019 |
]. |
|
8020 |
||
8021 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
8022 |
^ false |
|
8023 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8024 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8025 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8026 |
|
6226 | 8027 |
"Modified: / 17-06-1998 / 15:51:10 / cg" |
8028 |
"Modified (comment): / 11-11-2017 / 12:49:29 / cg" |
|
8029 |
! |
|
8030 |
||
8031 |
checkModificationsAllowedFlashIfNot:doFlashIfNot |
|
8032 |
"check if the text can be modified (i.e. is not readOnly), return true or false. |
|
8033 |
If not, and an exceptionBlock has been defined, evaluate it. |
|
8034 |
The exceptionBlock can be provided by the application or user of the textView, |
|
8035 |
and may show a warnBox or whatever, or ask again. |
|
8036 |
It can return true to allow the modification. |
|
8037 |
If either no exceptionBlock was defined or it returned false, |
|
8038 |
and doFlashIfNot is true then flash the view to tell the user." |
|
8039 |
||
8040 |
self isReadOnly ifTrue: [ |
|
8041 |
(exceptionBlock isNil |
|
8042 |
or:[(exceptionBlock value:'Text may not be modified') ~~ true]) ifTrue:[ |
|
8043 |
doFlashIfNot ifTrue:[ |
|
8044 |
self flashReadOnly |
|
8045 |
]. |
|
8046 |
^ false |
|
8047 |
]. |
|
8048 |
]. |
|
8049 |
^ true |
|
8050 |
||
8051 |
"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
|
8052 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8053 |
|
2596 | 8054 |
currentSelectionBgColor |
8055 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 8056 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
5787 | 8057 |
]. |
8058 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
|
2596 | 8059 |
^ super currentSelectionBgColor |
8060 |
||
8061 |
" |
|
8062 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
8063 |
" |
|
8064 |
! |
|
8065 |
||
8066 |
currentSelectionFgColor |
|
8067 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 8068 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 8069 |
]. |
8070 |
^ super currentSelectionFgColor |
|
8071 |
! |
|
8072 |
||
3996 | 8073 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8074 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 8075 |
|
8076 |
super resetVariablesBeforeNewSearch. |
|
8077 |
||
8078 |
"/ new search invalidates remembered string |
|
4048 | 8079 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8080 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8081 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 8082 |
! |
8083 |
||
4053 | 8084 |
setLastStringToReplace: aString |
8085 |
||
8086 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
8087 |
||
8088 |
|lastReplaceIgnoredCase| |
|
8089 |
||
4064 | 8090 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
8091 |
self clearSearchAction. |
|
8092 |
||
4053 | 8093 |
lastReplacementInfo lastStringToReplace: aString. |
8094 |
lastStringFromReplaceForNextSearch := aString. |
|
8095 |
||
8096 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
5787 | 8097 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
6152 | 8098 |
ifTrue: [lastSearchIgnoredCase] |
8099 |
ifFalse: [nil]. |
|
4053 | 8100 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
8101 |
! |
|
8102 |
||
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8103 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8104 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8105 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8106 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8107 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8108 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8109 |
textChanged |
522 | 8110 |
"my text was modified (internally). |
8111 |
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
|
8112 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 8113 |
is used to notify scrollers, other views etc.). |
8114 |
||
5979 | 8115 |
As some authors of this code have been very sloppy in the past |
4635 | 8116 |
(not sending contentsChanged, but textChanged), |
8117 |
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
|
8118 |
|
641 | 8119 |
self contentsChanged. |
1015 | 8120 |
self modified:true. |
5774 | 8121 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8122 |
contentsWasSaved := false |
641 | 8123 |
|
1015 | 8124 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 8125 |
! |
8126 |
||
2617 | 8127 |
textChangedButNoSizeChange |
2207 | 8128 |
"my text was modified (internally). |
8129 |
Sent whenever text has been edited (not to confuse with |
|
8130 |
contentsChanged, which is triggered when the size has changed, and |
|
8131 |
is used to notify scrollers, other views etc.)" |
|
8132 |
||
8133 |
self modified:true. |
|
8134 |
contentsWasSaved := false |
|
8135 |
||
8136 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8137 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8138 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8139 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8140 |
|
5216 | 8141 |
canAccept |
8142 |
"true if text can be accepts. |
|
8143 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8144 |
||
8145 |
^ acceptEnabled ~~ false |
|
8146 |
! |
|
8147 |
||
8148 |
canCut |
|
8149 |
"true if there is a selection possibly to be cut. |
|
8150 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8151 |
||
8152 |
self isReadOnly ifTrue:[ ^ false ]. |
|
8153 |
^ self hasSelection |
|
8154 |
! |
|
8155 |
||
8156 |
canDoAgain |
|
8157 |
"true if there is a possible repeat last edit operation. |
|
8158 |
Used to disable the menu if there is nothing" |
|
8159 |
||
8160 |
self isReadOnly ifTrue:[ ^ false ]. |
|
5972 | 8161 |
^ lastReplacementInfo lastStringToReplace notNil |
8162 |
||
8163 |
"Modified: / 19-11-2016 / 20:19:02 / cg" |
|
5216 | 8164 |
! |
8165 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8166 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8167 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8168 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8169 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8170 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8171 |
"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
|
8172 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8173 |
|
4064 | 8174 |
hasSearchActionSelection |
8175 |
||
8176 |
^ typeOfSelection == #searchAction |
|
8177 |
! |
|
8178 |
||
1878 | 8179 |
isKeyboardConsumer |
8180 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 8181 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 8182 |
|
3476 | 8183 |
^ self isReadOnly not |
1878 | 8184 |
! |
8185 |
||
997 | 8186 |
specClass |
1390 | 8187 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
8188 |
||
997 | 8189 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 8190 |
^ super specClass |
8191 |
||
1390 | 8192 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 8193 |
! |
8194 |
||
324 | 8195 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
8196 |
"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
|
8197 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8198 |
"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
|
8199 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8200 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 8201 |
|
8202 |
"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
|
8203 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8204 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8205 |
widthOfContents |
6230 | 8206 |
"return the width of the contents in pixels. |
8207 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8208 |
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
|
8209 |
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
|
8210 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8211 |
|
697 | 8212 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8213 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8214 |
w := super widthOfContents. |
5643 | 8215 |
(dev := device ) isNil ifTrue:[ |
6152 | 8216 |
"/ really don't know ... |
8217 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
8218 |
]. |
6230 | 8219 |
"/ add width of a space (so cursor is always seen) |
4889 | 8220 |
^ w + (gc font widthOn:dev) |
697 | 8221 |
|
6230 | 8222 |
"Modified: / 28-05-1996 / 19:32:25 / cg" |
8223 |
"Modified (comment): / 19-11-2017 / 14:05:16 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8224 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8225 |
|
1588 | 8226 |
!EditTextView methodsFor:'realization'! |
8227 |
||
8228 |
realize |
|
8229 |
"make the view visible - scroll to make the cursor visible." |
|
8230 |
||
8231 |
super realize. |
|
8232 |
||
8233 |
self makeCursorVisible. |
|
5643 | 8234 |
cursorFgColor := cursorFgColor onDevice:device. |
8235 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 8236 |
|
8237 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
8238 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
8239 |
! ! |
|
8240 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8241 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8242 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8243 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8244 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8245 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8246 |
cursorShown ifTrue:[ |
6152 | 8247 |
cursorVisibleLine notNil ifTrue:[ |
8248 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
8249 |
self drawCursorCharacter |
|
8250 |
] |
|
8251 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8252 |
] |
105 | 8253 |
! |
8254 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8255 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8256 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8257 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8258 |
cursorShown ifTrue:[ |
6152 | 8259 |
(visLine == cursorVisibleLine) ifTrue:[ |
8260 |
self drawCursorCharacter |
|
8261 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8262 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8263 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8264 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8265 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8266 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8267 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8268 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8269 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8270 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8271 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8272 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8273 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8274 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8275 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8276 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8277 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8278 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8279 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8280 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8281 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8282 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8283 |
cursorShown ifTrue:[ |
6152 | 8284 |
(visLine == cursorVisibleLine) ifTrue:[ |
8285 |
(colNr == cursorCol) ifTrue:[ |
|
8286 |
self drawCursorCharacter. |
|
8287 |
^ self |
|
8288 |
] |
|
8289 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8290 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8291 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8292 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8293 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8294 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8295 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8296 |
"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
|
8297 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8298 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 8299 |
cursorShown ifTrue:[ |
6152 | 8300 |
self redrawCursorIfInVisibleLine:visLine |
4494 | 8301 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8302 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8303 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8304 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8305 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8306 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8307 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8308 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8309 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8310 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8311 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8312 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8313 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8314 |
"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
|
8315 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8316 |
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
|
8317 |
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
|
8318 |
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
|
8319 |
|
4889 | 8320 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8321 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8322 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8323 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8324 |
"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
|
8325 |
within the real text " |
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 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8328 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8329 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8330 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8331 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8332 |
! |
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 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8335 |
"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
|
8336 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8337 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8338 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8339 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8340 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8341 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8342 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8343 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8344 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8345 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8346 |
"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
|
8347 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8348 |
super originChanged:delta. |
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 |
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
|
8351 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
8352 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8353 |
prevCursorState ifTrue:[ |
6152 | 8354 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8355 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8356 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8357 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
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 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8361 |
"sent before scrolling - have to hide the cursor" |
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 |
prevCursorState := cursorShown. |
1601 | 8364 |
"/ cursorShown := false. |
1591 | 8365 |
cursorShown ifTrue:[ |
6152 | 8366 |
self hideCursor |
1591 | 8367 |
] |
8368 |
||
1601 | 8369 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8370 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8371 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8372 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8373 |
"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
|
8374 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8375 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8376 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8377 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8378 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8379 |
super pageDown. |
6184 | 8380 |
prevCursorLine notNil ifTrue:[ |
8381 |
"https://expeccoalm.exept.de/D204551" |
|
8382 |
self cursorVisibleLine:prevCursorLine col:cursorCol. |
|
8383 |
]. |
|
8384 |
||
8385 |
"Modified: / 18-07-2017 / 12:31:47 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8386 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8387 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8388 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8389 |
"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
|
8390 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8391 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8392 |
|prevCursorLine| |
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 := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8395 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8396 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8397 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8398 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8399 |
!EditTextView methodsFor:'searching'! |
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 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8402 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8403 |
|
2822 | 8404 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8405 |
! |
8406 |
||
8407 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8408 |
"do a backward search" |
|
8409 |
||
8410 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8411 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8412 |
! |
8413 |
||
8414 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8415 |
"do a backward search" |
|
8416 |
||
8417 |
cursorLine isNil ifTrue:[^ self]. |
|
8418 |
||
3160 | 8419 |
self |
6152 | 8420 |
searchBackwardFor:pattern |
8421 |
ignoreCase:ign |
|
8422 |
startingAtLine:startLine col:startCol |
|
8423 |
ifFound:[:line :col :endColOrNil | |
|
8424 |
self cursorMovementAllowed ifTrue:[ |
|
8425 |
self cursorLine:line col:col. |
|
8426 |
]. |
|
8427 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
|
1339 | 8428 |
"/ self makeLineVisible:cursorLine |
6152 | 8429 |
typeOfSelection := #search] |
8430 |
ifAbsent:aBlock |
|
1339 | 8431 |
|
8432 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8435 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8436 |
"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
|
8437 |
|
2554 | 8438 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8439 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8440 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8441 |
searchForMatchingParenthesis |
3160 | 8442 |
"search for a matching parenthesis starting at cursor position. |
6096 | 8443 |
Search for the corresponding character is done forward if it's an opening, |
8444 |
backwards if it's a closing parenthesis. |
|
8445 |
Positions the cursor if found, beeps if not" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8446 |
|
2822 | 8447 |
self cursorMovementAllowed ifFalse:[^ self]. |
8448 |
||
3160 | 8449 |
self |
6096 | 8450 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8451 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8452 |
ifNotFound:[self showNotFound] |
|
6262 | 8453 |
onError:[self beepInEditor] |
6096 | 8454 |
|
8455 |
"Modified: / 09-10-1997 / 12:56:30 / cg" |
|
8456 |
"Modified (comment): / 13-02-2017 / 20:10:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8457 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8458 |
|
3967 | 8459 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8460 |
"do a forward search" |
8461 |
||
8462 |
cursorLine isNil ifTrue:[^ self]. |
|
5787 | 8463 |
self |
6152 | 8464 |
searchForwardFor:pattern |
8465 |
ignoreCase:ign |
|
8466 |
match: match |
|
8467 |
startingAtLine:startLine col:startCol |
|
8468 |
ifFound:[:line :col :endColOrNil| |
|
8469 |
self cursorMovementAllowed ifTrue:[ |
|
8470 |
self cursorLine:line col:col. |
|
8471 |
]. |
|
8472 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
|
1339 | 8473 |
"/ self makeLineVisible:cursorLine |
6152 | 8474 |
typeOfSelection := #search |
8475 |
] |
|
8476 |
ifAbsent:aBlock |
|
1339 | 8477 |
|
8478 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8479 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8480 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8481 |
|
3967 | 8482 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8483 |
"do a forward search" |
|
8484 |
||
8485 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8486 |
! |
|
8487 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8488 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8489 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8490 |
|
2822 | 8491 |
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
|
8492 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8493 |
|
3982 | 8494 |
searchPatternForSearchBar |
8495 |
||
8496 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8497 |
||
8498 |
|searchPattern| |
|
8499 |
||
4138 | 8500 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
5787 | 8501 |
searchPattern isNil |
6152 | 8502 |
ifTrue: [searchPattern := lastSearchPattern] |
8503 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
3982 | 8504 |
^ searchPattern |
8505 |
! |
|
8506 |
||
3578 | 8507 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8508 |
"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
|
8509 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8510 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8511 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8512 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8513 |
"/ |
3967 | 8514 |
"/ 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
|
8515 |
"/ original string (for search after again) |
4121 | 8516 |
"/ 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
|
8517 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8518 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8519 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8520 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8521 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8522 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8523 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8524 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8525 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8526 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8527 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8528 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8529 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8530 |
"/ 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
|
8531 |
"/ if there was a previous search, only take the selection if |
3967 | 8532 |
"/ 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
|
8533 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8534 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8535 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8536 |
sel notNil ifTrue:[ |
6152 | 8537 |
(lastSearchPattern isNil |
8538 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
|
8539 |
) ifTrue:[ |
|
8540 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8541 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8542 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8543 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8544 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8545 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8546 |
"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
|
8547 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8548 |
|
5717 | 8549 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8550 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8551 |
typeOfSelection := #search. |
8552 |
! |
|
8553 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8554 |
startPositionForSearchBackward |
2822 | 8555 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8556 |
! |
|
8557 |
||
8558 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8559 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8560 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8561 |
selectionStartLine notNil ifTrue:[ |
6152 | 8562 |
startLine := selectionStartLine. |
8563 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8564 |
] ifFalse:[ |
6152 | 8565 |
cursorLine isNil ifTrue:[ |
8566 |
startLine := list size. |
|
8567 |
startCol := self listAt:startLine size. |
|
8568 |
] ifFalse:[ |
|
8569 |
startLine := cursorLine min:list size. |
|
8570 |
startCol := cursorCol |
|
8571 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8572 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8573 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8574 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8575 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8576 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8577 |
startPositionForSearchForward |
2822 | 8578 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8579 |
! |
|
8580 |
||
8581 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8582 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8583 |
|
3160 | 8584 |
"/ 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
|
8585 |
"/ 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
|
8586 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8587 |
self hasSelection ifTrue:[ |
6152 | 8588 |
^ selectionEndCol @ selectionEndLine. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8589 |
] ifFalse:[ |
6152 | 8590 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8591 |
startCol := 0 |
|
8592 |
]. |
|
8593 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8594 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8595 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8596 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8597 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8598 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8599 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8600 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8601 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8602 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8603 |
addToSelectionAfter:aBlock |
5145 | 8604 |
<resource: #obsolete> |
8605 |
||
8606 |
"evaluate aBlock while unselected. |
|
8607 |
Restore the previous selection afterwards. |
|
8608 |
CG: I am not sure, if this is a leftover and is still used at all. |
|
6152 | 8609 |
It is therefore temporarily marked as obsolete. Please check |
8610 |
and let me know." |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8611 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8612 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8613 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8614 |
self hasSelection ifTrue: [ |
6152 | 8615 |
startLine := selectionStartLine . |
8616 |
startCol := selectionStartCol . |
|
8617 |
endLine := selectionEndLine . |
|
8618 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8619 |
] ifFalse: [ |
6152 | 8620 |
startLine := endLine := cursorLine . |
8621 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8622 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8623 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8624 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8625 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8626 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8627 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8628 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8629 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
6152 | 8630 |
ifTrue: [ |
8631 |
startCol := cursorCol. |
|
8632 |
] ifFalse: [ |
|
8633 |
endCol := cursorCol - 1. |
|
8634 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8635 |
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
|
8636 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8637 |
|
1850 | 8638 |
autoMoveCursorToEndOfSelection |
8639 |
"return true, if the cursor should be automatically moved to the |
|
8640 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8641 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8642 |
not be affected by selecting" |
8643 |
||
8644 |
^ true |
|
8645 |
! |
|
8646 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8647 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8648 |
typeOfSelection ~~ newType ifTrue:[ |
6152 | 8649 |
typeOfSelection := newType. |
8650 |
selectionStartLine notNil ifTrue:[ |
|
8651 |
self |
|
8652 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8653 |
toLine:selectionEndLine col:selectionEndCol |
|
8654 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8655 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8656 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8657 |
|
4707 | 8658 |
findNextWordAfterSelectionAndAddToSelection |
8659 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8660 |
||
8661 |
selectionStartCol isNil ifTrue:[ |
|
6152 | 8662 |
self selectWordUnderCursor. |
8663 |
^ self |
|
4707 | 8664 |
]. |
8665 |
||
8666 |
selStartCol := selectionStartCol. |
|
8667 |
selEndCol := selectionEndCol. |
|
8668 |
selStartLine := selectionStartLine. |
|
8669 |
selEndLine := selectionEndLine. |
|
8670 |
||
8671 |
self cursorToNextWord. |
|
8672 |
self selectWordUnderCursor. |
|
8673 |
||
8674 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8675 |
! |
|
8676 |
||
4138 | 8677 |
searchPatternFromUserSelectionOrReplace |
8678 |
||
8679 |
|sel searchPattern| |
|
8680 |
||
8681 |
"/ |
|
8682 |
"/ if the last operation was a replace, set pattern to last |
|
8683 |
"/ original string (for search after again) |
|
8684 |
"/ |
|
8685 |
(lastStringFromReplaceForNextSearch notNil |
|
8686 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
6152 | 8687 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
8688 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8689 |
] ifFalse:[ |
|
8690 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8691 |
]. |
|
8692 |
^ searchPattern |
|
4138 | 8693 |
]. |
8694 |
||
8695 |
"/ |
|
8696 |
"/ if there is a selection: |
|
8697 |
"/ if there was no previous search, take it as search pattern. |
|
8698 |
"/ if there was a previous search, only take the selection if |
|
8699 |
"/ it did not result from a paste. |
|
8700 |
"/ (to allow search-paste to be repeated) |
|
8701 |
"/ |
|
8702 |
sel := self selection. |
|
8703 |
sel notNil ifTrue:[ |
|
6152 | 8704 |
typeOfSelection ~~ #search ifTrue:[ |
8705 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8706 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8707 |
searchPattern := sel asStringWithoutFinalCR. |
|
8708 |
] |
|
8709 |
]. |
|
4138 | 8710 |
]. |
8711 |
||
8712 |
^ searchPattern |
|
8713 |
! |
|
8714 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8715 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8716 |
"select the whole text. |
5593 | 8717 |
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
|
8718 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8719 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8720 |
list isNil ifTrue:[ |
6152 | 8721 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8722 |
] ifFalse:[ |
6152 | 8723 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8724 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8725 |
] |
1082 | 8726 |
|
8727 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8728 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8729 |
|
4117 | 8730 |
selectAllInitially |
8731 |
"select the whole text. This is called only once during the initialization |
|
8732 |
for editFields which are shown in a table or tree. |
|
8733 |
The selectAll is called via this method to allow for easier redefinition and |
|
8734 |
to distinguish auto-select from user-initiated selects." |
|
8735 |
||
8736 |
self selectAll |
|
8737 |
! |
|
8738 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8739 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8740 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8741 |
|
3160 | 8742 |
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
|
8743 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8744 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8745 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8746 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8747 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8748 |
cursorCol > 1 ifTrue:[ |
6152 | 8749 |
self selectFromLine:cursorLine col:1 |
8750 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8751 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8752 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8753 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8754 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8755 |
|
6354 | 8756 |
selectCursorLineToEnd |
8757 |
"select cursorline from cursor position to the end" |
|
8758 |
||
8759 |
self selectFromLine:cursorLine col:cursorCol |
|
8760 |
toLine:(cursorLine+1) col:0 |
|
8761 |
||
8762 |
"Created: / 16-06-2018 / 00:46:21 / Claus Gittinger" |
|
8763 |
! |
|
8764 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8765 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8766 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8767 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8768 |
selectionStartLine isNil ifTrue:[ |
6152 | 8769 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8770 |
] ifFalse:[ |
6152 | 8771 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8772 |
toLine:cursorLine+1 col:0. |
|
8773 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8774 |
] |
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 |
|
4257 | 8777 |
selectFromBeginOfLine |
8778 |
"select the text from the beginning of the current line to the current cursor position." |
|
8779 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8780 |
| newCursorCol ln | |
4271 | 8781 |
|
4257 | 8782 |
list isNil ifTrue:[ |
6152 | 8783 |
self unselect |
4257 | 8784 |
] ifFalse:[ |
6152 | 8785 |
cursorCol > 1 ifTrue:[ |
8786 |
ln := list at: cursorLine. |
|
8787 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
|
8788 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
|
6207 | 8789 |
"/ cursorCol := newCursorCol. |
8790 |
self setCursorCol:newCursorCol. |
|
6152 | 8791 |
typeOfSelection := nil |
8792 |
] |
|
4257 | 8793 |
] |
8794 |
||
8795 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8796 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8797 |
! |
8798 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8799 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8800 |
"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
|
8801 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8802 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8803 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8804 |
list isNil ifTrue:[ |
6152 | 8805 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8806 |
] ifFalse:[ |
6152 | 8807 |
cursorCol == 0 ifTrue:[ |
8808 |
col := 0 |
|
8809 |
] ifFalse:[ |
|
8810 |
col := cursorCol - 1 |
|
8811 |
]. |
|
8812 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8813 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8814 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8815 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8816 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8817 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8818 |
"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
|
8819 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8820 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8821 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 8822 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
6152 | 8823 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 8824 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8825 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8826 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8827 |
|
4257 | 8828 |
selectToEndOfLine |
8829 |
"select the text from the current cursor position to the end of the current line" |
|
8830 |
||
4271 | 8831 |
| newCursorCol line | |
8832 |
||
4257 | 8833 |
list isNil ifTrue:[ |
6152 | 8834 |
self unselect |
4257 | 8835 |
] ifFalse:[ |
6152 | 8836 |
cursorCol >= 1 ifTrue:[ |
8837 |
line := list at: cursorLine. |
|
8838 |
newCursorCol := line size. |
|
8839 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8840 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8841 |
||
8842 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
6207 | 8843 |
"/ cursorCol := newCursorCol. |
8844 |
self setCursorCol:newCursorCol. |
|
6152 | 8845 |
typeOfSelection := nil |
8846 |
] |
|
4257 | 8847 |
] |
8848 |
||
8849 |
"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
|
8850 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8851 |
! |
8852 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8853 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8854 |
"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
|
8855 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8856 |
list isNil ifTrue:[ |
6152 | 8857 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8858 |
] ifFalse:[ |
6152 | 8859 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8860 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8861 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8862 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8863 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8864 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8865 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8866 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8867 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8868 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8869 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8870 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8871 |
"forget and unhilight selection - must take care of cursor here" |
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 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8874 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8875 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8876 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8877 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8878 |
wasOn ifTrue:[self showCursor] |
105 | 8879 |
! ! |
8880 |
||
8881 |
!EditTextView methodsFor:'undo & again'! |
|
8882 |
||
2952 | 8883 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8884 |
^ undoSupport addUndo:action. |
2952 | 8885 |
! |
8886 |
||
105 | 8887 |
again |
8888 |
"repeat the last action (which was a cut or replace). |
|
8889 |
If current selection is not last string, search forward to |
|
3160 | 8890 |
next occurrence of it before repeating the last operation." |
105 | 8891 |
|
5787 | 8892 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8893 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8894 |
|
8895 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8896 |
lastStringToReplace isNil ifTrue:[ |
6152 | 8897 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8898 |
]. |
4048 | 8899 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8900 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8901 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8902 |
self undoableDo:[ |
6152 | 8903 |
s := lastStringToReplace asString. |
8904 |
"remove final cr" |
|
8905 |
(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
|
8906 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8907 |
|
6152 | 8908 |
"set lastStringToReplace as the next search string |
8909 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
8910 |
lastStringFromReplaceForNextSearch := s. |
|
8911 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
|
8912 |
||
8913 |
savedSelectStyle := selectStyle. |
|
8914 |
selectStyle := nil. |
|
8915 |
||
8916 |
sel := self selection. |
|
8917 |
||
6156 | 8918 |
"if we are already there (after a find), omit search" |
6152 | 8919 |
|
8920 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
|
8921 |
l := selectionStartLine "cursorLine". |
|
8922 |
c := selectionStartCol "cursorCol". |
|
8923 |
self deleteSelection. |
|
8924 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
8925 |
self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false. |
|
8926 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
|
8927 |
typeOfSelection := #paste |
|
8928 |
]. |
|
8929 |
selectStyle := savedSelectStyle. |
|
8930 |
^ true |
|
8931 |
]. |
|
8932 |
||
8933 |
sel isEmptyOrNil ifTrue:[ |
|
8934 |
startColForSearch := cursorCol - 1 |
|
8935 |
] ifFalse:[ |
|
8936 |
startColForSearch := selectionEndCol ? (cursorCol - 1) |
|
8937 |
]. |
|
8938 |
self |
|
8939 |
searchForwardFor:s |
|
8940 |
ignoreCase: lastReplaceIgnoredCase |
|
8941 |
match: lastReplaceWasMatch |
|
8942 |
startingAtLine:cursorLine col:startColForSearch |
|
8943 |
ifFound: |
|
8944 |
[ |
|
8945 |
:line :col | |
|
8946 |
||
8947 |
|repl| |
|
8948 |
||
8949 |
self selectFromLine:line col:col |
|
8950 |
toLine:line col:(col + s size - 1). |
|
8951 |
self makeLineVisible:line. |
|
8952 |
||
8953 |
self deleteSelection. |
|
8954 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
8955 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8956 |
repl := lastReplacementInfo lastReplacement asString "withoutSpaces" |
|
8957 |
] ifTrue:[ |
|
8958 |
repl := lastReplacementInfo lastReplacement "withoutSpaces". |
|
8959 |
]. |
|
8960 |
self insertLines:repl asStringCollection withCR:false. |
|
8961 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
|
8962 |
undoSupport actionInfo:'replace'. |
|
8963 |
]. |
|
8964 |
selectStyle := savedSelectStyle. |
|
8965 |
typeOfSelection := #paste. |
|
8966 |
^ true |
|
8967 |
] |
|
8968 |
ifAbsent: |
|
8969 |
[ |
|
8970 |
self sensor compressKeyPressEventsWithKey:#Again. |
|
8971 |
self showNotFound. |
|
8972 |
selectStyle := savedSelectStyle. |
|
8973 |
^ false |
|
8974 |
]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8975 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8976 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8977 |
^ true. |
501 | 8978 |
|
6156 | 8979 |
"Modified: / 09-10-1996 / 16:14:11 / cg" |
8980 |
"Modified (comment): / 17-05-2017 / 16:19:32 / mawalch" |
|
105 | 8981 |
! |
8982 |
||
2952 | 8983 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8984 |
^ undoSupport hasRedoAction. |
2952 | 8985 |
! |
8986 |
||
8987 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8988 |
^ undoSupport hasUndoAction. |
2952 | 8989 |
! |
8990 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8991 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8992 |
"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
|
8993 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8994 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8995 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8996 |
|
2952 | 8997 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8998 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8999 |
! |
9000 |
||
9001 |
redo |
|
3780 | 9002 |
"undo the last undo" |
9003 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9004 |
undoSupport hasRedoAction ifFalse:[ |
6262 | 9005 |
self beepInEditor |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9006 |
] ifTrue:[ |
6152 | 9007 |
undoSupport redo. |
2952 | 9008 |
] |
9009 |
! |
|
9010 |
||
121 | 9011 |
undo |
3780 | 9012 |
"undo the last edit operation" |
9013 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9014 |
undoSupport hasUndoAction ifFalse:[ |
6262 | 9015 |
self beepInEditor |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9016 |
] ifTrue:[ |
5834 | 9017 |
undoSupport undo. |
9018 |
self makeSelectionVisible. |
|
9019 |
self makeCursorVisible. |
|
121 | 9020 |
] |
2952 | 9021 |
! |
9022 |
||
9023 |
undoableDo:aBlock |
|
3495 | 9024 |
self undoableDo:aBlock info:nil. |
9025 |
||
9026 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 9027 |
! |
9028 |
||
9029 |
undoableDo:aBlock info:aString |
|
5689 | 9030 |
|selectionRestore| |
9031 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9032 |
self checkModificationsAllowed ifFalse:[ |
6152 | 9033 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
9034 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9035 |
] ifTrue:[ |
6152 | 9036 |
undoSupport isInTransaction ifFalse:[ |
9037 |
selectionRestore := RestoreSelectionAndCursor new |
|
9038 |
cursorLine:cursorLine cursorCol:cursorCol |
|
9039 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
9040 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
9041 |
info:nil. |
|
9042 |
]. |
|
9043 |
undoSupport |
|
9044 |
undoableDo:[ |
|
9045 |
aBlock value. |
|
9046 |
selectionRestore notNil ifTrue:[ |
|
9047 |
undoSupport transactionNotEmpty ifTrue:[ |
|
9048 |
undoSupport addUndoFirst:selectionRestore |
|
9049 |
]. |
|
9050 |
]. |
|
9051 |
] |
|
9052 |
info:aString. |
|
5689 | 9053 |
]. |
9054 |
||
9055 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 9056 |
! ! |
9057 |
||
9058 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
9059 |
||
9060 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9061 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9062 |
! |
|
9063 |
||
3115 | 9064 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 9065 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 9066 |
! |
9067 |
||
2952 | 9068 |
line:arg1 col:arg2 character:arg3 |
9069 |
^ self new line:arg1 col:arg2 character:arg3 |
|
9070 |
! |
|
9071 |
||
3115 | 9072 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 9073 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 9074 |
! |
9075 |
||
3235 | 9076 |
line:arg1 col:arg2 characters:arg3 info:info |
9077 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
9078 |
! |
|
9079 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9080 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9081 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9082 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9083 |
|
2952 | 9084 |
line:arg1 col:arg2 string:arg3 |
9085 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 9086 |
! |
9087 |
||
9088 |
line:arg1 col:arg2 string:arg3 info:info |
|
9089 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 9090 |
! |
9091 |
||
9092 |
line:arg1 string:arg3 info:info |
|
9093 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 9094 |
! |
9095 |
||
9096 |
text:arg info:info |
|
9097 |
^ (self new text:arg) info:info |
|
3115 | 9098 |
! ! |
9099 |
||
9100 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
9101 |
||
9102 |
info |
|
9103 |
^ userFriendlyInfo |
|
9104 |
! |
|
9105 |
||
9106 |
info:aString |
|
9107 |
userFriendlyInfo := aString |
|
2952 | 9108 |
! ! |
9109 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9110 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9111 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9112 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9113 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9114 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9115 |
"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
|
9116 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9117 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9118 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9119 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9120 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9121 |
^ false |
5710 | 9122 |
! |
9123 |
||
9124 |
isRestoreSelectionAndCursor |
|
9125 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9126 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9127 |
|
2952 | 9128 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
9129 |
||
3160 | 9130 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 9131 |
"set instance variables (automatically generated)" |
9132 |
||
9133 |
self assert:(line1Arg notNil). |
|
9134 |
self assert:(col1Arg notNil). |
|
9135 |
self assert:(line2Arg notNil). |
|
9136 |
self assert:(col2Arg notNil). |
|
9137 |
||
9138 |
line1 := line1Arg. |
|
9139 |
col1 := col1Arg. |
|
9140 |
line2 := line2Arg. |
|
9141 |
col2 := col2Arg. |
|
9142 |
! ! |
|
9143 |
||
9144 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
9145 |
||
3160 | 9146 |
executeIn:editor |
2952 | 9147 |
editor unselect. |
3160 | 9148 |
editor |
6152 | 9149 |
deleteFromLine:line1 |
9150 |
col:col1 |
|
9151 |
toLine:line2 |
|
9152 |
col:col2. |
|
2952 | 9153 |
editor cursorLine:line1 col:col1. |
9154 |
! ! |
|
9155 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9156 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9157 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9158 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9159 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9160 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9161 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9162 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9163 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9164 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9165 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9166 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9167 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9168 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9169 |
|
3160 | 9170 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9171 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9172 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9173 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9174 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9175 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9176 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9177 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9178 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9179 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9180 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9181 |
|
3160 | 9182 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9183 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9184 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9185 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9186 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9187 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9188 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9189 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9190 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9191 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9192 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9193 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9194 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9195 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9196 |
|
3160 | 9197 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9198 |
"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
|
9199 |
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
|
9200 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9201 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9202 |
previousDeleteAction line == line ifTrue:[ |
6152 | 9203 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
9204 |
^ true |
|
9205 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9206 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9207 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9208 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9209 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9210 |
|
3160 | 9211 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9212 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9213 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9214 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9215 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9216 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
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 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9219 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9220 |
|
3160 | 9221 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9222 |
editor unselect. |
3160 | 9223 |
editor |
6152 | 9224 |
deleteFromLine:line |
9225 |
col:col1 |
|
9226 |
toLine:line |
|
9227 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9228 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9229 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9230 |
|
3235 | 9231 |
!EditTextView::EditMode class methodsFor:'constants'! |
9232 |
||
9233 |
insertAndSelectMode |
|
9234 |
^ InsertAndSelectMode |
|
9235 |
! |
|
9236 |
||
9237 |
insertMode |
|
9238 |
^ InsertMode |
|
9239 |
! |
|
9240 |
||
9241 |
overwriteMode |
|
9242 |
^ OverwriteMode |
|
9243 |
! ! |
|
9244 |
||
9245 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
9246 |
||
9247 |
isInsertAndSelectMode |
|
9248 |
^ false |
|
9249 |
! |
|
9250 |
||
9251 |
isInsertMode |
|
9252 |
^ false |
|
9253 |
! |
|
9254 |
||
9255 |
symbolicName |
|
9256 |
self subclassResponsibility |
|
9257 |
! ! |
|
9258 |
||
9259 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
9260 |
||
9261 |
infoPrintString |
|
9262 |
^ 'IS' |
|
9263 |
! ! |
|
9264 |
||
9265 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
9266 |
||
9267 |
isInsertAndSelectMode |
|
9268 |
^ true |
|
9269 |
! |
|
9270 |
||
9271 |
isInsertMode |
|
9272 |
^ true |
|
9273 |
! ! |
|
9274 |
||
9275 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
9276 |
||
9277 |
infoPrintString |
|
9278 |
^ 'I' |
|
9279 |
! ! |
|
9280 |
||
9281 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
9282 |
||
9283 |
isInsertMode |
|
9284 |
^ true |
|
9285 |
! ! |
|
9286 |
||
9287 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
9288 |
||
9289 |
infoPrintString |
|
9290 |
^ 'O' |
|
9291 |
! ! |
|
9292 |
||
4048 | 9293 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
9294 |
||
9295 |
lastReplaceIgnoredCase |
|
9296 |
^ lastReplaceIgnoredCase ? false |
|
9297 |
! |
|
9298 |
||
9299 |
lastReplaceIgnoredCase:something |
|
9300 |
lastReplaceIgnoredCase := something. |
|
9301 |
! |
|
9302 |
||
9303 |
lastReplaceWasMatch |
|
9304 |
^ lastReplaceWasMatch ? false |
|
9305 |
! |
|
9306 |
||
9307 |
lastReplaceWasMatch:something |
|
9308 |
lastReplaceWasMatch := something. |
|
9309 |
! |
|
9310 |
||
9311 |
lastReplacement |
|
9312 |
^ lastReplacement |
|
9313 |
! |
|
9314 |
||
9315 |
lastReplacement:something |
|
4053 | 9316 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 9317 |
lastReplacement := something. |
9318 |
! |
|
9319 |
||
9320 |
lastStringToReplace |
|
9321 |
^ lastStringToReplace |
|
9322 |
! |
|
9323 |
||
9324 |
lastStringToReplace:something |
|
9325 |
lastStringToReplace := something. |
|
4818 | 9326 |
! |
9327 |
||
9328 |
previousReplacements |
|
9329 |
^ previousReplacements ? #() |
|
9330 |
! |
|
9331 |
||
9332 |
stillCollectingInput |
|
9333 |
^ stillCollectingInput |
|
9334 |
! |
|
9335 |
||
9336 |
stillCollectingInput:aBoolean |
|
9337 |
stillCollectingInput := aBoolean. |
|
9338 |
! ! |
|
9339 |
||
9340 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9341 |
||
9342 |
rememberReplacement |
|
9343 |
"remember the previous replacement (called when a new one appears). |
|
9344 |
Mostly for the benefit of the code completion..." |
|
9345 |
||
9346 |
|oldString newString| |
|
9347 |
||
9348 |
oldString := lastStringToReplace. |
|
9349 |
newString := lastReplacement. |
|
9350 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
6152 | 9351 |
previousReplacements isNil ifTrue:[ |
9352 |
previousReplacements := OrderedCollection new. |
|
9353 |
]. |
|
9354 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9355 |
previousReplacements addFirst:(oldString -> newString). |
|
9356 |
previousReplacements size > 20 ifTrue:[ |
|
9357 |
previousReplacements removeLast. |
|
9358 |
] |
|
4818 | 9359 |
]. |
4048 | 9360 |
! ! |
9361 |
||
2952 | 9362 |
!EditTextView::PasteString methodsFor:'accessing'! |
9363 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9364 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9365 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9366 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9367 |
"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
|
9368 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9369 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9370 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9371 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9372 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9373 |
"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
|
9374 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9375 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9376 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9377 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9378 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9379 |
"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
|
9380 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9381 |
|
3160 | 9382 |
line:lineArg col:colArg string:stringArg |
2952 | 9383 |
self assert:(lineArg notNil). |
9384 |
self assert:(colArg notNil). |
|
9385 |
self assert:(stringArg notNil). |
|
9386 |
||
9387 |
line := lineArg. |
|
9388 |
col := colArg. |
|
9389 |
string := stringArg. |
|
9390 |
! |
|
9391 |
||
9392 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9393 |
self assert:(lineArg notNil). |
|
9394 |
self assert:(colArg notNil). |
|
9395 |
self assert:(stringArg notNil). |
|
9396 |
||
9397 |
line := lineArg. |
|
9398 |
col := colArg. |
|
9399 |
string := stringArg. |
|
9400 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9401 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9402 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9403 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9404 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9405 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9406 |
"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
|
9407 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9408 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9409 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9410 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9411 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9412 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9413 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9414 |
"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
|
9415 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9416 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9417 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9418 |
"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
|
9419 |
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
|
9420 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9421 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9422 |
previousPasteAction line == line ifTrue:[ |
6152 | 9423 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9424 |
^ true |
|
9425 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9426 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9427 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9428 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9429 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9430 |
"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
|
9431 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9432 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9433 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9434 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9435 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9436 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9437 |
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
|
9438 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9439 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9440 |
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
|
9441 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9442 |
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
|
9443 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9444 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9445 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9446 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9447 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9448 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9449 |
! ! |
9450 |
||
9451 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9452 |
||
3160 | 9453 |
executeIn:editor |
2952 | 9454 |
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
|
9455 |
editor paste:string. |
2952 | 9456 |
selected ~~ true ifTrue:[ |
6152 | 9457 |
editor unselect |
2952 | 9458 |
]. |
9459 |
! ! |
|
9460 |
||
9461 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9462 |
||
3235 | 9463 |
col |
9464 |
^ col |
|
9465 |
! |
|
9466 |
||
9467 |
col1 |
|
9468 |
^ col |
|
9469 |
! |
|
9470 |
||
9471 |
col2 |
|
9472 |
^ col |
|
9473 |
! |
|
9474 |
||
9475 |
line |
|
9476 |
^ line |
|
9477 |
! |
|
9478 |
||
3160 | 9479 |
line:lineArg col:colArg character:characterArg |
2952 | 9480 |
line := lineArg. |
9481 |
col := colArg. |
|
9482 |
character := characterArg. |
|
9483 |
! ! |
|
9484 |
||
9485 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9486 |
||
3160 | 9487 |
executeIn:editor |
9488 |
editor |
|
6152 | 9489 |
replace:character |
9490 |
atLine:line |
|
9491 |
col:col. |
|
2952 | 9492 |
editor cursorLine:line col:col. |
105 | 9493 |
! ! |
9494 |
||
3235 | 9495 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9496 |
||
9497 |
characters |
|
9498 |
^ characters |
|
9499 |
! |
|
9500 |
||
9501 |
col1 |
|
9502 |
^ col1 |
|
9503 |
! |
|
9504 |
||
9505 |
col2 |
|
9506 |
^ col2 |
|
9507 |
! |
|
9508 |
||
9509 |
line |
|
9510 |
^ line |
|
9511 |
! |
|
9512 |
||
9513 |
line:lineArg col:colArg character:characterArg |
|
9514 |
line := lineArg. |
|
9515 |
col1 := col2 := colArg. |
|
9516 |
characters := characterArg asString. |
|
9517 |
! |
|
9518 |
||
9519 |
line:lineArg col:colArg characters:charactersArg |
|
9520 |
line := lineArg. |
|
9521 |
col1 := colArg. |
|
9522 |
characters := charactersArg asString. |
|
9523 |
col2 := col1 + charactersArg size - 1 |
|
9524 |
! ! |
|
9525 |
||
9526 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9527 |
||
9528 |
canCombineWithNext:anotherAction |
|
9529 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9530 |
! |
|
9531 |
||
9532 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9533 |
"I will combine only if we both are single character deletes, |
|
9534 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9535 |
(i.e. single-character typing)" |
|
9536 |
||
9537 |
previousReplaceAction line == line ifTrue:[ |
|
6152 | 9538 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9539 |
^ true |
|
9540 |
]. |
|
3235 | 9541 |
]. |
9542 |
||
9543 |
^ false |
|
9544 |
! |
|
9545 |
||
9546 |
combineWithNext:nextReplaceAction |
|
9547 |
self assert:(line == nextReplaceAction line). |
|
9548 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9549 |
||
9550 |
col2 := nextReplaceAction col2. |
|
9551 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9552 |
characters := characters , nextReplaceAction characters. |
|
9553 |
! ! |
|
9554 |
||
9555 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9556 |
||
9557 |
executeIn:editor |
|
9558 |
editor |
|
6152 | 9559 |
replaceString:characters |
9560 |
atLine:line |
|
9561 |
col:col1. |
|
3235 | 9562 |
editor cursorLine:line col:col1. |
9563 |
! ! |
|
9564 |
||
3131 | 9565 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9566 |
||
9567 |
text:something |
|
9568 |
text := something. |
|
9569 |
! ! |
|
9570 |
||
9571 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9572 |
||
3160 | 9573 |
executeIn:editor |
3131 | 9574 |
editor contents:text |
9575 |
! ! |
|
9576 |
||
3130 | 9577 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9578 |
||
3160 | 9579 |
line:lineArg string:stringArg |
3130 | 9580 |
line := lineArg. |
9581 |
text := stringArg. |
|
9582 |
! ! |
|
9583 |
||
9584 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9585 |
||
3160 | 9586 |
executeIn:editor |
3130 | 9587 |
editor list at:line put:text. |
9588 |
editor invalidateLine:line |
|
9589 |
! ! |
|
9590 |
||
3402 | 9591 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9592 |
||
9593 |
line:lineArg lines:lineCollectionArg |
|
9594 |
line := lineArg. |
|
9595 |
text := lineCollectionArg. |
|
9596 |
||
9597 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9598 |
! ! |
|
9599 |
||
9600 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9601 |
||
9602 |
executeIn:editor |
|
9603 |
|lnr| |
|
9604 |
||
9605 |
lnr := line. |
|
9606 |
text do:[:eachLine | |
|
6152 | 9607 |
editor list at:lnr put:eachLine. |
9608 |
editor invalidateLine:lnr. |
|
9609 |
lnr := lnr + 1. |
|
3402 | 9610 |
]. |
9611 |
||
9612 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9613 |
! ! |
|
9614 |
||
5689 | 9615 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9616 |
||
5787 | 9617 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
5689 | 9618 |
cursorLine := cursorLineArg. |
9619 |
cursorCol := cursorColArg. |
|
9620 |
selectionStartLine := selectionStartLineArg. |
|
9621 |
selectionStartCol := selectionStartColArg. |
|
9622 |
selectionEndLine := selectionEndLineArg. |
|
9623 |
selectionEndCol := selectionEndColArg. |
|
9624 |
! |
|
9625 |
||
5787 | 9626 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
6152 | 9627 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
9628 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9629 |
info:info |
|
5689 | 9630 |
|
9631 |
cursorLine := cursorLineArg. |
|
9632 |
cursorCol := cursorColArg. |
|
9633 |
selectionStartLine := selectionStartLineArg. |
|
9634 |
selectionStartCol := selectionStartColArg. |
|
9635 |
selectionEndLine := selectionEndLineArg. |
|
9636 |
selectionEndCol := selectionEndColArg. |
|
9637 |
userFriendlyInfo := info. |
|
9638 |
||
9639 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9640 |
! ! |
|
9641 |
||
9642 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9643 |
||
9644 |
executeIn:editor |
|
9645 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9646 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
6152 | 9647 |
editor setCursorLine:cursorLine col:cursorCol. |
9648 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
5689 | 9649 |
] ifFalse:[ |
6152 | 9650 |
editor cursorLine:cursorLine col:cursorCol. |
5689 | 9651 |
]. |
9652 |
||
9653 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9654 |
! ! |
|
9655 |
||
5710 | 9656 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9657 |
||
9658 |
isRestoreSelectionAndCursor |
|
9659 |
^ true |
|
9660 |
! ! |
|
9661 |
||
865 | 9662 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9663 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9664 |
version |
5361 | 9665 |
^ '$Header$' |
3945 | 9666 |
! |
9667 |
||
9668 |
version_CVS |
|
5361 | 9669 |
^ '$Header$' |
0 | 9670 |
! ! |
4481 | 9671 |