author | Stefan Vogel <sv@exept.de> |
Tue, 10 Mar 2020 15:19:04 +0100 | |
changeset 6844 | 235a4c848100 |
parent 6829 | 84d0b230b24a |
permissions | -rw-r--r-- |
6733 | 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 |
6610 | 899 |
"get the programming language (for comments, indentation etc.). |
900 |
Here, in the generic editor, we don't know anything about languages" |
|
901 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
902 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
903 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
904 |
"Created: / 18-09-2013 / 14:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6610 | 905 |
"Modified (comment): / 26-06-2019 / 22:07:54 / Claus Gittinger" |
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
906 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
907 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
908 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
909 |
"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
|
910 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
911 |
"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
|
912 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
913 |
|
4609 | 914 |
editedMethod |
915 |
|cm| |
|
916 |
||
917 |
cm := self editedMethodOrClass. |
|
918 |
cm isMethod ifTrue:[^ cm]. |
|
919 |
cm isBehavior ifTrue:[^ nil]. |
|
920 |
^ nil |
|
921 |
! |
|
922 |
||
923 |
editedMethodOrClass |
|
924 |
^ nil |
|
925 |
! |
|
926 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
927 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
928 |
"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
|
929 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
930 |
"Created: / 27-09-2013 / 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
|
931 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
932 |
|
4585 | 933 |
hasSelectionOrTextInCursorLine |
934 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
935 |
! |
|
936 |
||
4589 | 937 |
selectionOrTextOfCursorLine |
938 |
^ self selectionOrTextOfCursorLine:true |
|
939 |
! |
|
940 |
||
4585 | 941 |
selectionOrTextOfCursorLine:doSelect |
942 |
|sel lNr line| |
|
943 |
||
944 |
sel := self selectionAsString. |
|
945 |
sel notNil ifTrue:[^ sel]. |
|
946 |
||
947 |
lNr := self cursorLine. |
|
948 |
line := self listAt:lNr. |
|
949 |
line notEmptyOrNil ifTrue:[ |
|
6152 | 950 |
doSelect ifTrue:[ |
951 |
self selectLine:lNr. |
|
952 |
]. |
|
953 |
^ line |
|
4585 | 954 |
]. |
955 |
||
956 |
^ nil |
|
957 |
! ! |
|
958 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
959 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
960 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
961 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
962 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
963 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
964 |
^ acceptAction |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
967 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
968 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
969 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
970 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
971 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
972 |
|
2792 | 973 |
acceptChannel |
974 |
"return the valueHolder holding true if text was accepted. |
|
975 |
By placing a true into this channel, an accept can also be forced." |
|
976 |
||
977 |
^ acceptChannel |
|
978 |
||
979 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
980 |
! |
|
981 |
||
982 |
acceptChannel:aValueHolder |
|
983 |
"set the valueHolder holding true if text was accepted. |
|
984 |
By placing a true into this channel, an accept can also be forced." |
|
985 |
||
986 |
|prev| |
|
987 |
||
988 |
prev := acceptChannel. |
|
989 |
acceptChannel := aValueHolder. |
|
990 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
991 |
||
992 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
993 |
! |
|
994 |
||
1108 | 995 |
acceptEnabled:aBoolean |
996 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
997 |
||
998 |
acceptEnabled := aBoolean |
|
999 |
||
1000 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
1001 |
! |
|
1002 |
||
2792 | 1003 |
accepted |
1004 |
"return true if text was accepted" |
|
1005 |
||
1006 |
^ acceptChannel value |
|
1007 |
||
1008 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1009 |
! |
|
1010 |
||
1011 |
accepted:aBoolean |
|
1012 |
"set/clear the accepted flag. |
|
1013 |
This may force my current contents to be placed into my model." |
|
1014 |
||
1015 |
acceptChannel value:aBoolean. |
|
1016 |
||
1017 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1018 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1019 |
! |
|
1020 |
||
6609 | 1021 |
autoIndent |
6829 | 1022 |
"true if autoIndent mode is on" |
1023 |
||
6614 | 1024 |
^ autoIndent value |
1025 |
||
1026 |
"Modified: / 26-06-2019 / 23:16:17 / Claus Gittinger" |
|
6609 | 1027 |
! |
1028 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1029 |
autoIndent:aBoolean |
6829 | 1030 |
"set to true for autoIndent mode" |
1031 |
||
6614 | 1032 |
autoIndent value: aBoolean |
1033 |
||
1034 |
"Created: / 05-03-1996 / 14:37:50 / cg" |
|
1035 |
"Modified: / 26-06-2019 / 23:19:24 / Claus Gittinger" |
|
1036 |
! |
|
1037 |
||
1038 |
autoIndentHolder |
|
6829 | 1039 |
"holds true if autoIndent mode is on" |
1040 |
||
6614 | 1041 |
^ autoIndent |
1042 |
||
1043 |
"Created: / 26-06-2019 / 23:16:24 / Claus Gittinger" |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1044 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1045 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1046 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1047 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1048 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1049 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1050 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1051 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1052 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1053 |
|
2774 | 1054 |
cursorMovementWhenUpdating |
3160 | 1055 |
"return what is be done with the cursor, |
2774 | 1056 |
when I get a new text (via the model or the #contents/#list) |
1057 |
Allowed arguments are: |
|
6152 | 1058 |
#keep / nil -> stay where it was |
1059 |
#endOfText -> position cursor to the end |
|
1060 |
#beginOfText -> position cursor to the beginning |
|
1061 |
#endOfLine -> position cursor to the current lines end |
|
1062 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1063 |
The default is #beginOfText. |
1064 |
This may be useful for fields which get new values assigned from |
|
1065 |
the program (i.e. not from the user)" |
|
1066 |
||
1067 |
^ cursorMovementWhenUpdating |
|
1068 |
||
1069 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1070 |
! |
|
1071 |
||
2133 | 1072 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1073 |
"define what should be done with the cursor, |
2133 | 1074 |
when I get a new text (via the model or the #contents/#list) |
1075 |
Allowed arguments are: |
|
6152 | 1076 |
#keep / nil -> stay where it was |
1077 |
#endOfText -> position cursor to the end |
|
1078 |
#beginOfText -> position cursor to the beginning |
|
1079 |
#endOfLine -> position cursor to the current lines end |
|
1080 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1081 |
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
|
1082 |
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
|
1083 |
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
|
1084 |
|
2133 | 1085 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1086 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1087 |
"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
|
1088 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1089 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1090 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1091 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1092 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1093 |
|
2438 | 1094 |
dontReplaceSelectionOnInput |
4742 | 1095 |
"remember that the current selection was created by a paste operation |
1096 |
(as opposed to an explicit selection by the user). |
|
1097 |
This selection will not be replaced by followup user input, |
|
1098 |
so multiple pastes will be possible." |
|
1099 |
||
2438 | 1100 |
typeOfSelection := #paste |
1101 |
! |
|
1102 |
||
3235 | 1103 |
editModeHolder |
6829 | 1104 |
"the edit mode (insert, overwrite,...)" |
1105 |
||
3235 | 1106 |
^ editMode. |
1107 |
! |
|
1108 |
||
1109 |
editModeInsert |
|
6829 | 1110 |
"set to insert mode" |
1111 |
||
3235 | 1112 |
editMode value:EditMode insertMode |
1113 |
! |
|
1114 |
||
1115 |
editModeInsertAndSelect |
|
6829 | 1116 |
"set to selecting insert mode" |
1117 |
||
3235 | 1118 |
editMode value:EditMode insertAndSelectMode |
1119 |
! |
|
1120 |
||
1121 |
editModeOverwrite |
|
6829 | 1122 |
"set to overwrite mode" |
1123 |
||
3235 | 1124 |
editMode value:EditMode overwriteMode |
1125 |
! |
|
1126 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1127 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1128 |
"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
|
1129 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1130 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1131 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1132 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1133 |
|
5858 | 1134 |
generateTextAfterEndHook:aBlock |
1135 |
"some applications may want to dynamically generate lines below the bottom line, |
|
1136 |
when the cursor is moved there. |
|
1137 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1138 |
which want to automatically generate additional lines lazily, |
|
1139 |
but which cannot afford to generate the whole text in advance |
|
1140 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1141 |
If set, this hook is called whenever the cursor is about to be moved below the |
5859 | 1142 |
last line, getting the new lineNr (i.e > contents size) as argument. |
5858 | 1143 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1144 |
number, into which the cursor should be moved |
1145 |
(eg. if 10 additional lines are generated, it may want to return oldSize+1, |
|
5858 | 1146 |
to make the cursor end in the last line which was inserted)" |
5890 | 1147 |
|
5858 | 1148 |
self setAttribute:#generateTextAfterEndHook to:aBlock |
1149 |
! |
|
1150 |
||
1151 |
generateTextBeforeStartHook:aBlock |
|
1152 |
"some applications may want to dynamically generate lines above the top |
|
1153 |
line, when the cursor is moved there. |
|
1154 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1155 |
which want to automatically generate additional lines lazily, |
|
1156 |
but which cannot afford to generate the whole text in advance |
|
1157 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1158 |
If set, this hook is called whenever the cursor is about to be moved above the |
5859 | 1159 |
top, getting the new lineNr (i.e < 1) as argument. |
5858 | 1160 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1161 |
number, into which the cursor should be moved |
1162 |
(eg. if 10 additional lines are generated, it may want to return 10, to make the |
|
5858 | 1163 |
cursor end in the last line which was inserted)" |
5890 | 1164 |
|
5858 | 1165 |
self setAttribute:#generateTextBeforeStartHook to:aBlock |
1166 |
! |
|
1167 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1168 |
insertMode:aBoolean |
6829 | 1169 |
"set to true if inserting (as opposed to overwrite)" |
1170 |
||
3235 | 1171 |
editMode value:(aBoolean ifTrue:[EditMode insertMode] ifFalse:[EditMode overwriteMode]) |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1172 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1173 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1174 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1175 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1176 |
insertModeHolder |
6829 | 1177 |
"holds true if inserting (as opposed to overwrite)" |
1178 |
||
3235 | 1179 |
^ BlockValue |
6152 | 1180 |
with:[:m | m isInsertMode] |
1181 |
argument:(editMode). |
|
3465 | 1182 |
|
1183 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1184 |
! |
1185 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1186 |
isInInsertMode |
6829 | 1187 |
"true if inserting (as opposed to overwrite)" |
1188 |
||
3235 | 1189 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1190 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1191 |
|
5216 | 1192 |
isNotReadOnly |
1193 |
"return true, if the text is not readonly." |
|
1194 |
||
1195 |
^ self isReadOnly not |
|
1196 |
! |
|
1197 |
||
2792 | 1198 |
isReadOnly |
1199 |
"return true, if the text is readonly." |
|
1200 |
||
1201 |
^ readOnly value |
|
1202 |
||
1203 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1204 |
! |
|
1205 |
||
6572 | 1206 |
lineEndCRLF:aBoolean |
1207 |
"If aBoolean is true, use CRLF (as in windows) for end of line. |
|
1208 |
Otherwise and default use Character cr (which in newline as in unix)." |
|
1209 |
||
1210 |
lineEndCRLF := aBoolean. |
|
1211 |
||
1212 |
"Created: / 16-04-2019 / 10:59:47 / Stefan Vogel" |
|
1213 |
! |
|
1214 |
||
2796 | 1215 |
modeLabelHolder |
1216 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1217 |
||
3160 | 1218 |
^ BlockValue |
6152 | 1219 |
with:[:e :l | |
1220 |
self isReadOnly ifTrue:[ |
|
1221 |
'' |
|
1222 |
] ifFalse:[ |
|
1223 |
l ifTrue:[ 'L' allBold withColor:#red] |
|
1224 |
ifFalse:[ e infoPrintString]]] |
|
1225 |
argument:(self editModeHolder) |
|
1226 |
argument:(self learnModeHolder). |
|
3465 | 1227 |
|
1228 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1229 |
! |
1230 |
||
2792 | 1231 |
modified |
1232 |
"return true if text was modified" |
|
1233 |
||
1234 |
^ modifiedChannel value |
|
1235 |
! |
|
1236 |
||
1237 |
modified:aBoolean |
|
1238 |
"set/clear the modified flag" |
|
1239 |
||
1240 |
modifiedChannel value:aBoolean |
|
1241 |
||
1242 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1243 |
! |
|
1244 |
||
1245 |
modifiedChannel |
|
1246 |
"return the valueHolder holding true if text was modified" |
|
1247 |
||
1248 |
^ modifiedChannel |
|
1249 |
! |
|
1250 |
||
1251 |
modifiedChannel:aValueHolder |
|
1252 |
"set the valueHolder holding true if text was modified" |
|
1253 |
||
1254 |
|prev| |
|
1255 |
||
1256 |
prev := modifiedChannel. |
|
1257 |
modifiedChannel := aValueHolder. |
|
1258 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1259 |
||
1260 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1261 |
! |
|
1262 |
||
1263 |
readOnly |
|
1264 |
"make the text readonly. |
|
4664 | 1265 |
Obsolete because it is obfuscating (looks like a getter) |
1266 |
- use #readOnly:" |
|
2792 | 1267 |
|
1268 |
<resource:#obsolete> |
|
1269 |
||
1270 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1271 |
self readOnly:true. |
2792 | 1272 |
|
4664 | 1273 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1274 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1275 |
! |
1276 |
||
6401 | 1277 |
readOnly:aBooleanOrValueHolder |
2792 | 1278 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
1279 |
The argument may also be a valueHolder." |
|
1280 |
||
6401 | 1281 |
readOnly := aBooleanOrValueHolder |
1282 |
||
1283 |
"Created: / 14-02-1997 / 17:35:39 / cg" |
|
1284 |
"Modified (format): / 22-08-2018 / 15:35:14 / Claus Gittinger" |
|
2792 | 1285 |
! |
1286 |
||
4782 | 1287 |
reallyModifiedChannel |
1288 |
"return the valueHolder holding true if text was really modified. |
|
1289 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1290 |
||
1291 |
^ self modifiedChannel |
|
1292 |
! |
|
1293 |
||
5909 | 1294 |
st80EditMode |
1295 |
"If on, the cursor wraps at the line end (like in vi or st80); |
|
1296 |
if off, we have the Rand-editor behavior (random access)" |
|
1297 |
||
1298 |
^ st80Mode ? (UserPreferences current st80EditMode) |
|
1299 |
! |
|
1300 |
||
1301 |
st80EditMode:aBooleanOrNil |
|
4192 | 1302 |
"set/clear the st80Mode flag. |
1303 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1304 |
if off, we have the Rand-editor behavior (random access) |
1305 |
if nil, the setting follows the current userPref setting." |
|
1306 |
||
1307 |
st80Mode := aBooleanOrNil |
|
4192 | 1308 |
|
1309 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1310 |
! |
|
1311 |
||
5909 | 1312 |
st80Mode:aBooleanOrNil |
6070 | 1313 |
<resource: #obsolete> |
5909 | 1314 |
self obsoleteMethodWarning. |
1315 |
self st80EditMode:aBooleanOrNil |
|
1316 |
||
1317 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1318 |
! |
|
1319 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1320 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1321 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1322 |
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
|
1323 |
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
|
1324 |
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
|
1325 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1326 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1327 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1328 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1329 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1330 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1331 |
"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
|
1332 |
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
|
1333 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1334 |
|
3160 | 1335 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1336 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1337 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1338 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1339 |
"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
|
1340 |
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
|
1341 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1342 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1343 |
tabRequiresControl := aBoolean |
5909 | 1344 |
! |
1345 |
||
1346 |
trimBlankLines |
|
6310 | 1347 |
"If true, the blank lines are trimmed to zero size and trailing blank lines are removed; |
1348 |
if false, they are left as is; |
|
5909 | 1349 |
if nil, the setting follows the current userPref setting." |
1350 |
||
1351 |
^ trimBlankLines ? (UserPreferences current trimBlankLines) |
|
1352 |
! |
|
1353 |
||
1354 |
trimBlankLines:aBooleanOrNil |
|
6310 | 1355 |
"If true, the blank lines are trimmed to zero size and trailing blank lines are removed; |
1356 |
if false, they are left as is; |
|
5909 | 1357 |
if nil, the setting follows the current userPref setting." |
1358 |
||
1359 |
trimBlankLines := aBooleanOrNil. |
|
6329 | 1360 |
! |
1361 |
||
1362 |
trimLastCR |
|
1363 |
"If true, the last line is returned without a trailing CR character; |
|
1364 |
The default is false; this is only used by very specialized editors." |
|
1365 |
||
1366 |
^ (self objectAttributeAt:#trimLastCR) ? false |
|
1367 |
||
1368 |
"Created: / 28-05-2018 / 12:05:34 / Claus Gittinger" |
|
1369 |
! |
|
1370 |
||
1371 |
trimLastCR:aBooleanOrNil |
|
1372 |
"If true, the last line is returned without a trailing CR character; |
|
1373 |
The default is false; this is only used by very specialized editors." |
|
1374 |
||
1375 |
self objectAttributeAt:#trimLastCR put:aBooleanOrNil. |
|
1376 |
||
1377 |
"Created: / 28-05-2018 / 12:05:02 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1378 |
! ! |
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 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1381 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1382 |
at:lineNr basicPut:aLine |
5413 | 1383 |
"change a line without change notification. |
1384 |
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
|
1385 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1386 |
(self at:lineNr) = aLine ifFalse:[ |
6152 | 1387 |
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
|
1388 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1389 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1390 |
|
522 | 1391 |
at:lineNr put:aLine |
5413 | 1392 |
"replace a line by something new. |
1393 |
this is not undoably, unless you care for yourself" |
|
1394 |
||
5393 | 1395 |
|oldLine| |
1396 |
||
1397 |
oldLine := (self at:lineNr) ? ''. |
|
1398 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
6152 | 1399 |
super at:lineNr put:aLine. |
1400 |
self textChanged |
|
522 | 1401 |
]. |
1402 |
! |
|
1403 |
||
4700 | 1404 |
characterAfterCursor |
1405 |
"return the character one after the cursor - space if beyond line." |
|
1406 |
||
1407 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1408 |
! |
|
1409 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1410 |
characterBeforeCursor |
4700 | 1411 |
"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
|
1412 |
|
5142 | 1413 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1414 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1415 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1416 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1417 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1418 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1419 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1420 |
characterUnderCursor |
2707 | 1421 |
"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
|
1422 |
For non-block cursors, this is the character immediately to the right |
5787 | 1423 |
of the insertion-bar or caret. |
5413 | 1424 |
For block cursors, this is the highlighted cursor-character" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1425 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1426 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1427 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1428 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1429 |
contents |
6330 | 1430 |
"return the contents as a String or Text (i.e. with emphasis). |
1431 |
Cares for trimBlankLines and trimLastCR options." |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1432 |
|
6329 | 1433 |
|numLines contents| |
5988 | 1434 |
|
1435 |
list isNil ifTrue:[^ '']. |
|
1436 |
self trimBlankLines ifTrue:[ |
|
1437 |
self removeTrailingBlankLines. |
|
1438 |
] ifFalse:[ |
|
1439 |
"/ the last line does not count, if the cursor is at |
|
1440 |
"/ the begining |
|
1441 |
cursorCol == 1 ifTrue:[ |
|
1442 |
numLines := list size. |
|
1443 |
cursorLine == numLines ifTrue:[ |
|
1444 |
numLines > 1 ifTrue:[ |
|
1445 |
(self listAt:numLines) isEmptyOrNil ifTrue:[ |
|
1446 |
list grow:numLines-1. |
|
1447 |
]. |
|
1448 |
]. |
|
1449 |
]. |
|
1450 |
]. |
|
1451 |
]. |
|
6329 | 1452 |
contents := super contents. |
1453 |
(self trimLastCR) ifTrue:[ |
|
1454 |
contents isString ifTrue:[ |
|
1455 |
(contents endsWith:Character cr) ifTrue:[ |
|
1456 |
^ contents copyButLast |
|
1457 |
]. |
|
1458 |
]. |
|
1459 |
]. |
|
1460 |
^ contents |
|
3313 | 1461 |
|
1462 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
6330 | 1463 |
"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
|
1464 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1465 |
|
5413 | 1466 |
contents:aStringOrStringCollectionOrNil |
1467 |
"replace the whole contents by something new. |
|
5414 | 1468 |
this is not undoably, unless you care for yourself. |
1469 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1470 |
|
1471 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1472 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1473 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1474 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1475 |
"set the contents and optionally clear the undo history. |
1476 |
The contents-change is not undoable." |
|
1477 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1478 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1479 |
keepUndoHistory ifFalse:[ |
6152 | 1480 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1481 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1482 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1483 |
|
2213 | 1484 |
contentsAsString |
6563 | 1485 |
"return the contents as a String (i.e. without emphasis). |
1486 |
Trims always (i.e. ignores trimBlankLines and trimLastCR options)" |
|
2213 | 1487 |
|
1488 |
list isNil ifTrue:[^ '']. |
|
1489 |
self removeTrailingBlankLines. |
|
6412 | 1490 |
^ (list collect:[:each | |
1491 |
each isNil |
|
1492 |
ifTrue:[''] |
|
1493 |
ifFalse:[each string] |
|
1494 |
]) asStringWithCRs |
|
1495 |
||
6563 | 1496 |
"Modified (comment): / 21-03-2019 / 13:09:54 / Claus Gittinger" |
2213 | 1497 |
! |
1498 |
||
5067 | 1499 |
contentsAsStringWithTabs |
1500 |
"return the contents as a String (i.e. without emphasis) |
|
1501 |
and with leading spaces replaced by tab characters |
|
6563 | 1502 |
(i.e. as would be written to a file). |
1503 |
Trims always (i.e. ignores trimBlankLines and trimLastCR options)" |
|
5067 | 1504 |
|
1505 |
list isNil ifTrue:[^ '']. |
|
1506 |
self removeTrailingBlankLines. |
|
5787 | 1507 |
^ (list collect:[:each | |
6152 | 1508 |
each isNil |
1509 |
ifTrue:[''] |
|
1510 |
ifFalse:[each string withTabs] |
|
5067 | 1511 |
]) asStringWithCRs |
6563 | 1512 |
|
1513 |
"Modified (format): / 21-03-2019 / 13:10:33 / Claus Gittinger" |
|
5067 | 1514 |
! |
1515 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1516 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1517 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1518 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1519 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1520 |
^ cursorCol |
125 | 1521 |
! |
1522 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1523 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1524 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1525 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1526 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1527 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1528 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1529 |
cursorLine |
3160 | 1530 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1531 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1532 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1533 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1534 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1535 |
|
6295 | 1536 |
cursorLineAndColumnHolder |
1537 |
"return a valueHolder for the cursors line and column as an |
|
1538 |
array of the form { lineNr . col } |
|
1539 |
This can be used directly as a model to react on cursor movement" |
|
1540 |
||
1541 |
^ BlockValue |
|
1542 |
with:[:l :c | (Array with:l with:c) ] |
|
1543 |
argument:self cursorLineHolder |
|
1544 |
argument:self cursorColHolder |
|
1545 |
! |
|
1546 |
||
5400 | 1547 |
cursorLineAndColumnLabelHolder |
5399 | 1548 |
"return a valueHolder for the cursors line and column as an info string |
5787 | 1549 |
of the form 'line : col'. |
5399 | 1550 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
1551 |
||
1552 |
^ BlockValue |
|
6152 | 1553 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
1554 |
argument:self cursorLineHolder |
|
1555 |
argument:self cursorColHolder |
|
5399 | 1556 |
! |
1557 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1558 |
cursorLineHolder |
3160 | 1559 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1560 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1561 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1562 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1563 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1564 |
|
4713 | 1565 |
lineStringBeforeCursor |
1566 |
"return the line's string before the cursor. |
|
1567 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1568 |
||
6563 | 1569 |
|line prevCol| |
1570 |
||
1571 |
prevCol := cursorCol-1. |
|
1572 |
line := ((self at:cursorLine) ? '') string. |
|
1573 |
line size < prevCol ifTrue:[ |
|
1574 |
^ line paddedTo:prevCol |
|
1575 |
]. |
|
1576 |
^ line copyTo:prevCol |
|
1577 |
||
1578 |
" |
|
1579 |
EditTextView new |
|
1580 |
contents:c'line1\nline2\nline3'; |
|
1581 |
lineStringBeforeCursor |
|
1582 |
||
1583 |
EditTextView new |
|
1584 |
contents:c'line1\nline2\nline3'; |
|
1585 |
cursorLine:2 col:1; |
|
1586 |
lineStringBeforeCursor |
|
1587 |
||
1588 |
EditTextView new |
|
1589 |
contents:c'line1\nline2\nline3'; |
|
1590 |
cursorLine:2 col:3; |
|
1591 |
lineStringBeforeCursor |
|
1592 |
||
1593 |
EditTextView new |
|
1594 |
contents:c'line1\nline2\nline3'; |
|
1595 |
cursorLine:2 col:20; |
|
1596 |
lineStringBeforeCursor |
|
1597 |
" |
|
1598 |
||
1599 |
"Modified: / 21-03-2019 / 12:55:56 / Claus Gittinger" |
|
1600 |
! |
|
1601 |
||
1602 |
lineStringFromCursor |
|
1603 |
"return the line's string beginning at the cursor position to the line's end." |
|
1604 |
||
4713 | 1605 |
|line| |
1606 |
||
1607 |
line := ((self at:cursorLine) ? '') string. |
|
6563 | 1608 |
line size < cursorCol ifTrue:[ |
1609 |
^ '' |
|
1610 |
]. |
|
1611 |
^ line copyFrom:cursorCol |
|
1612 |
||
1613 |
" |
|
1614 |
EditTextView new |
|
1615 |
contents:c'line1\nline2\nline3'; |
|
1616 |
lineStringFromCursor |
|
1617 |
||
1618 |
EditTextView new |
|
1619 |
contents:c'line1\nline2\nline3'; |
|
1620 |
cursorLine:2 col:1; |
|
1621 |
lineStringFromCursor |
|
1622 |
||
1623 |
EditTextView new |
|
1624 |
contents:c'line1\nline2\nline3'; |
|
1625 |
cursorLine:2 col:3; |
|
1626 |
lineStringFromCursor |
|
1627 |
" |
|
1628 |
||
1629 |
"Created: / 21-03-2019 / 12:51:08 / Claus Gittinger" |
|
4713 | 1630 |
! |
1631 |
||
6289 | 1632 |
list:newCollectionOfLinesOrNil |
5413 | 1633 |
"replace the whole contents by something new. |
1634 |
this is not undoably, unless you care for yourself. |
|
6289 | 1635 |
Positions the cursor as defined in cursorMovementWhenUpdating |
1636 |
(which defaults to: home)" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1637 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1638 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1639 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1640 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1641 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1642 |
|
6289 | 1643 |
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
|
1644 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1645 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1646 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
6152 | 1647 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1648 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1649 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1650 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
6152 | 1651 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1652 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1653 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1654 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1655 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
6152 | 1656 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1657 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1658 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
6152 | 1659 |
^ 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
|
1660 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1661 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1662 |
"/ 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
|
1663 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1664 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1665 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1666 |
setContents:something |
5787 | 1667 |
"replace the whole contents by something new |
5413 | 1668 |
AND clear the remembered undo actions" |
1669 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1670 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1671 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1672 |
undoSupport resetHistories. |
2955 | 1673 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1674 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1675 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1676 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1677 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1678 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
6667 | 1679 |
! |
1680 |
||
1681 |
wordBeforeCursor |
|
1682 |
"return the word to the left of cursor - empty string if there is none" |
|
1683 |
||
1684 |
^ self wordBeforeCursorConsisitingOfCharactersMatching:#isAlphaNumeric |
|
1685 |
! |
|
1686 |
||
1687 |
wordBeforeCursorConsisitingOfCharactersMatching:characterMatchBlock |
|
1688 |
"return the word to the left of cursor, where characters match the given condition; |
|
1689 |
empty string if there is none" |
|
1690 |
||
1691 |
| currentLine wordStart wordEnd | |
|
1692 |
||
1693 |
currentLine := self list at: self cursorLine ifAbsent:[ ^ '' ]. |
|
1694 |
currentLine isNil ifTrue:[ ^ '' ]. |
|
1695 |
wordEnd := self cursorCol - 1. |
|
1696 |
wordEnd > currentLine size ifTrue:[ ^ '' ]. |
|
1697 |
wordEnd ~~ 0 ifTrue:[ |
|
1698 |
wordStart := wordEnd. |
|
1699 |
[ wordStart > 0 and:[characterMatchBlock value:(currentLine at: wordStart) ] ] whileTrue:[ |
|
1700 |
wordStart := wordStart - 1. |
|
1701 |
]. |
|
1702 |
wordStart := wordStart + 1. |
|
1703 |
wordStart <= wordEnd ifTrue:[ |
|
1704 |
^ currentLine copyFrom: wordStart to: wordEnd. |
|
1705 |
]. |
|
1706 |
]. |
|
1707 |
^ '' |
|
1708 |
||
1709 |
"Created: / 31-03-2014 / 23:02:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1710 |
"Modified: / 17-06-2014 / 07:27:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1711 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1712 |
|
4609 | 1713 |
!EditTextView methodsFor:'accessing-dimensions'! |
1714 |
||
1715 |
xOfCursor |
|
4728 | 1716 |
|point| |
1717 |
||
1718 |
cursorVisibleLine isNil ifTrue:[ |
|
6152 | 1719 |
"/ take the end of the selection, if any |
1720 |
(selectionStartLine notNil |
|
1721 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1722 |
ifTrue:[ |
|
1723 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1724 |
]. |
|
5787 | 1725 |
|
1726 |
"/ point := device |
|
4728 | 1727 |
"/ translatePoint:(device pointerPosition) |
1728 |
"/ fromView:nil |
|
1729 |
"/ toView:self. |
|
1730 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1731 |
"/ ^ point x |
|
1732 |
"/ ]. |
|
1733 |
"/ ^ 0 |
|
6152 | 1734 |
^ nil |
4728 | 1735 |
]. |
4609 | 1736 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1737 |
||
1738 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1739 |
! ! |
|
4590 | 1740 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1741 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1742 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1743 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1744 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1745 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1746 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1747 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1748 |
wasOn := self hideCursor. |
5643 | 1749 |
cursorFgColor := color1 onDevice:device. |
1750 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1751 |
wasOn ifTrue:[self showCursor] |
1333 | 1752 |
! |
1753 |
||
1899 | 1754 |
cursorType |
1755 |
"return the style of the text cursor. |
|
4721 | 1756 |
Currently, supported are: #none |
6152 | 1757 |
#block, #frame, #ibeam, #caret, #solidCaret |
1758 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1759 |
|
1760 |
^ cursorType |
|
1761 |
||
1762 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1763 |
! |
|
1764 |
||
1333 | 1765 |
cursorType:aCursorTypeSymbol |
1766 |
"set the style of the text cursor. |
|
4721 | 1767 |
Currently, supported are: #none |
6152 | 1768 |
#block, #frame, #ibeam, #caret, #solidCaret |
1769 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1770 |
|
1334 | 1771 |
cursorType := aCursorTypeSymbol. |
1333 | 1772 |
|
1773 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1774 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1775 |
! |
1776 |
||
1899 | 1777 |
cursorTypeNoFocus |
1778 |
"return the style of the text cursor when the view has no focus. |
|
1779 |
If left unspecified, this is the same as the regular cursorType." |
|
1780 |
||
1781 |
^ cursorTypeNoFocus |
|
1782 |
||
1783 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1784 |
! |
|
1785 |
||
1334 | 1786 |
cursorTypeNoFocus:aCursorTypeSymbol |
1787 |
"set the style of the text cursor when the view has no focus. |
|
1788 |
If left unspecified, this is the same as the regular cursorType." |
|
1789 |
||
1790 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1791 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1792 |
|
4048 | 1793 |
!EditTextView methodsFor:'accessing-replace'! |
1794 |
||
4746 | 1795 |
lastReplacementInfo |
1796 |
^ lastReplacementInfo |
|
1797 |
! |
|
1798 |
||
4048 | 1799 |
lastStringToReplace: aString |
4818 | 1800 |
! |
1801 |
||
1802 |
previousReplacements |
|
1803 |
"accessor for the code completion" |
|
1804 |
||
1805 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1806 |
! ! |
1807 |
||
2119 | 1808 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1809 |
|
125 | 1810 |
accept |
1811 |
"accept the current contents by executing the accept-action and/or |
|
5937 | 1812 |
changeMessage. |
1813 |
Historically, ST/X used a callBack (acceptAction); |
|
1814 |
and ST80/VW used the model, into which the text is stored. |
|
1815 |
We support both; if there is a mode, it gets a value: message, |
|
1816 |
If there is an acceptAction, it is called." |
|
125 | 1817 |
|
1108 | 1818 |
acceptEnabled == false ifTrue:[ |
6262 | 1819 |
self beepInEditor. |
5937 | 1820 |
^ self |
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1821 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1822 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
5937 | 1823 |
^ self |
1108 | 1824 |
]. |
1825 |
||
125 | 1826 |
lockUpdates := true. |
1013 | 1827 |
|
1828 |
"/ |
|
1829 |
"/ ST-80 way of doing it |
|
1830 |
"/ |
|
1831 |
model notNil ifTrue:[ |
|
5937 | 1832 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
1833 |
acceptChannel notNil ifTrue:[ |
|
1834 |
acceptChannel value:true withoutNotifying:self. |
|
1835 |
]. |
|
2999 | 1836 |
]. |
1837 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1838 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1839 |
"/ ST/X way of doing things |
5937 | 1840 |
"/ as a historic leftover, |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1841 |
"/ 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
|
1842 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1843 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1844 |
acceptAction notNil ifTrue:[ |
5937 | 1845 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1846 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1847 |
|
125 | 1848 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1849 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1850 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1851 |
! |
1852 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1853 |
argForChangeMessage |
597 | 1854 |
"return the argument to be passed with the change notification. |
1855 |
Defined as separate method for easier subclassability." |
|
1856 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1857 |
^ self contents |
597 | 1858 |
|
1859 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1860 |
! |
1861 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1862 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1863 |
"get my contents from the model. |
597 | 1864 |
Redefined to ignore updates resulting from my own changes |
1865 |
(i.e. if lockUpdates is true)." |
|
121 | 1866 |
|
1867 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1868 |
ignore updates from my own change |
121 | 1869 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1870 |
lockUpdates ifTrue:[ |
6152 | 1871 |
lockUpdates := false. |
1872 |
^ self |
|
121 | 1873 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1874 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1875 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1876 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1877 |
"/ validate the cursorLine |
3160 | 1878 |
(cursorLine notNil |
2310 | 1879 |
and:[ cursorLine > list size ]) ifTrue:[ |
6152 | 1880 |
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
|
1881 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1882 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1883 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1884 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1885 |
changedObject == acceptChannel ifTrue:[ |
6152 | 1886 |
acceptChannel value == true ifTrue:[ |
1887 |
self accept. |
|
1888 |
]. |
|
1889 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1890 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1891 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1892 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1893 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1894 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1895 |
! ! |
1896 |
||
6015 | 1897 |
!EditTextView methodsFor:'commenting'! |
1898 |
||
1899 |
commentFrom:line1 to:line2 commentStrings:commentStrings |
|
1900 |
"helper function to comment out a block. |
|
1901 |
All lines from line1 to line2 get an end-of-line comment |
|
1902 |
in the first col |
|
1903 |
(if no eol comment is available, a bracketing comment is used)." |
|
1904 |
||
1905 |
|eolComment opening closing| |
|
1906 |
||
1907 |
eolComment := commentStrings at:1. |
|
1908 |
eolComment isNil ifTrue:[ |
|
1909 |
opening := (commentStrings at:2) at:1. |
|
1910 |
closing := (commentStrings at:2) at:2. |
|
1911 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1912 |
]. |
|
1913 |
||
1914 |
line1 to:line2 do:[:lineNr | |
|
1915 |
|l| |
|
1916 |
||
1917 |
l := self listAt:lineNr. |
|
1918 |
l isNil ifTrue:[l := '']. |
|
1919 |
eolComment notNil ifTrue:[ |
|
1920 |
l := eolComment , l |
|
1921 |
] ifFalse:[ |
|
1922 |
l := opening , l , closing |
|
1923 |
]. |
|
1924 |
self replaceLine:lineNr with:l. |
|
1925 |
widthOfWidestLine notNil ifTrue:[ |
|
1926 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1927 |
]. |
|
1928 |
]. |
|
1929 |
self textChanged. |
|
1930 |
||
1931 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
|
1932 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1933 |
! |
|
1934 |
||
1935 |
commentSelection:commentStrings |
|
1936 |
"convenient function to comment out a block. |
|
1937 |
All lines from line1 to line2 get an end-of-line comment |
|
1938 |
in the first col." |
|
1939 |
||
1940 |
|e commentPair opening closing| |
|
1941 |
||
1942 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
6301 | 1943 |
commentStrings isEmptyOrNil ifTrue:[ self beepInEditor. ^ self]. |
6015 | 1944 |
|
1945 |
self |
|
1946 |
undoableDo:[ |
|
1947 |
selectionStartLine isNil ifTrue:[ |
|
1948 |
self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1949 |
] ifFalse:[ |
|
1950 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1951 |
self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1952 |
] ifFalse:[ |
|
1953 |
commentPair := commentStrings at:2 ifAbsent:nil. |
|
1954 |
commentPair isNil ifTrue:[ |
|
1955 |
self beep. |
|
1956 |
] ifFalse:[ |
|
1957 |
opening := commentPair at:1. |
|
1958 |
closing := commentPair at:2. |
|
1959 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1960 |
||
1961 |
e := selectionEndCol. |
|
1962 |
||
1963 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1964 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
1965 |
||
1966 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
|
1967 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1968 |
toLine:selectionEndLine col:e+closing size. |
|
1969 |
] |
|
1970 |
] |
|
1971 |
]. |
|
1972 |
] |
|
1973 |
info:'Comment'. |
|
1974 |
||
1975 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
|
1976 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
|
1977 |
! |
|
1978 |
||
1979 |
uncommentFrom:line1 to:line2 commentStrings:commentStrings |
|
1980 |
"helper function to comment out a block. |
|
1981 |
All lines from line1 to line2 get an end-of-line comment |
|
1982 |
in the first col. |
|
1983 |
(if no eol comment is available, a bracketing comment is removed)." |
|
1984 |
||
1985 |
|eolComment opening closing rest| |
|
1986 |
||
1987 |
eolComment := commentStrings at:1. |
|
1988 |
eolComment isNil ifTrue:[ |
|
1989 |
opening := (commentStrings at:2) at:1. |
|
1990 |
closing := (commentStrings at:2) at:2. |
|
1991 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1992 |
] ifFalse:[ |
|
1993 |
rest := eolComment size + 1. |
|
1994 |
]. |
|
1995 |
||
1996 |
line1 to:line2 do:[:lineNr | |
|
1997 |
|l| |
|
1998 |
||
1999 |
l := self listAt:lineNr. |
|
2000 |
l notNil ifTrue:[ |
|
2001 |
eolComment notNil ifTrue:[ |
|
2002 |
(l startsWith:eolComment) ifTrue:[ |
|
2003 |
l := l copyFrom:rest |
|
2004 |
] ifFalse:[ |
|
2005 |
(l withoutLeadingSeparators startsWith:eolComment) ifTrue:[ |
|
2006 |
"/ only for single lines? |
|
2007 |
true "line1 = line2" ifTrue:[ |
|
2008 |
|numSpaces| |
|
2009 |
||
2010 |
numSpaces := l indexOfNonSeparator - 1. |
|
2011 |
l := l copyFrom:numSpaces+1+rest. |
|
2012 |
l := (String new:numSpaces),l |
|
2013 |
]. |
|
2014 |
]. |
|
2015 |
] |
|
2016 |
] ifFalse:[ |
|
2017 |
((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[ |
|
2018 |
l := l copyFrom:opening size + 1. |
|
2019 |
l := l copyButLast:closing size. |
|
2020 |
]. |
|
2021 |
]. |
|
2022 |
self replaceLine:lineNr with:l. |
|
2023 |
] |
|
2024 |
]. |
|
2025 |
||
2026 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
2027 |
self textChanged. |
|
2028 |
! |
|
2029 |
||
2030 |
uncommentSelection:commentStrings |
|
2031 |
"convenient function to comment out a block. |
|
2032 |
All lines from line1 to line2 get an end-of-line comment |
|
2033 |
in the first col." |
|
2034 |
||
2035 |
|e commentPair opening closing sz1 sz2 l1 l2 c1 c2| |
|
2036 |
||
2037 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
6262 | 2038 |
commentStrings isNil ifTrue:[ self beepInEditor. ^ self]. |
6015 | 2039 |
|
2040 |
self |
|
2041 |
undoableDo:[ |
|
2042 |
selectionStartLine isNil ifTrue:[ |
|
2043 |
self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
2044 |
] ifFalse:[ |
|
2045 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
2046 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
2047 |
] ifFalse:[ |
|
2048 |
commentPair := commentStrings at:2. |
|
2049 |
opening := commentPair at:1. |
|
2050 |
closing := commentPair at:2. |
|
2051 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
2052 |
||
2053 |
sz1 := opening size. |
|
2054 |
sz2 := closing size. |
|
2055 |
||
2056 |
((self |
|
2057 |
stringAtLine:selectionStartLine |
|
2058 |
from:selectionStartCol |
|
2059 |
to:selectionStartCol+sz1 - 1) = opening |
|
2060 |
and:[(self |
|
2061 |
stringAtLine:selectionEndLine |
|
2062 |
from:selectionEndCol - sz2 + 1 |
|
2063 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
2064 |
||
2065 |
l2 := selectionEndLine. c2 := selectionEndCol. |
|
2066 |
l1 := selectionStartLine. c1 := selectionStartCol. |
|
2067 |
self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2. |
|
2068 |
self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1. |
|
2069 |
||
2070 |
e := c2 - sz2. |
|
2071 |
l1 == l2 ifTrue:[e := e - sz1]. |
|
2072 |
self selectFromLine:l1 col:c1 toLine:l2 col:e. |
|
2073 |
] |
|
2074 |
] |
|
2075 |
]. |
|
2076 |
] |
|
2077 |
info:'Uncomment'. |
|
2078 |
||
2079 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
|
2080 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
|
2081 |
! ! |
|
2082 |
||
121 | 2083 |
!EditTextView methodsFor:'cursor handling'! |
2084 |
||
4820 | 2085 |
basicCursorReturn |
2086 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2087 |
||
2088 |
|wasOn| |
|
2089 |
||
2090 |
self checkForExistingLine:(cursorLine + 1). |
|
2091 |
cursorVisibleLine notNil ifTrue:[ |
|
6152 | 2092 |
nFullLinesShown notNil ifTrue:[ |
6339 | 2093 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDownLines:1] |
6152 | 2094 |
] |
4820 | 2095 |
]. |
2096 |
||
2097 |
wasOn := self hideCursor. |
|
2098 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
2099 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2100 |
||
6339 | 2101 |
"Modified: / 22-05-1996 / 18:27:34 / cg" |
2102 |
"Modified: / 13-06-2018 / 22:14:31 / Claus Gittinger" |
|
4820 | 2103 |
! |
2104 |
||
2406 | 2105 |
characterPositionOfCursor |
2106 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
2107 |
! |
|
2108 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2109 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2110 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2111 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2112 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2113 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2114 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2115 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2116 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2117 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2118 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2119 |
|
2822 | 2120 |
(cursorCol == newCol) 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 setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2124 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2125 |
|
2126 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2127 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2128 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2129 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2130 |
"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
|
2131 |
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
|
2132 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2133 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2134 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2135 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2136 |
|
2707 | 2137 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2138 |
cursorLine > list size ifTrue:[ |
6152 | 2139 |
wasOn := self hideCursor. |
2140 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
2141 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6262 | 2142 |
self beepInEditor. |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2143 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2144 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2145 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2146 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2147 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2148 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2149 |
"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
|
2150 |
|
5857 | 2151 |
|inLastLine wasOn nv nL cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2152 |
|
4595 | 2153 |
(nL := cursorLine) isNil ifTrue:[ |
5857 | 2154 |
nL := firstLineShown |
2155 |
]. |
|
2156 |
||
2157 |
inLastLine := (nL == list size). |
|
5890 | 2158 |
|
5857 | 2159 |
inLastLine ifTrue:[ |
5858 | 2160 |
|generateTextAfterEndHook| |
5857 | 2161 |
|
2162 |
cursorColBefore := cursorCol. |
|
5858 | 2163 |
(generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[ |
5860 | 2164 |
wasOn := self hideCursor. |
2165 |
nL := generateTextAfterEndHook value:(nL + n). |
|
2166 |
self setValidatedCursorLine:nL col:cursorColBefore. |
|
2167 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2168 |
^ self. |
|
5890 | 2169 |
]. |
4595 | 2170 |
]. |
2171 |
||
2172 |
self st80EditMode ifTrue:[ |
|
5857 | 2173 |
nL == list size ifTrue:[ |
2174 |
wasOn := self hideCursor. |
|
2175 |
self setValidatedCursorLine:nL col:(self listAt:nL) size + 1. |
|
2176 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6262 | 2177 |
self beepInEditor. |
5857 | 2178 |
^ self. |
2179 |
] |
|
4595 | 2180 |
]. |
2181 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2182 |
cursorVisibleLine notNil ifTrue:[ |
5857 | 2183 |
wasOn := self hideCursor. |
2184 |
nv := cursorVisibleLine + n - 1. |
|
2185 |
(nv >= nFullLinesShown) ifTrue:[ |
|
6339 | 2186 |
self scrollDownLines:(nv - nFullLinesShown + 1) |
5857 | 2187 |
]. |
2188 |
self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol). |
|
2189 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2190 |
] ifFalse:[ |
5857 | 2191 |
self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol). |
2192 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2193 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2194 |
|
6339 | 2195 |
"Modified: / 10-06-1998 / 16:59:17 / cg" |
2196 |
"Modified: / 13-06-2018 / 22:08:21 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2197 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2198 |
|
121 | 2199 |
cursorHome |
597 | 2200 |
"scroll to top AND move cursor to first line of text." |
121 | 2201 |
|
674 | 2202 |
self cursorLine:1 col:1 |
2203 |
||
2204 |
"/ |wasOn| |
|
2205 |
"/ |
|
2206 |
"/ wasOn := self hideCursor. |
|
2207 |
"/ self scrollToTop. |
|
2208 |
"/ cursorLine := cursorVisibleLine := 1. |
|
2209 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
2210 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
2211 |
||
2212 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 2213 |
! |
2214 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2215 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2216 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2217 |
|
6207 | 2218 |
|wasOn| |
2219 |
||
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2220 |
(cursorCol ~~ 1) ifTrue:[ |
6207 | 2221 |
wasOn := self hideCursor. |
2222 |
self setValidatedCursorCol:(cursorCol - 1). |
|
2223 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2224 |
"/ self cursorCol:(cursorCol - 1) |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2225 |
] ifFalse:[ |
6152 | 2226 |
cursorLine ~~ 1 ifTrue:[ |
2227 |
self st80EditMode ifTrue:[ |
|
2228 |
self cursorUp. |
|
2229 |
self cursorToEndOfLine. |
|
2230 |
] |
|
2231 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2232 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2233 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
2234 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2235 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2236 |
|
4126 | 2237 |
cursorLeft:n |
2238 |
"move cursor to left" |
|
2239 |
||
2240 |
n timesRepeat:[ |
|
6152 | 2241 |
self cursorLeft |
4126 | 2242 |
]. |
2243 |
! |
|
2244 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2245 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2246 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2247 |
|
5056 | 2248 |
self cursorLine:line col:col makeVisible:true |
2249 |
! |
|
2250 |
||
2251 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
2252 |
"this positions onto physical - not visible - line" |
|
2253 |
||
676 | 2254 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2255 |
|
2822 | 2256 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
2257 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2258 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2259 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2260 |
|
6563 | 2261 |
newCol := (col max:1). |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2262 |
self st80EditMode ifTrue:[ |
6152 | 2263 |
(cursorLine == list size |
2264 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
2265 |
newCol := (self listAt:(list size)) size + 1. |
|
2266 |
] |
|
1419 | 2267 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2268 |
self setValidatedCursorCol:newCol. |
5056 | 2269 |
makeVisibleBoolean ifTrue:[ |
6152 | 2270 |
self makeCursorVisibleAndShowCursor:wasOn. |
5056 | 2271 |
] ifFalse:[ |
6152 | 2272 |
wasOn ifTrue:[self showCursor] |
5056 | 2273 |
]. |
672 | 2274 |
|
6563 | 2275 |
"Modified: / 20-06-1998 / 18:19:06 / cg" |
2276 |
"Modified: / 21-03-2019 / 12:53:27 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2277 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2278 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2279 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2280 |
"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
|
2281 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2282 |
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
|
2283 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2284 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2285 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2286 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2287 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2288 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2289 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2290 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2291 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2292 |
"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
|
2293 |
|
4820 | 2294 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2295 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2296 |
|
5529 | 2297 |
cursorReturn:withPossibleAutoIndent |
2298 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2299 |
||
2300 |
self basicCursorReturn |
|
2301 |
! |
|
2302 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2303 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2304 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2305 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2306 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2307 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2308 |
self st80EditMode ifTrue:[ |
6210 | 2309 |
self isInputField ifFalse:[ |
2310 |
l := (self listAt:cursorLine). |
|
2311 |
cursorCol >= (l size + 1) ifTrue:[ |
|
2312 |
cursorLine <= list size ifTrue:[ |
|
2313 |
self cursorReturn:false. "/ no autoindent |
|
2314 |
]. |
|
2315 |
^ self |
|
2316 |
] |
|
2317 |
]. |
|
3160 | 2318 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2319 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2320 |
|
6210 | 2321 |
"Modified: / 27-09-2017 / 15:38:26 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2322 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2323 |
|
4126 | 2324 |
cursorRight:n |
2325 |
"move cursor to right" |
|
2326 |
||
2327 |
n timesRepeat:[ |
|
6152 | 2328 |
self cursorRight |
4126 | 2329 |
]. |
2330 |
! |
|
2331 |
||
1833 | 2332 |
cursorShown:aBoolean |
2333 |
"change cursor visibility |
|
2334 |
return true if cursor was visible before." |
|
2335 |
||
2336 |
|oldState| |
|
2337 |
||
4494 | 2338 |
aBoolean == cursorShown ifTrue:[ |
6152 | 2339 |
^ cursorShown |
4494 | 2340 |
]. |
1833 | 2341 |
oldState := cursorShown. |
2342 |
||
2343 |
aBoolean ifTrue:[ |
|
6152 | 2344 |
self drawCursor. |
1833 | 2345 |
] ifFalse:[ |
6152 | 2346 |
(cursorShown and:[shown]) ifTrue: [ |
2347 |
self undrawCursor. |
|
2348 |
]. |
|
1833 | 2349 |
]. |
2350 |
cursorShown := aBoolean. |
|
2351 |
||
2352 |
^ oldState |
|
2353 |
||
2354 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
2355 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
2356 |
! |
|
2357 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2358 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2359 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2360 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2361 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2362 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2363 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2364 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2365 |
"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
|
2366 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2367 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2368 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2369 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2370 |
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
|
2371 |
cursorCol > textStart ifTrue:[ |
6152 | 2372 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2373 |
] ifFalse:[ |
6152 | 2374 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2375 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2376 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2377 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2378 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2379 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2380 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2381 |
"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
|
2382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2383 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2384 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2385 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2386 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2387 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2388 |
(newTop < 1) ifTrue:[ |
6152 | 2389 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2390 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2391 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2392 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2393 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2394 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2395 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2396 |
|
674 | 2397 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2398 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2399 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2400 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2401 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2402 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2403 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2404 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2405 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2406 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2407 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2408 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2409 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2410 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2411 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2412 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2413 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2414 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2415 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2416 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2417 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2418 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2419 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2420 |
cursorLine >= lineNr ifTrue:[ |
6152 | 2421 |
line := self listAt:cursorLine. |
2422 |
(line isEmptyOrNil) ifTrue:[ |
|
2423 |
^ self |
|
2424 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2425 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2426 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2427 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2428 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2429 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2430 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2431 |
(newTop < 1) ifTrue:[ |
6152 | 2432 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2433 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2434 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2435 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2436 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2437 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2438 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2439 |
|
674 | 2440 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2441 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2442 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2443 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2444 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2445 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2446 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2447 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2448 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2449 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2450 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2451 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2452 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2453 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2454 |
cursorToEndOfText |
4288 | 2455 |
"move cursor to the end of the text (behind the last character in last line)" |
2456 |
||
2457 |
|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
|
2458 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2459 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2460 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2461 |
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
|
2462 |
(newTop < 1) ifTrue:[ |
6152 | 2463 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2464 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2465 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2466 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2467 |
self setValidatedCursorLine:list size. |
4288 | 2468 |
lastLineLength := (self listAt:cursorLine) size. |
2469 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2470 |
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
|
2471 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2472 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2473 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2474 |
"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
|
2475 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2476 |
|
3310 | 2477 |
cursorToEndOfWord |
2478 |
"move the cursor to the end of the word" |
|
2479 |
||
2480 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2481 |
||
2482 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2483 |
:beginLine :beginCol :endLine :endCol :style | |
2484 |
||
2485 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2486 |
] |
2487 |
||
2488 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2489 |
! |
|
2490 |
||
131 | 2491 |
cursorToFirstVisibleLine |
2492 |
"place cursor into the first visible line; do not scroll." |
|
2493 |
||
2494 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2495 |
! |
|
2496 |
||
2497 |
cursorToLastVisibleLine |
|
2498 |
"place cursor into the first visible line; do not scroll." |
|
2499 |
||
2500 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2501 |
! |
|
2502 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2503 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2504 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2505 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2506 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2507 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2508 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2509 |
|
5787 | 2510 |
self |
6152 | 2511 |
wordAtLine:cursorLine col:cursorCol |
2512 |
do:[ |
|
2513 |
:beginLine :beginCol :endLine :endCol :style | |
|
6154 | 2514 |
|lineSize| |
6152 | 2515 |
|
2516 |
line := endLine. |
|
2517 |
col := endCol + 1. |
|
6154 | 2518 |
lineSize := (self listAt:line) size. |
2519 |
(endCol ~= lineSize or:[lineSize == 0]) ifTrue:[ |
|
2520 |
searching := true. |
|
2521 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
2522 |
self wordAtLine:line col:col do:[ |
|
2523 |
:beginLine :beginCol :endLine :endCol :style | |
|
2524 |
||
2525 |
(line > list size) ifTrue:[ |
|
2526 |
"break out" |
|
2527 |
searching := false |
|
2528 |
] ifFalse:[ |
|
2529 |
line := endLine. |
|
2530 |
col := endCol + 1. |
|
2531 |
] |
|
6152 | 2532 |
] |
6154 | 2533 |
]. |
6152 | 2534 |
]. |
2535 |
self cursorLine:line col:col |
|
4707 | 2536 |
] |
6154 | 2537 |
|
2538 |
"Modified: / 11-05-2017 / 17:50:47 / stefan" |
|
121 | 2539 |
! |
2540 |
||
499 | 2541 |
cursorToPreviousWord |
2542 |
"move the cursor to the beginning of this or the previous word" |
|
2543 |
||
6154 | 2544 |
|col line searching| |
499 | 2545 |
|
2546 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2547 |
:beginLine :beginCol :endLine :endCol :style | |
2548 |
||
2549 |
line := beginLine. |
|
2550 |
col := beginCol. |
|
2551 |
style == #wordLeft ifTrue:[ |
|
2552 |
col := col + 1 |
|
2553 |
]. |
|
2554 |
||
2555 |
(cursorLine == line |
|
2556 |
and:[cursorCol == col]) ifTrue:[ |
|
2557 |
searching := true. |
|
2558 |
||
2559 |
col > 1 ifTrue:[ |
|
2560 |
col := col - 1. |
|
2561 |
]. |
|
2562 |
||
2563 |
[searching] whileTrue:[ |
|
2564 |
(col == 1) ifTrue:[ |
|
2565 |
line == 1 ifTrue:[ |
|
2566 |
searching := false |
|
2567 |
] ifFalse:[ |
|
2568 |
line := line - 1. |
|
6154 | 2569 |
col := (list at:line) size + 1. |
2570 |
col ~~ 1 ifTrue:[ |
|
2571 |
"at end of word in previous line" |
|
2572 |
searching := false. |
|
2573 |
]. |
|
6152 | 2574 |
] |
2575 |
] ifFalse:[ |
|
2576 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2577 |
self wordAtLine:line col:col do:[ |
|
2578 |
:beginLine :beginCol :endLine :endCol :style | |
|
2579 |
||
2580 |
line := beginLine. |
|
2581 |
col := beginCol. |
|
2582 |
style == #wordLeft ifTrue:[ |
|
2583 |
col := col + 1 |
|
2584 |
]. |
|
2585 |
searching := false. |
|
2586 |
] |
|
2587 |
] ifTrue:[ |
|
2588 |
col := col - 1 |
|
2589 |
] |
|
2590 |
] |
|
2591 |
] |
|
2592 |
]. |
|
2593 |
self cursorLine:line col:col |
|
499 | 2594 |
] |
2595 |
||
6154 | 2596 |
"Created: / 08-03-1996 / 21:52:48 / cg" |
2597 |
"Modified (format): / 11-05-2017 / 17:45:11 / stefan" |
|
499 | 2598 |
! |
2599 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2600 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2601 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2602 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2603 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2604 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2605 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2606 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2607 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2608 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2609 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2610 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2611 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2612 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2613 |
"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
|
2614 |
|
5856 | 2615 |
|wasOn nv nl cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2616 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2617 |
cursorLine isNil ifTrue:[ |
5850 | 2618 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2619 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2620 |
nl := cursorLine - n. |
5850 | 2621 |
nl < 1 ifTrue:[ |
5858 | 2622 |
|generateTextBeforeStartHook| |
5890 | 2623 |
|
5856 | 2624 |
cursorColBefore := cursorCol. |
5858 | 2625 |
(generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[ |
2626 |
nl := generateTextBeforeStartHook value:nl |
|
5890 | 2627 |
]. |
5850 | 2628 |
nl := nl max:1 |
2629 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2630 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2631 |
(nl ~~ cursorLine) ifTrue: [ |
5850 | 2632 |
wasOn := self hideCursor. |
2633 |
cursorVisibleLine notNil ifTrue:[ |
|
2634 |
nv := cursorVisibleLine - n. |
|
2635 |
nv < 1 ifTrue:[ |
|
6339 | 2636 |
self scrollUpLines:(nv negated + 1) |
5850 | 2637 |
]. |
2638 |
]. |
|
5856 | 2639 |
self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol). |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2640 |
"/ wasOn ifTrue:[self showCursor]. |
5850 | 2641 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2642 |
] |
672 | 2643 |
|
6339 | 2644 |
"Modified: / 22-05-1996 / 18:28:11 / cg" |
2645 |
"Modified: / 13-06-2018 / 22:45:32 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2646 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2647 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2648 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2649 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2650 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2651 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2652 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2653 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2654 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2655 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2656 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2657 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2658 |
|
676 | 2659 |
newCol := colNr. |
2660 |
(newCol < 1) ifTrue:[ |
|
6152 | 2661 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2662 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2663 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2664 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2665 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2666 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2667 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2668 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2669 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2670 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2671 |
"put cursor to position next to x/y coordinate in view" |
121 | 2672 |
|
2673 |
|line col| |
|
2674 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2675 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2676 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2677 |
self cursorVisibleLine:line col:col. |
121 | 2678 |
! |
2679 |
||
2680 |
drawCursor |
|
2681 |
"draw the cursor if shown and cursor is visible. |
|
2682 |
(but not, if there is a selection - to avoid confusion)" |
|
2683 |
||
2684 |
shown ifTrue:[ |
|
6152 | 2685 |
cursorVisibleLine notNil ifTrue:[ |
2686 |
self hasSelection ifFalse:[ |
|
2687 |
self drawCursorCharacter |
|
2688 |
] |
|
2689 |
] |
|
121 | 2690 |
] |
2691 |
! |
|
2692 |
||
2693 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2694 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2695 |
of cursor should be drawn. |
5787 | 2696 |
Currently, supported are: #none, |
6031 | 2697 |
#block, #frame, #ibeam, #caret, #solidCaret |
2698 |
#bigCaret and #bigSolidCaret" |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2699 |
|
2570 | 2700 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2701 |
|
2702 |
self hasSelection ifTrue:[ |
|
6031 | 2703 |
" |
2704 |
hide cursor, if there is a selection |
|
2705 |
" |
|
2706 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2707 |
]. |
2708 |
||
1334 | 2709 |
cursorType == #none ifTrue:[ |
6031 | 2710 |
^ self |
1334 | 2711 |
]. |
2712 |
||
121 | 2713 |
cursorType == #block ifTrue:[ |
6031 | 2714 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
2715 |
^ self |
|
121 | 2716 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2717 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2718 |
y := self yOfVisibleLine:cursorVisibleLine. |
2719 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2720 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2721 |
cursorType == #frame ifTrue:[ |
6031 | 2722 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2723 |
||
2724 |
char := self characterUnderCursor asString. |
|
6068 | 2725 |
gc paint:bgColor. |
2726 |
gc displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
|
133 | 2727 |
] ifFalse:[ |
6031 | 2728 |
self paint:bgColor. |
2729 |
cursorType == #ibeam ifTrue:[ |
|
2730 |
x1 := x - 1. |
|
2731 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2732 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2733 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
6031 | 2734 |
^ self |
2735 |
]. |
|
2736 |
||
2737 |
cursorType == #Ibeam ifTrue:[ |
|
2738 |
x1 := x - 1. |
|
2739 |
y := y + 1. |
|
2740 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2741 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2742 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
2743 |
gc displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2744 |
gc displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
6031 | 2745 |
^ self |
2746 |
]. |
|
2747 |
||
2748 |
y := y + fontHeight - 3. |
|
2749 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2750 |
w := (fontWidth * 2 // 3) max:4. |
|
2751 |
y2 := y + w + (w//2). |
|
2752 |
] ifFalse:[ |
|
2753 |
w := (fontWidth // 2) max:4. |
|
2754 |
y2 := y + w. |
|
2755 |
]. |
|
2756 |
x1 := x - w. |
|
2757 |
x2 := x + w. |
|
2758 |
||
2759 |
oldClip := self clippingBoundsOrNil. |
|
2760 |
self clippingBounds:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2761 |
||
2762 |
cursorType == #caret ifTrue:[ |
|
6068 | 2763 |
gc lineWidth:2. |
2764 |
gc displayLineFromX:x1 y:y2 toX:x y:y. |
|
2765 |
gc displayLineFromX:x y:y toX:x2 y:y2. |
|
6031 | 2766 |
] ifFalse:[ |
2767 |
"anything else: solidCaret" |
|
2768 |
||
6068 | 2769 |
gc fillPolygon:(Array with:(x1 @ y2) |
2770 |
with:(x @ y) |
|
2771 |
with:(x2 @ y2)) |
|
6031 | 2772 |
]. |
2773 |
||
2774 |
self clippingBounds:oldClip |
|
121 | 2775 |
]. |
6068 | 2776 |
gc paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2777 |
|
2088 | 2778 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2779 |
! |
2780 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2781 |
drawCursorCharacter |
3160 | 2782 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2783 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2784 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2785 |
|
3160 | 2786 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2787 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2788 |
and:[self isReadOnly not]]) ifTrue:[ |
6152 | 2789 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2790 |
] ifFalse:[ |
6152 | 2791 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2792 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2793 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2794 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2795 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2796 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2797 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2798 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2799 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2800 |
self hasSelection ifTrue:[ |
6152 | 2801 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2802 |
]. |
2803 |
cursorType == #none ifTrue:[ |
|
6152 | 2804 |
^ self undrawCursor |
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 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2807 |
|
2808 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2809 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2810 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2811 |
drawNoFocusCursor |
3160 | 2812 |
"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
|
2813 |
|
1334 | 2814 |
|cType| |
2815 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2816 |
self hasSelection ifTrue:[ |
6152 | 2817 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2818 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2819 |
|
1334 | 2820 |
cType := cursorTypeNoFocus ? cursorType. |
2821 |
cType == #none ifTrue:[ |
|
6152 | 2822 |
^ self undrawCursor |
1334 | 2823 |
]. |
2824 |
||
2825 |
cType == #block ifTrue:[ |
|
6152 | 2826 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2827 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2828 |
|
1334 | 2829 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2830 |
||
2831 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2832 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2833 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2834 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2835 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2836 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2837 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2838 |
self makeLineVisible:aLineNumber. |
2951 | 2839 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2840 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2841 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2842 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2843 |
hideCursor |
1833 | 2844 |
"make cursor invisible if currently invisible" |
2845 |
||
2846 |
^ self cursorShown:false |
|
2847 |
||
2848 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2849 |
! |
2850 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2851 |
makeCursorVisible |
3160 | 2852 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2853 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2854 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2855 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2856 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2857 |
cursorLine notNil ifTrue:[ |
6152 | 2858 |
line := cursorLine. |
2859 |
col := cursorCol. |
|
2860 |
" |
|
2861 |
if there is a selection, its better to |
|
2862 |
have its start being visible, instead of the end |
|
2863 |
" |
|
2864 |
(selectionStartLine notNil |
|
2865 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2866 |
expandingTop ~~ false ifTrue:[ |
|
2867 |
line := selectionStartLine. |
|
2868 |
col := selectionStartCol. |
|
2869 |
] ifFalse:[ |
|
2870 |
line := selectionEndLine. |
|
2871 |
col := selectionEndCol |
|
2872 |
] |
|
2873 |
]. |
|
2874 |
self makeLineVisible:line. |
|
2875 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2876 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2877 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2878 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2879 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2880 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2881 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2882 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2883 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2884 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2885 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2886 |
flag ifTrue:[self showCursor] |
121 | 2887 |
! |
2888 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2889 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2890 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2891 |
|
2815 | 2892 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2893 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2894 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2895 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2896 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2897 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2898 |
|
3303 | 2899 |
"/ self assert:(lineNr notNil). |
2900 |
||
2901 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2902 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2903 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2904 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2905 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2906 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2907 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2908 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2909 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2910 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2911 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2912 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2913 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2914 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2915 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2916 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
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 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2919 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2920 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2921 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2922 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2923 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2924 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2925 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2926 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2927 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2928 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2929 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2930 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2931 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2932 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2933 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2934 |
|
1833 | 2935 |
^ self cursorShown:true |
2936 |
||
2937 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2938 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2939 |
|
5761 | 2940 |
singleQuoteSelection |
2941 |
"place single quotes around the selected text" |
|
2942 |
||
2943 |
|line1 col1 line2 col2| |
|
2944 |
||
2945 |
line1 := self selectionStartLine. |
|
2946 |
col1 := self selectionStartCol. |
|
2947 |
line2 := self selectionEndLine. |
|
2948 |
col2 := self selectionEndCol. |
|
2949 |
(line1 notNil |
|
6152 | 2950 |
and:[ col1 notNil |
2951 |
and:[ line2 notNil |
|
2952 |
and:[ col2 notNil ]]]) |
|
5761 | 2953 |
ifTrue:[ |
6152 | 2954 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
2955 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2956 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
5761 | 2957 |
] ifFalse:[ |
6262 | 2958 |
self beepInEditor. |
5761 | 2959 |
] |
2960 |
||
2961 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2962 |
! |
|
2963 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2964 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2965 |
"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
|
2966 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2967 |
|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
|
2968 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2969 |
cursorVisibleLine notNil ifTrue:[ |
6031 | 2970 |
prevCol := cursorCol - 1. |
2971 |
||
2972 |
"/ if there is any italic stuff in the cursor line, |
|
2973 |
"/ redraw it completely (because characters overlap). |
|
2974 |
cursorCol > 1 ifTrue:[ |
|
2975 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2976 |
line hasChangeOfEmphasis ifTrue:[ |
|
2977 |
line size >= (cursorCol-1) ifTrue:[ |
|
2978 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2979 |
line size >= (cursorCol) ifTrue:[ |
|
2980 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2981 |
line size >= (cursorCol+1) ifTrue:[ |
|
2982 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2983 |
]. |
|
2984 |
]. |
|
2985 |
]. |
|
2986 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2987 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2988 |
] |
|
2989 |
] |
|
2990 |
] |
|
2991 |
]. |
|
2992 |
||
2993 |
((cursorType == #caret) |
|
2994 |
or:[cursorType == #solidCaret |
|
2995 |
or:[cursorType == #bigSolidCaret |
|
2996 |
or:[cursorType == #bigCaret |
|
2997 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2998 |
"caret-cursor touches 4 characters" |
|
2999 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
3000 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
3001 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
3002 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
3003 |
] ifFalse:[ |
|
3004 |
"care for left margin" |
|
3005 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
3006 |
]. |
|
3007 |
^ self |
|
3008 |
]. |
|
3009 |
||
3010 |
cursorType == #ibeam ifTrue:[ |
|
3011 |
"ibeam-cursor touches 2 characters" |
|
3012 |
cursorCol > 1 ifTrue:[ |
|
3013 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
3014 |
] ifFalse:[ |
|
3015 |
"care for left margin" |
|
3016 |
super redrawVisibleLine:cursorVisibleLine. |
|
3017 |
]. |
|
3018 |
^ self |
|
3019 |
]. |
|
3020 |
||
3021 |
"block cursor is simple - just one character under cursor" |
|
3022 |
||
3023 |
"/ however, if italic characters are involved, we must care |
|
3024 |
"/ for the chars before/after the cursor. |
|
3025 |
"/ We redraw the part of the previous character which got |
|
3026 |
"/ detroyed by the block cursor. |
|
3027 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
3028 |
||
3029 |
line := self visibleAt:cursorVisibleLine. |
|
3030 |
(line notNil and:[line isText]) ifTrue:[ |
|
3031 |
cursorCol > 1 ifTrue:[ |
|
3032 |
oldClip := self clippingBoundsOrNil. |
|
3033 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
3034 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
3035 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
|
3036 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
3037 |
self clippingBounds:oldClip. |
|
3038 |
^ self. |
|
3039 |
]. |
|
3040 |
]. |
|
3041 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3042 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
3043 |
|
2088 | 3044 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 3045 |
! |
3046 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3047 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3048 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3049 |
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
|
3050 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3051 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3052 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3053 |
|
672 | 3054 |
validateCursorCol:col inLine:line |
674 | 3055 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 3056 |
Here, no limits are enforced (and col is returned), |
5593 | 3057 |
but it may be redefined in EditFields or views which don't like the |
674 | 3058 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 3059 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
3060 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
3061 |
|
1419 | 3062 |
"/ in ST80 mode, |
2707 | 3063 |
"/ the cursor may not be positioned beyond the |
3064 |
"/ end of a line or beyond the last line of the text |
|
3160 | 3065 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3066 |
self st80EditMode ifTrue:[ |
6152 | 3067 |
l := (self listAt:line). |
3068 |
max := l size + 1. |
|
3069 |
col > max ifTrue:[ |
|
3070 |
^ max |
|
3071 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
3072 |
]. |
672 | 3073 |
^ col |
3074 |
||
1419 | 3075 |
"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
|
3076 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 3077 |
! |
3078 |
||
3079 |
validateCursorLine:line |
|
6171 | 3080 |
"check if line is a valid cursor line; return a fixed line-nr if not. |
3160 | 3081 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 3082 |
redefined in views which don't like the cursor to be positioned |
674 | 3083 |
behind the end of the text (vi/st-80 behavior), or want to |
3084 |
skip reserved regions" |
|
3085 |
||
1419 | 3086 |
"/ |
3087 |
"/ in st80Mode, the cursor may not be positioned |
|
5787 | 3088 |
"/ beyond the last line |
6091 | 3089 |
"/ (but it must be possible to place it on one line below the last one |
5367 | 3090 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
1419 | 3091 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3092 |
self st80EditMode ifTrue:[ |
6091 | 3093 |
^ (line min:(list size + 1)) max:1 |
1419 | 3094 |
]. |
674 | 3095 |
^ line |
3096 |
||
6091 | 3097 |
"Created: / 22-05-1996 / 18:22:23 / cg" |
3098 |
"Modified: / 20-06-1998 / 18:19:26 / cg" |
|
3099 |
"Modified (comment): / 11-02-2017 / 09:12:37 / cg" |
|
6171 | 3100 |
"Modified (comment): / 19-06-2017 / 16:25:27 / mawalch" |
672 | 3101 |
! |
3102 |
||
121 | 3103 |
withCursorOffDo:aBlock |
3104 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
3105 |
||
3106 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
6152 | 3107 |
^ aBlock value |
121 | 3108 |
]. |
3109 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
3110 |
aBlock ensure:[ |
6152 | 3111 |
self showCursor |
121 | 3112 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3113 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3114 |
|
2589 | 3115 |
!EditTextView methodsFor:'drag & drop'! |
3116 |
||
3117 |
allowDrop:aBoolean |
|
3236 | 3118 |
"enable/disable drop support" |
3119 |
||
2589 | 3120 |
aBoolean ifFalse:[ |
6152 | 3121 |
dropTarget := nil. |
2589 | 3122 |
] ifTrue:[ |
6152 | 3123 |
dropTarget isNil ifTrue:[ |
3124 |
dropTarget := DropTarget |
|
3125 |
receiver:self |
|
3126 |
argument:nil |
|
3127 |
dropSelector:#'drop:' |
|
3128 |
canDropSelector:#'canDrop:' |
|
3129 |
] |
|
3236 | 3130 |
]. |
3131 |
! |
|
3132 |
||
3412 | 3133 |
canDrop:aDropContext |
3134 |
"public from d&d. |
|
3135 |
I accept textObjects and fileObjects only." |
|
3136 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
3137 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 3138 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
3139 |
^ self canDropObjects:aDropContext dropObjects |
|
3140 |
||
3141 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
3142 |
! |
|
3143 |
||
3144 |
canDropObjects:aCollectionOfDropObjects |
|
3145 |
"public from d&d. |
|
3146 |
I accept textObjects and fileObjects only." |
|
2589 | 3147 |
|
3148 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
3149 |
||
3412 | 3150 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
3151 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
3152 |
||
3153 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
3154 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
3155 |
! |
|
3156 |
||
3157 |
drop:aDropContext |
|
3158 |
"public from d&d. |
|
3159 |
drop objects (new API)" |
|
3160 |
||
3161 |
self dropObjects:(aDropContext dropObjects) |
|
3162 |
||
3163 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
3164 |
! |
|
3165 |
||
3166 |
dropFileObject:aDropObject |
|
2589 | 3167 |
"drop objects |
3236 | 3168 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
3169 |
||
4136 | 3170 |
|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
|
3171 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3172 |
pasteWhat := #name. |
3412 | 3173 |
|
3174 |
fn := aDropObject asFilename. |
|
3175 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
6152 | 3176 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
3177 |
(enforcedDropMode notNil |
|
3178 |
and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[ |
|
3179 |
pasteWhat := enforcedDropMode. |
|
3180 |
] ifFalse:[ |
|
3181 |
sensor := self sensor. |
|
3182 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
|
3183 |
pasteWhat := #name. |
|
3184 |
] ifFalse:[ |
|
3185 |
(sensor metaDown) ifTrue:[ |
|
3186 |
pasteWhat := #contents. |
|
3187 |
] ifFalse:[ |
|
3188 |
dontAskAgainHolder := false asValue. |
|
3189 |
answer := Dialog |
|
3190 |
confirmWithCancel:(resources |
|
3191 |
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.' |
|
3192 |
with:fn name allBold) |
|
3193 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
|
3194 |
values:#( nil #name #contents ) |
|
3195 |
default:#contents |
|
3196 |
check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder |
|
3197 |
title:(resources string:'Drop What'). |
|
3198 |
answer isNil ifTrue:[ ^ self ]. |
|
3199 |
||
3200 |
dontAskAgainHolder value ifTrue:[ |
|
3201 |
UserPreferences current enforcedDropModeForFiles:#contents |
|
3202 |
]. |
|
3203 |
pasteWhat := answer. |
|
3204 |
] |
|
3205 |
] |
|
3206 |
]. |
|
3886 | 3207 |
]. |
3208 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3209 |
pasteWhat == #name ifTrue:[ |
6152 | 3210 |
text := fn pathName |
3886 | 3211 |
] ifFalse:[ |
6152 | 3212 |
self withWaitCursorDo:[ |
3213 |
text := fn contentsAsString |
|
3214 |
]. |
|
3215 |
(app := self application) notNil ifTrue:[ |
|
3216 |
app droppedFile:fn in:self |
|
3217 |
]. |
|
5787 | 3218 |
]. |
3219 |
||
3220 |
self |
|
6152 | 3221 |
undoablePaste:text |
3222 |
info:'Drop File'. |
|
3412 | 3223 |
|
3224 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 3225 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 3226 |
! |
3227 |
||
3228 |
dropObject:aDropObject |
|
3229 |
"drop objects |
|
3230 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
3231 |
||
3415 | 3232 |
|text| |
3233 |
||
3412 | 3234 |
(aDropObject isFileObject) ifTrue:[ |
6152 | 3235 |
self dropFileObject:aDropObject |
3412 | 3236 |
] ifFalse:[ |
6152 | 3237 |
aDropObject isTextObject ifTrue:[ |
3238 |
text := aDropObject theObject. |
|
3239 |
text isStringCollection ifTrue:[ |
|
3240 |
text := text asStringWithoutFinalCR |
|
3241 |
]. |
|
3242 |
] ifFalse:[ |
|
3243 |
text := aDropObject theObject asString |
|
3244 |
]. |
|
3245 |
self |
|
3246 |
undoablePaste:text |
|
3247 |
info:'Drop'. |
|
3412 | 3248 |
]. |
3249 |
||
3250 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 3251 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 3252 |
! |
3253 |
||
3254 |
dropObjects:aCollectionOfDropObjects |
|
3255 |
"public from d&d. |
|
3256 |
drop objects (old API)" |
|
3257 |
||
3868 | 3258 |
aCollectionOfDropObjects do:[:el | |
6152 | 3259 |
self dropObject:el |
3412 | 3260 |
]. |
3261 |
||
3262 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
3263 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 3264 |
! ! |
3265 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3266 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3267 |
|
5761 | 3268 |
applyConverterToSelection:converter |
3269 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3270 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3271 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3272 |
|
6226 | 3273 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
3274 |
||
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3275 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3276 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3277 |
line1 isNil ifTrue:[ |
6152 | 3278 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
3279 |
line1 notNil ifTrue:[ |
|
3280 |
line2 := line1 |
|
3281 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3282 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3283 |
line1 notNil ifTrue:[ |
6152 | 3284 |
line1 to:line2 do:[:lineNr | |
3285 |
|line col1 col2 newLine| |
|
3286 |
||
3287 |
line := (self listAt:lineNr) copy. |
|
6548 | 3288 |
line size ~~ 0 ifTrue:[ |
6152 | 3289 |
lineNr == line1 ifTrue:[ |
3290 |
col1 := selectionStartCol. |
|
3291 |
] ifFalse:[ |
|
3292 |
col1 := 1. |
|
3293 |
]. |
|
3294 |
lineNr == line2 ifTrue:[ |
|
3295 |
col2 := selectionEndCol. |
|
3296 |
] ifFalse:[ |
|
3297 |
col2 := (self listAt:lineNr) size. |
|
3298 |
]. |
|
6682 | 3299 |
col1 isNil ifTrue:[ |
3300 |
"/ no selection |
|
3301 |
] ifFalse:[ |
|
3302 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
|
3303 |
self withoutRedrawAt:lineNr put:newLine. |
|
3304 |
self invalidateLine:lineNr. |
|
3305 |
]. |
|
6152 | 3306 |
]. |
3307 |
]. |
|
5761 | 3308 |
] |
3309 |
||
3310 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
6226 | 3311 |
"Modified: / 11-11-2017 / 12:55:25 / cg" |
6548 | 3312 |
"Modified: / 01-03-2019 / 14:54:42 / Claus Gittinger" |
5761 | 3313 |
! |
3314 |
||
3315 |
convertSelectionToLowercase |
|
3316 |
"to-lower selected text" |
|
3317 |
||
3318 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3319 |
col1 to:col2 do:[:col | |
3320 |
|ch| |
|
3321 |
||
3322 |
ch := line at:col. |
|
3323 |
line at:col put:ch asLowercase. |
|
3324 |
]. |
|
3325 |
line. |
|
5761 | 3326 |
]. |
3327 |
||
3328 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
3329 |
! |
|
3330 |
||
3331 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
3332 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
3333 |
||
3334 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
6152 | 3335 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
3336 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
3337 |
||
3338 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
3339 |
col1 to:col2 do:[:col | |
|
3340 |
|ch| |
|
3341 |
||
3342 |
ch := line at:col. |
|
3343 |
ch isUppercase ifTrue:[ |
|
3344 |
isAllLower := false. |
|
3345 |
col == col1 ifTrue:[ |
|
3346 |
isLowerFirst := false. |
|
3347 |
]. |
|
3348 |
] ifFalse:[ |
|
3349 |
ch isLowercase ifTrue:[ |
|
3350 |
isAllUpper := false. |
|
3351 |
col == col1 ifTrue:[ |
|
3352 |
isUpperFirst := false. |
|
3353 |
]. |
|
3354 |
] |
|
3355 |
]. |
|
3356 |
]. |
|
3357 |
||
3358 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
3359 |
isLowerFirst ifTrue:[ |
|
3360 |
makeUppercaseFirst := true. |
|
3361 |
] ifFalse:[ |
|
3362 |
"/ must remember where we come from - otherwise, we end up |
|
3363 |
"/ in upperFirst - lowerFirst cycle. |
|
3364 |
"/ think about a good place to store this state |
|
3365 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
3366 |
makeLowercaseFirst := true. |
|
3367 |
] ifFalse:[ |
|
3368 |
isAllUpper ifTrue:[ |
|
3369 |
makeLowercase := true. |
|
3370 |
] ifFalse:[ |
|
3371 |
makeUppercase := true. |
|
3372 |
] |
|
3373 |
] |
|
3374 |
]. |
|
3375 |
makeUppercaseFirst ifTrue:[ |
|
3376 |
line at:col1 put:(line at:col1) asUppercase. |
|
3377 |
] ifFalse:[ |
|
3378 |
makeLowercaseFirst ifTrue:[ |
|
3379 |
line at:col1 put:(line at:col1) asLowercase. |
|
3380 |
] ifFalse:[ |
|
3381 |
col1 to:col2 do:[:col | |
|
3382 |
|ch| |
|
3383 |
||
3384 |
ch := line at:col. |
|
3385 |
ch := makeLowercase |
|
3386 |
ifTrue:[ ch asLowercase ] |
|
3387 |
ifFalse:[ |
|
3388 |
makeUppercase |
|
3389 |
ifTrue:[ ch asUppercase ] |
|
3390 |
ifFalse:[ |
|
3391 |
col == col1 |
|
3392 |
ifTrue:[ ch asUppercase ] |
|
3393 |
ifFalse:[ ch asLowercase ] |
|
3394 |
] |
|
3395 |
]. |
|
3396 |
line at:col put:ch. |
|
3397 |
]. |
|
3398 |
]. |
|
3399 |
]. |
|
3400 |
line |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3401 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3402 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3403 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 3404 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
3405 |
! |
|
3406 |
||
3407 |
convertSelectionToUppercase |
|
3408 |
"to-upper selected text" |
|
3409 |
||
3410 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3411 |
col1 to:col2 do:[:col | |
3412 |
|ch| |
|
3413 |
||
3414 |
ch := line at:col. |
|
3415 |
line at:col put:ch asUppercase. |
|
3416 |
]. |
|
3417 |
line. |
|
5761 | 3418 |
]. |
3419 |
||
3420 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
3421 |
! |
|
3422 |
||
3423 |
convertSelectionToUppercaseFirst |
|
3424 |
"to-upperFirst selected text" |
|
3425 |
||
3426 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3427 |
|state| |
3428 |
||
3429 |
state := #first. |
|
3430 |
col1 to:col2 do:[:col | |
|
3431 |
|ch| |
|
3432 |
||
3433 |
ch := line at:col. |
|
3434 |
ch isSeparator ifFalse:[ |
|
3435 |
state == #first ifTrue:[ |
|
3436 |
line at:col put:ch asUppercase. |
|
3437 |
state := #skipRest |
|
3438 |
] |
|
3439 |
] ifTrue:[ |
|
3440 |
state := #first |
|
3441 |
] |
|
3442 |
]. |
|
3443 |
line. |
|
5761 | 3444 |
]. |
3445 |
||
3446 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3447 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3448 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3449 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3450 |
"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
|
3451 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3452 |
selectionStartLine notNil ifTrue:[ |
6152 | 3453 |
self setClipboardText:(self selection). |
3454 |
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
|
3455 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3456 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3457 |
"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
|
3458 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3459 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3460 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3461 |
"delete single character under cursor; does not merge lines" |
121 | 3462 |
|
3463 |
|wasOn| |
|
3464 |
||
3465 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3466 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3467 |
wasOn ifTrue:[self showCursor] |
3468 |
! |
|
3469 |
||
827 | 3470 |
deleteCharAtLine:lineNr col:colNr |
3471 |
"delete a single character at colNr in line lineNr" |
|
3472 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3473 |
self st80EditMode ifTrue:[ |
6152 | 3474 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3475 |
| wasOn | |
|
3476 |
wasOn := self hideCursor. |
|
3477 |
self |
|
3478 |
cursorReturn; |
|
3479 |
cursorCol:1; |
|
3480 |
deleteCharBeforeCursor. |
|
3481 |
wasOn ifTrue:[ self showCursor]. |
|
3482 |
^ self. |
|
3483 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3484 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3485 |
|
827 | 3486 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3487 |
! |
|
3488 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3489 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3490 |
"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
|
3491 |
|
4592 | 3492 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3493 |
|
6050 | 3494 |
list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete. |
3495 |
||
121 | 3496 |
wasOn := self hideCursor. |
6614 | 3497 |
(self autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
6050 | 3498 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
3499 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
|
3500 |
ln size < prevTab ifTrue:[ |
|
6567 | 3501 |
ln := ln , (String new:prevTab). |
6050 | 3502 |
]. |
3503 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3504 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3505 |
cursorCol > prevTab ifTrue:[ |
|
3506 |
self st80EditMode ifTrue:[ |
|
3507 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3508 |
"/ not allow a cursor position beyond the end of line, |
|
3509 |
"/ so ensure that cursorLine:col: will force us to the beginning of the line |
|
3510 |
originalLine size < prevTab ifTrue:[ |
|
3511 |
self checkForExistingLine:cursorLine. |
|
3512 |
self basicListAt:cursorLine put:ln |
|
3513 |
] |
|
3514 |
]. |
|
3515 |
self cursorLine:cursorLine col:prevTab. |
|
3516 |
wasOn ifTrue:[ self showCursor ]. |
|
3517 |
^ self |
|
3518 |
]. |
|
3519 |
] ifFalse:[ |
|
3520 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
3521 |
self cursorLine:cursorLine col:prevTab. |
|
3522 |
wasOn ifTrue:[ self showCursor ]. |
|
3523 |
^ self. |
|
3524 |
] |
|
3525 |
]. |
|
827 | 3526 |
]. |
3527 |
||
6614 | 3528 |
"/ (self autoIndent |
2491 | 3529 |
"/ and:[cursorCol ~~ 1 |
3160 | 3530 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3531 |
"/ ifTrue:[ |
3532 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3533 |
"/ |
|
3534 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3535 |
"/ ln := list at:cursorLine. |
|
3536 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3537 |
"/ soCol := 1 |
|
3538 |
"/ ] |
|
3539 |
"/ ] |
|
3540 |
"/ ] ifFalse:[ |
|
6050 | 3541 |
soCol := 1. |
2491 | 3542 |
"/ ]. |
3543 |
||
1419 | 3544 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
6050 | 3545 |
" |
3546 |
somewhere in the middle of a line |
|
3547 |
" |
|
3548 |
self cursorLeft. |
|
3549 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3550 |
] ifFalse:[ |
6050 | 3551 |
" |
3552 |
at begin of line - merge with previous line; |
|
3553 |
except for the very first line. |
|
3554 |
" |
|
3555 |
(cursorLine == 1) ifFalse:[ |
|
3556 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3557 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3558 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3559 |
"/ we are beyond the end of the text. |
|
3560 |
"/ move the cursor to the previous line. |
|
3561 |
self cursorLine:lineNrAboveCursor col:1. |
|
3562 |
] ifFalse:[ |
|
3563 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3564 |
] |
|
3565 |
] |
|
3566 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3567 |
]. |
827 | 3568 |
wasOn ifTrue:[ self showCursor ] |
3569 |
||
6567 | 3570 |
"Modified: / 16-01-1998 / 22:33:04 / cg" |
6614 | 3571 |
"Modified: / 26-06-2019 / 23:19:59 / Claus Gittinger" |
827 | 3572 |
! |
3573 |
||
3574 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3575 |
"delete characters from colNr up to the end in line lineNr" |
|
3576 |
||
3577 |
|line| |
|
3578 |
||
3579 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
6152 | 3580 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3581 |
] |
3582 |
||
3583 |
! |
|
3584 |
||
4458 | 3585 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3586 |
"delete characters from startCol to endCol in line lineNr" |
|
3587 |
||
3588 |
|deleted| |
|
3589 |
||
6641 | 3590 |
undoSupport isInTransaction ifFalse:[ |
3591 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3592 |
] ifTrue:[ |
|
3593 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3594 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3595 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3596 |
]. |
|
3597 |
||
3598 |
"Modified: / 17-07-2019 / 07:30:14 / Claus Gittinger" |
|
4458 | 3599 |
! |
3600 |
||
827 | 3601 |
deleteCharsAtLine:lineNr toCol:colNr |
3602 |
"delete characters from start up to colNr in line lineNr" |
|
3603 |
||
3604 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3605 |
||
3606 |
||
121 | 3607 |
! |
3608 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3609 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3610 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3611 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3612 |
self deleteLine:cursorLine |
121 | 3613 |
! |
3614 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3615 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3616 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3617 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3618 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3619 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3620 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3621 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3622 |
col1 == 0 ifTrue:[ |
6152 | 3623 |
line1 := line1 - 1. |
3624 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3625 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3626 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3627 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3628 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3629 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3630 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3631 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3632 |
|
2954 | 3633 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3634 |
"delete all text from startLine/startCol to endLine/endCol - |
|
6163 | 3635 |
joining lines if necessary" |
2954 | 3636 |
|
3637 |
|line newLine lineSize nMore| |
|
3638 |
||
3639 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3640 |
list isNil ifTrue:[^ self]. |
|
3641 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3642 |
||
3643 |
(startLine == endLine) ifTrue:[ |
|
6152 | 3644 |
"/ delete chars within a line |
3645 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3646 |
^ self |
|
2954 | 3647 |
]. |
3648 |
||
3649 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
6152 | 3650 |
"/ delete full lines only |
3651 |
endLine > startLine ifTrue:[ |
|
3652 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3653 |
]. |
|
3654 |
^ self |
|
2954 | 3655 |
]. |
3656 |
||
3657 |
"/ delete right rest of 1st line |
|
4786 | 3658 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3659 |
|
3660 |
"/ delete the inner lines ... |
|
3661 |
endLine > (startLine + 1) ifTrue:[ |
|
6152 | 3662 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3663 |
]. |
3664 |
||
3665 |
(endCol ~~ 0) ifTrue:[ |
|
6152 | 3666 |
"/ delete the left rest of the last line |
3667 |
||
3668 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3669 |
||
3670 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3671 |
startLine <= list size ifTrue:[ |
|
3672 |
line := list at:startLine. |
|
3673 |
lineSize := line size. |
|
3674 |
(startCol > lineSize) ifTrue:[ |
|
3675 |
newLine := line. |
|
3676 |
line isNil ifTrue:[ |
|
3677 |
newLine := String new:(startCol - 1) |
|
3678 |
] ifFalse:[ |
|
3679 |
nMore := startCol - 1 - lineSize. |
|
3680 |
nMore > 0 ifTrue:[ |
|
3681 |
newLine := line , (line species new:nMore) |
|
3682 |
] |
|
3683 |
]. |
|
3684 |
newLine ~~ line ifTrue:[ |
|
3685 |
self basicListAt:startLine put:newLine. |
|
3686 |
]. |
|
3687 |
"/ TODO: remember old maxwidth of linerange, |
|
3688 |
"/ only clear widthOfWidestLine, if this max |
|
3689 |
"/ length was (one of) the longest. |
|
3690 |
"/ avoids slow delete with huge texts. |
|
3691 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3692 |
self textChanged. |
|
3693 |
] |
|
3694 |
] |
|
2954 | 3695 |
]. |
3696 |
||
3697 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3698 |
self mergeLine:startLine removeBlanks:false |
|
3699 |
||
4225 | 3700 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3701 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
6163 | 3702 |
"Modified (comment): / 30-05-2017 / 17:34:03 / mawalch" |
2954 | 3703 |
! |
3704 |
||
4458 | 3705 |
deleteFromLine:startLineNr toLine:endLineNr |
3706 |
"delete some lines" |
|
3707 |
||
3708 |
|deleted| |
|
3709 |
||
3710 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3711 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3712 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3713 |
! |
|
3714 |
||
827 | 3715 |
deleteLine:lineNr |
3716 |
"delete line" |
|
3717 |
||
3718 |
self deleteFromLine:lineNr toLine:lineNr |
|
3719 |
||
3720 |
||
3721 |
! |
|
3722 |
||
4458 | 3723 |
deleteLineWithoutRedraw:lineNr |
3724 |
"delete line - no redraw; |
|
3725 |
return true, if something was really deleted" |
|
3726 |
||
3727 |
|deleted ret| |
|
3728 |
||
3729 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3730 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3731 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3732 |
^ ret. |
|
3733 |
! |
|
3734 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3735 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3736 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3737 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3738 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3739 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3740 |
|
4771 | 3741 |
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
|
3742 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3743 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3744 |
(endLine > list size) ifTrue:[ |
6152 | 3745 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3746 |
] ifFalse:[ |
6152 | 3747 |
lastLine := endLine |
4771 | 3748 |
]. |
3749 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3750 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3751 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3752 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3753 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3754 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3755 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3756 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3757 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3758 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3759 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3760 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3761 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3762 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3763 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3764 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3765 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3766 |
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
|
3767 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3768 |
selectionStartLine notNil ifTrue:[ |
6152 | 3769 |
wasOn := self hideCursor. |
3770 |
||
3771 |
startLine := selectionStartLine. |
|
3772 |
startCol := selectionStartCol. |
|
3773 |
endLine := selectionEndLine. |
|
3774 |
endCol := selectionEndCol. |
|
3775 |
self unselectWithoutRedraw. |
|
3776 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3777 |
self setCursorLine:startLine col:startCol. |
|
3778 |
||
3779 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3780 |
] |
121 | 3781 |
! |
3782 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3783 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3784 |
"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
|
3785 |
|
2952 | 3786 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3787 |
|
3799 | 3788 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3789 |
cursorCol <= 1 ifTrue:[ |
6152 | 3790 |
self deleteCharBeforeCursor. |
3791 |
^ self |
|
5361 | 3792 |
]. |
3799 | 3793 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3794 |
wasOn := self hideCursor. |
5787 | 3795 |
self |
6152 | 3796 |
undoableDo:[ |
3797 |
endCol := cursorCol-1. |
|
3798 |
endLine := cursorLine. |
|
3799 |
self cursorToPreviousWord. |
|
3800 |
beginCol := cursorCol. |
|
3801 |
beginLine := cursorLine. |
|
3802 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3803 |
self cursorLine:cursorLine col:beginCol. |
|
3804 |
] |
|
3805 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3806 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3807 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3808 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3809 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3810 |
|
5761 | 3811 |
indentSelectionBy1 |
3812 |
"indent selected line-range |
|
3813 |
by 1 space (i.e. to the right)" |
|
3814 |
||
3815 |
self indentBy:1 |
|
3816 |
||
3817 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3818 |
! |
|
3819 |
||
4458 | 3820 |
insert:aCharacter atLine:lineNr col:colNr |
3821 |
"insert a single character at lineNr/colNr; |
|
3822 |
set emphasis to character at current position" |
|
3823 |
||
3824 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
6641 | 3825 |
undoSupport isInTransaction ifTrue:[ |
3826 |
aCharacter ~~ Character cr ifTrue:[ |
|
3827 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
|
3828 |
] |
|
3829 |
]. |
|
3830 |
||
3831 |
"Modified: / 17-07-2019 / 07:30:46 / Claus Gittinger" |
|
4458 | 3832 |
! |
3833 |
||
121 | 3834 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3835 |
"insert a single character at cursor-position - advance cursor." |
121 | 3836 |
|
3837 |
|wasOn| |
|
3838 |
||
3839 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3840 |
aCharacter == Character tab ifTrue:[ |
6152 | 3841 |
"/ needs special care to advance cursor correctly |
3842 |
self insertTabAtCursor |
|
121 | 3843 |
] ifFalse:[ |
6152 | 3844 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3845 |
aCharacter == (Character cr) ifTrue:[ |
|
3846 |
self basicCursorReturn |
|
3847 |
] ifFalse:[ |
|
3848 |
self cursorRight. |
|
3849 |
]. |
|
121 | 3850 |
]. |
3851 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3852 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3853 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3854 |
! |
3855 |
||
641 | 3856 |
insertLine:aString before:lineNr |
3857 |
"insert the line aString before line lineNr" |
|
3858 |
||
3859 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3860 |
||
3861 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3862 |
! |
|
3863 |
||
155 | 3864 |
insertLines:aStringCollection before:lineNr |
3865 |
"insert a bunch before line lineNr" |
|
3866 |
||
3867 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3868 |
||
3869 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3870 |
! |
|
3871 |
||
4771 | 3872 |
insertLines:someText from:start to:end before:lineNr |
3873 |
"insert a bunch of lines before line lineNr. |
|
3874 |
The cursor position is left unchanged." |
|
3875 |
||
3876 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3877 |
srcY "{ Class: SmallInteger }" |
|
3878 |
dstY "{ Class: SmallInteger }" | |
|
3879 |
||
5357 | 3880 |
"wrong when pasting multiple lines" |
3881 |
false "autoIndent" ifTrue:[ |
|
6152 | 3882 |
indent := self leftIndentForLine:lineNr. |
3883 |
||
3884 |
text := someText |
|
3885 |
collect:[:ln||line| |
|
3886 |
ln notNil ifTrue:[ |
|
3887 |
line := ln withoutLeadingSeparators. |
|
3888 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3889 |
line := (String new:indent), line |
|
3890 |
]. |
|
3891 |
line |
|
3892 |
] ifFalse:[ |
|
3893 |
nil |
|
3894 |
] |
|
3895 |
]. |
|
4771 | 3896 |
] ifFalse:[ |
6152 | 3897 |
text := someText |
4771 | 3898 |
]. |
3899 |
||
3900 |
visLine := self listLineToVisibleLine:lineNr. |
|
3901 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
6152 | 3902 |
self withoutRedrawInsertLines:text |
3903 |
from:start to:end |
|
3904 |
before:lineNr. |
|
4771 | 3905 |
] ifFalse:[ |
6152 | 3906 |
nLines := end - start + 1. |
3907 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3908 |
self withoutRedrawInsertLines:text |
|
3909 |
from:start to:end |
|
3910 |
before:lineNr. |
|
3911 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3912 |
] ifFalse:[ |
|
3913 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3914 |
and:(firstLineShown + nLines + nLinesShown). |
|
3915 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3916 |
dstY := srcY + (nLines * fontHeight). |
|
3917 |
||
3918 |
"/ |
|
3919 |
"/ scroll ... |
|
3920 |
"/ |
|
3921 |
" |
|
3922 |
stupid: must catchExpose before inserting new |
|
3923 |
stuff - since catchExpose may perform redraws |
|
3924 |
" |
|
3925 |
self catchExpose. |
|
3926 |
self withoutRedrawInsertLines:text |
|
3927 |
from:start to:end |
|
3928 |
before:lineNr. |
|
3929 |
self |
|
3930 |
copyFrom:self |
|
3931 |
x:textStartLeft y:srcY |
|
3932 |
toX:textStartLeft y:dstY |
|
3933 |
width:w |
|
3934 |
height:(height - dstY) |
|
3935 |
async:true. |
|
3936 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3937 |
self waitForExpose |
|
3938 |
]. |
|
4771 | 3939 |
]. |
3940 |
widthOfWidestLine notNil ifTrue:[ |
|
6152 | 3941 |
text do:[:line | |
3942 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3943 |
] |
|
4771 | 3944 |
]. |
3945 |
self textChanged. |
|
3946 |
||
3947 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3948 |
! |
|
3949 |
||
654 | 3950 |
insertLines:lines withCR:withCr |
3160 | 3951 |
"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
|
3952 |
Cursor is moved behind insertion. |
641 | 3953 |
If withCr is true, append cr after last line" |
3954 |
||
3955 |
|start end nLines wasOn| |
|
3956 |
||
3957 |
lines notNil ifTrue:[ |
|
6152 | 3958 |
nLines := lines size. |
3959 |
(nLines == 1) ifTrue:[ |
|
3960 |
self insertStringAtCursor:(lines at:1). |
|
3961 |
withCr ifTrue:[ |
|
3962 |
self insertCharAtCursor:(Character cr) |
|
3963 |
] |
|
3964 |
] ifFalse:[ |
|
3965 |
(cursorCol ~~ 1) ifTrue:[ |
|
3966 |
self insertStringAtCursor:(lines at:1). |
|
3967 |
self insertCharAtCursor:(Character cr). |
|
3968 |
start := 2 |
|
3969 |
] ifFalse:[ |
|
3970 |
start := 1 |
|
3971 |
]. |
|
3972 |
withCr ifTrue:[ |
|
3973 |
end := nLines |
|
3974 |
] ifFalse:[ |
|
3975 |
end := nLines - 1 |
|
3976 |
]. |
|
3977 |
(start <= nLines) ifTrue:[ |
|
3978 |
(end >= start) ifTrue:[ |
|
3979 |
wasOn := self hideCursor. |
|
3980 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3981 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3982 |
wasOn ifTrue:[self showCursor]. |
|
3983 |
] |
|
3984 |
]. |
|
3985 |
withCr ifFalse:[ |
|
3986 |
"last line without cr" |
|
3987 |
self insertStringAtCursor:(lines at:nLines) |
|
3988 |
] |
|
3989 |
] |
|
641 | 3990 |
] |
654 | 3991 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3992 |
"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
|
3993 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3994 |
! |
3995 |
||
3996 |
insertLines:lines withCr:withCr |
|
3997 |
"insert a bunch of lines at cursor position. Cursor |
|
3998 |
is moved behind insertion. |
|
3999 |
If withCr is true, append cr after last line" |
|
4000 |
||
2363 | 4001 |
<resource:#obsolete> |
4002 |
||
1292 | 4003 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
4004 |
self insertLines:lines withCR:withCr. |
|
4005 |
||
4006 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 4007 |
! |
4008 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4009 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4010 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4011 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4012 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4013 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4014 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4015 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4016 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4017 |
self selectFromLine:startLine col:startCol |
6152 | 4018 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
4019 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4020 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4021 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4022 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4023 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4024 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4025 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4026 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4027 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4028 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 4029 |
col == 0 ifTrue:[ |
6152 | 4030 |
line > 1 ifTrue:[ |
4031 |
line := line - 1. |
|
4032 |
col := (self listAt:line) size + 1. |
|
4033 |
] ifFalse:[ |
|
4034 |
col := 1. |
|
4035 |
] |
|
5060 | 4036 |
]. |
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4037 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4038 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
4039 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4040 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4041 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4042 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4043 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4044 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4045 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4046 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4047 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4048 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4049 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4050 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
4051 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 4052 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 4053 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
4054 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4055 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4056 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4057 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4058 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4059 |
[start <= end] whileTrue:[ |
6152 | 4060 |
stop := aString indexOf:(Character cr) startingAt:start. |
4061 |
stop == 0 ifTrue:[ |
|
4062 |
stop := end + 1 |
|
4063 |
]. |
|
4064 |
subString := aString copyFrom:start to:(stop - 1). |
|
4065 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
4066 |
(stop <= end) ifTrue:[ |
|
4067 |
c := c + subString size. |
|
4068 |
self insert:(Character cr) atLine:l col:c. |
|
4069 |
l := l + 1. |
|
4070 |
c := 1 |
|
4071 |
]. |
|
4072 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4073 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
4074 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
4075 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 4076 |
! |
4077 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4078 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4079 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4080 |
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
|
4081 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4082 |
aString isNil ifTrue:[ |
6152 | 4083 |
"new:" |
4084 |
self insertCharAtCursor:(Character cr). |
|
4085 |
^ self |
|
105 | 4086 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
4087 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 4088 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 4089 |
]. |
4090 |
||
654 | 4091 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4092 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
4093 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 4094 |
! |
4095 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4096 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4097 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4098 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4099 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 4100 |
shown ifTrue:[ |
6152 | 4101 |
gc font hasOverlappingCharacters ifTrue:[ |
4102 |
self invalidateLine:lineNr. |
|
4103 |
] ifFalse:[ |
|
4104 |
self redrawLine:lineNr from:colNr |
|
4105 |
] |
|
4190 | 4106 |
] |
4107 |
||
4191 | 4108 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 4109 |
! |
4110 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4111 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4112 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4113 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4114 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4115 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
4116 |
|
6548 | 4117 |
aString size ~~ 0 ifTrue:[ |
6152 | 4118 |
wasOn := self hideCursor. |
4119 |
(aString includes:Character tab) ifTrue:[ |
|
4120 |
self checkForExistingLine:cursorLine. |
|
4121 |
oldLen := (list at:cursorLine) size. |
|
4122 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
4123 |
newLen := (list at:cursorLine) size. |
|
4124 |
deltaLen := newLen - oldLen. |
|
4125 |
] ifFalse:[ |
|
4126 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
4127 |
deltaLen := aString size. |
|
4128 |
]. |
|
4129 |
self setCursorCol:(cursorCol + deltaLen). |
|
4130 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4131 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
4132 |
|
6548 | 4133 |
"Modified: / 10-06-1998 / 20:43:52 / cg" |
4134 |
"Modified: / 01-03-2019 / 14:54:49 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4135 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4136 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4137 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4138 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4139 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4140 |
|wasOn nextTab| |
105 | 4141 |
|
121 | 4142 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4143 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4144 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4145 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 4146 |
! |
4147 |
||
3542 | 4148 |
joinLines |
3890 | 4149 |
"join lines (remove line-break)" |
4150 |
||
3583 | 4151 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
4152 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
4153 |
self |
6152 | 4154 |
undoableDo:[ |
4155 |
|line col lineLen| |
|
4156 |
||
4157 |
line := cursorLine. |
|
4158 |
col := cursorCol. |
|
4159 |
lineLen := (list at:line) size. |
|
4160 |
col > lineLen ifTrue:[ |
|
4161 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
4162 |
] ifFalse:[ |
|
4163 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
4164 |
]. |
|
4165 |
self mergeLine:line removeBlanks:true. |
|
4166 |
self cursorLine:line col:col. |
|
4167 |
] |
|
4168 |
info:'Join' |
|
3542 | 4169 |
! |
4170 |
||
2952 | 4171 |
mergeLine:lineNr |
4172 |
"merge line lineNr with line lineNr+1" |
|
4173 |
||
4174 |
self mergeLine:lineNr removeBlanks:true |
|
4175 |
||
4176 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
4177 |
! |
|
4178 |
||
4458 | 4179 |
mergeLine:lineNr removeBlanks:removeBlanks |
4180 |
"merge line lineNr with line lineNr+1" |
|
4181 |
||
4182 |
|len| |
|
4183 |
||
4184 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4185 |
||
4186 |
len := (self listAt:lineNr) size. |
|
4187 |
self nonUndoableDo:[ |
|
6152 | 4188 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 4189 |
]. |
4190 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
4191 |
! |
|
4192 |
||
5761 | 4193 |
parenthizeSelection |
6198 | 4194 |
"place parentheses around the selected text. |
5761 | 4195 |
if already parenthized, de-parenthize it" |
4196 |
||
4197 |
self parenthizeSelectionWith:$( and:$) |
|
4198 |
||
4199 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
6198 | 4200 |
"Modified (comment): / 30-08-2017 / 20:17:46 / cg" |
5761 | 4201 |
! |
4202 |
||
2506 | 4203 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 4204 |
"if already parenthized, de-parenthize it" |
4205 |
||
5560 | 4206 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4207 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4208 |
self hasSelection ifFalse:[^ self]. |
5560 | 4209 |
startLine := selectionStartLine. |
4210 |
endLine := selectionEndLine. |
|
4211 |
startCol := selectionStartCol. |
|
4212 |
endCol := selectionEndCol. |
|
5787 | 4213 |
|
5560 | 4214 |
newSelectionEnd := endCol. |
5787 | 4215 |
|
5560 | 4216 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
6152 | 4217 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
4218 |
self deleteCharAtLine:endLine col:endCol. |
|
4219 |
newSelectionEnd := newSelectionEnd-1. |
|
4220 |
]. |
|
4221 |
self deleteCharAtLine:startLine col:startCol. |
|
4222 |
startLine == endLine ifTrue:[ |
|
4223 |
newSelectionEnd := newSelectionEnd-1. |
|
4224 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4225 |
] ifFalse:[ |
6152 | 4226 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4227 |
newSelectionEnd := newSelectionEnd+1. |
|
4228 |
self insert:openingCharacter atLine:startLine col:startCol. |
|
4229 |
startLine == endLine ifTrue:[ |
|
4230 |
newSelectionEnd := newSelectionEnd+1. |
|
4231 |
] |
|
3160 | 4232 |
]. |
4233 |
self |
|
6152 | 4234 |
selectFromLine:startLine col:startCol |
4235 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 4236 |
|
4237 |
"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
|
4238 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4239 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4240 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4241 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4242 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4243 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4244 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4245 |
|
5114 | 4246 |
NoModificationError handle:[:ex | |
6152 | 4247 |
^ self |
5114 | 4248 |
] do:[ |
6152 | 4249 |
lastLine := list size. |
4250 |
finished := false. |
|
4251 |
[finished] whileFalse:[ |
|
6469 | 4252 |
((lastLine <= 1) or:[lastLine = cursorLine]) ifTrue:[ |
6152 | 4253 |
finished := true |
4254 |
] ifFalse:[ |
|
4255 |
line := list at:lastLine. |
|
4256 |
line notNil ifTrue:[ |
|
4257 |
line isBlank ifTrue:[ |
|
4258 |
self basicListAt:lastLine put:nil. |
|
4259 |
line := nil |
|
4260 |
] |
|
4261 |
]. |
|
4262 |
line notNil ifTrue:[ |
|
4263 |
finished := true |
|
4264 |
] ifFalse:[ |
|
4265 |
lastLine := lastLine - 1 |
|
4266 |
] |
|
4267 |
] |
|
4268 |
]. |
|
4269 |
(lastLine ~~ list size) ifTrue:[ |
|
4270 |
list grow:lastLine. |
|
4271 |
"/ self textChanged |
|
4272 |
] |
|
118 | 4273 |
]. |
6469 | 4274 |
|
4275 |
"Modified: / 26-10-2018 / 18:22:26 / Claus Gittinger" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4276 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4277 |
|
4458 | 4278 |
replace:aCharacter atLine:lineNr col:colNr |
4279 |
"replace a single character at lineNr/colNr" |
|
4280 |
||
4281 |
|originalChar| |
|
4282 |
||
4283 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
4284 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
4285 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
4286 |
! |
|
4287 |
||
4713 | 4288 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 4289 |
|pattern replacePattern| |
4290 |
||
4291 |
pattern := patternArg string. |
|
4292 |
replacePattern := replacePatternArg string. |
|
4630 | 4293 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
6152 | 4294 |
self rememberSearchPattern:pattern. |
4295 |
self rememberSearchPattern:replacePattern. |
|
4296 |
LastSearchIgnoredCase := ignoreCase. |
|
4297 |
self |
|
4298 |
undoableDo:[ |
|
4299 |
all ifTrue:[ |
|
4300 |
self |
|
4301 |
replaceString:pattern |
|
4302 |
to:replacePattern |
|
4303 |
ignoreCase:ignoreCase |
|
4304 |
] ifFalse:[ |
|
4305 |
(self selectionAsString notNil |
|
4306 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
|
4307 |
ifTrue:[ |
|
4308 |
self replaceSelectionBy:replacePattern. |
|
4309 |
self |
|
4310 |
search:pattern |
|
4311 |
ignoreCase:ignoreCase |
|
4312 |
forward:(lastSearchDirection = #forward). |
|
4313 |
]. |
|
4314 |
] |
|
4315 |
] |
|
4316 |
info:'Replace' |
|
3430 | 4317 |
] |
4318 |
||
4319 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
4320 |
! |
|
4321 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4322 |
replaceCharAtCursor:aCharacter |
5413 | 4323 |
"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
|
4324 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4325 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4326 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4327 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4328 |
aCharacter == (Character cr) ifTrue:[ |
6152 | 4329 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4330 |
] ifFalse:[ |
6152 | 4331 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
4332 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4333 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4334 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4335 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4336 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4337 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4338 |
|
4458 | 4339 |
replaceContentsWith:newContents |
5413 | 4340 |
"undoably replace everything" |
4458 | 4341 |
|
4342 |
|originalContents| |
|
4343 |
||
6641 | 4344 |
undoSupport isInTransaction ifFalse:[ |
4345 |
self contents:newContents keepUndoHistory:true. |
|
4346 |
] ifTrue:[ |
|
4347 |
originalContents := self contents. |
|
4348 |
self contents:newContents keepUndoHistory:true. |
|
4349 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
4350 |
]. |
|
4351 |
||
4352 |
"Modified: / 17-07-2019 / 08:02:15 / Claus Gittinger" |
|
4458 | 4353 |
! |
4354 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4355 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 4356 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4357 |
|
5216 | 4358 |
"/ 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
|
4359 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4360 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4361 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4362 |
|
4458 | 4363 |
replaceLine:lineNr with:newText |
5413 | 4364 |
"undoably replace a line at lineNr" |
4458 | 4365 |
|
4366 |
|originalLine| |
|
4367 |
||
4368 |
originalLine := self listAt:lineNr. |
|
4369 |
originalLine isNil ifTrue:[ |
|
6152 | 4370 |
self checkForExistingLine:lineNr |
4458 | 4371 |
]. |
4372 |
self list at:lineNr put:newText. |
|
4373 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4374 |
self invalidateLine:lineNr. |
|
4375 |
||
4376 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
4377 |
! |
|
4378 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4379 |
replaceLines:lines withCR:withCr |
5413 | 4380 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4381 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4382 |
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
|
4383 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4384 |
|
1809 | 4385 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4386 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4387 |
lines notNil ifTrue:[ |
6152 | 4388 |
wasOn := self hideCursor. |
4389 |
nLines := lines size. |
|
4390 |
line := cursorLine. |
|
4391 |
col := cursorCol. |
|
4392 |
lines keysAndValuesDo:[:i :l | |
|
4393 |
self replaceString:(l ? '') atLine:line col:col. |
|
4394 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
4395 |
line := line + 1. |
|
4396 |
col := 1. |
|
4397 |
] ifFalse:[ |
|
4398 |
col := col + (l size). |
|
4399 |
] |
|
4400 |
]. |
|
4401 |
self cursorLine:line col:col. |
|
4402 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
4403 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4404 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4405 |
|
4661 | 4406 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
4407 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4408 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4409 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4410 |
replaceSelectionBy:something |
5413 | 4411 |
"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
|
4412 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4413 |
|
4666 | 4414 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 4415 |
! |
4416 |
||
4417 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 4418 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 4419 |
leave cursor after insertion or leave it, depending on keep" |
4420 |
||
4666 | 4421 |
self replaceSelectionBy:something keepCursor:keep select:false |
4422 |
||
4423 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
4424 |
! |
|
4425 |
||
4426 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 4427 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 4428 |
leave cursor after insertion or leave it, depending on keep. |
4429 |
If selectNewText is true, select the new text; otherwise deselect" |
|
4430 |
||
4431 |
|sel l c selStartLine selStartCol| |
|
105 | 4432 |
|
4433 |
l := cursorLine. |
|
4434 |
c := cursorCol. |
|
4435 |
||
4818 | 4436 |
sel := self selectionAsString. |
4666 | 4437 |
sel isNil ifTrue:[ |
6152 | 4438 |
selStartLine := l. |
4439 |
selStartCol := c. |
|
4666 | 4440 |
] ifFalse:[ |
6152 | 4441 |
selStartLine := selectionStartLine. |
4442 |
selStartCol := selectionStartCol. |
|
4443 |
||
4444 |
self setLastStringToReplace: sel. |
|
4445 |
||
4446 |
self deleteSelection. |
|
4447 |
replacing := true. |
|
4448 |
lastReplacementInfo rememberReplacement. |
|
4449 |
lastReplacementInfo lastReplacement: ''. |
|
4450 |
lastReplacementInfo stillCollectingInput:true. |
|
4451 |
undoSupport actionInfo:'replace'. |
|
3161 | 4452 |
]. |
4453 |
||
4454 |
something isCharacter ifTrue:[ |
|
6152 | 4455 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4456 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
|
4457 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
|
4458 |
]. |
|
4459 |
]. |
|
4460 |
self isInInsertMode ifTrue:[ |
|
4461 |
self insertCharAtCursor:something |
|
4462 |
] ifFalse:[ |
|
4463 |
self replaceCharAtCursor:something |
|
4464 |
] |
|
105 | 4465 |
] ifFalse:[ |
6152 | 4466 |
something isString ifTrue:[ |
4467 |
lastReplacementInfo lastReplacement: something. |
|
4468 |
self isInInsertMode ifTrue:[ |
|
4469 |
self insertStringAtCursor:something |
|
4470 |
] ifFalse:[ |
|
4471 |
self replaceStringAtCursor:something |
|
4472 |
] |
|
4473 |
] ifFalse:[ |
|
4474 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4475 |
]. |
|
105 | 4476 |
]. |
4477 |
keep ifTrue:[ |
|
6152 | 4478 |
self cursorLine:l col:c |
4666 | 4479 |
]. |
4480 |
selectNewText ifTrue:[ |
|
6152 | 4481 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
105 | 4482 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4483 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4484 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4485 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4486 |
|
4458 | 4487 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4488 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4489 |
This is not prepared to encounter special chars (except TAB) in the string." |
4490 |
||
4491 |
|originalString| |
|
4492 |
||
4493 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4494 |
||
4495 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4496 |
||
4497 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4498 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4499 |
! |
|
4500 |
||
4713 | 4501 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4502 |
|continue count| |
4503 |
||
4504 |
self cursorToTop. |
|
4505 |
self selectFromBeginning. |
|
4506 |
count := 0. |
|
4507 |
continue := true. |
|
4508 |
[ continue ] whileTrue:[ |
|
6152 | 4509 |
(self selectionAsString notNil |
4510 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4511 |
ifTrue:[ |
|
4512 |
self replaceSelectionBy:aNewString. |
|
4513 |
count := count + 1. |
|
4514 |
]. |
|
4515 |
self |
|
4516 |
searchFwd:aString |
|
4517 |
ignoreCase:ignoreCase |
|
4518 |
ifAbsent:[ |
|
4519 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4520 |
bindWith:aString with:aNewString with:count). |
|
4521 |
continue := false. |
|
4522 |
]. |
|
3549 | 4523 |
]. |
3430 | 4524 |
|
4525 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4526 |
! |
|
4527 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4528 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4529 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4530 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4531 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4532 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4533 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4534 |
(aString includes:Character tab) ifTrue:[ |
6152 | 4535 |
"/ need special care for TAB (to move cursor correctly) |
4536 |
i1 := 1. |
|
4537 |
[i1 ~~ 0] whileTrue:[ |
|
4538 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4539 |
i2 ~~ 0 ifTrue:[ |
|
4540 |
i1 ~~ i2 ifTrue:[ |
|
4541 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4542 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4543 |
]. |
|
4544 |
self replaceTABAtCursor. |
|
4545 |
i2 := i2 + 1. |
|
4546 |
] ifFalse:[ |
|
4547 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4548 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4549 |
]. |
|
4550 |
i1 := i2. |
|
4551 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4552 |
] ifFalse:[ |
6152 | 4553 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
4554 |
self setValidatedCursorCol:(cursorCol + aString size). |
|
4555 |
"/ self cursorCol:(cursorCol + aString size). |
|
5325 | 4556 |
]. |
4557 |
wasOn ifTrue:[ |
|
6152 | 4558 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
4559 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
5325 | 4560 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4561 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4562 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4563 |
"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
|
4564 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4565 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4566 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4567 |
"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
|
4568 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4569 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4570 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4571 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4572 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4573 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4574 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4575 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4576 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4577 |
! |
4578 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4579 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4580 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4581 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4582 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4583 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4584 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4585 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4586 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4587 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4588 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4589 |
self cursorToPreviousWord. |
5787 | 4590 |
beginCol := cursorCol. |
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4591 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4592 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4593 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4594 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4595 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4596 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4597 |
|
4458 | 4598 |
splitLine:lineNr before:colNr |
4599 |
"split the line linNr before colNr; the right part (from colNr) |
|
4600 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4601 |
||
4602 |
self basicSplitLine:lineNr before:colNr. |
|
4603 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4604 |
! |
|
4605 |
||
5761 | 4606 |
toggleTabSetting |
4607 |
"toggle between 4-col |
|
4608 |
and 8-col tabs" |
|
4609 |
||
4610 |
(tabPositions == self class tab4Positions) |
|
6152 | 4611 |
ifTrue:[self setTab8] |
4612 |
ifFalse:[self setTab4] |
|
5761 | 4613 |
|
4614 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4615 |
! |
|
4616 |
||
4617 |
undentSelectionBy1 |
|
4618 |
"undent selected line-range |
|
4619 |
by 1 space (i.e. to the left)" |
|
4620 |
||
4621 |
self undentBy:1 |
|
4622 |
||
4623 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4624 |
! |
|
4625 |
||
5146 | 4626 |
withAutoIndent:aBoolean do:aBlock |
4627 |
|sav| |
|
4628 |
||
6614 | 4629 |
sav := self autoIndent. |
4630 |
self autoIndent:aBoolean. |
|
4631 |
aBlock ensure:[ self autoIndent:sav ]. |
|
4632 |
||
4633 |
"Modified: / 26-06-2019 / 23:18:17 / Claus Gittinger" |
|
5146 | 4634 |
! |
4635 |
||
4458 | 4636 |
withoutRedrawAt:lineNr put:aString |
4637 |
"replace a line at lineNr" |
|
4638 |
||
4639 |
|originalLine| |
|
4640 |
||
6641 | 4641 |
undoSupport isInTransaction ifTrue:[ |
4642 |
originalLine := self listAt:lineNr. |
|
4643 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4644 |
]. |
|
4458 | 4645 |
super withoutRedrawAt:lineNr put:aString. |
6641 | 4646 |
|
4647 |
"Modified: / 17-07-2019 / 07:29:18 / Claus Gittinger" |
|
4458 | 4648 |
! |
4649 |
||
4650 |
withoutRedrawInsertLine:aString before:lineNr |
|
4651 |
"insert the argument, aString before line lineNr; the string |
|
4652 |
becomes line lineNr; everything else is moved down; the view |
|
4653 |
is not redrawn" |
|
4654 |
||
4771 | 4655 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4656 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4657 |
! |
|
4658 |
||
4659 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4660 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4661 |
||
4662 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4663 |
self isReadOnly ifFalse:[ |
|
6641 | 4664 |
undoSupport isInTransaction ifTrue:[ |
4665 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
|
4666 |
]. |
|
4667 |
]. |
|
4668 |
||
4669 |
"Modified: / 17-07-2019 / 07:27:40 / Claus Gittinger" |
|
4458 | 4670 |
! |
4671 |
||
4672 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4673 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4674 |
||
4675 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4676 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4677 |
! |
|
4678 |
||
3890 | 4679 |
wrapLines |
4680 |
"wrap lines (insert line-break)" |
|
4681 |
||
4682 |
|lineLength answerString string| |
|
4683 |
||
4684 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4685 |
||
4686 |
self hasSelection ifFalse:[ |
|
6152 | 4687 |
self selectLine:cursorLine. |
3890 | 4688 |
]. |
4689 |
string := self selectionAsString. |
|
4690 |
string isEmptyOrNil ifTrue:[ |
|
6152 | 4691 |
Dialog information:(resources string:'Nothing selected.'). |
4692 |
^ self. |
|
3890 | 4693 |
]. |
4694 |
||
4695 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4696 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4697 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4698 |
lineLength < 1 ifTrue:[ |
6152 | 4699 |
lineLength := 1. |
3890 | 4700 |
]. |
4701 |
||
4702 |
self |
|
6152 | 4703 |
undoableDo:[ |
4704 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4705 |
||
4706 |
line := selectionStartLine. |
|
4707 |
col := selectionStartCol. |
|
4708 |
||
4709 |
self cutSelection. |
|
4710 |
self cursorLine:line col:col. |
|
4711 |
||
4712 |
lastGoodCol := col. |
|
4713 |
||
4714 |
inStream := string readStream. |
|
4715 |
[ inStream atEnd ] whileFalse:[ |
|
4716 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4717 |
word := CharacterWriteStream new. |
|
4718 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4719 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4720 |
self insertCharAtCursor:(Character cr). |
|
4721 |
col := 1. |
|
4722 |
] ifFalse:[ |
|
4723 |
col ~~ 1 ifTrue:[ |
|
4724 |
self insertStringAtCursor:' '. |
|
4725 |
col := col + 1. |
|
4726 |
] |
|
4727 |
]. |
|
4728 |
self insertStringAtCursor:word contents. |
|
4729 |
col := col + word size. |
|
4730 |
]. |
|
4731 |
] |
|
4732 |
info:'Wrap' |
|
4388 | 4733 |
|
4734 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4735 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4736 |
|
2752 | 4737 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4738 |
|
2952 | 4739 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4740 |
"delete characters from startCol to endCol in line lineNr" |
4741 |
||
6232 | 4742 |
|line lineSize newLine start stop |
6207 | 4743 |
prevWidth newWidth newCol| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4744 |
|
4673 | 4745 |
self unselect. |
4746 |
||
4747 |
cursorLine == lineNr ifTrue:[ |
|
5909 | 4748 |
cursorCol >= startCol ifTrue:[ |
4749 |
cursorCol >= endCol ifTrue:[ |
|
6207 | 4750 |
newCol := startCol. |
5909 | 4751 |
] ifFalse:[ |
6207 | 4752 |
newCol := cursorCol - (endCol - startCol + 1). |
5909 | 4753 |
"/ self assert:(cursorCol >= 0). |
6207 | 4754 |
newCol := newCol max:1. |
4755 |
]. |
|
4756 |
self setCursorCol:newCol. |
|
5909 | 4757 |
]. |
4673 | 4758 |
]. |
4759 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4760 |
line := self listAt:lineNr. |
827 | 4761 |
|
4673 | 4762 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4763 |
||
4764 |
lineSize := line size. |
|
4765 |
||
4766 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4767 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4768 |
||
4769 |
stop >= start ifTrue:[ |
|
5909 | 4770 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
4771 |
ifFalse:[ newLine := '' ]. |
|
4772 |
||
4773 |
stop == lineSize ifFalse:[ |
|
4774 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4775 |
newLine := line string species fromString:newLine. |
|
4776 |
]. |
|
4777 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
4778 |
]. |
|
4779 |
||
4780 |
(self trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4781 |
newLine := nil |
|
4782 |
]. |
|
4783 |
||
4784 |
prevWidth := self widthOfLine:lineNr. |
|
4785 |
||
4786 |
self basicListAt:lineNr put:newLine. |
|
4787 |
||
4788 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4789 |
"/ remember old width of this line, |
|
4790 |
"/ only clear widthOfWidestLine, if this lines |
|
4791 |
"/ length was (one of) the longest. |
|
4792 |
"/ avoids slow delete with huge texts. |
|
4793 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4794 |
||
6232 | 4795 |
"/ scroll left if required |
5909 | 4796 |
viewOrigin x > 0 ifTrue:[ |
4797 |
newWidth := self widthOfLine:lineNr. |
|
4798 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4799 |
self scrollHorizontalTo:(newWidth |
|
4800 |
- width |
|
4801 |
+ margin + margin |
|
4802 |
+ (gc font widthOf:' ')) |
|
4803 |
] |
|
4804 |
]. |
|
4805 |
self textChanged. |
|
4806 |
] ifFalse:[ |
|
4807 |
self textChanged "/ textChangedButNoSizeChange |
|
4808 |
]. |
|
4809 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4810 |
self invalidateLine:lineNr. |
|
4811 |
] ifFalse:[ |
|
4812 |
self redrawLine:lineNr from:start. |
|
4813 |
]. |
|
4673 | 4814 |
]. |
827 | 4815 |
|
4191 | 4816 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
6232 | 4817 |
"Modified (format): / 20-11-2017 / 20:17:55 / mawalch" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4818 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4819 |
|
2952 | 4820 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4821 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4822 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4823 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4824 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4825 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4826 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4827 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4828 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4829 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4830 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4831 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4832 |
startLineNr <= list size ifTrue:[ |
6152 | 4833 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4834 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4835 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4836 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4837 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4838 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4839 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4840 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4841 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4842 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4843 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4844 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4845 |
(firstLineShown >= nLines) ifTrue:[ |
6152 | 4846 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4847 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4848 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4849 |
|
4226 | 4850 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4851 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4852 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4853 |
|
2952 | 4854 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4855 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4856 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4857 |
|
2952 | 4858 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4859 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4860 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4861 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4862 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4863 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4864 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4865 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4866 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4867 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4868 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4869 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4870 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4871 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4872 |
|
2952 | 4873 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4874 |
"insert a single character at lineNr/colNr; |
827 | 4875 |
set emphasis to character at current position" |
4876 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4877 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4878 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4879 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
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 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4882 |
self splitLine:lineNr before:colNr. |
4883 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4884 |
]. |
827 | 4885 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4886 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4887 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4888 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4889 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4890 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4891 |
self st80EditMode ifFalse:[ |
5909 | 4892 |
(self trimBlankLines |
6469 | 4893 |
and:[colNr > (lineSize + 1) |
5909 | 4894 |
and:[aCharacter == Character space]]) ifTrue:[ |
4895 |
^ self |
|
4896 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4897 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4898 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4899 |
(lineSize == 0) ifTrue:[ |
5909 | 4900 |
newLine := aCharacter asString species new:colNr. |
4901 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4902 |
] ifFalse: [ |
5909 | 4903 |
(colNr > lineSize) ifTrue: [ |
4904 |
colNr == (lineSize +1) ifTrue:[ |
|
4905 |
attribute := line emphasisAt:lineSize |
|
4906 |
]. |
|
4907 |
newLine := line species new:colNr. |
|
4908 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4909 |
drawCharacterOnly := true |
|
4910 |
] ifFalse: [ |
|
4911 |
attribute := line emphasisAt:colNr. |
|
4912 |
newLine := line species new:(lineSize + 1). |
|
4913 |
||
4914 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4915 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
4916 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4917 |
]. |
827 | 4918 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4919 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
5909 | 4920 |
newLine := aCharacter asString species fromString:newLine. |
4921 |
line isText ifTrue:[ |
|
4922 |
newLine := newLine asText |
|
4923 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4924 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4925 |
newLine at:colNr put:aCharacter. |
827 | 4926 |
|
4927 |
attribute notNil ifTrue:[ |
|
5909 | 4928 |
newLine emphasisAt:colNr put:attribute. |
827 | 4929 |
]. |
4930 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4931 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4932 |
newLine := self withTabsExpanded:newLine. |
4933 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4934 |
]. |
827 | 4935 |
|
4771 | 4936 |
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
|
4937 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4938 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4939 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4940 |
self textChanged. |
6399 | 4941 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4942 |
shown ifTrue:[ |
5909 | 4943 |
"/ care for italic text - in this case, we must also |
4944 |
"/ redraw the character before the insertion in order |
|
4945 |
"/ to fix the slanted piece of the character. |
|
4946 |
"/ (but we must clip, to avoid destoying the character before) |
|
4947 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
4948 |
colNr > 1 ifTrue:[ |
|
4949 |
cursorVisibleLine notNil ifTrue:[ |
|
6031 | 4950 |
oldClip := self clippingBoundsOrNil. |
5909 | 4951 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
4952 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4953 |
||
4954 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4955 |
self invalidateLine:lineNr. |
|
4956 |
] ifFalse:[ |
|
4957 |
drawCharacterOnly ifTrue:[ |
|
6031 | 4958 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
5909 | 4959 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4960 |
] ifFalse:[ |
|
6031 | 4961 |
self clippingBounds:(x@y extent:((width - x) @ fontHeight)). |
5909 | 4962 |
self redrawLine:lineNr from:colNr-1 |
4963 |
]. |
|
6031 | 4964 |
self clippingBounds:oldClip. |
5909 | 4965 |
]. |
4966 |
]. |
|
4967 |
^ self. |
|
4968 |
]. |
|
4969 |
]. |
|
4970 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4971 |
self invalidateLine:lineNr. |
|
4972 |
] ifFalse:[ |
|
4973 |
drawCharacterOnly ifTrue:[ |
|
4974 |
self redrawLine:lineNr col:colNr |
|
4975 |
] ifFalse:[ |
|
4976 |
self redrawLine:lineNr from:colNr |
|
4977 |
] |
|
4978 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4979 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4980 |
|
4191 | 4981 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
6469 | 4982 |
"Modified: / 26-10-2018 / 18:18:17 / Claus Gittinger" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4983 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4984 |
|
4771 | 4985 |
basicListAt:lineNr put:newLine |
4986 |
"redefinable for special subclasses (with virtual list)" |
|
4987 |
||
4988 |
list at:lineNr put:newLine. |
|
4989 |
! |
|
4990 |
||
4991 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4992 |
"redefinable for special subclasses (with virtual list)" |
|
4993 |
||
4994 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4995 |
! |
|
4996 |
||
2952 | 4997 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4998 |
"merge line lineNr with line lineNr+1" |
4999 |
||
827 | 5000 |
|leftPart rightPart bothParts nextLineNr i| |
5001 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
5002 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
5909 | 5003 |
"/ empty list or beyond end of text |
5004 |
^ self |
|
827 | 5005 |
]. |
5006 |
leftPart := self listAt:lineNr. |
|
5007 |
||
5008 |
leftPart isNil ifTrue:[ |
|
5909 | 5009 |
leftPart := ''. |
6614 | 5010 |
self autoIndent ifTrue:[ |
6147 | 5011 |
"/ cg: only do this, if the second line has no indent |
5012 |
(i := self leftIndentOfLine:(lineNr+1)) == 0 ifTrue:[ |
|
5013 |
leftPart := String new:(self leftIndentForLine:lineNr) |
|
5909 | 5014 |
] |
5015 |
] |
|
827 | 5016 |
]. |
5017 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
5018 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
5019 |
||
5020 |
nextLineNr > (list size) ifFalse:[ |
|
5909 | 5021 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
5022 |
rightPart := '' |
|
5023 |
] ifFalse:[ |
|
5024 |
removeBlanks ifTrue:[ |
|
5025 |
rightPart := rightPart withoutLeadingSeparators. |
|
5026 |
] |
|
5027 |
]. |
|
5028 |
||
5029 |
bothParts := leftPart , rightPart. |
|
5030 |
(self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
5031 |
self basicListAt:lineNr put:bothParts. |
|
5032 |
self redrawLine:lineNr. |
|
5033 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5034 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5035 |
|
6147 | 5036 |
"Created: / 09-09-1997 / 09:27:38 / cg" |
5037 |
"Modified: / 25-04-2017 / 12:41:20 / cg" |
|
6614 | 5038 |
"Modified: / 26-06-2019 / 23:19:41 / Claus Gittinger" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5039 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5040 |
|
2952 | 5041 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5042 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5043 |
|
5045 | 5044 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5045 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5046 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5047 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5048 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 5049 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5050 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5051 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
5052 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5053 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5054 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5055 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
5056 |
|
5909 | 5057 |
(self trimBlankLines |
6469 | 5058 |
and:[colNr > (lineSize + 1) |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
5059 |
and:[aCharacter == Character space]]) ifTrue:[ |
5909 | 5060 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5061 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
5062 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5063 |
(lineSize == 0) ifTrue:[ |
5909 | 5064 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5065 |
] ifFalse: [ |
5909 | 5066 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5067 |
newLineSpecies := aCharacter stringSpecies |
|
5068 |
] ifFalse:[ |
|
5069 |
newLineSpecies := line species |
|
5070 |
]. |
|
5071 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
5072 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5073 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5074 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
5075 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 5076 |
newLine := self withTabsExpanded:newLine. |
5077 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
5078 |
]. |
4771 | 5079 |
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
|
5080 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 5081 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5082 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5083 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5084 |
shown ifTrue:[ |
5909 | 5085 |
gc font hasOverlappingCharacters ifTrue:[ |
5086 |
self invalidateLine:lineNr. |
|
5087 |
] ifFalse:[ |
|
5088 |
drawCharacterOnly ifTrue:[ |
|
5089 |
self redrawLine:lineNr col:colNr |
|
5090 |
] ifFalse:[ |
|
5091 |
self redrawLine:lineNr from:colNr |
|
5092 |
] |
|
5093 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5094 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
5095 |
|
4190 | 5096 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 5097 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
6469 | 5098 |
"Modified: / 26-10-2018 / 18:21:21 / Claus Gittinger" |
105 | 5099 |
! |
5100 |
||
3235 | 5101 |
basicReplaceString:aString atLine:lineNr col:colNr |
5102 |
"replace multiple characters starting at lineNr/colNr. |
|
5103 |
This is not prepared to encounter special chars (except TAB) |
|
5104 |
in the string." |
|
5105 |
||
5045 | 5106 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 5107 |
|
5108 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
5109 |
||
5110 |
self checkForExistingLine:lineNr. |
|
5111 |
line := list at:lineNr. |
|
5112 |
lineSize := line size. |
|
5113 |
||
5114 |
endCol := colNr + aString size - 1. |
|
5115 |
(lineSize == 0) ifTrue:[ |
|
6152 | 5116 |
newLine := aString species new:endCol. |
3235 | 5117 |
] ifFalse: [ |
6152 | 5118 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5119 |
newLineSpecies := aString stringSpecies |
|
5120 |
] ifFalse:[ |
|
5121 |
newLineSpecies := line species |
|
5122 |
]. |
|
5123 |
||
5124 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
5125 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 5126 |
]. |
5127 |
newLine replaceFrom:colNr with:aString. |
|
5128 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 5129 |
newLine := self withTabsExpanded:newLine. |
3235 | 5130 |
]. |
4771 | 5131 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 5132 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 5133 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 5134 |
]. |
5135 |
self textChanged. |
|
5136 |
shown ifTrue:[ |
|
6152 | 5137 |
gc font hasOverlappingCharacters ifTrue:[ |
5138 |
self invalidateLine:lineNr. |
|
5139 |
] ifFalse:[ |
|
5140 |
self redrawLine:lineNr from:colNr |
|
5141 |
] |
|
3235 | 5142 |
] |
5143 |
||
4190 | 5144 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 5145 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 5146 |
! |
5147 |
||
2952 | 5148 |
basicSplitLine:lineNr before:colNr |
5149 |
"split the line linNr before colNr; the right part (from colNr) |
|
5150 |
is cut off and inserted after lineNr; the view is redrawn" |
|
5151 |
||
3160 | 5152 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 5153 |
srcY "{ Class: SmallInteger }" | |
5154 |
||
3027 | 5155 |
list isNil ifTrue:[ ^ self ]. |
5156 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
5157 |
||
5158 |
(colNr == 1) ifTrue:[ |
|
5909 | 5159 |
self nonUndoableDo:[ |
5160 |
self insertLine:nil before:lineNr. |
|
5161 |
]. |
|
5162 |
^ self |
|
3027 | 5163 |
]. |
5164 |
||
5165 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5166 |
line notNil ifTrue:[ |
5909 | 5167 |
lineSize := line size. |
5168 |
(colNr <= lineSize) ifTrue:[ |
|
5169 |
rightRest := line copyFrom:colNr to:lineSize. |
|
5170 |
(colNr > 1) ifTrue:[ |
|
5171 |
leftRest := line copyTo:(colNr - 1) |
|
5172 |
] |
|
5173 |
] ifFalse:[ |
|
5174 |
leftRest := line |
|
5175 |
] |
|
3027 | 5176 |
]. |
6400 | 5177 |
"/ -- debug: self windowGroup sensor hasDamage ifTrue:[self halt]. |
5178 |
||
3027 | 5179 |
leftRest notNil ifTrue:[ |
6400 | 5180 |
(self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]. |
5181 |
]. |
|
5182 |
leftRest = (self listAt:lineNr) ifFalse:[ |
|
5183 |
self basicListAt:lineNr put:leftRest. |
|
5184 |
]. |
|
5185 |
"/ -- debug: (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt]. |
|
5186 |
||
5187 |
"/ -- debug: TraceDamage := self. |
|
5188 |
||
3027 | 5189 |
self nonUndoableDo:[ |
5909 | 5190 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 5191 |
]. |
6400 | 5192 |
|
5193 |
"/ Delay waitForSeconds:1. |
|
5194 |
"/ (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt]. |
|
5195 |
"/ TraceDamage := nil. |
|
5196 |
||
3027 | 5197 |
visLine := self listLineToVisibleLine:(lineNr). |
5198 |
visLine notNil ifTrue:[ |
|
5909 | 5199 |
w := self widthForScrollBetween:lineNr |
5200 |
and:(firstLineShown + nLinesShown). |
|
5201 |
srcY := topMargin + (visLine * fontHeight). |
|
5202 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
5203 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
6306 | 5204 |
mustWait := self catchExpose. |
5909 | 5205 |
self |
5206 |
copyFrom:self |
|
5207 |
x:textStartLeft y:srcY |
|
5208 |
toX:textStartLeft y:(srcY + fontHeight) |
|
5209 |
width:w |
|
5210 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
5211 |
async:true. |
|
5212 |
]. |
|
5213 |
self redrawLine:lineNr. |
|
5214 |
self redrawLine:(lineNr + 1). |
|
6400 | 5215 |
mustWait ifTrue:[self waitForExpose]. |
3027 | 5216 |
]. |
5217 |
widthOfWidestLine := nil. "/ unknown |
|
5218 |
self textChanged. |
|
2952 | 5219 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5220 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
6306 | 5221 |
"Modified: / 19-04-2018 / 12:21:52 / stefan" |
6400 | 5222 |
"Modified: / 22-08-2018 / 12:56:24 / Claus Gittinger" |
2952 | 5223 |
! |
5224 |
||
2954 | 5225 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 5226 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
5227 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5228 |
because the text might have been pasted from an alien view." |
|
2954 | 5229 |
|
5230 |
|newLine newLines nLines| |
|
5231 |
||
5232 |
nLines := end - start + 1. |
|
5233 |
newLines := Array new:(lines size). |
|
5234 |
start to:end do:[:index | |
|
6152 | 5235 |
newLine := lines at:index. |
5236 |
newLine notNil ifTrue:[ |
|
5237 |
newLine isString ifTrue:[ |
|
5238 |
newLine isBlank ifTrue:[ |
|
5239 |
newLine := nil |
|
5240 |
] ifFalse:[ |
|
5241 |
(newLine includes:(Character tab)) ifTrue:[ |
|
5242 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
5243 |
] |
|
5244 |
] |
|
5245 |
] |
|
5246 |
]. |
|
5247 |
newLines at:index put:newLine |
|
2954 | 5248 |
]. |
5249 |
list isNil ifTrue: [ |
|
6152 | 5250 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 5251 |
] ifFalse: [ |
6152 | 5252 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 5253 |
]. |
5254 |
||
5255 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 5256 |
overlapping copy - if it didn't, we had to use:" |
5257 |
" |
|
5258 |
index := list size. |
|
5259 |
[index > lineNr] whileTrue: [ |
|
6152 | 5260 |
pIndex := index - 1. |
5261 |
list at:index put:(list at:pIndex). |
|
5262 |
index := pIndex |
|
2954 | 5263 |
]. |
5264 |
" |
|
5265 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
5266 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
5267 |
self contentsChanged |
|
5268 |
||
4328 | 5269 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 5270 |
! |
5271 |
||
5272 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 5273 |
"insert aString (which has no crs) at lineNr/colNr. |
5274 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5275 |
because the text might have been pasted from an alien view." |
|
2954 | 5276 |
|
4360 | 5277 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 5278 |
|
4623 | 5279 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 5280 |
|
5281 |
strLen := aString size. |
|
5282 |
self checkForExistingLine:lineNr. |
|
5283 |
||
5284 |
stringType := aString string species. |
|
5285 |
isText := aString isText. |
|
5286 |
line := list at:lineNr. |
|
5287 |
||
5288 |
line notNil ifTrue:[ |
|
6152 | 5289 |
lineSize := line size. |
5290 |
line isString ifFalse:[ |
|
5291 |
stringType := line species |
|
5292 |
] ifTrue:[ |
|
5293 |
lineCharWidth := line bitsPerCharacter. |
|
5294 |
stringCharWidth := aString bitsPerCharacter. |
|
5295 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
5296 |
stringType := line string species |
|
5297 |
] ifFalse:[ |
|
5298 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
5299 |
stringType := aString string species |
|
5300 |
] |
|
5301 |
]. |
|
5302 |
line isText ifTrue:[ isText := true ] |
|
5303 |
]. |
|
2954 | 5304 |
] ifFalse:[ |
6152 | 5305 |
lineSize := 0 |
2954 | 5306 |
]. |
5307 |
||
5308 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
6152 | 5309 |
newLine := aString |
2954 | 5310 |
] ifFalse:[ |
6152 | 5311 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
5312 |
sz := colNr + strLen - 1 |
|
5313 |
] ifFalse:[ |
|
5314 |
sz := lineSize + strLen |
|
5315 |
]. |
|
5316 |
||
5317 |
newLine := stringType new:sz. |
|
5318 |
isText ifTrue:[ |
|
5319 |
newLine := Text string:newLine |
|
5320 |
]. |
|
5321 |
||
5322 |
(lineSize ~~ 0) ifTrue: [ |
|
5323 |
(colNr > lineSize) ifTrue: [ |
|
5324 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
5325 |
] ifFalse: [ |
|
5326 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
5327 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
5328 |
] |
|
5329 |
]. |
|
5330 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 5331 |
]. |
5332 |
||
5333 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 5334 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 5335 |
]. |
5336 |
||
4771 | 5337 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 5338 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 5339 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 5340 |
]. |
5341 |
self textChanged. |
|
5342 |
||
4360 | 5343 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5344 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5345 |
|
2752 | 5346 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5347 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5348 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5349 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5350 |
|
5216 | 5351 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 5352 |
dragIsActive := false. |
5353 |
||
5787 | 5354 |
completionSupport notNil ifTrue:[ |
6152 | 5355 |
"/ also give that guy a chance to close its popup view |
5356 |
completionSupport buttonPress:button x:x y:y |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5357 |
]. |
4609 | 5358 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
5359 |
cursorShown ifTrue: [ |
6152 | 5360 |
self drawCursor |
5787 | 5361 |
]. |
5362 |
||
5363 |
"On X11, be nice and paste PRIMARY when middle click. |
|
4420 | 5364 |
Note, that middle button on X11 is translated to button |
5365 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
6649 | 5366 |
(button == #paste and:[device isX11Platform]) ifTrue:[ |
6313 | 5367 |
"change the cursor position..." |
5368 |
super buttonPress:1 x:x y:y. |
|
5369 |
self buttonRelease:1 x:x y:y. |
|
6152 | 5370 |
self undoableDo:[ |
5371 |
self paste: (self getClipboardText:#selection). |
|
5372 |
]. |
|
6313 | 5373 |
^ self. |
4420 | 5374 |
]. |
5375 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5376 |
(button == 1) ifTrue:[ |
6152 | 5377 |
self hideCursor |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5378 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5379 |
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
|
5380 |
|
4420 | 5381 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
5382 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6313 | 5383 |
"Modified (format): / 27-04-2018 / 13:35:09 / stefan" |
6649 | 5384 |
"Modified: / 25-07-2019 / 12:30:42 / Claus Gittinger" |
121 | 5385 |
! |
5386 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5387 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5388 |
"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
|
5389 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
5390 |
|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
|
5391 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5392 |
(button == 1) ifTrue:[ |
5882 | 5393 |
typeOfSelection := nil. |
5394 |
||
5395 |
dragIsActive ifTrue:[ |
|
5396 |
self unselect |
|
5397 |
]. |
|
5398 |
selectionStartLine isNil ifTrue:[ |
|
5399 |
clickCol notNil ifTrue:[ |
|
5400 |
self cursorMovementAllowed ifTrue:[ |
|
5401 |
newCursorCol := clickCol. |
|
5402 |
||
5403 |
cursorType ~~ #block ifTrue:[ |
|
5404 |
clickPos notNil ifTrue:[ |
|
5405 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
6096 | 5406 |
"/ (i.e. if it's an ibeam). |
5882 | 5407 |
"/ adjust clickCol if the user clicked in the right third of a character. |
5408 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
5409 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
5410 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
5411 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
5412 |
]. |
|
5413 |
]. |
|
5414 |
"/ the following fixes the ugly select behavior when double clicking on |
|
5415 |
"/ a partially visible last line (where the first click used to |
|
5416 |
"/ scroll the text so that the second click was handled on another |
|
5417 |
"/ line. An alternative (possibly better) solution would be to |
|
5418 |
"/ remember the last click position and adjust in the double click |
|
5419 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
5420 |
"/ Time will show, if this hack works. |
|
5421 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
|
5422 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
5423 |
Processor |
|
5424 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
5425 |
after:0.3 seconds. |
|
5426 |
] ifFalse:[ |
|
5427 |
self cursorLine:clickLine col:newCursorCol. |
|
5428 |
]. |
|
5429 |
]. |
|
5430 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
|
5431 |
list notEmptyOrNil ifTrue:[ |
|
5432 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
|
5433 |
(clickLine >= list size) ifTrue:[ |
|
5434 |
(clickLine > (self list size + 2) |
|
5435 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
|
5436 |
self selectAll |
|
5437 |
]. |
|
5438 |
]. |
|
5439 |
] |
|
5440 |
] |
|
5441 |
] |
|
5442 |
] |
|
5443 |
] ifFalse:[ |
|
5444 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
|
5445 |
]. |
|
5446 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5447 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5448 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
5449 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5450 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
6096 | 5451 |
"Modified (format): / 13-02-2017 / 20:10:18 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5452 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5453 |
|
2580 | 5454 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5455 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5456 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5457 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5458 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5459 |
self changeTypeOfSelectionTo:nil. |
2580 | 5460 |
|
5461 |
(key == #CursorRight) ifTrue:[ |
|
6137 | 5462 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5463 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5464 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
5465 |
expandingTop := false. |
|
5466 |
self validateNewSelection. |
|
5467 |
self setPrimarySelection. |
|
5468 |
self selectionChanged. |
|
5469 |
self redrawLine:selectionStartLine. |
|
5470 |
^ self. |
|
5471 |
]. |
|
5472 |
||
5473 |
selectionStartLine notNil ifTrue:[ |
|
5474 |
self cursorMovementAllowed ifTrue:[ |
|
5475 |
"/ |
|
5476 |
"/ treat the whole selection as cursor |
|
5477 |
"/ |
|
5478 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5479 |
selectionEndCol == 0 ifTrue:[ |
|
5480 |
selectionEndCol := 1. |
|
5481 |
]. |
|
5482 |
self setCursorCol:selectionEndCol. |
|
5483 |
shifted ifTrue:[ |
|
5484 |
self expandSelectionRight. |
|
5485 |
^ self |
|
5486 |
]. |
|
5487 |
self unselect; makeCursorVisible. |
|
5488 |
"/ cursorCol == 1 ifTrue:[^ self]. |
|
5489 |
]. |
|
5490 |
]. |
|
5491 |
self cursorRight. |
|
5492 |
^ self |
|
2580 | 5493 |
]. |
5494 |
(key == #CursorDown) ifTrue:[ |
|
6137 | 5495 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5496 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
5497 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
5498 |
selectionEndCol == 1 ifTrue:[ |
|
5499 |
selectionEndCol := 0. |
|
5500 |
]. |
|
5501 |
self validateNewSelection. |
|
5502 |
self selectionChanged. |
|
5503 |
self redrawLine:selectionStartLine. |
|
5504 |
expandingTop := false. |
|
5505 |
self redrawLine:selectionEndLine. |
|
5506 |
^ self |
|
5507 |
]. |
|
5508 |
||
5509 |
selectionStartLine notNil ifTrue:[ |
|
5510 |
self cursorMovementAllowed ifTrue:[ |
|
5511 |
"/ |
|
5512 |
"/ treat the whole selection as cursor |
|
5513 |
"/ |
|
5514 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5515 |
self setCursorCol:selectionStartCol. |
|
5516 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
|
5517 |
self setCursorCol:1. |
|
5518 |
self setCursorLine:(cursorLine - 1). |
|
5519 |
]. |
|
5520 |
self makeCursorVisible. |
|
5521 |
||
5522 |
shifted ifTrue:[ |
|
5523 |
clickLine := cursorLine. |
|
5524 |
clickCol := cursorCol. |
|
5525 |
self expandSelectionDown. |
|
5526 |
^ self |
|
5527 |
]. |
|
5528 |
self unselect. |
|
5529 |
]. |
|
5530 |
]. |
|
5531 |
||
5532 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
|
5533 |
self cursorDown:n. |
|
5534 |
"/ |
|
5535 |
"/ flush keyboard to avoid runaway cursor |
|
5536 |
"/ |
|
5537 |
self sensor flushKeyboardFor:self. |
|
5538 |
^ self |
|
2580 | 5539 |
]. |
5540 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
6137 | 5541 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5542 |
expandingTop := true. |
|
5543 |
key == #CursorLeft ifTrue:[ |
|
5544 |
cursorCol > 1 ifTrue:[ |
|
5545 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5546 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
5547 |
selectionStartCol := cursorCol-1. |
|
5548 |
self validateNewSelection. |
|
5549 |
self selectionChanged. |
|
5550 |
self redrawLine:selectionStartLine. |
|
5551 |
^ self |
|
5552 |
] |
|
5553 |
] ifFalse:[ |
|
5554 |
cursorLine > 1 ifTrue:[ |
|
5555 |
selectionEndLine := clickStartLine := cursorLine. |
|
5556 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
5557 |
selectionStartLine := cursorLine - 1. |
|
5558 |
selectionEndCol == 1 ifTrue:[ |
|
5559 |
selectionEndCol := 0. |
|
5560 |
]. |
|
5561 |
self validateNewSelection. |
|
5562 |
self selectionChanged. |
|
5563 |
self redrawFromLine:selectionStartLine to:cursorLine. |
|
5564 |
^ self |
|
5565 |
] |
|
5566 |
] |
|
5567 |
]. |
|
5568 |
||
5569 |
selectionStartLine notNil ifTrue:[ |
|
5570 |
self cursorMovementAllowed ifTrue:[ |
|
5571 |
"/ |
|
5572 |
"/ treat the whole selection as cursor |
|
5573 |
"/ |
|
5574 |
self setCursorLine:selectionStartLine. |
|
5575 |
self setCursorCol:selectionStartCol. |
|
5576 |
(key == #CursorLeft) ifTrue:[ |
|
5577 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
5578 |
]. |
|
5579 |
self makeCursorVisible. |
|
5580 |
||
5581 |
shifted ifTrue:[ |
|
5582 |
(key == #CursorUp) ifTrue:[ |
|
5583 |
clickLine := cursorLine. |
|
5584 |
self expandSelectionUp. |
|
5585 |
] ifFalse:[ |
|
5586 |
self expandSelectionLeft. |
|
5587 |
]. |
|
5588 |
^ self |
|
5589 |
]. |
|
5590 |
self unselect. |
|
5591 |
]. |
|
5592 |
]. |
|
5593 |
(key == #CursorLeft) ifTrue:[ |
|
5594 |
self cursorLeft. ^self |
|
5595 |
]. |
|
5596 |
(key == #CursorUp) ifTrue:[ |
|
5597 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
|
5598 |
self cursorUp:n. |
|
5599 |
"/ |
|
5600 |
"/ flush keyboard to avoid runaway cursor |
|
5601 |
"/ |
|
5602 |
self sensor flushKeyboardFor:self. |
|
5603 |
^ self |
|
5604 |
]. |
|
2580 | 5605 |
]. |
4420 | 5606 |
|
5607 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6137 | 5608 |
"Modified: / 19-03-2017 / 10:08:54 / cg" |
2580 | 5609 |
! |
5610 |
||
2952 | 5611 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5612 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5613 |
|
4521 | 5614 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
6147 | 5615 |
#Replace #Undo #Redo #Accept |
5616 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
|
5617 |
#DeleteSpaces #Join |
|
5618 |
#SearchMatchingParent #SelectMatchingParents |
|
5619 |
#SelectWord #ExpandSelectionByWord |
|
5620 |
#SelectToEnd #SelectFromBeginning |
|
5621 |
#SelectLine #ExpandSelectionByLine |
|
5622 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
5623 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5624 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5625 |
#GotoLine #BeginOfText #EndOfText |
|
5626 |
#InsertLine #DeleteLine |
|
6354 | 5627 |
#SelectLineFromBeginning #SelectToLineEnd |
6147 | 5628 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
5629 |
#OpenSpecialCharacterWindow #InsertUUID |
|
5630 |
#'F*' #'f*')> |
|
2017 | 5631 |
|
6610 | 5632 |
|fKeyMacros shiftPressed ctrlPressed event macroName |
6702 | 5633 |
currentUserPrefs rawKey| |
4818 | 5634 |
|
5635 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5636 |
|
6702 | 5637 |
completionSupport isNil ifTrue:[ |
5638 |
(currentUserPrefs immediateCodeCompletion |
|
5639 |
or:[currentUserPrefs codeCompletionOnControlKey |
|
5640 |
or:[currentUserPrefs codeCompletionOnTabKey]] |
|
5641 |
) ifTrue:[ |
|
6147 | 5642 |
self initializeCompletionSupport. |
5643 |
]. |
|
5787 | 5644 |
]. |
5645 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5646 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5647 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5648 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5649 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5650 |
completionSupport notNil ifTrue:[ |
6147 | 5651 |
completionSupport stopCompletionProcess. |
6702 | 5652 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:[ |
5653 |
"event handled & eaten" |
|
5654 |
^ self |
|
5655 |
]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5656 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5657 |
|
4818 | 5658 |
key isSymbol ifTrue:[ |
6147 | 5659 |
(device modifierKeys includes:key) ifFalse:[ |
5660 |
lastReplacementInfo stillCollectingInput:false. |
|
5661 |
] |
|
4818 | 5662 |
]. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5663 |
(key == #LearnKeyboardMacro) ifTrue:[ |
6147 | 5664 |
lastReplacementInfo stillCollectingInput:false. |
5665 |
self toggleLearnMode. |
|
5666 |
^ self |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5667 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5668 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
6147 | 5669 |
lastReplacementInfo stillCollectingInput:false. |
5670 |
self executeLearnedKeyboardMacro. |
|
5671 |
^ self. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5672 |
]. |
3799 | 5673 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5674 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5675 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5676 |
self learnMode ifTrue:[ |
6390 | 5677 |
event := WindowGroup lastEvent. |
6147 | 5678 |
learnedMacro add:event. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5679 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5680 |
|
4238 | 5681 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
6147 | 5682 |
"the macro named key exists" |
5683 |
^ self |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5684 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5685 |
|
4482 | 5686 |
key isSymbol ifFalse:[ |
6147 | 5687 |
"the usual case: key is a character, but maybe a string also (in X11)" |
5688 |
self handleNonCommandKey:key. |
|
5689 |
^ self |
|
4482 | 5690 |
]. |
5691 |
||
5692 |
event isNil ifTrue:[ |
|
6390 | 5693 |
event := WindowGroup lastEvent. |
4482 | 5694 |
]. |
5695 |
shiftPressed := event hasShift. |
|
5696 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5697 |
rawKey := event rawKey. |
4482 | 5698 |
|
5133 | 5699 |
key == #InsertUUID ifTrue:[ |
6147 | 5700 |
self insertUUID. |
5701 |
^ self. |
|
5133 | 5702 |
]. |
5703 |
||
4253 | 5704 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
6147 | 5705 |
self deleteWordBeforeCursor. |
5706 |
^ self. |
|
4253 | 5707 |
]. |
5708 |
||
6697 | 5709 |
(rawKey == #BackSpace or:[key == #BackSpace or:[key == #BasicBackspace]]) ifTrue:[ |
6147 | 5710 |
selectionStartLine notNil ifTrue:[ |
5711 |
((key == #BasicBackspace) |
|
5712 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
|
5713 |
ifTrue:[ |
|
5714 |
self deleteSelection. |
|
5715 |
] ifFalse: [ |
|
5716 |
self copyAndDeleteSelection. |
|
5717 |
]. |
|
5718 |
] ifFalse:[ |
|
5719 |
self makeCursorVisible. |
|
4609 | 5720 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
5721 |
"/ self deleteWordBeforeCursor. |
|
5722 |
"/ ] ifFalse:[ |
|
6147 | 5723 |
self deleteCharBeforeCursor. |
6399 | 5724 |
|
5725 |
self maybeShowMatchingParenthesisFor:(self characterBeforeCursor). |
|
5726 |
||
4609 | 5727 |
"/ ]. |
6147 | 5728 |
]. |
6702 | 5729 |
completionSupport notNil ifTrue:[ |
5730 |
completionSupport postKeyPress:key |
|
6147 | 5731 |
]. |
5732 |
^ self |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5733 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5734 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5735 |
(key == #ToggleAutoIndent) ifTrue:[ |
6614 | 5736 |
self autoIndent:(self autoIndent not). |
6147 | 5737 |
^ self. |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5738 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5739 |
|
3235 | 5740 |
key == #ToggleInsertMode ifTrue:[ |
6147 | 5741 |
self insertMode:(editMode value == EditMode insertMode) not. |
5742 |
^ self. |
|
3160 | 5743 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5744 |
|
4162 | 5745 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
6147 | 5746 |
CharacterSetView notNil ifTrue:[ |
5747 |
self specialCharacters. |
|
5748 |
^ self. |
|
5749 |
] |
|
4162 | 5750 |
]. |
5751 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5752 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5753 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5754 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5755 |
Fn pastes a key-sequence (but only if not overlayed with |
6147 | 5756 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5757 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5758 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5759 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5760 |
(key at:1) asLowercase == $f ifTrue:[ |
6147 | 5761 |
(('[fF][0-9]' match:key) |
5762 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5763 |
shiftPressed ifFalse:[ |
|
5764 |
fKeyMacros := currentUserPrefs functionKeySequences. |
|
5765 |
fKeyMacros notNil ifTrue:[ |
|
5766 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5767 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5768 |
^ self |
|
5769 |
] |
|
5770 |
] |
|
5771 |
] |
|
5772 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5773 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5774 |
|
2506 | 5775 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
6147 | 5776 |
self parenthizeSelectionWith:$( and:$). |
5777 |
^ self. |
|
2506 | 5778 |
]. |
5779 |
(key == #'Ctrl2') ifTrue:[ |
|
6147 | 5780 |
self parenthizeSelectionWith:$" and:$". |
5781 |
^ self. |
|
2506 | 5782 |
]. |
5783 |
(key == #'Ctrl#') ifTrue:[ |
|
6147 | 5784 |
self parenthizeSelectionWith:$' and:$'. |
5785 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5786 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5787 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
6147 | 5788 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
5789 |
^ self. |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5790 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5791 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5792 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5793 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5794 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5795 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5796 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5797 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5798 |
|
3542 | 5799 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5800 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5801 |
(key == #ExpandSelectionByWord) ifTrue:[ |
6147 | 5802 |
self makeCursorVisible. |
5803 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5804 |
^ self |
|
4707 | 5805 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5806 |
(key == #SelectWord) ifTrue:[ |
6147 | 5807 |
self makeCursorVisible. |
5808 |
self selectWordUnderCursor. |
|
5809 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5810 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5811 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5812 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5813 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5814 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5815 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5816 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5817 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5818 |
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
|
5819 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5820 |
(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
|
5821 |
(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
|
5822 |
(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
|
5823 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5824 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5825 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5826 |
(key == #BeginOfLine) ifTrue:[ |
6147 | 5827 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5828 |
"/ some shifted key to selectFromBeginOfLine |
|
5829 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5830 |
"/ see code below. |
|
5831 |
false "shiftPressed" ifTrue: [ |
|
5832 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5833 |
"/ self unselect. |
|
5834 |
"/ self cursorHome. |
|
5835 |
"Jan's modification" |
|
5836 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
|
5837 |
"/ Jan's modification modified by his own request ;-)) |
|
5838 |
self selectFromBeginOfLine. |
|
5839 |
] ifFalse: [ |
|
5840 |
self unselect. |
|
5841 |
ctrlPressed ifTrue:[ |
|
5842 |
self cursorHome. |
|
5843 |
] ifFalse:[ |
|
5844 |
self cursorToBeginOfLine. |
|
5845 |
] |
|
5846 |
]. |
|
5847 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5848 |
]. |
5226 | 5849 |
(key == #BSelectFromeginOfLine) ifTrue:[ |
6147 | 5850 |
self selectFromBeginOfLine. |
5851 |
^ self |
|
5226 | 5852 |
]. |
5853 |
||
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5854 |
(key == #EndOfLine) ifTrue:[ |
6147 | 5855 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5856 |
"/ some shifted key to selectFromBeginOfLine |
|
5857 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5858 |
"/ see code below. |
|
5859 |
false "shiftPressed" ifTrue:[ |
|
5860 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5861 |
"/ self unselect. |
|
5862 |
"/ self cursorToBottom |
|
5863 |
" Jan's modification" |
|
5864 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5865 |
"/ Jan's modification modified by his own request ;-)) |
|
5866 |
self selectToEndOfLine. |
|
5867 |
] ifFalse:[ |
|
5868 |
self unselect. |
|
5869 |
ctrlPressed ifTrue:[ |
|
5870 |
self cursorToBottom |
|
5871 |
] ifFalse:[ |
|
5872 |
self cursorToEndOfLine. |
|
5873 |
] |
|
5874 |
]. |
|
5875 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5876 |
]. |
5226 | 5877 |
|
5878 |
(key == #SelectToEndOfLine) ifTrue:[ |
|
6147 | 5879 |
self selectToEndOfLine. |
5880 |
^ self |
|
5226 | 5881 |
]. |
5882 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5883 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5884 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5885 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5886 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5887 |
|
5119 | 5888 |
(rawKey == #CursorRight |
5889 |
or:[rawKey == #CursorDown |
|
5890 |
or:[rawKey == #CursorLeft |
|
5891 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
6147 | 5892 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
5893 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5894 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5895 |
|
5119 | 5896 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
6147 | 5897 |
self unselect. self cursorReturn. |
5898 |
^ self |
|
3257 | 5899 |
]. |
5900 |
||
5901 |
(key == #Return) ifTrue:[ |
|
6665 | 5902 |
self handleReturnPressed:shiftPressed. |
6147 | 5903 |
^ self |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5904 |
]. |
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
|
5905 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5906 |
(key == #NonInsertingTab) ifTrue:[ |
6150 | 5907 |
((rawKey == #ShiftTab) |
5908 |
and:[self hasSelection |
|
5909 |
and:[selectStyle == #line]] |
|
5910 |
) ifTrue:[ |
|
5911 |
self executekeyboardMacroNamed:#UndentBy4. |
|
5912 |
^ self. |
|
5913 |
]. |
|
6147 | 5914 |
self unselect. self cursorTab. |
5915 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5916 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5917 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
6147 | 5918 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5919 |
||
5920 |
self hasSelection ifTrue:[ |
|
5921 |
selectStyle == #line ifTrue:[ |
|
5922 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
|
5923 |
macroName := #IndentBy4. |
|
5924 |
] ifFalse:[ |
|
5925 |
macroName := #UndentBy4. |
|
5926 |
]. |
|
5927 |
macroName notNil ifTrue:[ |
|
5928 |
self executekeyboardMacroNamed:macroName. |
|
6150 | 5929 |
^ self. |
6147 | 5930 |
]. |
5931 |
] |
|
5932 |
]. |
|
5933 |
||
5934 |
self unselect. |
|
5935 |
(key == #Tab) ifTrue:[ |
|
5936 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5937 |
self cursorTab. |
|
5938 |
^ self |
|
5939 |
]. |
|
5940 |
self insertTabAtCursor. |
|
5941 |
^ self |
|
5942 |
]. |
|
5943 |
self cursorBacktab. |
|
5944 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5945 |
]. |
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
|
5946 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5947 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5948 |
(rawKey == #Delete) ifTrue:[ |
6147 | 5949 |
shiftPressed ifTrue:[ |
5950 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5951 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5952 |
self makeCursorVisible. |
|
5953 |
self deleteCharAtCursor. |
|
5954 |
]. |
|
5955 |
^ self |
|
5956 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5957 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5958 |
|
5119 | 5959 |
(rawKey == #Delete |
870 | 5960 |
or:[key == #BasicDelete]) ifTrue:[ |
6147 | 5961 |
selectionStartLine notNil ifTrue:[ |
4130 | 5962 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5963 |
"/ To remove text repetetively, use Cut instead. |
|
5964 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5965 |
"/ lastReplacementInfo lastReplacement: nil. |
|
6147 | 5966 |
((key == #BasicDelete) |
5967 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
|
5968 |
self deleteSelection. |
|
5969 |
] ifFalse:[ |
|
5970 |
self copyAndDeleteSelection. |
|
5971 |
]. |
|
5972 |
^ self |
|
5973 |
]. |
|
5974 |
self makeCursorVisible. |
|
5975 |
self deleteCharAtCursor. |
|
5976 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5977 |
]. |
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
|
5978 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5979 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
6147 | 5980 |
self unselect. |
5981 |
cursorVisibleLine == 1 ifTrue:[ |
|
5982 |
self cursorHome. |
|
5983 |
] ifFalse:[ |
|
5984 |
self cursorToFirstVisibleLine |
|
5985 |
]. |
|
5986 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5987 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5988 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
6147 | 5989 |
self unselect. |
5990 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5991 |
self cursorToBottom. |
|
5992 |
] ifFalse:[ |
|
5993 |
self cursorToLastVisibleLine |
|
5994 |
]. |
|
5995 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5996 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5997 |
((key == #Escape) |
3257 | 5998 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
6147 | 5999 |
self makeCursorVisible. |
6000 |
self unselect. self selectCursorLineFromBeginning. |
|
6001 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6002 |
]. |
6354 | 6003 |
(key == #SelectToLineEnd) ifTrue:[ |
6004 |
self makeCursorVisible. |
|
6005 |
self unselect. self selectCursorLineToEnd. |
|
6006 |
^ self |
|
6007 |
]. |
|
3257 | 6008 |
(key == #SelectLine) ifTrue:[ |
6147 | 6009 |
self makeCursorVisible. |
6010 |
self unselect. self selectCursorLine. |
|
6011 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6012 |
]. |
3257 | 6013 |
(key == #ExpandSelectionByLine) ifTrue:[ |
6147 | 6014 |
"/ self makeCursorVisible. |
6015 |
self selectExpandCursorLine. |
|
6016 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6017 |
]. |
3257 | 6018 |
(key == #DeleteLine) ifTrue:[ |
6147 | 6019 |
self makeCursorVisible. |
6020 |
self unselect. self deleteCursorLine. |
|
6021 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6022 |
]. |
3257 | 6023 |
(key == #InsertLine) ifTrue:[ |
6147 | 6024 |
self makeCursorVisible. |
6025 |
self unselect. self insertLine:nil before:cursorLine. |
|
6026 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6027 |
]. |
3781 | 6028 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6029 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6030 |
|
3310 | 6031 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6032 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6152 | 6033 |
"Modified: / 28-04-2017 / 09:25:22 / cg" |
6614 | 6034 |
"Modified: / 26-06-2019 / 23:17:08 / Claus Gittinger" |
121 | 6035 |
! |
6036 |
||
2952 | 6037 |
executeKeyboardMacro:cmdMacro |
6038 |
Error handle:[:ex | |
|
6152 | 6039 |
self warn:'Error in keyboard macro: ' , ex description. |
6040 |
ex return. |
|
2952 | 6041 |
] do:[ |
6152 | 6042 |
AbortOperationRequest handle:[:ex | |
6043 |
self warn:'Keyboard macro aborted'. |
|
6044 |
ex return. |
|
6045 |
] do:[ |
|
6046 |
Parser |
|
6047 |
evaluate:cmdMacro asString |
|
6048 |
receiver:self |
|
6049 |
notifying:nil |
|
6050 |
compile:false. |
|
6051 |
]. |
|
2952 | 6052 |
]. |
6053 |
! |
|
6054 |
||
6055 |
handleNonCommandKey:keyArg |
|
4700 | 6056 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 6057 |
|
6226 | 6058 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
2952 | 6059 |
|
6060 |
key := keyArg. |
|
6061 |
||
6062 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 6063 |
"pasted selection will NOT be replaced by keystroke" |
6064 |
self unselect |
|
2952 | 6065 |
]. |
6066 |
||
4700 | 6067 |
selStartLineBefore := selectionStartLine. |
6068 |
selStartColBefore := self selectionStartCol. |
|
6069 |
selEndLineBefore := selectionEndLine. |
|
6070 |
selEndColBefore := self selectionEndCol. |
|
2952 | 6071 |
|
6270 | 6072 |
gc characterEncoding ~~ #'iso10646-1' ifTrue:[ |
6073 |
key := CharacterEncoder encodeString:key asString from:#'iso10646-1' into:gc characterEncoding. |
|
2952 | 6074 |
]. |
6075 |
||
6076 |
"replace selection by what is typed in - |
|
3235 | 6077 |
if word was selected with a space, keep it. |
4700 | 6078 |
if there was no selection, the key's character is inserted" |
3235 | 6079 |
|
6080 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
6152 | 6081 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 6082 |
]. |
2952 | 6083 |
|
6084 |
(selectStyle == #wordLeft) ifTrue:[ |
|
6152 | 6085 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 6086 |
] ifFalse:[ |
6152 | 6087 |
(selectStyle == #wordRight) ifTrue:[ |
6088 |
self replaceSelectionBy:(key asString , ' '). |
|
6089 |
self cursorLeft |
|
6090 |
] ifFalse:[ |
|
6091 |
self replaceSelectionBy:key |
|
6092 |
] |
|
3160 | 6093 |
]. |
2952 | 6094 |
selectStyle := nil. |
6095 |
||
3235 | 6096 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 6097 |
selectionStartLine := selStartLineBefore. |
6098 |
selectionStartCol := selStartColBefore. |
|
6099 |
selectionEndLine := selEndLineBefore. |
|
6100 |
selectionEndCol := selEndColBefore. |
|
3235 | 6101 |
]. |
6102 |
||
6399 | 6103 |
self maybeShowMatchingParenthesisFor:key. |
2952 | 6104 |
|
6105 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
6106 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
6107 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
6108 |
"/ |
|
6109 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
6110 |
"/ self selection. |
|
6111 |
"/ typeOfSelection := #paste. |
|
3160 | 6112 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6113 |
"/ ]. |
3235 | 6114 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 6115 |
selectionStartLine isNil ifTrue:[ |
6116 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
|
6117 |
] ifFalse:[ |
|
6118 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
|
6119 |
]. |
|
3235 | 6120 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6121 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 6122 |
|
6226 | 6123 |
"Modified: / 11-11-2017 / 12:54:01 / cg" |
6270 | 6124 |
"Modified: / 19-01-2018 / 12:23:41 / stefan" |
6399 | 6125 |
"Modified: / 22-08-2018 / 08:34:25 / Claus Gittinger" |
2952 | 6126 |
! |
6127 |
||
6610 | 6128 |
handleReturnPressed |
6129 |
"return key pressed - handle autoIndent" |
|
6130 |
||
6623 | 6131 |
|i leftPart rightPart startIndent oldIndent newIndent language |
6652 | 6132 |
bracketStrings endsWithOpeningBracket startsWithClosingBracket |
6133 |
cursorColBefore| |
|
6610 | 6134 |
|
6135 |
self isReadOnly ifTrue:[ |
|
6136 |
self unselect; makeCursorVisible. |
|
6137 |
self cursorReturn. |
|
6138 |
^ self. |
|
6139 |
]. |
|
6652 | 6140 |
|
6610 | 6141 |
self isInInsertMode ifFalse:[ |
6142 |
self cursorReturn:true. |
|
6614 | 6143 |
self autoIndent ifTrue:[ |
6610 | 6144 |
i := self leftIndentForLine:(cursorLine + 1). |
6145 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
|
6146 |
self cursorCol:(i+1 max:1) |
|
6147 |
] |
|
6148 |
]. |
|
6149 |
^ self. |
|
6150 |
]. |
|
6151 |
||
6652 | 6152 |
cursorColBefore := cursorCol. |
6153 |
||
6610 | 6154 |
"/ old version just unselected ... |
6155 |
"/ self unselect; makeCursorVisible. |
|
6156 |
||
6157 |
"/ new version deletes ... |
|
6158 |
typeOfSelection == #paste ifTrue:[ |
|
6159 |
self unselect; makeCursorVisible. |
|
6160 |
] ifFalse:[ |
|
6161 |
self copyAndDeleteSelection. |
|
6162 |
]. |
|
6163 |
||
6623 | 6164 |
startIndent := self leftIndentOfLine:cursorLine. |
6165 |
||
6610 | 6166 |
"/ split the line |
6167 |
leftPart := ((self listAt:cursorLine to:cursorCol-1) ? '') string. |
|
6168 |
rightPart := ((self listAt:cursorLine from:cursorCol) ? '') string. |
|
6169 |
self insertCharAtCursor:(Character cr). |
|
6620 | 6170 |
self autoIndent ifFalse:[^ self]. |
6652 | 6171 |
cursorColBefore == 1 ifTrue:[^ self]. |
6610 | 6172 |
|
6173 |
endsWithOpeningBracket := startsWithClosingBracket := [:line | false]. |
|
6642 | 6174 |
|
6610 | 6175 |
(language := self editedLanguage) notNil ifTrue:[ |
6176 |
bracketStrings := language bracketStrings ? #(). |
|
6177 |
endsWithOpeningBracket := |
|
6178 |
[:line | |
|
6179 |
bracketStrings contains:[:pair | line endsWith:(pair first)]. |
|
6180 |
]. |
|
6181 |
startsWithClosingBracket := |
|
6182 |
[:line | |
|
6183 |
bracketStrings contains:[:pair | line startsWith:(pair second)]. |
|
6184 |
]. |
|
6185 |
]. |
|
6186 |
||
6620 | 6187 |
(rightPart isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
6188 |
"/ nothing to do. |
|
6189 |
] ifFalse:[ |
|
6190 |
i := self leftIndentForLine:cursorLine. |
|
6191 |
||
6192 |
leftPart := leftPart withoutSeparators. |
|
6193 |
rightPart := rightPart withoutSeparators. |
|
6194 |
oldIndent := self leftIndentOfLine:cursorLine. |
|
6195 |
||
6196 |
rightPart isEmptyOrNil ifTrue:[ |
|
6197 |
(endsWithOpeningBracket value:leftPart) ifTrue:[ |
|
6198 |
newIndent := i. "/ leftIndentForLine already adjusted the value if ending in an opening bracket |
|
6610 | 6199 |
] ifFalse:[ |
6620 | 6200 |
(false "(left endsWith:']')" or:[(startsWithClosingBracket value:rightPart)]) ifTrue:[ |
6201 |
newIndent := (self prevTabBefore:i)-1. |
|
6610 | 6202 |
] ifFalse:[ |
6620 | 6203 |
newIndent := i. "/ leftIndentForLine returns the previous line's indent |
6204 |
] |
|
6205 |
]. |
|
6206 |
] ifFalse:[ |
|
6207 |
(endsWithOpeningBracket value:leftPart) ifTrue:[ |
|
6208 |
newIndent := i. |
|
6623 | 6209 |
(startsWithClosingBracket value:rightPart) ifTrue:[ |
6210 |
"/ entered return inside [] - insert another empty line |
|
6211 |
self insertCharAtCursor:(Character cr). |
|
6212 |
self indentFromLine:cursorLine toLine:cursorLine by:startIndent. |
|
6213 |
self cursorUp. |
|
6214 |
] |
|
6620 | 6215 |
] ifFalse:[ |
6216 |
(startsWithClosingBracket value:rightPart) ifTrue:[ |
|
6217 |
leftPart notEmptyOrNil ifTrue:[ |
|
6218 |
newIndent := (self prevTabBefore:i)-1. |
|
6610 | 6219 |
] |
6620 | 6220 |
] ifFalse:[ |
6221 |
newIndent := i |
|
6610 | 6222 |
] |
6620 | 6223 |
] |
6224 |
]. |
|
6225 |
]. |
|
6226 |
newIndent notNil ifTrue:[ |
|
6227 |
self indentFromLine:cursorLine toLine:cursorLine by:(newIndent-oldIndent). |
|
6228 |
self st80EditMode ifTrue:[ |
|
6229 |
(self listAt:cursorLine) size < newIndent ifTrue:[ |
|
6230 |
self insertStringAtCursor:(String new:((newIndent-oldIndent) max:0)). |
|
6612 | 6231 |
]. |
6620 | 6232 |
]. |
6233 |
self cursorCol:(newIndent+1 max:1) |
|
6610 | 6234 |
]. |
6235 |
||
6236 |
"Created: / 26-06-2019 / 21:57:50 / Claus Gittinger" |
|
6642 | 6237 |
"Modified: / 18-07-2019 / 08:28:52 / Claus Gittinger" |
6610 | 6238 |
! |
6239 |
||
6665 | 6240 |
handleReturnPressed:shiftPressed |
6241 |
"return key pressed - handle autoIndent" |
|
6242 |
||
6243 |
|i leftPart rightPart startIndent oldIndent newIndent language |
|
6244 |
bracketStrings endsWithOpeningBracket startsWithClosingBracket |
|
6245 |
cursorColBefore| |
|
6246 |
||
6247 |
shiftPressed ifTrue:[ |
|
6248 |
self unselect. |
|
6249 |
self cursorReturn. |
|
6250 |
self autoIndent ifTrue:[ |
|
6251 |
i := self leftIndentOfLine:cursorLine. |
|
6252 |
self cursorCol:(i+1 max:1) |
|
6253 |
]. |
|
6254 |
^ self |
|
6255 |
]. |
|
6256 |
||
6257 |
self isReadOnly ifTrue:[ |
|
6258 |
self unselect; makeCursorVisible. |
|
6259 |
self cursorReturn. |
|
6260 |
^ self. |
|
6261 |
]. |
|
6262 |
||
6263 |
self isInInsertMode ifFalse:[ |
|
6264 |
self cursorReturn:true. |
|
6265 |
self autoIndent ifTrue:[ |
|
6266 |
i := self leftIndentForLine:(cursorLine + 1). |
|
6267 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
|
6268 |
self cursorCol:(i+1 max:1) |
|
6269 |
] |
|
6270 |
]. |
|
6271 |
^ self. |
|
6272 |
]. |
|
6273 |
||
6274 |
cursorColBefore := cursorCol. |
|
6275 |
||
6276 |
"/ old version just unselected ... |
|
6277 |
"/ self unselect; makeCursorVisible. |
|
6278 |
||
6279 |
"/ new version deletes ... |
|
6280 |
typeOfSelection == #paste ifTrue:[ |
|
6281 |
self unselect; makeCursorVisible. |
|
6282 |
] ifFalse:[ |
|
6283 |
self copyAndDeleteSelection. |
|
6284 |
]. |
|
6285 |
||
6286 |
startIndent := self leftIndentOfLine:cursorLine. |
|
6287 |
||
6288 |
"/ split the line |
|
6289 |
leftPart := ((self listAt:cursorLine to:cursorCol-1) ? '') string. |
|
6290 |
rightPart := ((self listAt:cursorLine from:cursorCol) ? '') string. |
|
6291 |
self insertCharAtCursor:(Character cr). |
|
6292 |
self autoIndent ifFalse:[^ self]. |
|
6293 |
cursorColBefore == 1 ifTrue:[^ self]. |
|
6294 |
||
6295 |
endsWithOpeningBracket := startsWithClosingBracket := [:line | false]. |
|
6296 |
||
6297 |
(language := self editedLanguage) notNil ifTrue:[ |
|
6298 |
bracketStrings := language bracketStrings ? #(). |
|
6299 |
endsWithOpeningBracket := |
|
6300 |
[:line | |
|
6301 |
bracketStrings contains:[:pair | line endsWith:(pair first)]. |
|
6302 |
]. |
|
6303 |
startsWithClosingBracket := |
|
6304 |
[:line | |
|
6305 |
bracketStrings contains:[:pair | line startsWith:(pair second)]. |
|
6306 |
]. |
|
6307 |
]. |
|
6308 |
||
6309 |
(rightPart isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
|
6310 |
"/ nothing to do. |
|
6311 |
] ifFalse:[ |
|
6312 |
i := self leftIndentForLine:cursorLine. |
|
6313 |
||
6314 |
leftPart := leftPart withoutSeparators. |
|
6315 |
rightPart := rightPart withoutSeparators. |
|
6316 |
oldIndent := self leftIndentOfLine:cursorLine. |
|
6317 |
||
6318 |
rightPart isEmptyOrNil ifTrue:[ |
|
6319 |
(endsWithOpeningBracket value:leftPart) ifTrue:[ |
|
6320 |
newIndent := i. "/ leftIndentForLine already adjusted the value if ending in an opening bracket |
|
6321 |
] ifFalse:[ |
|
6322 |
(false "(left endsWith:']')" or:[(startsWithClosingBracket value:rightPart)]) ifTrue:[ |
|
6323 |
newIndent := (self prevTabBefore:i)-1. |
|
6324 |
] ifFalse:[ |
|
6325 |
newIndent := i. "/ leftIndentForLine returns the previous line's indent |
|
6326 |
] |
|
6327 |
]. |
|
6328 |
] ifFalse:[ |
|
6329 |
(endsWithOpeningBracket value:leftPart) ifTrue:[ |
|
6330 |
newIndent := i. |
|
6331 |
(startsWithClosingBracket value:rightPart) ifTrue:[ |
|
6332 |
"/ entered return inside [] - insert another empty line |
|
6333 |
self insertCharAtCursor:(Character cr). |
|
6334 |
self indentFromLine:cursorLine toLine:cursorLine by:startIndent. |
|
6335 |
self cursorUp. |
|
6336 |
] |
|
6337 |
] ifFalse:[ |
|
6338 |
(startsWithClosingBracket value:rightPart) ifTrue:[ |
|
6339 |
leftPart notEmptyOrNil ifTrue:[ |
|
6340 |
newIndent := (self prevTabBefore:i)-1. |
|
6341 |
] |
|
6342 |
] ifFalse:[ |
|
6343 |
newIndent := i |
|
6344 |
] |
|
6345 |
] |
|
6346 |
]. |
|
6347 |
]. |
|
6348 |
newIndent notNil ifTrue:[ |
|
6349 |
self indentFromLine:cursorLine toLine:cursorLine by:(newIndent-oldIndent). |
|
6350 |
self st80EditMode ifTrue:[ |
|
6351 |
(self listAt:cursorLine) size < newIndent ifTrue:[ |
|
6352 |
self insertStringAtCursor:(String new:((newIndent-oldIndent) max:0)). |
|
6353 |
]. |
|
6354 |
]. |
|
6355 |
self cursorCol:(newIndent+1 max:1) |
|
6356 |
]. |
|
6357 |
||
6358 |
"Created: / 26-06-2019 / 21:57:50 / Claus Gittinger" |
|
6359 |
"Modified: / 18-07-2019 / 08:28:52 / Claus Gittinger" |
|
6360 |
! |
|
6361 |
||
2952 | 6362 |
keyPress:key x:x y:y |
6363 |
"handle keyboard input" |
|
6364 |
||
4771 | 6365 |
|wasOn| |
6366 |
||
6641 | 6367 |
( #( #Control_L #Control_R #Control ) includes:key) ifTrue:[ |
6368 |
super keyPress:key x:x y:y. |
|
6369 |
^ self. |
|
6370 |
]. |
|
6371 |
||
4771 | 6372 |
wasOn := cursorShown. |
6373 |
||
5787 | 6374 |
NoModificationError |
6152 | 6375 |
handle:[:ex | |
6376 |
self flashReadOnly. |
|
6377 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
6378 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6379 |
]. |
|
6380 |
] |
|
6381 |
do:[ |
|
6382 |
self undoableDo:[ |
|
6383 |
self doKeyPress:key x:x y:y |
|
6384 |
]. |
|
6385 |
]. |
|
5689 | 6386 |
|
4242 | 6387 |
self repairDamage |
6388 |
||
6389 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 6390 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
6641 | 6391 |
"Modified: / 17-07-2019 / 07:23:42 / Claus Gittinger" |
2952 | 6392 |
! |
6393 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6394 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6395 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6396 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6397 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6398 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6399 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6400 |
|
6399 | 6401 |
maybeShowMatchingParenthesisFor:characterBeforeCursor |
6402 |
showMatchingParenthesis ifTrue:[ |
|
6403 |
"emacs style parenthesis shower" |
|
6404 |
"claus: only do it for closing parenthesis - otherwise its too anoying." |
|
6405 |
("'()[]{}'" ')]}' includes:characterBeforeCursor) ifTrue:[ |
|
6406 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
|
6407 |
self |
|
6408 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
6409 |
ifFound:[:line :col | self showMatchingParenthesisAtLine:line col:col ] |
|
6410 |
ifNotFound:[self showNotFound] |
|
6411 |
onError:[self beepInEditor] |
|
6412 |
]. |
|
6413 |
] |
|
6414 |
]. |
|
6415 |
||
6416 |
"Created: / 22-08-2018 / 08:34:04 / Claus Gittinger" |
|
6417 |
! |
|
6418 |
||
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6419 |
requestAutoAccept |
5068 | 6420 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
6421 |
This forces my value to be accepted into my model. |
|
6422 |
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
|
6423 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6424 |
acceptEnabled == false ifTrue:[ |
6152 | 6425 |
"/ nope - |
6426 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6427 |
]. |
5404 | 6428 |
"/ cg: only do this if modified. |
6429 |
"/ otherwise, users would have to make sure that the contents is |
|
6430 |
"/ always correct (which they don't). If you change this back, |
|
6431 |
"/ please check the expecco file-save or file-reimport dialog, |
|
6432 |
"/ which has a problem with that behavior. |
|
6433 |
self modified ifTrue:[ |
|
6152 | 6434 |
self accept. |
5404 | 6435 |
]. |
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6436 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6437 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6438 |
|
6399 | 6439 |
showMatchingParenthesisAtLine:line col:col |
6440 |
self withCursor:Cursor eye do:[ |
|
6441 |
|savLine savCol sensor| |
|
6442 |
||
6443 |
savLine := cursorLine. |
|
6444 |
savCol := cursorCol. |
|
6445 |
self cursorLine:line col:col. |
|
6446 |
self flush. |
|
6447 |
||
6448 |
"/ want to wait 240ms, but not if another keyPress |
|
6449 |
"/ arrives in the meantime ... |
|
6450 |
||
6451 |
sensor := self sensor. |
|
6452 |
6 timesRepeat:[ |
|
6453 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
6454 |
Processor activeProcess millisecondDelay:40. |
|
6455 |
] |
|
6456 |
]. |
|
6457 |
self cursorLine:savLine col:savCol |
|
6458 |
] |
|
6459 |
||
6460 |
"Created: / 22-08-2018 / 08:22:13 / Claus Gittinger" |
|
6461 |
! |
|
6462 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6463 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6464 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6465 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6466 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6467 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6468 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6469 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6470 |
cv notNil ifTrue:[ |
6152 | 6471 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6472 |
] |
4967 | 6473 |
! |
6474 |
||
6475 |
unmapped |
|
6476 |
super unmapped. |
|
6477 |
||
6478 |
completionSupport notNil ifTrue:[ |
|
6152 | 6479 |
completionSupport release. |
4967 | 6480 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6481 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6482 |
|
1807 | 6483 |
!EditTextView methodsFor:'focus handling'! |
6484 |
||
4818 | 6485 |
focusOut |
6486 |
super focusOut. |
|
6487 |
||
6488 |
completionSupport notNil ifTrue:[ |
|
6152 | 6489 |
completionSupport release. |
4818 | 6490 |
]. |
6491 |
! |
|
6492 |
||
1807 | 6493 |
hasKeyboardFocus:aBoolean |
6494 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
6495 |
(otherwise, I would not know about this)" |
|
6496 |
||
6497 |
hasKeyboardFocus := aBoolean. |
|
4609 | 6498 |
|
3160 | 6499 |
(cursorShown |
6500 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6501 |
and:[self isReadOnly not]]) ifTrue:[ |
5890 | 6502 |
self drawCursor |
4609 | 6503 |
]. |
6504 |
||
6505 |
hasKeyboardFocus ifFalse:[ |
|
5890 | 6506 |
completionSupport notNil ifTrue:[ |
6507 |
"/ this is a hack for Windows: |
|
6508 |
"/ on windows, an activate:false event is first sent to my textView, |
|
6509 |
"/ then an activate is sent to the completion popup. |
|
6510 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
6511 |
"/ therefore, allow for the activate of the completionMenu and its button event to be processed. |
|
6512 |
"/ before forcing it to be closed... |
|
6513 |
completionSupport startTimeoutForEditViewLostFocus. |
|
6514 |
]. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6515 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6516 |
|
4821 | 6517 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 6518 |
! |
6519 |
||
6520 |
showFocus:explicit |
|
6521 |
"in addition to however my superclass thinks how a focusView is to be |
|
6522 |
displayed, show the cursor when I got the focus" |
|
6523 |
||
5239 | 6524 |
self hasKeyboardFocus:true. |
1807 | 6525 |
self showCursor. |
6526 |
super showFocus:explicit |
|
6527 |
||
6528 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6529 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6530 |
|
4967 | 6531 |
showNoFocus:explicit |
5787 | 6532 |
"the view lost the keyboard focus |
4967 | 6533 |
(either explicit, via tabbing; or implicit, by pointer movement) |
6534 |
- change any display attributes as req'd." |
|
6535 |
||
6536 |
super showNoFocus:explicit. |
|
5149 | 6537 |
|
6538 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
6539 |
"/ not when the focus is lost normally (because this also happens when |
|
6540 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
6541 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
6542 |
explicit ifTrue:[ |
|
6152 | 6543 |
completionSupport notNil ifTrue:[ |
6544 |
completionSupport release. |
|
6545 |
]. |
|
4818 | 6546 |
]. |
6547 |
! |
|
6548 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6549 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6550 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6551 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6552 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6553 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6554 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6555 |
and:[self enabled |
4781 | 6556 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6557 |
) ifTrue:[ |
6152 | 6558 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6559 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6560 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6561 |
^ false |
1807 | 6562 |
! ! |
6563 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6564 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6565 |
|
4237 | 6566 |
executekeyboardMacroNamed:macroName |
5787 | 6567 |
"try to execute the keyboard macro; |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6568 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6569 |
|
4482 | 6570 |
|cmdMacro| |
6571 |
||
6572 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6573 |
self |
6152 | 6574 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
6575 |
info: macroName. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6576 |
^ true |
4238 | 6577 |
|
6578 |
" |
|
4483 | 6579 |
EditTextView open |
6152 | 6580 |
contents:'bla'; |
6581 |
selectAll; |
|
6582 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6583 |
EditTextView open |
6152 | 6584 |
contents:'bla'; |
6585 |
selectAll; |
|
6586 |
executekeyboardMacroNamed:#blabla. |
|
4238 | 6587 |
" |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6588 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6589 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6590 |
! |
6591 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6592 |
indent |
3221 | 6593 |
"indent a line-range - this is done by searching for the |
6594 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6595 |
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
|
6596 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6597 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6598 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6599 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6600 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6601 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6602 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6603 |
(selectionEndCol == 0) ifTrue:[ |
6152 | 6604 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6605 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6606 |
self unselect. |
3160 | 6607 |
self |
6152 | 6608 |
undoableDo:[self indentFromLine:start toLine:end] |
6609 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6610 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6611 |
|
4237 | 6612 |
indentBy4 |
5050 | 6613 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6614 |
||
6615 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6616 |
! |
|
6617 |
||
6618 |
indentBy8 |
|
6619 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6620 |
|
6621 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6622 |
! |
|
6623 |
||
5050 | 6624 |
indentBy:n |
6625 |
|line1 line2| |
|
6626 |
||
6627 |
line1 := self selectionStartLine. |
|
6628 |
line2 := self selectionEndLine. |
|
6629 |
line1 isNil ifTrue:[ |
|
5833 | 6630 |
line1 := self cursorLine. |
6631 |
line1 notNil ifTrue:[ |
|
6632 |
line2 := line1 |
|
6633 |
] |
|
5769 | 6634 |
] ifFalse:[ |
5833 | 6635 |
line2 notNil ifTrue:[ |
6636 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
6637 |
]. |
|
5787 | 6638 |
]. |
5050 | 6639 |
line1 notNil ifTrue:[ |
5833 | 6640 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6641 |
] |
6642 |
! |
|
6643 |
||
6644 |
indentByTab |
|
6645 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6646 |
! |
|
6647 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6648 |
indentFromLine:start toLine:end |
3221 | 6649 |
"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
|
6650 |
last non-empty line before start, and change the indent |
4742 | 6651 |
of the selected line-range based on that line's indent." |
6652 |
||
4811 | 6653 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6654 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6655 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6656 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6657 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6658 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6659 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6660 |
self indentFromLine:start toLine:end by:delta |
6661 |
! |
|
6662 |
||
6663 |
indentFromLine:start toLine:end by:delta |
|
6664 |
"indent a line-range - this is done by searching for the |
|
6665 |
last non-empty line before start, and change the indent |
|
6666 |
of the selected line-range based on that line's indent." |
|
6667 |
||
6668 |
|d line spaces anyChange| |
|
6669 |
||
6670 |
(delta == 0) ifTrue:[^ self]. |
|
6226 | 6671 |
|
6672 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[ ^ self]. |
|
6673 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6674 |
(delta > 0) ifTrue:[ |
6152 | 6675 |
spaces := String new:delta |
4742 | 6676 |
]. |
6677 |
||
6678 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6679 |
start to:end do:[:lineNr | |
6152 | 6680 |
line := self listAt:lineNr. |
6681 |
line notNil ifTrue:[ |
|
6682 |
line isBlank ifTrue:[ |
|
6683 |
self basicListAt:lineNr put:nil |
|
6684 |
] ifFalse:[ |
|
6685 |
(delta > 0) ifTrue:[ |
|
6686 |
line := spaces , line. |
|
6687 |
widthOfWidestLine notNil ifTrue:[ |
|
6688 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6689 |
] |
|
6690 |
] ifFalse:[ |
|
6691 |
"check if deletion is ok" |
|
6249 | 6692 |
d := delta negated. |
6152 | 6693 |
|
6694 |
line size > d ifTrue:[ |
|
6249 | 6695 |
(line copyTo:d) withoutSeparators isEmpty ifTrue:[ |
6696 |
line := line copyFrom:(d+1) |
|
6152 | 6697 |
] |
6698 |
]. |
|
6699 |
widthOfWidestLine := nil |
|
6700 |
]. |
|
6701 |
self replaceLine:lineNr with:line. |
|
6702 |
anyChange := true. |
|
6703 |
] |
|
6704 |
] |
|
4742 | 6705 |
]. |
6706 |
||
6707 |
anyChange ifTrue:[ self textChanged ]. |
|
6708 |
||
3221 | 6709 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6710 |
|
6226 | 6711 |
"Modified: / 11-11-2017 / 12:54:33 / cg" |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6712 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6713 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6714 |
leftIndentForLine:lineNr |
6612 | 6715 |
"compute an appropriate indent for a line. |
6716 |
This is done by searching for the last non-empty line before it |
|
4823 | 6717 |
and returning its indent. |
6612 | 6718 |
If the previous line ends with a bracket, adjust by the tab spacing as required. |
4823 | 6719 |
cg: changed: only look for the single previous line." |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6720 |
|
827 | 6721 |
"SHOULD GO TO ListView" |
6722 |
||
6612 | 6723 |
|line lnr indent |
6724 |
endsWithOpeningBracket endsWithClosingBracket bracketStrings language| |
|
6725 |
||
6726 |
endsWithOpeningBracket := endsWithClosingBracket := [:line | false]. |
|
6613 | 6727 |
language := self editedLanguage ? SmalltalkLanguage instance. |
6728 |
||
6729 |
bracketStrings := language bracketStrings ? #(). |
|
6730 |
endsWithOpeningBracket := |
|
6731 |
[:line | |
|
6732 |
bracketStrings contains:[:pair | line endsWith:(pair first)]. |
|
6733 |
]. |
|
6734 |
endsWithClosingBracket := |
|
6735 |
[:line | |
|
6736 |
bracketStrings contains:[:pair | line endsWith:(pair second)]. |
|
6737 |
]. |
|
827 | 6738 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6739 |
lnr := lineNr. |
6147 | 6740 |
[lnr > 1] whileTrue:[ |
6741 |
lnr := lnr - 1. |
|
6742 |
line := self listAt:lnr. |
|
6743 |
||
6744 |
line notEmptyOrNil ifTrue:[ |
|
6745 |
indent := (line indexOfNonSeparatorStartingAt:1) - 1. |
|
6746 |
indent >= 0 ifTrue:[ |
|
6613 | 6747 |
(endsWithOpeningBracket value:line) ifTrue:[ |
6748 |
"/ ^ indent + 4 |
|
6749 |
^ (self nextTabAfter:indent+1)-1 |
|
6147 | 6750 |
]. |
6613 | 6751 |
"/ no, not with kr indentation style |
6752 |
"/ (endsWithClosingBracket value:line) ifTrue:[ |
|
6753 |
"/ "/ ^ indent - 4 |
|
6754 |
"/ ^ (self prevTabBefore:indent)-1 |
|
6755 |
"/ ]. |
|
6147 | 6756 |
^ indent |
6757 |
] |
|
6758 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6759 |
]. |
827 | 6760 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6761 |
|
6147 | 6762 |
"Created: / 05-03-1996 / 14:58:53 / cg" |
6763 |
"Modified (format): / 25-04-2017 / 12:57:44 / cg" |
|
6613 | 6764 |
"Modified: / 26-06-2019 / 23:05:47 / Claus Gittinger" |
4237 | 6765 |
! |
6766 |
||
6767 |
undentBy4 |
|
5050 | 6768 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6769 |
||
6770 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6771 |
! |
|
6772 |
||
6773 |
undentBy8 |
|
6774 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6775 |
|
6776 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6777 |
! |
6778 |
||
6779 |
undentBy:n |
|
6780 |
self indentBy:(n negated) |
|
6781 |
! |
|
6782 |
||
6783 |
undentByTab |
|
6784 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6785 |
! ! |
6786 |
||
0 | 6787 |
!EditTextView methodsFor:'initialization'! |
6788 |
||
941 | 6789 |
fetchDeviceResources |
6790 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6791 |
||
6792 |
super fetchDeviceResources. |
|
6793 |
||
5643 | 6794 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6795 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6796 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6797 |
|
6798 |
"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
|
6799 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6800 |
! |
6801 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6802 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6803 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6804 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6805 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6806 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6807 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6808 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6809 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6810 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6811 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6812 |
super initStyle. |
4576 | 6813 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6814 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6815 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6816 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6817 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6818 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6819 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6820 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6821 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6152 | 6822 |
cursorTypeNoFocus := cursorType. |
6823 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6824 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6825 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6826 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6827 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6828 |
cursorNoFocusFgColor isNil ifTrue:[ |
6152 | 6829 |
cursorType ~~ #block ifTrue:[ |
6830 |
cursorNoFocusFgColor := cursorBgColor |
|
6831 |
] ifFalse:[ |
|
6832 |
cursorNoFocusFgColor := cursorFgColor |
|
6833 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6834 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6835 |
|
2088 | 6836 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6837 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6838 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6839 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6840 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6841 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6842 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6843 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6844 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6845 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6846 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6847 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6848 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6849 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6850 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6851 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6852 |
cursorCol := 1. |
5251 | 6853 |
cursorLineHolder := ValueHolder with:1. |
6854 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6855 |
modifiedChannel := ValueHolder with:false. |
6856 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6857 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6858 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6859 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6860 |
tabMeansNextField := false. |
6614 | 6861 |
"/ autoIndent := UserPreferences current autoIndentInCodeView asValue. |
6862 |
autoIndent := false asValue. |
|
5251 | 6863 |
editMode := ValueHolder with:EditMode insertMode. |
6864 |
learnMode := ValueHolder with:false. |
|
2131 | 6865 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6866 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6867 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6868 |
"/ enable drop by default |
2589 | 6869 |
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
|
6870 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6871 |
undoSupport := UndoSupport for:self. |
5251 | 6872 |
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
|
6873 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6874 |
"Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6614 | 6875 |
"Modified (comment): / 26-06-2019 / 23:21:46 / Claus Gittinger" |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6876 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6877 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6878 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6879 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6880 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6881 |
completionSupport isNil ifTrue:[ |
6152 | 6882 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
6883 |
completionSupport := supportClass for:self. |
|
6884 |
]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6885 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6886 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6887 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6888 |
! |
6889 |
||
6890 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6891 |
completionSupport notNil ifTrue:[ |
6152 | 6892 |
completionSupport release |
4771 | 6893 |
]. |
6517 | 6894 |
CharacterInputViewSingleton notNil ifTrue:[ |
6895 |
CharacterInputViewSingleton consumingView == self ifTrue:[ |
|
6896 |
CharacterInputViewSingleton closeRequest. |
|
6897 |
CharacterInputViewSingleton := nil |
|
6898 |
] |
|
6899 |
]. |
|
6900 |
||
4771 | 6901 |
super release |
6517 | 6902 |
|
6903 |
"Modified: / 08-01-2019 / 18:16:31 / Claus Gittinger" |
|
0 | 6904 |
! ! |
6905 |
||
2580 | 6906 |
!EditTextView methodsFor:'macros'! |
6907 |
||
6908 |
executeLearnedKeyboardMacro |
|
4673 | 6909 |
"replay the characters as learned previously" |
6910 |
||
6548 | 6911 |
(self learnMode not and:[learnedMacro size ~~ 0]) ifTrue:[ |
6152 | 6912 |
ExecutingMacroQuery |
6913 |
answer:true |
|
6914 |
do:[ |
|
6915 |
learnedMacro do:[:event | |
|
6436 | 6916 |
self |
6917 |
dispatchEvent:event |
|
6918 |
withFocusOn:nil |
|
6919 |
delegate:false |
|
6152 | 6920 |
] |
6921 |
]. |
|
2580 | 6922 |
] ifFalse:[ |
6152 | 6923 |
self flash:'no macro'. |
2580 | 6924 |
]. |
6436 | 6925 |
|
6548 | 6926 |
"Modified: / 01-03-2019 / 14:54:46 / Claus Gittinger" |
2580 | 6927 |
! |
6928 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6929 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6930 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6931 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6932 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6933 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6934 |
|
2580 | 6935 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6936 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6937 |
|
2580 | 6938 |
|fg bg| |
6939 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6940 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6941 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6942 |
aBoolean ifTrue:[ |
5795 | 6943 |
learnedMacro := OrderedCollection new. |
6944 |
fg := self whiteColor. |
|
6945 |
bg := self blackColor. |
|
2580 | 6946 |
] ifFalse:[ |
5795 | 6947 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6948 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6949 |
]. |
6950 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6951 |
! |
|
6952 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6953 |
learnModeHolder |
4673 | 6954 |
"a holder returning true, if in learn mode" |
6955 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6956 |
learnMode isNil ifTrue:[ |
6152 | 6957 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6958 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6959 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6960 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6961 |
|
4673 | 6962 |
rememberLearnedMacroAs: nameString |
6963 |
Macros isNil ifTrue:[ |
|
6152 | 6964 |
Macros := Dictionary new. |
4673 | 6965 |
]. |
6966 |
Macros at:nameString put:learnedMacro |
|
6967 |
! |
|
6968 |
||
2580 | 6969 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6970 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6971 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6972 |
self learnMode:(self learnMode not). |
2580 | 6973 |
! ! |
6974 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6975 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6976 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6977 |
babelFishTranslate:fromToModeString |
5962 | 6978 |
"translate the selected text and paste it after the selection. |
6804 | 6979 |
Used to use babelFish, which is now obsolete, as that web service no longer exists (sigh). |
6980 |
So now we use google..." |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6981 |
|
6790 | 6982 |
^ self googleTranslate:fromToModeString. |
6804 | 6983 |
|
6790 | 6984 |
"/ |original translated| |
6985 |
"/ |
|
6986 |
"/ original := self selectionAsString. |
|
6987 |
"/ original size == 0 ifTrue:[^ self]. |
|
6988 |
"/ |
|
6989 |
"/ self withWaitCursorDo:[ |
|
6990 |
"/ (HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
|
6991 |
"/ Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
6992 |
"/ ] do:[ |
|
6993 |
"/ translated := SOAP::BabelFishClient new |
|
6994 |
"/ translate:original mode:fromToModeString. |
|
6995 |
"/ ] |
|
6996 |
"/ ]. |
|
6997 |
"/ |
|
6998 |
"/ "/ v pasteOrReplace:translated |
|
6999 |
"/ self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
|
7000 |
"/ self unselect. |
|
7001 |
"/ self |
|
7002 |
"/ undoablePaste:translated |
|
7003 |
"/ info:'Translate' |
|
7004 |
"/ |
|
7005 |
"/ "Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
7006 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
7007 |
|
6733 | 7008 |
canDivertOutput |
7009 |
"only for text collectors" |
|
7010 |
||
7011 |
^ false. |
|
7012 |
! |
|
7013 |
||
5689 | 7014 |
copySelection |
7015 |
"copy contents into smalltalk copybuffer. |
|
7016 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
7017 |
||
7018 |
self hasSelection ifTrue:[ |
|
6152 | 7019 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
5689 | 7020 |
]. |
7021 |
super copySelection. |
|
7022 |
||
7023 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
7024 |
! |
|
7025 |
||
121 | 7026 |
cut |
7027 |
"cut selection into copybuffer" |
|
7028 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7029 |
self deleteCopyToClipboard:true |
121 | 7030 |
! |
7031 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7032 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7033 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7034 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7035 |
cursorLine notNil ifTrue:[ |
6152 | 7036 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7037 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7038 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7039 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7040 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7041 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7042 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7043 |
|
4129 | 7044 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7045 |
|
6226 | 7046 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7047 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7048 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7049 |
sel notNil ifTrue:[ |
6152 | 7050 |
self setLastStringToReplace: sel. |
7051 |
||
7052 |
line := selectionStartLine. |
|
7053 |
col := selectionStartCol. |
|
7054 |
||
7055 |
toClipboard ifTrue:[ |
|
7056 |
" |
|
7057 |
remember in CopyBuffer |
|
7058 |
" |
|
7059 |
self setClipboardText:sel. "/ lastString. |
|
7060 |
]. |
|
7061 |
||
7062 |
" |
|
7063 |
append to DeleteHistory (if there is one) |
|
7064 |
" |
|
7065 |
history := Smalltalk at:#DeleteHistory. |
|
7066 |
history notNil ifTrue:[ |
|
7067 |
history addAll:(sel asStringCollection). |
|
7068 |
history size > 1000 ifTrue:[ |
|
7069 |
history := history copyFrom:(history size - 1000) |
|
7070 |
]. |
|
7071 |
]. |
|
7072 |
||
7073 |
" |
|
7074 |
now, delete it |
|
7075 |
" |
|
6641 | 7076 |
self undoableDo:[self deleteSelection] info:'Delete'. |
6152 | 7077 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7078 |
] ifFalse:[ |
6152 | 7079 |
" |
7080 |
a cut without selection will search&cut again |
|
7081 |
" |
|
7082 |
self undoableDo:[ |
|
7083 |
self again |
|
7084 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7085 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7086 |
|
6226 | 7087 |
"Modified: / 11-11-2017 / 12:53:45 / cg" |
6641 | 7088 |
"Modified (format): / 17-07-2019 / 07:35:03 / Claus Gittinger" |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7089 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
7090 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7091 |
editMenu |
5977 | 7092 |
"return the view's middleButtonMenu" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7093 |
|
5787 | 7094 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 7095 |
#Find #GotoLine #SaveAs #Print |
7096 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
|
7097 |
#ToggleAutoIndent #ToggleInsertMode |
|
7098 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
7099 |
<resource: #programMenu> |
1054 | 7100 |
|
6241 | 7101 |
|items m sub translateItems sortItems miscItems toolItems convertItems subSubMenu toolSubMenu |
7102 |
transSubMenu sortSubMenu convertSubMenu what undoIdx redoIdx sensor main mainItems| |
|
1515 | 7103 |
|
2460 | 7104 |
items := #( |
5826 | 7105 |
('Redo' redo Redo ) |
7106 |
('Again (for All)' multipleAgain AgainForAll ) |
|
7107 |
('-' ) |
|
7108 |
('Search...' search Find ) |
|
7109 |
('Goto Line...' gotoLine GotoLine ) |
|
7110 |
('-' ) |
|
7111 |
('Tools' tools ) |
|
7112 |
('Font...' changeFont ) |
|
7113 |
('Insert Unicode...' insertUnicode ) |
|
6599 | 7114 |
). |
4213 | 7115 |
CharacterSetView notNil ifTrue:[ |
5826 | 7116 |
items := items , |
7117 |
#( |
|
7118 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
7119 |
). |
|
4213 | 7120 |
]. |
6599 | 7121 |
self showLineLimitInMenu ifTrue:[ |
7122 |
items := items , |
|
7123 |
#( |
|
7124 |
('Set Line Limit...' doSetLineLimit ) |
|
7125 |
). |
|
7126 |
]. |
|
7127 |
||
4213 | 7128 |
items := items , #( |
5826 | 7129 |
('-' ) |
7130 |
('Save As...' save SaveAs ) |
|
6733 | 7131 |
('Print' doPrint Print ) ). |
7132 |
self canDivertOutput ifTrue:[ |
|
7133 |
self isDivertingOutput ifTrue:[ |
|
7134 |
items := items , #( |
|
7135 |
('-' ) |
|
7136 |
('Stop Diverting Output' stopDivertingOutput ) ). |
|
7137 |
] ifFalse:[ |
|
7138 |
items := items , #( |
|
7139 |
('-' ) |
|
7140 |
('Start Diverting Output To...' startDivertingOutput ) ). |
|
7141 |
]. |
|
7142 |
]. |
|
7143 |
items := items , #( |
|
5826 | 7144 |
('=' ) |
7145 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 7146 |
|
2866 | 7147 |
miscItems := #( |
5826 | 7148 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
7149 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
7150 |
('-' ) |
|
6134 | 7151 |
('Copy Box' copySelectionBox CopyBox ) |
7152 |
('Paste Box' pasteOrReplaceBox PasteBox ) |
|
5826 | 7153 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
7154 |
('Join Lines' joinLines Join ) |
|
7155 |
('Wrap Lines...' wrapLines Wrap ) |
|
7156 |
('-' ) |
|
7157 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
7158 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
7159 |
('-' ) |
|
7160 |
('Insert File...' insertFile ) |
|
7161 |
('Insert URL Contents...' insertURL ) |
|
7162 |
('Insert new UUID' insertUUID ) |
|
7163 |
('Insert Date && Time' insertDateAndTime ) |
|
7164 |
('-' ) |
|
7165 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
7166 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
7167 |
). |
|
4213 | 7168 |
"/ CharacterSetView notNil ifTrue:[ |
7169 |
"/ miscItems := miscItems , |
|
7170 |
"/ #( |
|
5529 | 7171 |
"/ ('-' ) |
4213 | 7172 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 7173 |
"/ ('Font...' changeFont ) |
4213 | 7174 |
"/ ). |
5529 | 7175 |
"/ ] ifFalse:[ |
7176 |
"/ miscItems := miscItems , |
|
7177 |
"/ #( |
|
7178 |
"/ ('Font...' changeFont ) |
|
7179 |
"/"/ ('Encoding...' changeEncoding ) |
|
7180 |
"/ ). |
|
5787 | 7181 |
"/ ]. |
2866 | 7182 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
7183 |
translateItems := #( |
5826 | 7184 |
('English -> German' (babelFishTranslate: 'en_de') ) |
7185 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
7186 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
7187 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
7188 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
7189 |
('-' ) |
|
7190 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
7191 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
7192 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
7193 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
7194 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6792 | 7195 |
('-' ) |
6804 | 7196 |
('any -> English' (babelFishTranslate: 'auto_en') ) |
6792 | 7197 |
('any -> German' (babelFishTranslate: 'auto_de') ) |
7198 |
('any -> French' (babelFishTranslate: 'auto_fr') ) |
|
7199 |
('any -> Italian' (babelFishTranslate: 'auto_it') ) |
|
7200 |
('any -> Spanish' (babelFishTranslate: 'auto_es') ) |
|
7201 |
('any -> Portuguese' (babelFishTranslate: 'auto_pt') ) |
|
7202 |
('-' ) |
|
5826 | 7203 |
). |
3221 | 7204 |
|
7205 |
sortItems := #( |
|
5826 | 7206 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
7207 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
7208 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
7209 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
7210 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
7211 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
7212 |
('-' ) |
|
7213 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
7214 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
7215 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
7216 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
7217 |
('-' ) |
|
7218 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
7219 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
7220 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
7221 |
|
2762 | 7222 |
toolItems := #( |
5826 | 7223 |
('Indent' indent ) |
7224 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6241 | 7225 |
('Sort' sortMenu ) |
5826 | 7226 |
('Split...' splitLinesAtCharacterOrString ) |
6241 | 7227 |
('Convert...' convertMenu ) |
5826 | 7228 |
('-' ) |
7229 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6241 | 7230 |
('Builtin Spell Check' internalSpellingSuggestion ) |
7231 |
('Translate' babelFishTranslateMenu ) |
|
5826 | 7232 |
('Compare with Clipboard...' compareWithClipboard ) |
7233 |
('Compare with File...' compareWithFile ) |
|
7234 |
). |
|
2762 | 7235 |
|
6241 | 7236 |
convertItems := #( |
7237 |
('Base64 Decode' selectionDecodeBase64 ) |
|
7238 |
('Base64 Encode' selectionEncodeBase64 ) |
|
7239 |
('Rot13' selectionRot13 ) |
|
7240 |
). |
|
7241 |
||
6359 | 7242 |
toolItems := toolItems , #( |
7243 |
('-' ) |
|
7244 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
7245 |
('Open WebBrowser on It' openWebBrowserOnIt ) |
|
7246 |
). |
|
7247 |
||
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
7248 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 7249 |
toolItems := toolItems , #( |
7250 |
('-' ) |
|
6564 | 7251 |
('Open Workspace with It' openWorkspaceWithIt OpenWorkspaceOnIt) |
5826 | 7252 |
('Inspect Selected String' inspectSelectedString ) |
6669 | 7253 |
('Inspect Selected JSON' inspectSelectedJSON ) |
5826 | 7254 |
). |
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
7255 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
7256 |
|
2460 | 7257 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 7258 |
sub receiver:self. |
2460 | 7259 |
|
6241 | 7260 |
toolSubMenu := PopUpMenu itemList:toolItems resources:resources performer:model. |
7261 |
toolSubMenu receiver:self. |
|
7262 |
sub subMenuAt:#tools put:toolSubMenu. |
|
7263 |
||
7264 |
transSubMenu := PopUpMenu itemList:translateItems resources:resources performer:model. |
|
7265 |
transSubMenu receiver:self. |
|
7266 |
toolSubMenu subMenuAt:#babelFishTranslateMenu put:transSubMenu. |
|
7267 |
||
7268 |
sortSubMenu := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
7269 |
sortSubMenu receiver:self. |
|
7270 |
toolSubMenu subMenuAt:#sortMenu put:sortSubMenu. |
|
7271 |
||
7272 |
convertSubMenu := PopUpMenu itemList:convertItems resources:resources performer:model. |
|
7273 |
convertSubMenu receiver:self. |
|
7274 |
toolSubMenu subMenuAt:#convertMenu put:convertSubMenu. |
|
7275 |
||
7276 |
subSubMenu := PopUpMenu itemList:miscItems resources:resources performer:model. |
|
7277 |
subSubMenu receiver:self. |
|
6614 | 7278 |
subSubMenu checkToggleAt:#autoIndent: put:(self autoIndent). |
6241 | 7279 |
subSubMenu checkToggleAt:#insertMode: put:(self isInInsertMode). |
7280 |
subSubMenu checkToggleAt:#learnMode: put:(self learnModeHolder value). |
|
7281 |
||
7282 |
sub subMenuAt:#misc put:subSubMenu. |
|
2866 | 7283 |
|
3495 | 7284 |
mainItems := #( |
5826 | 7285 |
('Undo' undo Undo ) |
7286 |
('Again' again Again ) |
|
7287 |
('-' ) |
|
6134 | 7288 |
('Cut' cut Cut )). |
6586 | 7289 |
(self sensor metaDown or:[self sensor altDown]) ifTrue:[ |
6134 | 7290 |
mainItems := mainItems , #( |
7291 |
('Copy Box' copySelectionBox CopyBox ) |
|
7292 |
('Paste Box' pasteOrReplaceBox PasteBox )) |
|
7293 |
] ifFalse:[ |
|
7294 |
mainItems := mainItems , #( |
|
6586 | 7295 |
('Copy' copySelection Copy ) |
7296 |
('Paste' pasteOrReplace Paste ) |
|
6477
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
7297 |
('Paste...' pasteOrReplaceFromHistory PasteFromHistory )) |
6134 | 7298 |
]. |
7299 |
mainItems := mainItems , #( |
|
5826 | 7300 |
('-' ) |
7301 |
('Accept' accept Accept ) |
|
7302 |
('=' ) |
|
6134 | 7303 |
('More' others Ctrl )). |
7304 |
||
3495 | 7305 |
main := PopUpMenu itemList:mainItems resources:resources. |
7306 |
main subMenuAt:#others put:sub. |
|
7307 |
||
7308 |
sensor := self sensor. |
|
7309 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
7310 |
sensor shiftDown ifTrue:[ |
|
6241 | 7311 |
m := subSubMenu |
5826 | 7312 |
] ifFalse:[ |
7313 |
m := sub |
|
7314 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7315 |
] ifFalse:[ |
5826 | 7316 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7317 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7318 |
|
4742 | 7319 |
"/ the 'Smalltalk at:' code is here to |
7320 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 7321 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 7322 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
7323 |
m disable:#googleSpellingSuggestion |
|
2676 | 7324 |
]. |
4742 | 7325 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 7326 |
m disable:#internalSpellingSuggestion |
4742 | 7327 |
]. |
2676 | 7328 |
|
3811 | 7329 |
HTTPInterface isNil ifTrue:[ |
5826 | 7330 |
m disableAll:#(insertURL) |
3811 | 7331 |
]. |
7332 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7333 |
self isReadOnly ifTrue:[ |
5826 | 7334 |
m disableAll:#(accept undo again multipleAgain redo |
6134 | 7335 |
paste pasteOrReplace pasteOrReplaceBox pasteOrReplaceFromHistory |
5826 | 7336 |
cut indent autoIndent: insertMode: |
7337 |
insertFile insertFileAsStringLiteral insertURL |
|
6241 | 7338 |
babelFishTranslateMenu googleSpellingSuggestion sortMenu |
5826 | 7339 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
6228 | 7340 |
splitLinesAtCharacterOrString |
5826 | 7341 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
6241 | 7342 |
insertUnicode specialCharacters convertMenu) |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7343 |
]. |
2817 | 7344 |
self hasSelectionForCopy ifFalse:[ |
5826 | 7345 |
m disable:#copySelection. |
6134 | 7346 |
m disable:#copySelectionBox. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7347 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
7348 |
self hasSelection ifFalse:[ |
6241 | 7349 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslateMenu openFileBrowserOnIt |
6359 | 7350 |
openWebBrowserOnIt |
6241 | 7351 |
openWorkspaceWithIt sortMenu indent splitLinesAtCharacterOrString inspectSelectedString |
7352 |
convertMenu). |
|
2762 | 7353 |
] ifTrue:[ |
5826 | 7354 |
(Error handle:[:ex | |
7355 |
ex return:false |
|
7356 |
] do:[ |
|
7357 |
|fn| |
|
6374 | 7358 |
fn := self selectionAsString withoutSeparators. |
7359 |
fn asFilename exists or:[ fn withoutQuotes asFilename exists ] |
|
5826 | 7360 |
]) ifFalse:[ |
7361 |
m disableAll:#(openFileBrowserOnIt). |
|
6359 | 7362 |
]. |
7363 |
(Error handle:[:ex | |
|
7364 |
ex return:false |
|
7365 |
] do:[ |
|
6374 | 7366 |
|url| |
7367 |
url := self selectionAsString withoutSeparators. |
|
7368 |
#('http' 'https' 'ftp') includes:url asURL method |
|
6359 | 7369 |
]) ifFalse:[ |
7370 |
m disableAll:#(openWebBrowserOnIt). |
|
5826 | 7371 |
] |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7372 |
]. |
2569 | 7373 |
self hasUndoAction ifFalse:[ |
5826 | 7374 |
m disable:#undo. |
3115 | 7375 |
] ifTrue:[ |
5826 | 7376 |
what := undoSupport undoActionInfo. |
7377 |
what notNil ifTrue:[ |
|
7378 |
undoIdx := m indexOf:#undo. |
|
7379 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
7380 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
7381 |
]. |
2952 | 7382 |
self hasRedoAction ifFalse:[ |
5826 | 7383 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
7384 |
] ifTrue:[ |
5826 | 7385 |
what := undoSupport redoActionInfo. |
7386 |
what notNil ifTrue:[ |
|
7387 |
redoIdx := sub indexOf:#redo. |
|
7388 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
7389 |
] |
|
2952 | 7390 |
]. |
5216 | 7391 |
self canAccept ifFalse:[ |
5826 | 7392 |
m disable:#accept |
1108 | 7393 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7394 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7395 |
|
6241 | 7396 |
"Modified: / 30-11-2017 / 15:06:03 / cg" |
6614 | 7397 |
"Modified: / 26-06-2019 / 23:17:26 / Claus Gittinger" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7398 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7399 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7400 |
getTextSelectionFromHistory |
6328 | 7401 |
"present the copyBufferHistory as a shortened list (first line of each), |
7402 |
and let user select from it. |
|
7403 |
Return the corresponding copyBuffer text or nil. |
|
7404 |
Used with 'Paste Previous' menu function" |
|
7405 |
||
6752 | 7406 |
|sel listOfPasteTextLines box history textView scrTextView| |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7407 |
|
5643 | 7408 |
history := device getCopyBufferHistory copy. |
6452 | 7409 |
|
7410 |
"/ the list presents each first line only |
|
6328 | 7411 |
listOfPasteTextLines := |
7412 |
history collect:[:entry | |
|
7413 |
|text shown| |
|
7414 |
||
7415 |
text := entry asString string asCollectionOfLines. |
|
7416 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
|
7417 |
text size > 1 ifTrue:[ |
|
6752 | 7418 |
shown := shown,((resources string:' ... [%1 lines]' with:text size) withColor:Color gray). |
6152 | 7419 |
]. |
6328 | 7420 |
shown |
7421 |
]. |
|
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7422 |
|
6752 | 7423 |
textView := TextView with:c'\n\n'. |
7424 |
||
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7425 |
box := ListSelectionBox |
6152 | 7426 |
title:(resources string:'Clipboard History') |
7427 |
okText:(resources string:'Paste') |
|
7428 |
abortText:(resources string:'Cancel') |
|
6328 | 7429 |
list:listOfPasteTextLines |
6752 | 7430 |
action:[:idx | |
7431 |
idx notNil ifTrue:[ |
|
7432 |
sel := history at:idx |
|
7433 |
]. |
|
7434 |
]. |
|
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7435 |
box label:(resources string:'Select Previous Copybuffer String'). |
6752 | 7436 |
scrTextView := HVScrollableView forView:textView. |
7437 |
scrTextView height:100. |
|
7438 |
box verticalPanel verticalLayout:#bottomFit; add:scrTextView. |
|
7439 |
box listView |
|
7440 |
onChangeEvaluate:[:what :parameter :changedObject | |
|
7441 |
what == #selection ifTrue:[ textView contents:(history at:parameter ifAbsent:'') ] |
|
7442 |
]. |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7443 |
box useIndex:true. |
6752 | 7444 |
box width:600. |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7445 |
box show. |
3160 | 7446 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7447 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7448 |
"Modified: / 25-08-2010 / 22:02:14 / cg" |
6328 | 7449 |
"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
|
7450 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7451 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7452 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7453 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7454 |
self sensor shiftDown ifTrue:[ |
6152 | 7455 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7456 |
]. |
2724 | 7457 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7458 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7459 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7460 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7461 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7462 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7463 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7464 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7465 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7466 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7467 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7468 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7469 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7470 |
"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
|
7471 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7472 |
|
2676 | 7473 |
googleSpellingSuggestion |
7474 |
"insert the google-spelling suggestion for the selected text. |
|
7475 |
Requires that the SOAP stuff is loaded and working." |
|
7476 |
||
2677 | 7477 |
|text suggestion| |
2676 | 7478 |
|
7479 |
self withWaitCursorDo:[ |
|
6152 | 7480 |
text := self selection asString string withoutSeparators. |
7481 |
text size == 0 ifTrue:[^ self]. |
|
7482 |
||
7483 |
"/ the 'Smalltalk at:' code is here to |
|
7484 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
7485 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
7486 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
7487 |
^ self. |
|
7488 |
] do:[ |
|
7489 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
|
7490 |
]. |
|
7491 |
suggestion size == 0 ifTrue:[ |
|
7492 |
self information:('No spelling suggestion from Google for: ' , text). |
|
7493 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
7494 |
^ self. |
|
7495 |
]. |
|
5787 | 7496 |
]. |
7497 |
self |
|
6152 | 7498 |
undoablePaste:suggestion |
7499 |
info:'Spelling Suggestion'. |
|
3495 | 7500 |
|
7501 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 7502 |
! |
7503 |
||
6790 | 7504 |
googleTranslate:fromToModeString |
6804 | 7505 |
"translate the selected text and paste it after the selection. |
7506 |
fromToModeString is of the form sourceLang_destLang" |
|
7507 |
||
7508 |
|sourceLang targetLang| |
|
6790 | 7509 |
|
7510 |
"/ 'en_de' upTo:$_. |
|
7511 |
"/ 'en_de' copyAfter:$_. |
|
7512 |
sourceLang := fromToModeString upTo:$_. |
|
7513 |
targetLang := fromToModeString copyAfter:$_. |
|
6804 | 7514 |
self googleTranslateFrom:sourceLang to:targetLang |
7515 |
! |
|
7516 |
||
7517 |
googleTranslate:original from:sourceLang to:targetLang |
|
7518 |
"translate the selected text and return it" |
|
7519 |
||
6805 | 7520 |
|response url o translated data| |
6790 | 7521 |
|
7522 |
self withWaitCursorDo:[ |
|
7523 |
url := 'http://translate.googleapis.com/translate_a/single?client=gtx&sl=%1&tl=%2&dt=t&ie=UTF-8&oe=UTF-8&q=%3' |
|
6791 | 7524 |
bindWith:sourceLang with:targetLang with:(HTMLUtilities urlEncoded:(original utf8Encoded)). |
6790 | 7525 |
response := HTTPInterface get:url. |
7526 |
||
7527 |
"/ url := 'http://translation.googleapis.com/language/v2'. |
|
7528 |
"/ req := '{ "q": ["%3"], "source": "%1", "target": "%2" }' |
|
7529 |
"/ bindWith:sourceLang with:targetLang with:original. |
|
7530 |
"/ |
|
7531 |
"/ response := HTTPInterface post:url with:req. |
|
7532 |
]. |
|
6804 | 7533 |
response isErrorResponse ifTrue:[^ nil]. |
6805 | 7534 |
data := response data. |
7535 |
response encoding = 'utf-8' ifTrue:[ |
|
7536 |
data := data utf8Decoded |
|
7537 |
]. |
|
7538 |
o := JSONReader decode:data. |
|
6790 | 7539 |
translated := o first first first. |
6804 | 7540 |
translated isEmpty ifTrue:[^ nil]. |
7541 |
^ translated |
|
7542 |
! |
|
7543 |
||
7544 |
googleTranslateFrom:sourceLang to:targetLang |
|
7545 |
"translate the selected text and paste it after the selection." |
|
7546 |
||
7547 |
|original translated| |
|
7548 |
||
7549 |
original := self selectionAsString. |
|
7550 |
original size == 0 ifTrue:[^ self]. |
|
7551 |
||
7552 |
translated := self googleTranslate:original from:sourceLang to:targetLang. |
|
7553 |
translated isNil ifTrue:[^ self]. |
|
6790 | 7554 |
|
7555 |
"/ v pasteOrReplace:translated |
|
7556 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
|
7557 |
self unselect. |
|
7558 |
self |
|
7559 |
undoablePaste:translated |
|
7560 |
info:'Translate' |
|
7561 |
||
7562 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
7563 |
! |
|
7564 |
||
3595 | 7565 |
insertDateAndTime |
6274 | 7566 |
"insert the current date and time string" |
3595 | 7567 |
|
7568 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7569 |
self |
6152 | 7570 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
7571 |
info:'Paste Date and Time' |
|
6274 | 7572 |
|
7573 |
"Modified (comment): / 25-01-2018 / 19:10:40 / mawalch" |
|
3595 | 7574 |
! |
7575 |
||
2676 | 7576 |
insertFile |
3160 | 7577 |
"insert contents of a file |
2676 | 7578 |
- ask user for filename using a fileSelectionBox." |
7579 |
||
3731 | 7580 |
self insertFileAsStringLiteral:false |
7581 |
! |
|
7582 |
||
7583 |
insertFileAsStringLiteral |
|
7584 |
"insert a file's contents as a string literal. |
|
7585 |
Almost the same as the insert file, but single-quotes are doubled, |
|
7586 |
to make it a legal string literal" |
|
7587 |
||
7588 |
self insertFileAsStringLiteral:true |
|
7589 |
! |
|
7590 |
||
7591 |
insertFileAsStringLiteral:asStringLiteral |
|
7592 |
"insert contents of a file; either as-is or as a string literal. |
|
7593 |
- ask user for filename using a fileSelectionBox." |
|
7594 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7595 |
|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
|
7596 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7597 |
((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
|
7598 |
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
|
7599 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7600 |
ifTrue:[ |
6152 | 7601 |
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
|
7602 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7603 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7604 |
[ |
6152 | 7605 |
|why| |
7606 |
||
7607 |
file := Dialog |
|
7608 |
requestFileName:(resources string:'Insert Contents Of:') |
|
7609 |
default:initial |
|
7610 |
ok:(resources string:'Insert') |
|
7611 |
abort:(resources string:'Cancel') |
|
7612 |
pattern:nil |
|
7613 |
fromDirectory:directoryForFileDialog. |
|
7614 |
file isNil ifTrue:[ |
|
7615 |
"cancel" |
|
7616 |
^ self. |
|
7617 |
]. |
|
7618 |
file := file asFilename. |
|
7619 |
directoryForFileDialog := file. |
|
7620 |
||
7621 |
ok := file isReadable and:[file isDirectory not]. |
|
7622 |
ok ifFalse:[ |
|
7623 |
file isReadable ifFalse:[ |
|
6543 | 7624 |
why := '"%1" is unreadable.\\Please try again.' |
6152 | 7625 |
] ifTrue:[ |
6543 | 7626 |
why := '"%1" is a directory.\\Please try again.' |
6152 | 7627 |
]. |
7628 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
7629 |
]. |
|
2909 | 7630 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7631 |
|
5063 | 7632 |
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
|
7633 |
self |
6152 | 7634 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
7635 |
info:'Paste File' |
|
3495 | 7636 |
|
7637 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6543 | 7638 |
"Modified: / 21-02-2019 / 17:42:47 / Claus Gittinger" |
3495 | 7639 |
! |
7640 |
||
3811 | 7641 |
insertURL |
7642 |
"insert contents of a URL |
|
7643 |
- ask user for URL using a dialog." |
|
7644 |
||
7645 |
self insertURLAsStringLiteral:false |
|
7646 |
! |
|
7647 |
||
7648 |
insertURLAsStringLiteral:asStringLiteral |
|
7649 |
"insert contents of a file; either as-is or as a string literal. |
|
7650 |
- ask user for filename using a fileSelectionBox." |
|
7651 |
||
7652 |
|sel url text response initial| |
|
7653 |
||
7654 |
(sel := self selectionAsString) notEmptyOrNil |
|
7655 |
ifTrue:[ |
|
6152 | 7656 |
initial := sel. |
3811 | 7657 |
]. |
7658 |
||
7659 |
url := Dialog |
|
6152 | 7660 |
request:(resources string:'Insert Contents of URL:') |
7661 |
initialAnswer:initial |
|
7662 |
okLabel:(resources string:'Insert') |
|
7663 |
title:(resources string:'URL'). |
|
3811 | 7664 |
url isNil ifTrue:[ |
6152 | 7665 |
"cancel" |
7666 |
^ self. |
|
3811 | 7667 |
]. |
6514 | 7668 |
|
7669 |
self withWaitCursorDo:[ |
|
7670 |
response := HTTPInterface get:url. |
|
7671 |
]. |
|
3811 | 7672 |
response isErrorResponse ifTrue:[ |
6152 | 7673 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
7674 |
^ self. |
|
3811 | 7675 |
]. |
7676 |
text := response data asString. |
|
7677 |
||
7678 |
self |
|
6152 | 7679 |
undoableDo:[ |
7680 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
7681 |
] |
|
7682 |
info:'Insert Contents of URL' |
|
6514 | 7683 |
|
7684 |
"Modified: / 20-12-2018 / 10:27:46 / Claus Gittinger" |
|
3811 | 7685 |
! |
7686 |
||
3495 | 7687 |
insertUUID |
7688 |
"insert a new UUID's string" |
|
7689 |
||
7690 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7691 |
self |
6152 | 7692 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
7693 |
info:'Paste New UUID' |
|
3495 | 7694 |
|
7695 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 7696 |
! |
7697 |
||
4940 | 7698 |
insertUnicode |
7699 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
7700 |
||
7701 |
|unicodePoint unicodeChar unicodeString| |
|
7702 |
||
5904 | 7703 |
unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):'). |
4940 | 7704 |
unicodeString size < 2 ifTrue:[ |
5904 | 7705 |
^ self. |
4940 | 7706 |
]. |
7707 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
5904 | 7708 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
4940 | 7709 |
] ifFalse:[ |
5904 | 7710 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
5787 | 7711 |
]. |
7712 |
||
4940 | 7713 |
unicodeChar := Character value:unicodePoint. |
7714 |
self keyPress:unicodeChar x:0 y:0. |
|
7715 |
self keyRelease:unicodeChar x:0 y:0. |
|
7716 |
! |
|
7717 |
||
6669 | 7718 |
inspectSelectedJSON |
7719 |
"inspect the selected (decoded) JSON text" |
|
7720 |
||
7721 |
|obj| |
|
7722 |
||
7723 |
[ |
|
7724 |
obj := JSONReader decode:self selectionAsString |
|
7725 |
] on:Error do:[:ex | |
|
7726 |
Dialog warn:'Could not decode JSON (not a valid JSON string)'. |
|
7727 |
^ self |
|
7728 |
]. |
|
7729 |
obj inspect. |
|
7730 |
! |
|
7731 |
||
5331 | 7732 |
inspectSelectedString |
7733 |
"inspect the selected text" |
|
7734 |
||
7735 |
self selectionAsString inspect. |
|
7736 |
! |
|
7737 |
||
4742 | 7738 |
internalSpellingSuggestion |
7739 |
"insert the internal-spelling suggestion for the selected text. |
|
7740 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7741 |
||
7742 |
|text suggestions best| |
|
7743 |
||
7744 |
self withWaitCursorDo:[ |
|
6152 | 7745 |
text := self selection asString string withoutSeparators. |
7746 |
text size == 0 ifTrue:[^ self]. |
|
7747 |
||
7748 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7749 |
suggestions size == 0 ifTrue:[ |
|
7750 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7751 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7752 |
^ self. |
|
7753 |
]. |
|
7754 |
Transcript showCR:suggestions. |
|
7755 |
best := suggestions first. |
|
5787 | 7756 |
]. |
7757 |
self |
|
6152 | 7758 |
undoablePaste:best |
7759 |
info:'Spelling Suggestion'. |
|
4742 | 7760 |
! |
7761 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7762 |
paste |
1289 | 7763 |
"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
|
7764 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7765 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7766 |
self checkModificationsAllowed ifTrue:[ |
6152 | 7767 |
self withSelfAndTextForPasteDo:[:me :text | |
7768 |
me unselect. |
|
7769 |
me undoablePaste:text |
|
7770 |
] |
|
2952 | 7771 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7772 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7773 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7774 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7775 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7776 |
|
3825 | 7777 |
self paste:someText withCR:false |
7778 |
! |
|
7779 |
||
7780 |
paste:someText withCR:withCR |
|
7781 |
"paste someText at cursor" |
|
7782 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7783 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7784 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7785 |
self checkModificationsAllowed ifFalse:[^ self]. |
6399 | 7786 |
someText isEmptyOrNil ifTrue:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7787 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7788 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7789 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7790 |
CharacterEncoderError handle:[:ex | |
6152 | 7791 |
|code msg| |
7792 |
||
7793 |
code := ex parameter. |
|
7794 |
codingErrorReported ifFalse:[ |
|
6399 | 7795 |
msg := 'Cannot represent pasted string in this view''s encoding (',gc characterEncoding,').'. |
6152 | 7796 |
code notNil ifTrue:[ |
7797 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7798 |
]. |
|
7799 |
Dialog warn:(resources stringWithCRs:msg). |
|
7800 |
codingErrorReported := true. |
|
7801 |
]. |
|
7802 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7803 |
] do:[ |
6152 | 7804 |
s isString ifTrue:[ |
7805 |
s encoding ~~ gc characterEncoding ifTrue:[ |
|
7806 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7807 |
]. |
|
7808 |
||
7809 |
s := s asStringCollection. |
|
7810 |
(someText endsWith:Character cr) ifTrue:[ |
|
7811 |
"/ s := s copyWith:nil. |
|
7812 |
s := s copyWith:'' "/ an empty line at the end |
|
7813 |
||
7814 |
] |
|
7815 |
] ifFalse:[ |
|
7816 |
s isStringCollection ifTrue:[ |
|
7817 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7818 |
] ifFalse:[ |
|
7819 |
(self |
|
7820 |
confirm:(resources |
|
7821 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7822 |
with:s class name)) ifFalse:[^ self]. |
|
7823 |
s := StringCollection with:s storeString . |
|
7824 |
"/ ^ self |
|
7825 |
]. |
|
7826 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7827 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7828 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7829 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7830 |
(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
|
7831 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7832 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7833 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7834 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7835 |
startCol := c1 := cursorCol. |
3180 | 7836 |
|
5787 | 7837 |
"do not autoindent here. |
7838 |
It does make things very ugly, in the inspector |
|
5194 | 7839 |
(try inspecting a multiline string)..." |
7840 |
self withAutoIndent:false do:[ |
|
6152 | 7841 |
"do not expand tabs into spaces here - |
7842 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7843 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7844 |
||
7845 |
self insertLines:s withCR:withCR. |
|
5194 | 7846 |
]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7847 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7848 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7849 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7850 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7851 |
|
4328 | 7852 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7853 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
6399 | 7854 |
"Modified: / 22-08-2018 / 08:29:13 / Claus Gittinger" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7855 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7856 |
|
3731 | 7857 |
pasteAsStringLiteral |
7858 |
"insert clipboard string as a string literal. |
|
7859 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7860 |
to make it a legal string literal" |
|
7861 |
||
7862 |
typeOfSelection := nil. |
|
7863 |
self |
|
6152 | 7864 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
7865 |
info:'Paste as String Literal' |
|
3731 | 7866 |
! |
7867 |
||
6134 | 7868 |
pasteBox |
7869 |
"paste the copybuffer as a box; |
|
7870 |
if there is a selection, unselect first. |
|
7871 |
Then paste at cursor position." |
|
7872 |
||
7873 |
self checkModificationsAllowed ifTrue:[ |
|
7874 |
self withSelfAndTextForPasteDo:[:me :text | |
|
7875 |
me unselect. |
|
7876 |
me undoablePasteBox:text |
|
7877 |
] |
|
7878 |
] |
|
7879 |
||
7880 |
"Created: / 14-03-2017 / 16:34:16 / cg" |
|
7881 |
! |
|
7882 |
||
7883 |
pasteBox:someText |
|
7884 |
"paste someText at cursor" |
|
7885 |
||
7886 |
self pasteBox:someText withCR:false |
|
7887 |
||
7888 |
"Created: / 14-03-2017 / 16:35:08 / cg" |
|
7889 |
! |
|
7890 |
||
7891 |
pasteBox:someText withCR:withCR |
|
7892 |
"paste someText at cursor" |
|
7893 |
||
7894 |
|lines nLines startLine startCol l1 l2 c1 c2| |
|
7895 |
||
7896 |
self checkModificationsAllowed ifFalse:[^ self]. |
|
7897 |
||
7898 |
lines := someText asStringCollection. |
|
7899 |
||
7900 |
(nLines := lines size) == 0 ifTrue:[^ self]. |
|
7901 |
(nLines == 1 and:[(lines at:1) size == 0]) ifTrue:[^ self]. |
|
7902 |
||
7903 |
typeOfSelection := #paste. |
|
7904 |
||
7905 |
startLine := l1 := cursorLine. |
|
7906 |
startCol := c1 := cursorCol. |
|
7907 |
||
7908 |
"do not autoindent here. |
|
7909 |
It does make things very ugly, in the inspector |
|
7910 |
(try inspecting a multiline string)..." |
|
7911 |
self withAutoIndent:false do:[ |
|
7912 |
"do not expand tabs into spaces here - |
|
7913 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7914 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7915 |
||
7916 |
lines do:[:eachLine | |
|
7917 |
self insertString:eachLine atLine:l1 col:startCol. |
|
7918 |
l1 := l1 + 1. |
|
7919 |
]. |
|
7920 |
]. |
|
7921 |
l2 := cursorLine. |
|
7922 |
c2 := (cursorCol - 1). |
|
7923 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
|
7924 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
|
7925 |
||
7926 |
"Created: / 14-03-2017 / 16:39:11 / cg" |
|
7927 |
! |
|
7928 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7929 |
pasteOrReplace |
1289 | 7930 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7931 |
otherwise paste at cursor position. |
7932 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7933 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7934 |
|
2724 | 7935 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7936 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7937 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7938 |
pasteOrReplace:someText |
1289 | 7939 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7940 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7941 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7942 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7943 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7944 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7945 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7946 |
self undoableDo:[ |
6152 | 7947 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7948 |
self replace:someText |
|
7949 |
] ifFalse:[ |
|
7950 |
self paste:someText. |
|
7951 |
] |
|
3542 | 7952 |
] info:'Paste/Replace'. |
1289 | 7953 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7954 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7955 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7956 |
|
6134 | 7957 |
pasteOrReplaceBox |
7958 |
"paste the copybuffer as a box; |
|
7959 |
if there is a selection, unselect first. |
|
7960 |
Then paste at cursor position." |
|
7961 |
||
7962 |
self pasteBox |
|
7963 |
||
7964 |
"Created: / 14-03-2017 / 16:40:08 / cg" |
|
7965 |
! |
|
7966 |
||
5387 | 7967 |
pasteOrReplaceByKeyPress |
7968 |
"paste a previous item from the copybuffer history. |
|
7969 |
(i.e. repaste some previously deleted or copied text)" |
|
7970 |
||
7971 |
|text| |
|
7972 |
||
6226 | 7973 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
7974 |
||
5387 | 7975 |
text := self getClipboardText:#clipboard. |
7976 |
text notNil ifTrue:[ |
|
6152 | 7977 |
self pasteOrReplace:text |
5387 | 7978 |
] |
6226 | 7979 |
|
7980 |
"Modified: / 11-11-2017 / 12:52:54 / cg" |
|
5387 | 7981 |
! |
7982 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7983 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7984 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7985 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7986 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7987 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7988 |
|
6226 | 7989 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
7990 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7991 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7992 |
text notNil ifTrue:[ |
6452 | 7993 |
"/ move to top of list. |
7994 |
device rememberInCopyBufferHistory:text. |
|
6152 | 7995 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7996 |
] |
6226 | 7997 |
|
7998 |
"Modified: / 11-11-2017 / 12:52:42 / cg" |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7999 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
8000 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8001 |
replace |
1289 | 8002 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8003 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
8004 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
8005 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
8006 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
8007 |
self withSelfAndTextForPasteDo:[:me :text | |
6152 | 8008 |
me undoableDo:[ me replace:text ] |
8009 |
info:'Replace' |
|
2952 | 8010 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8011 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8012 |
|
121 | 8013 |
replace:someText |
1289 | 8014 |
"replace the selection by someText" |
121 | 8015 |
|
3160 | 8016 |
|selected selectedString |
8017 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 8018 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
8019 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
8020 |
|
3130 | 8021 |
self undoableDo:[ |
6152 | 8022 |
selected := self selection. |
8023 |
selected isNil ifTrue:[ |
|
8024 |
^ self paste:someText |
|
8025 |
]. |
|
8026 |
||
8027 |
self deleteSelection. |
|
8028 |
||
8029 |
"take care, if we replace a selection without space by a word selected |
|
8030 |
with one - in this case we usually do not want the space. |
|
8031 |
But, if we replace a word-selected selection by something without a |
|
8032 |
space, we DO want the space added." |
|
8033 |
||
8034 |
selected size == 1 ifTrue:[ |
|
8035 |
selectedString := selected at:1. |
|
8036 |
]. |
|
8037 |
||
8038 |
someText size == 1 ifTrue:[ |
|
8039 |
|cutOffSpace addSpace replacement replacementString| |
|
8040 |
||
8041 |
cutOffSpace := false. |
|
8042 |
addSpace := false. |
|
8043 |
replacement := someText copyFrom:1. |
|
8044 |
||
8045 |
selectedString notNil ifTrue:[ |
|
8046 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
8047 |
"selection has no space" |
|
8048 |
||
8049 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
8050 |
cutOffSpace := true |
|
8051 |
] |
|
8052 |
] ifTrue:[ |
|
8053 |
addSpace := true |
|
8054 |
] |
|
8055 |
]. |
|
8056 |
replacementString := replacement at:1. |
|
8057 |
cutOffSpace ifTrue:[ |
|
8058 |
(replacementString startsWith:' ') ifTrue:[ |
|
8059 |
replacementString := replacementString withoutSpaces |
|
8060 |
]. |
|
8061 |
] ifFalse:[ |
|
8062 |
selectStyle == #wordLeft ifTrue:[ |
|
8063 |
"want a space at left" |
|
8064 |
(replacementString startsWith:' ') ifFalse:[ |
|
8065 |
replacementString := replacementString withoutSpaces. |
|
8066 |
replacementString := ' ' , replacementString |
|
8067 |
] |
|
8068 |
]. |
|
8069 |
selectStyle == #wordRight ifTrue:[ |
|
8070 |
"want a space at right" |
|
8071 |
||
8072 |
(replacementString endsWith:' ') ifFalse:[ |
|
8073 |
replacementString := replacementString withoutSpaces. |
|
8074 |
replacementString := replacementString , ' ' |
|
8075 |
] |
|
8076 |
]. |
|
8077 |
]. |
|
8078 |
replacement at:1 put: replacementString. |
|
8079 |
self paste:replacement. |
|
8080 |
] ifFalse:[ |
|
8081 |
self paste:someText |
|
8082 |
]. |
|
8083 |
self setLastStringToReplace: selectedString. |
|
8084 |
||
8085 |
lastReplacementInfo lastReplacement: someText. |
|
8086 |
||
8087 |
selStartLine := selectionStartLine. |
|
8088 |
selStartCol := self selectionStartCol. |
|
8089 |
selEndLine := selectionEndLine. |
|
8090 |
selEndCol := self selectionEndCol. |
|
3130 | 8091 |
] |
3542 | 8092 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
8093 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
8094 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
8095 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 8096 |
! |
8097 |
||
3430 | 8098 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8099 |
"search for a string - show a box to enter searchpattern |
3430 | 8100 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
8101 |
- 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
|
8102 |
|
3430 | 8103 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
8104 |
||
8105 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
8106 |
lastSearchDirection := #forward. |
|
8107 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 8108 |
caseHolder := ValueHolder with:ign. |
8109 |
patternHolder := ValueHolder with:''. |
|
8110 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 8111 |
lastSearchPattern notNil ifTrue:[ |
6152 | 8112 |
initialString := lastSearchPattern |
3430 | 8113 |
]. |
8114 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
6152 | 8115 |
initialString := self selectionAsString |
3430 | 8116 |
]. |
8117 |
initialString isNil ifTrue:[ |
|
6548 | 8118 |
LastSearchPatterns size ~~ 0 ifTrue:[ |
6152 | 8119 |
initialString := LastSearchPatterns first |
8120 |
] |
|
3430 | 8121 |
]. |
8122 |
initialString notNil ifTrue:[ |
|
6152 | 8123 |
patternHolder value:initialString. |
8124 |
replacePatternHolder value:initialString. |
|
3430 | 8125 |
]. |
8126 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8127 |
search := [:fwd | |
6152 | 8128 |
self |
8129 |
search:patternHolder value |
|
8130 |
ignoreCase:caseHolder value |
|
8131 |
forward:fwd. |
|
8132 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
8133 |
replace := [:all | |
6152 | 8134 |
self |
8135 |
replace:patternHolder value |
|
8136 |
by:replacePatternHolder value |
|
8137 |
all:all |
|
8138 |
ignoreCase:caseHolder value |
|
8139 |
]. |
|
3430 | 8140 |
bindings := IdentityDictionary new. |
8141 |
bindings at:#searchPattern put:patternHolder. |
|
8142 |
bindings at:#replacePattern put:replacePatternHolder. |
|
8143 |
modal ifTrue:[ |
|
6152 | 8144 |
bindings at:#nextAction |
8145 |
put:[ |
|
8146 |
flag := true. |
|
8147 |
action := search. |
|
8148 |
searchBox doAccept. |
|
8149 |
]. |
|
8150 |
bindings at:#prevAction |
|
8151 |
put:[ |
|
8152 |
flag := false. |
|
8153 |
action := search. |
|
8154 |
searchBox doAccept. |
|
8155 |
]. |
|
8156 |
bindings at:#replaceAction |
|
8157 |
put:[ |
|
8158 |
flag := false. |
|
8159 |
action := replace. |
|
8160 |
searchBox doAccept. |
|
8161 |
]. |
|
8162 |
bindings at:#replaceAllAction |
|
8163 |
put:[ |
|
8164 |
flag := true. |
|
8165 |
action := replace. |
|
8166 |
searchBox doAccept. |
|
8167 |
]. |
|
3430 | 8168 |
] ifFalse:[ |
6152 | 8169 |
bindings at:#nextAction put:[ search value:true. ]. |
8170 |
bindings at:#prevAction put:[ search value:false. ]. |
|
8171 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
8172 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 8173 |
]. |
8174 |
bindings at:#ignoreCase put:caseHolder. |
|
8175 |
bindings at:#patternList put:LastSearchPatterns. |
|
8176 |
modal ifTrue:[ |
|
6152 | 8177 |
searchBox := SimpleDialog new. |
3430 | 8178 |
] ifFalse:[ |
6152 | 8179 |
searchBox := ApplicationModel new. |
8180 |
searchBox createBuilder. |
|
3430 | 8181 |
]. |
8182 |
searchBox resources:(self resources). |
|
8183 |
bldr := searchBox builder. |
|
8184 |
bldr addBindings:bindings. |
|
8185 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
8186 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
8187 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
8188 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
8189 |
modal ifTrue:[ |
|
6152 | 8190 |
searchBox openDialog. |
8191 |
searchBox accepted ifTrue:[ |
|
8192 |
action value:flag |
|
8193 |
]. |
|
3430 | 8194 |
] ifFalse:[ |
6152 | 8195 |
(bldr componentAt:#nextButton) isReturnButton:false. |
8196 |
(bldr componentAt:#cancelButton) |
|
8197 |
label:(resources string:'Close'); |
|
8198 |
action:[ searchBox closeRequest ]. |
|
8199 |
||
8200 |
"/ searchBox masterApplication:self application. |
|
8201 |
||
8202 |
self topView beMaster. |
|
8203 |
(searchBox window) |
|
8204 |
beSlave; |
|
8205 |
openInGroup:(self windowGroup). |
|
8206 |
||
8207 |
"/ searchBox window open. |
|
8208 |
||
8209 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
|
3430 | 8210 |
] |
8211 |
||
8212 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
6548 | 8213 |
"Modified: / 01-03-2019 / 14:55:01 / Claus Gittinger" |
3430 | 8214 |
! |
8215 |
||
6241 | 8216 |
selectionDecodeBase64 |
8217 |
self paste:(Base64Coder decode:self selectionAsString) asString |
|
8218 |
||
8219 |
"Created: / 30-11-2017 / 15:07:31 / cg" |
|
8220 |
! |
|
8221 |
||
8222 |
selectionEncodeBase64 |
|
8223 |
self paste:(Base64Coder encode:self selectionAsString) |
|
8224 |
||
8225 |
"Created: / 30-11-2017 / 15:07:34 / cg" |
|
8226 |
! |
|
8227 |
||
8228 |
selectionRot13 |
|
8229 |
"a naive caesar cypher" |
|
8230 |
||
8231 |
self paste:(self selectionAsString rot13) |
|
8232 |
||
8233 |
"Created: / 30-11-2017 / 15:07:50 / cg" |
|
8234 |
! |
|
8235 |
||
121 | 8236 |
showDeleted |
8237 |
"open a readonly editor on all deleted text" |
|
8238 |
||
8239 |
|v| |
|
8240 |
||
8241 |
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
|
8242 |
v readOnly:true. |
121 | 8243 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
8244 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
8245 |
|
6599 | 8246 |
showLineLimitInMenu |
8247 |
"only for text collectors" |
|
8248 |
||
8249 |
^ false. |
|
8250 |
||
8251 |
"Created: / 06-06-2019 / 11:22:09 / Claus Gittinger" |
|
8252 |
! |
|
8253 |
||
3221 | 8254 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 8255 |
"sort/reorder the selected lines. |
8256 |
how: |
|
6152 | 8257 |
#lines |
8258 |
#linesByFirstWord |
|
8259 |
#linesByNthWord |
|
8260 |
#linesByNthNumber |
|
8261 |
#linesByNthHexNumber |
|
8262 |
#words |
|
8263 |
#linesByLength |
|
8264 |
#reverse |
|
4763 | 8265 |
" |
8266 |
||
8267 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 8268 |
|
8269 |
lineWise := true. |
|
8270 |
||
4763 | 8271 |
how == #reverse ifTrue:[ |
6152 | 8272 |
operation := [:lines | lines reverse]. |
4763 | 8273 |
] ifFalse:[ |
6152 | 8274 |
operation := [:linesOrWords | |
8275 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
8276 |
]. |
|
8277 |
||
8278 |
how == #linesByLength ifTrue:[ |
|
8279 |
fetcher := [:l | l size]. |
|
8280 |
] ifFalse:[ |
|
8281 |
how == #lines ifTrue:[ |
|
8282 |
extractor := [:l | l withoutLeadingSeparators]. |
|
8283 |
] ifFalse:[ |
|
8284 |
how == #linesByFirstWord ifTrue:[ |
|
8285 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
8286 |
] ifFalse:[ |
|
8287 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
8288 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
8289 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
8290 |
n := Integer readFrom:nStr onError:[^ self]. |
|
8291 |
LastColumnNumberForSort := n. |
|
8292 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
8293 |
how == #linesByNthNumber ifTrue:[ |
|
8294 |
innerExtractor := extractor. |
|
8295 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
8296 |
] ifFalse:[ |
|
8297 |
how == #linesByNthHexNumber ifTrue:[ |
|
8298 |
innerExtractor := extractor. |
|
8299 |
extractor := [:l | |
|
8300 |
|s| |
|
8301 |
s := innerExtractor value:l. |
|
8302 |
(s startsWith:'16r') ifTrue:[ |
|
8303 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
8304 |
] ifFalse:[ |
|
8305 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
8306 |
] |
|
8307 |
] |
|
8308 |
] |
|
8309 |
]. |
|
8310 |
] ifFalse:[ |
|
8311 |
how == #words ifTrue:[ |
|
8312 |
lineWise := false. |
|
8313 |
extractor := [:w | w]. |
|
8314 |
] ifFalse:[ |
|
8315 |
self error:'unknown sort criteria: ', how printString. |
|
8316 |
] |
|
8317 |
] |
|
8318 |
] |
|
8319 |
]. |
|
8320 |
ignoreCase ifTrue:[ |
|
8321 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
8322 |
] ifFalse:[ |
|
8323 |
fetcher := extractor. |
|
8324 |
]. |
|
8325 |
]. |
|
3221 | 8326 |
]. |
8327 |
||
8328 |
lineWise ifTrue:[ |
|
6152 | 8329 |
"process the lines of the selection (aka a collection of lines)" |
8330 |
start == end ifTrue:[^ self ]. |
|
8331 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
8332 |
lines := operation value:lines. |
|
8333 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
4763 | 8334 |
] ifFalse:[ |
6152 | 8335 |
"process the whole selection as a string" |
8336 |
s := self selectionAsString. |
|
8337 |
words := s asCollectionOfWords. |
|
8338 |
words := operation value:words. |
|
8339 |
s := words asStringCollection asStringWith:Character space. |
|
8340 |
self replace:s. |
|
4763 | 8341 |
]. |
3221 | 8342 |
self textChanged. |
4373 | 8343 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
8344 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 8345 |
! |
8346 |
||
8347 |
sortSelection:how ignoreCase:ignoreCase |
|
8348 |
"sort the selected lines" |
|
8349 |
||
8350 |
|start end| |
|
8351 |
||
8352 |
selectionStartLine isNil ifTrue:[^ self]. |
|
8353 |
||
8354 |
start := selectionStartLine. |
|
8355 |
end := selectionEndLine. |
|
8356 |
(selectionEndCol == 0) ifTrue:[ |
|
6152 | 8357 |
end := end - 1 |
3221 | 8358 |
]. |
8359 |
||
8360 |
self |
|
6152 | 8361 |
undoableDo:[ |
8362 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
8363 |
] |
|
8364 |
info:'Sort' |
|
4373 | 8365 |
|
8366 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 8367 |
! |
8368 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
8369 |
specialCharacters |
6517 | 8370 |
"open the special characters input window" |
8371 |
||
8372 |
"CharacterInputViewSingleton := nil" |
|
8373 |
||
8374 |
(CharacterInputViewSingleton notNil and:[CharacterInputViewSingleton isOpen]) ifTrue:[ |
|
8375 |
CharacterInputViewSingleton consumingView:self. |
|
8376 |
CharacterInputViewSingleton topView raiseDeiconified. |
|
8377 |
] ifFalse:[ |
|
8378 |
CharacterInputViewSingleton := |
|
8379 |
CharacterSetView |
|
8380 |
openAsInputFor:self |
|
8381 |
label:(resources string:'Special Character Input') |
|
8382 |
clickLabel:(resources string:'Click to Insert Character'). |
|
8383 |
]. |
|
8384 |
||
8385 |
"Modified (comment): / 08-01-2019 / 18:24:13 / Claus Gittinger" |
|
2866 | 8386 |
! |
8387 |
||
5370 | 8388 |
splitLinesAtCharacterOrString |
8389 |
"ask user for the character and split after it" |
|
8390 |
||
8391 |
|sel in out separator record| |
|
8392 |
||
8393 |
selectionStartLine isNil ifTrue:[^ self]. |
|
6227 | 8394 |
self checkModificationsAllowed ifFalse:[^ self]. |
5370 | 8395 |
|
8396 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
8397 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
8398 |
||
8399 |
sel := self selectionAsString. |
|
8400 |
in := sel readStream. |
|
5887 | 8401 |
out := CharacterWriteStream on:''. |
5370 | 8402 |
[in atEnd] whileFalse:[ |
5887 | 8403 |
record := in throughAll:separator. |
8404 |
out nextPutLine:record. |
|
5370 | 8405 |
]. |
8406 |
self |
|
5887 | 8407 |
undoableDo:[ |
8408 |
self replaceSelectionBy:(out contents). |
|
8409 |
] |
|
8410 |
info:'Split Selection' |
|
6227 | 8411 |
|
8412 |
"Modified: / 15-11-2017 / 11:56:45 / cg" |
|
5370 | 8413 |
! |
8414 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8415 |
undoablePaste:someText |
3495 | 8416 |
self undoablePaste:someText info:nil. |
8417 |
||
8418 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
8419 |
! |
|
8420 |
||
8421 |
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
|
8422 |
self |
6152 | 8423 |
undoableDo:[ |
8424 |
self paste:someText. |
|
8425 |
] |
|
8426 |
info:infoOrNil |
|
3495 | 8427 |
|
8428 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
8429 |
! |
|
8430 |
||
6134 | 8431 |
undoablePasteBox:someText |
8432 |
self undoablePasteBox:someText info:nil. |
|
8433 |
||
8434 |
"Created: / 14-03-2017 / 16:34:31 / cg" |
|
8435 |
! |
|
8436 |
||
8437 |
undoablePasteBox:someText info:infoOrNil |
|
8438 |
self |
|
8439 |
undoableDo:[ |
|
8440 |
self pasteBox:someText. |
|
8441 |
] |
|
8442 |
info:infoOrNil |
|
8443 |
||
8444 |
"Created: / 14-03-2017 / 16:34:55 / cg" |
|
8445 |
! |
|
8446 |
||
3495 | 8447 |
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
|
8448 |
self |
6152 | 8449 |
undoableDo:[ |
8450 |
self pasteOrReplace:someText. |
|
8451 |
] |
|
8452 |
info:infoOrNil |
|
3495 | 8453 |
|
8454 |
"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
|
8455 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8456 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8457 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8458 |
self |
6152 | 8459 |
undoableDo:[ |
8460 |
self selectAll. |
|
8461 |
self pasteOrReplace:someText. |
|
8462 |
] |
|
8463 |
info:infoOrNil |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8464 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8465 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8466 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
8467 |
|
2724 | 8468 |
withSelfAndTextForPasteDo:aBlock |
8469 |
"common code for paste/replace of the copybuffer" |
|
8470 |
||
8471 |
|sel| |
|
8472 |
||
6226 | 8473 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
2724 | 8474 |
|
8475 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
8476 |
sel notNil ifTrue:[ |
|
6152 | 8477 |
aBlock value:self value:sel. |
2724 | 8478 |
] |
6226 | 8479 |
|
8480 |
"Modified: / 11-11-2017 / 12:52:31 / cg" |
|
6477
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8481 |
! |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8482 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8483 |
withSelfAndTextForPasteFromHistoryDo:aBlock |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8484 |
"common code for paste/replace from the copyBuffer history" |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8485 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8486 |
|sel| |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8487 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8488 |
(self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self]. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8489 |
sel := self getTextSelectionFromHistory. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8490 |
sel notNil ifTrue:[ |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8491 |
aBlock value:self value:sel. |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8492 |
] |
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8493 |
|
9fb3de4fdc0f
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
6469
diff
changeset
|
8494 |
"Modified: / 11-11-2017 / 12:52:31 / cg" |
105 | 8495 |
! ! |
8496 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8497 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8498 |
|
3880 | 8499 |
beep |
5244 | 8500 |
"output an audible beep or bell on my screen device" |
8501 |
||
6262 | 8502 |
super beepInEditor |
3880 | 8503 |
! |
8504 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8505 |
checkModificationsAllowed |
6226 | 8506 |
"check if the text can be modified (i.e. is not readOnly), return true or false. |
8507 |
If not, and an exceptionBlock has been defined, evaluate it. |
|
8508 |
The exceptionBlock can be provided by the application or user of the textView, |
|
8509 |
and may show a warnBox or whatever, or ask again. |
|
8510 |
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
|
8511 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8512 |
self isReadOnly ifTrue: [ |
6152 | 8513 |
exceptionBlock isNil ifTrue:[ |
8514 |
^ false |
|
8515 |
]. |
|
8516 |
||
8517 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
8518 |
^ false |
|
8519 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8520 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8521 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8522 |
|
6226 | 8523 |
"Modified: / 17-06-1998 / 15:51:10 / cg" |
8524 |
"Modified (comment): / 11-11-2017 / 12:49:29 / cg" |
|
8525 |
! |
|
8526 |
||
8527 |
checkModificationsAllowedFlashIfNot:doFlashIfNot |
|
8528 |
"check if the text can be modified (i.e. is not readOnly), return true or false. |
|
8529 |
If not, and an exceptionBlock has been defined, evaluate it. |
|
8530 |
The exceptionBlock can be provided by the application or user of the textView, |
|
8531 |
and may show a warnBox or whatever, or ask again. |
|
8532 |
It can return true to allow the modification. |
|
8533 |
If either no exceptionBlock was defined or it returned false, |
|
8534 |
and doFlashIfNot is true then flash the view to tell the user." |
|
8535 |
||
8536 |
self isReadOnly ifTrue: [ |
|
8537 |
(exceptionBlock isNil |
|
8538 |
or:[(exceptionBlock value:'Text may not be modified') ~~ true]) ifTrue:[ |
|
8539 |
doFlashIfNot ifTrue:[ |
|
8540 |
self flashReadOnly |
|
8541 |
]. |
|
8542 |
^ false |
|
8543 |
]. |
|
8544 |
]. |
|
8545 |
^ true |
|
8546 |
||
8547 |
"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
|
8548 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8549 |
|
2596 | 8550 |
currentSelectionBgColor |
8551 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 8552 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
5787 | 8553 |
]. |
8554 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
|
2596 | 8555 |
^ super currentSelectionBgColor |
8556 |
||
8557 |
" |
|
8558 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
8559 |
" |
|
8560 |
! |
|
8561 |
||
8562 |
currentSelectionFgColor |
|
8563 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 8564 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 8565 |
]. |
8566 |
^ super currentSelectionFgColor |
|
8567 |
! |
|
8568 |
||
3996 | 8569 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8570 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 8571 |
|
8572 |
super resetVariablesBeforeNewSearch. |
|
8573 |
||
8574 |
"/ new search invalidates remembered string |
|
4048 | 8575 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8576 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8577 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 8578 |
! |
8579 |
||
4053 | 8580 |
setLastStringToReplace: aString |
8581 |
||
8582 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
8583 |
||
8584 |
|lastReplaceIgnoredCase| |
|
8585 |
||
4064 | 8586 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
8587 |
self clearSearchAction. |
|
8588 |
||
4053 | 8589 |
lastReplacementInfo lastStringToReplace: aString. |
8590 |
lastStringFromReplaceForNextSearch := aString. |
|
8591 |
||
8592 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
5787 | 8593 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
6152 | 8594 |
ifTrue: [lastSearchIgnoredCase] |
8595 |
ifFalse: [nil]. |
|
4053 | 8596 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
8597 |
! |
|
8598 |
||
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8599 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8600 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8601 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8602 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8603 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8604 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8605 |
textChanged |
522 | 8606 |
"my text was modified (internally). |
8607 |
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
|
8608 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 8609 |
is used to notify scrollers, other views etc.). |
8610 |
||
5979 | 8611 |
As some authors of this code have been very sloppy in the past |
4635 | 8612 |
(not sending contentsChanged, but textChanged), |
8613 |
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
|
8614 |
|
641 | 8615 |
self contentsChanged. |
1015 | 8616 |
self modified:true. |
5774 | 8617 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8618 |
contentsWasSaved := false |
641 | 8619 |
|
1015 | 8620 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 8621 |
! |
8622 |
||
2617 | 8623 |
textChangedButNoSizeChange |
2207 | 8624 |
"my text was modified (internally). |
8625 |
Sent whenever text has been edited (not to confuse with |
|
8626 |
contentsChanged, which is triggered when the size has changed, and |
|
8627 |
is used to notify scrollers, other views etc.)" |
|
8628 |
||
8629 |
self modified:true. |
|
8630 |
contentsWasSaved := false |
|
8631 |
||
8632 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8633 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8634 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8635 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8636 |
|
5216 | 8637 |
canAccept |
8638 |
"true if text can be accepts. |
|
8639 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8640 |
||
8641 |
^ acceptEnabled ~~ false |
|
8642 |
! |
|
8643 |
||
8644 |
canCut |
|
8645 |
"true if there is a selection possibly to be cut. |
|
8646 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8647 |
||
8648 |
self isReadOnly ifTrue:[ ^ false ]. |
|
8649 |
^ self hasSelection |
|
8650 |
! |
|
8651 |
||
8652 |
canDoAgain |
|
8653 |
"true if there is a possible repeat last edit operation. |
|
8654 |
Used to disable the menu if there is nothing" |
|
8655 |
||
8656 |
self isReadOnly ifTrue:[ ^ false ]. |
|
5972 | 8657 |
^ lastReplacementInfo lastStringToReplace notNil |
8658 |
||
8659 |
"Modified: / 19-11-2016 / 20:19:02 / cg" |
|
5216 | 8660 |
! |
8661 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8662 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8663 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8664 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8665 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8666 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8667 |
"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
|
8668 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8669 |
|
4064 | 8670 |
hasSearchActionSelection |
8671 |
||
8672 |
^ typeOfSelection == #searchAction |
|
8673 |
! |
|
8674 |
||
1878 | 8675 |
isKeyboardConsumer |
8676 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 8677 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 8678 |
|
3476 | 8679 |
^ self isReadOnly not |
1878 | 8680 |
! |
8681 |
||
997 | 8682 |
specClass |
1390 | 8683 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
8684 |
||
997 | 8685 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 8686 |
^ super specClass |
8687 |
||
1390 | 8688 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 8689 |
! |
8690 |
||
324 | 8691 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
8692 |
"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
|
8693 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8694 |
"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
|
8695 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8696 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 8697 |
|
8698 |
"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
|
8699 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8700 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8701 |
widthOfContents |
6230 | 8702 |
"return the width of the contents in pixels. |
8703 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8704 |
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
|
8705 |
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
|
8706 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8707 |
|
697 | 8708 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8709 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8710 |
w := super widthOfContents. |
5643 | 8711 |
(dev := device ) isNil ifTrue:[ |
6152 | 8712 |
"/ really don't know ... |
8713 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
8714 |
]. |
6230 | 8715 |
"/ add width of a space (so cursor is always seen) |
4889 | 8716 |
^ w + (gc font widthOn:dev) |
697 | 8717 |
|
6230 | 8718 |
"Modified: / 28-05-1996 / 19:32:25 / cg" |
8719 |
"Modified (comment): / 19-11-2017 / 14:05:16 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8720 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8721 |
|
1588 | 8722 |
!EditTextView methodsFor:'realization'! |
8723 |
||
8724 |
realize |
|
8725 |
"make the view visible - scroll to make the cursor visible." |
|
8726 |
||
8727 |
super realize. |
|
8728 |
||
8729 |
self makeCursorVisible. |
|
5643 | 8730 |
cursorFgColor := cursorFgColor onDevice:device. |
8731 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 8732 |
|
8733 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
8734 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
8735 |
! ! |
|
8736 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8737 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8738 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8739 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8740 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8741 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8742 |
cursorShown ifTrue:[ |
6152 | 8743 |
cursorVisibleLine notNil ifTrue:[ |
8744 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
8745 |
self drawCursorCharacter |
|
8746 |
] |
|
8747 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8748 |
] |
105 | 8749 |
! |
8750 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8751 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8752 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8753 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8754 |
cursorShown ifTrue:[ |
6152 | 8755 |
(visLine == cursorVisibleLine) ifTrue:[ |
8756 |
self drawCursorCharacter |
|
8757 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8758 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8759 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8760 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8761 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8762 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8763 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8764 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8765 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8766 |
! |
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 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8769 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8770 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8771 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8772 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8773 |
! |
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 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8776 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8777 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8778 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8779 |
cursorShown ifTrue:[ |
6152 | 8780 |
(visLine == cursorVisibleLine) ifTrue:[ |
8781 |
(colNr == cursorCol) ifTrue:[ |
|
8782 |
self drawCursorCharacter. |
|
8783 |
^ self |
|
8784 |
] |
|
8785 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8786 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8787 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8788 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8789 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8790 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8791 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8792 |
"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
|
8793 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8794 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 8795 |
cursorShown ifTrue:[ |
6152 | 8796 |
self redrawCursorIfInVisibleLine:visLine |
4494 | 8797 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8798 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8799 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8800 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8801 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8802 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8803 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8804 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8805 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8806 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8807 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8808 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8809 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8810 |
"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
|
8811 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8812 |
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
|
8813 |
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
|
8814 |
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
|
8815 |
|
4889 | 8816 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8817 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8818 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8819 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8820 |
"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
|
8821 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8822 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8823 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8824 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8825 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8826 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8827 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8828 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8829 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8830 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8831 |
"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
|
8832 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8833 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8834 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8835 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8836 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8837 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8838 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8839 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8840 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8841 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8842 |
"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
|
8843 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8844 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8845 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8846 |
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
|
8847 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
8848 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8849 |
prevCursorState ifTrue:[ |
6152 | 8850 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8851 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8852 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8853 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8854 |
! |
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 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8857 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8858 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8859 |
prevCursorState := cursorShown. |
1601 | 8860 |
"/ cursorShown := false. |
1591 | 8861 |
cursorShown ifTrue:[ |
6152 | 8862 |
self hideCursor |
1591 | 8863 |
] |
8864 |
||
1601 | 8865 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8868 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8869 |
"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
|
8870 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8871 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8872 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8873 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8874 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8875 |
super pageDown. |
6184 | 8876 |
prevCursorLine notNil ifTrue:[ |
8877 |
"https://expeccoalm.exept.de/D204551" |
|
8878 |
self cursorVisibleLine:prevCursorLine col:cursorCol. |
|
8879 |
]. |
|
8880 |
||
8881 |
"Modified: / 18-07-2017 / 12:31:47 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8882 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8883 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8884 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8885 |
"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
|
8886 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8887 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8888 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8889 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8890 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8891 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8892 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8893 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8894 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8895 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8896 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8897 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8898 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8899 |
|
2822 | 8900 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8901 |
! |
8902 |
||
8903 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8904 |
"do a backward search" |
|
8905 |
||
8906 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8907 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8908 |
! |
8909 |
||
8910 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8911 |
"do a backward search" |
|
8912 |
||
8913 |
cursorLine isNil ifTrue:[^ self]. |
|
8914 |
||
3160 | 8915 |
self |
6152 | 8916 |
searchBackwardFor:pattern |
8917 |
ignoreCase:ign |
|
8918 |
startingAtLine:startLine col:startCol |
|
8919 |
ifFound:[:line :col :endColOrNil | |
|
8920 |
self cursorMovementAllowed ifTrue:[ |
|
8921 |
self cursorLine:line col:col. |
|
8922 |
]. |
|
8923 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
|
1339 | 8924 |
"/ self makeLineVisible:cursorLine |
6152 | 8925 |
typeOfSelection := #search] |
8926 |
ifAbsent:aBlock |
|
1339 | 8927 |
|
8928 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8929 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8930 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8931 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8932 |
"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
|
8933 |
|
2554 | 8934 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8935 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8936 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8937 |
searchForMatchingParenthesis |
3160 | 8938 |
"search for a matching parenthesis starting at cursor position. |
6096 | 8939 |
Search for the corresponding character is done forward if it's an opening, |
8940 |
backwards if it's a closing parenthesis. |
|
8941 |
Positions the cursor if found, beeps if not" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8942 |
|
2822 | 8943 |
self cursorMovementAllowed ifFalse:[^ self]. |
8944 |
||
3160 | 8945 |
self |
6096 | 8946 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8947 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8948 |
ifNotFound:[self showNotFound] |
|
6262 | 8949 |
onError:[self beepInEditor] |
6096 | 8950 |
|
8951 |
"Modified: / 09-10-1997 / 12:56:30 / cg" |
|
8952 |
"Modified (comment): / 13-02-2017 / 20:10:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8953 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8954 |
|
3967 | 8955 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8956 |
"do a forward search" |
8957 |
||
8958 |
cursorLine isNil ifTrue:[^ self]. |
|
5787 | 8959 |
self |
6152 | 8960 |
searchForwardFor:pattern |
8961 |
ignoreCase:ign |
|
8962 |
match: match |
|
8963 |
startingAtLine:startLine col:startCol |
|
8964 |
ifFound:[:line :col :endColOrNil| |
|
8965 |
self cursorMovementAllowed ifTrue:[ |
|
8966 |
self cursorLine:line col:col. |
|
8967 |
]. |
|
8968 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
|
1339 | 8969 |
"/ self makeLineVisible:cursorLine |
6152 | 8970 |
typeOfSelection := #search |
8971 |
] |
|
8972 |
ifAbsent:aBlock |
|
1339 | 8973 |
|
8974 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8975 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8976 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8977 |
|
3967 | 8978 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8979 |
"do a forward search" |
|
8980 |
||
8981 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8982 |
! |
|
8983 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8984 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8985 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8986 |
|
2822 | 8987 |
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
|
8988 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8989 |
|
3982 | 8990 |
searchPatternForSearchBar |
8991 |
||
8992 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8993 |
||
8994 |
|searchPattern| |
|
8995 |
||
4138 | 8996 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
5787 | 8997 |
searchPattern isNil |
6152 | 8998 |
ifTrue: [searchPattern := lastSearchPattern] |
8999 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
3982 | 9000 |
^ searchPattern |
9001 |
! |
|
9002 |
||
3578 | 9003 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9004 |
"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
|
9005 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9006 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9007 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9008 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
9009 |
"/ |
3967 | 9010 |
"/ 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
|
9011 |
"/ original string (for search after again) |
4121 | 9012 |
"/ 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
|
9013 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9014 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9015 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9016 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9017 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9018 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9019 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9020 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9021 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9022 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9023 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
9024 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
9025 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
9026 |
"/ 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
|
9027 |
"/ if there was a previous search, only take the selection if |
3967 | 9028 |
"/ 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
|
9029 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
9030 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9031 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9032 |
sel notNil ifTrue:[ |
6152 | 9033 |
(lastSearchPattern isNil |
9034 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
|
9035 |
) ifTrue:[ |
|
9036 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
9037 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
9038 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
9039 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9040 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
9041 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
9042 |
"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
|
9043 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9044 |
|
5717 | 9045 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
9046 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 9047 |
typeOfSelection := #search. |
9048 |
! |
|
9049 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9050 |
startPositionForSearchBackward |
2822 | 9051 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
9052 |
! |
|
9053 |
||
9054 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9055 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9056 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9057 |
selectionStartLine notNil ifTrue:[ |
6152 | 9058 |
startLine := selectionStartLine. |
9059 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9060 |
] ifFalse:[ |
6152 | 9061 |
cursorLine isNil ifTrue:[ |
9062 |
startLine := list size. |
|
9063 |
startCol := self listAt:startLine size. |
|
9064 |
] ifFalse:[ |
|
9065 |
startLine := cursorLine min:list size. |
|
9066 |
startCol := cursorCol |
|
9067 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9068 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9069 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9070 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9071 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9072 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9073 |
startPositionForSearchForward |
2822 | 9074 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
9075 |
! |
|
9076 |
||
9077 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9078 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9079 |
|
3160 | 9080 |
"/ 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
|
9081 |
"/ 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
|
9082 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
9083 |
self hasSelection ifTrue:[ |
6152 | 9084 |
^ selectionEndCol @ selectionEndLine. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
9085 |
] ifFalse:[ |
6152 | 9086 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
9087 |
startCol := 0 |
|
9088 |
]. |
|
9089 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9090 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9091 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
9092 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
9093 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
9094 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9095 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9096 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9097 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9098 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9099 |
addToSelectionAfter:aBlock |
5145 | 9100 |
<resource: #obsolete> |
9101 |
||
9102 |
"evaluate aBlock while unselected. |
|
9103 |
Restore the previous selection afterwards. |
|
9104 |
CG: I am not sure, if this is a leftover and is still used at all. |
|
6152 | 9105 |
It is therefore temporarily marked as obsolete. Please check |
9106 |
and let me know." |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9107 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9108 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9109 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9110 |
self hasSelection ifTrue: [ |
6152 | 9111 |
startLine := selectionStartLine . |
9112 |
startCol := selectionStartCol . |
|
9113 |
endLine := selectionEndLine . |
|
9114 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9115 |
] ifFalse: [ |
6152 | 9116 |
startLine := endLine := cursorLine . |
9117 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9118 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9119 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9120 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9121 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9122 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9123 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9124 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9125 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
6152 | 9126 |
ifTrue: [ |
9127 |
startCol := cursorCol. |
|
9128 |
] ifFalse: [ |
|
9129 |
endCol := cursorCol - 1. |
|
9130 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9131 |
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
|
9132 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
9133 |
|
1850 | 9134 |
autoMoveCursorToEndOfSelection |
9135 |
"return true, if the cursor should be automatically moved to the |
|
9136 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
9137 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 9138 |
not be affected by selecting" |
9139 |
||
9140 |
^ true |
|
9141 |
! |
|
9142 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
9143 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
9144 |
typeOfSelection ~~ newType ifTrue:[ |
6152 | 9145 |
typeOfSelection := newType. |
9146 |
selectionStartLine notNil ifTrue:[ |
|
9147 |
self |
|
9148 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
9149 |
toLine:selectionEndLine col:selectionEndCol |
|
9150 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
9151 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
9152 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
9153 |
|
4707 | 9154 |
findNextWordAfterSelectionAndAddToSelection |
9155 |
|selStartCol selStartLine selEndCol selEndLine| |
|
9156 |
||
9157 |
selectionStartCol isNil ifTrue:[ |
|
6152 | 9158 |
self selectWordUnderCursor. |
9159 |
^ self |
|
4707 | 9160 |
]. |
9161 |
||
9162 |
selStartCol := selectionStartCol. |
|
9163 |
selEndCol := selectionEndCol. |
|
9164 |
selStartLine := selectionStartLine. |
|
9165 |
selEndLine := selectionEndLine. |
|
9166 |
||
9167 |
self cursorToNextWord. |
|
9168 |
self selectWordUnderCursor. |
|
9169 |
||
9170 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
9171 |
! |
|
9172 |
||
4138 | 9173 |
searchPatternFromUserSelectionOrReplace |
9174 |
||
9175 |
|sel searchPattern| |
|
9176 |
||
9177 |
"/ |
|
9178 |
"/ if the last operation was a replace, set pattern to last |
|
9179 |
"/ original string (for search after again) |
|
9180 |
"/ |
|
9181 |
(lastStringFromReplaceForNextSearch notNil |
|
9182 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
6152 | 9183 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
9184 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
9185 |
] ifFalse:[ |
|
9186 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
9187 |
]. |
|
9188 |
^ searchPattern |
|
4138 | 9189 |
]. |
9190 |
||
9191 |
"/ |
|
9192 |
"/ if there is a selection: |
|
9193 |
"/ if there was no previous search, take it as search pattern. |
|
9194 |
"/ if there was a previous search, only take the selection if |
|
9195 |
"/ it did not result from a paste. |
|
9196 |
"/ (to allow search-paste to be repeated) |
|
9197 |
"/ |
|
9198 |
sel := self selection. |
|
9199 |
sel notNil ifTrue:[ |
|
6152 | 9200 |
typeOfSelection ~~ #search ifTrue:[ |
9201 |
typeOfSelection ~~ #paste ifTrue:[ |
|
9202 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
9203 |
searchPattern := sel asStringWithoutFinalCR. |
|
9204 |
] |
|
9205 |
]. |
|
4138 | 9206 |
]. |
9207 |
||
9208 |
^ searchPattern |
|
9209 |
! |
|
9210 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9211 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9212 |
"select the whole text. |
5593 | 9213 |
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
|
9214 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9215 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9216 |
list isNil ifTrue:[ |
6152 | 9217 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9218 |
] ifFalse:[ |
6152 | 9219 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
9220 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9221 |
] |
1082 | 9222 |
|
9223 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9224 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9225 |
|
4117 | 9226 |
selectAllInitially |
9227 |
"select the whole text. This is called only once during the initialization |
|
9228 |
for editFields which are shown in a table or tree. |
|
9229 |
The selectAll is called via this method to allow for easier redefinition and |
|
9230 |
to distinguish auto-select from user-initiated selects." |
|
9231 |
||
9232 |
self selectAll |
|
9233 |
! |
|
9234 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9235 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9236 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9237 |
|
3160 | 9238 |
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
|
9239 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9240 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9241 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9242 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9243 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
9244 |
cursorCol > 1 ifTrue:[ |
6152 | 9245 |
self selectFromLine:cursorLine col:1 |
9246 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
9247 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
9248 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
9249 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9250 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9251 |
|
6354 | 9252 |
selectCursorLineToEnd |
9253 |
"select cursorline from cursor position to the end" |
|
9254 |
||
9255 |
self selectFromLine:cursorLine col:cursorCol |
|
9256 |
toLine:(cursorLine+1) col:0 |
|
9257 |
||
9258 |
"Created: / 16-06-2018 / 00:46:21 / Claus Gittinger" |
|
9259 |
! |
|
9260 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9261 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9262 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9263 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9264 |
selectionStartLine isNil ifTrue:[ |
6152 | 9265 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9266 |
] ifFalse:[ |
6152 | 9267 |
self selectFromLine:selectionStartLine col:selectionStartCol |
9268 |
toLine:cursorLine+1 col:0. |
|
9269 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9270 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9271 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9272 |
|
4257 | 9273 |
selectFromBeginOfLine |
9274 |
"select the text from the beginning of the current line to the current cursor position." |
|
9275 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
9276 |
| newCursorCol ln | |
4271 | 9277 |
|
4257 | 9278 |
list isNil ifTrue:[ |
6152 | 9279 |
self unselect |
4257 | 9280 |
] ifFalse:[ |
6152 | 9281 |
cursorCol > 1 ifTrue:[ |
9282 |
ln := list at: cursorLine. |
|
9283 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
|
9284 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
|
6207 | 9285 |
"/ cursorCol := newCursorCol. |
9286 |
self setCursorCol:newCursorCol. |
|
6152 | 9287 |
typeOfSelection := nil |
9288 |
] |
|
4257 | 9289 |
] |
9290 |
||
9291 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
9292 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 9293 |
! |
9294 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9295 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9296 |
"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
|
9297 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9298 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9299 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9300 |
list isNil ifTrue:[ |
6152 | 9301 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9302 |
] ifFalse:[ |
6152 | 9303 |
cursorCol == 0 ifTrue:[ |
9304 |
col := 0 |
|
9305 |
] ifFalse:[ |
|
9306 |
col := cursorCol - 1 |
|
9307 |
]. |
|
9308 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
9309 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9310 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9311 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9312 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9313 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9314 |
"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
|
9315 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9316 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9317 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 9318 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
6152 | 9319 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 9320 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9321 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9322 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9323 |
|
4257 | 9324 |
selectToEndOfLine |
9325 |
"select the text from the current cursor position to the end of the current line" |
|
9326 |
||
4271 | 9327 |
| newCursorCol line | |
9328 |
||
4257 | 9329 |
list isNil ifTrue:[ |
6152 | 9330 |
self unselect |
4257 | 9331 |
] ifFalse:[ |
6152 | 9332 |
cursorCol >= 1 ifTrue:[ |
9333 |
line := list at: cursorLine. |
|
9334 |
newCursorCol := line size. |
|
9335 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
9336 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
9337 |
||
9338 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
6207 | 9339 |
"/ cursorCol := newCursorCol. |
9340 |
self setCursorCol:newCursorCol. |
|
6152 | 9341 |
typeOfSelection := nil |
9342 |
] |
|
4257 | 9343 |
] |
9344 |
||
9345 |
"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
|
9346 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 9347 |
! |
9348 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9349 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9350 |
"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
|
9351 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9352 |
list isNil ifTrue:[ |
6152 | 9353 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9354 |
] ifFalse:[ |
6152 | 9355 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
9356 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9357 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9358 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9359 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9360 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9361 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9362 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9363 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9364 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9365 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9366 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9367 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9368 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9369 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9370 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9371 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9372 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
9373 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9374 |
wasOn ifTrue:[self showCursor] |
105 | 9375 |
! ! |
9376 |
||
9377 |
!EditTextView methodsFor:'undo & again'! |
|
9378 |
||
2952 | 9379 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9380 |
^ undoSupport addUndo:action. |
2952 | 9381 |
! |
9382 |
||
105 | 9383 |
again |
9384 |
"repeat the last action (which was a cut or replace). |
|
9385 |
If current selection is not last string, search forward to |
|
3160 | 9386 |
next occurrence of it before repeating the last operation." |
105 | 9387 |
|
5787 | 9388 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 9389 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 9390 |
|
9391 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 9392 |
lastStringToReplace isNil ifTrue:[ |
6152 | 9393 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
9394 |
]. |
4048 | 9395 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
9396 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
9397 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
9398 |
self undoableDo:[ |
6152 | 9399 |
s := lastStringToReplace asString. |
9400 |
"remove final cr" |
|
9401 |
(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
|
9402 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 9403 |
|
6152 | 9404 |
"set lastStringToReplace as the next search string |
9405 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
9406 |
lastStringFromReplaceForNextSearch := s. |
|
9407 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
|
9408 |
||
9409 |
savedSelectStyle := selectStyle. |
|
9410 |
selectStyle := nil. |
|
9411 |
||
9412 |
sel := self selection. |
|
9413 |
||
6156 | 9414 |
"if we are already there (after a find), omit search" |
6152 | 9415 |
|
9416 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
|
9417 |
l := selectionStartLine "cursorLine". |
|
9418 |
c := selectionStartCol "cursorCol". |
|
9419 |
self deleteSelection. |
|
9420 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
9421 |
self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false. |
|
9422 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
|
9423 |
typeOfSelection := #paste |
|
9424 |
]. |
|
9425 |
selectStyle := savedSelectStyle. |
|
9426 |
^ true |
|
9427 |
]. |
|
9428 |
||
9429 |
sel isEmptyOrNil ifTrue:[ |
|
9430 |
startColForSearch := cursorCol - 1 |
|
9431 |
] ifFalse:[ |
|
9432 |
startColForSearch := selectionEndCol ? (cursorCol - 1) |
|
9433 |
]. |
|
9434 |
self |
|
9435 |
searchForwardFor:s |
|
9436 |
ignoreCase: lastReplaceIgnoredCase |
|
9437 |
match: lastReplaceWasMatch |
|
9438 |
startingAtLine:cursorLine col:startColForSearch |
|
9439 |
ifFound: |
|
9440 |
[ |
|
9441 |
:line :col | |
|
9442 |
||
9443 |
|repl| |
|
9444 |
||
9445 |
self selectFromLine:line col:col |
|
9446 |
toLine:line col:(col + s size - 1). |
|
9447 |
self makeLineVisible:line. |
|
9448 |
||
9449 |
self deleteSelection. |
|
9450 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
9451 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
9452 |
repl := lastReplacementInfo lastReplacement asString "withoutSpaces" |
|
9453 |
] ifTrue:[ |
|
9454 |
repl := lastReplacementInfo lastReplacement "withoutSpaces". |
|
9455 |
]. |
|
9456 |
self insertLines:repl asStringCollection withCR:false. |
|
9457 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
|
9458 |
undoSupport actionInfo:'replace'. |
|
9459 |
]. |
|
9460 |
selectStyle := savedSelectStyle. |
|
9461 |
typeOfSelection := #paste. |
|
9462 |
^ true |
|
9463 |
] |
|
9464 |
ifAbsent: |
|
9465 |
[ |
|
9466 |
self sensor compressKeyPressEventsWithKey:#Again. |
|
9467 |
self showNotFound. |
|
9468 |
selectStyle := savedSelectStyle. |
|
9469 |
^ false |
|
9470 |
]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
9471 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
9472 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
9473 |
^ true. |
501 | 9474 |
|
6156 | 9475 |
"Modified: / 09-10-1996 / 16:14:11 / cg" |
9476 |
"Modified (comment): / 17-05-2017 / 16:19:32 / mawalch" |
|
105 | 9477 |
! |
9478 |
||
2952 | 9479 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9480 |
^ undoSupport hasRedoAction. |
2952 | 9481 |
! |
9482 |
||
9483 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9484 |
^ undoSupport hasUndoAction. |
2952 | 9485 |
! |
9486 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9487 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9488 |
"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
|
9489 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9490 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9491 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9492 |
|
2952 | 9493 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9494 |
undoSupport nonUndoableDo:aBlock. |
2952 | 9495 |
! |
9496 |
||
9497 |
redo |
|
3780 | 9498 |
"undo the last undo" |
9499 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9500 |
undoSupport hasRedoAction ifFalse:[ |
6262 | 9501 |
self beepInEditor |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9502 |
] ifTrue:[ |
6152 | 9503 |
undoSupport redo. |
2952 | 9504 |
] |
9505 |
! |
|
9506 |
||
121 | 9507 |
undo |
3780 | 9508 |
"undo the last edit operation" |
9509 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9510 |
undoSupport hasUndoAction ifFalse:[ |
6262 | 9511 |
self beepInEditor |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9512 |
] ifTrue:[ |
5834 | 9513 |
undoSupport undo. |
9514 |
self makeSelectionVisible. |
|
9515 |
self makeCursorVisible. |
|
121 | 9516 |
] |
2952 | 9517 |
! |
9518 |
||
9519 |
undoableDo:aBlock |
|
3495 | 9520 |
self undoableDo:aBlock info:nil. |
9521 |
||
9522 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 9523 |
! |
9524 |
||
9525 |
undoableDo:aBlock info:aString |
|
5689 | 9526 |
|selectionRestore| |
9527 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9528 |
self checkModificationsAllowed ifFalse:[ |
6152 | 9529 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
9530 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9531 |
] ifTrue:[ |
6152 | 9532 |
undoSupport isInTransaction ifFalse:[ |
9533 |
selectionRestore := RestoreSelectionAndCursor new |
|
9534 |
cursorLine:cursorLine cursorCol:cursorCol |
|
9535 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
9536 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
9537 |
info:nil. |
|
9538 |
]. |
|
9539 |
undoSupport |
|
9540 |
undoableDo:[ |
|
9541 |
aBlock value. |
|
9542 |
selectionRestore notNil ifTrue:[ |
|
9543 |
undoSupport transactionNotEmpty ifTrue:[ |
|
9544 |
undoSupport addUndoFirst:selectionRestore |
|
9545 |
]. |
|
9546 |
]. |
|
9547 |
] |
|
9548 |
info:aString. |
|
5689 | 9549 |
]. |
9550 |
||
9551 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 9552 |
! ! |
9553 |
||
9554 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
9555 |
||
9556 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9557 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9558 |
! |
|
9559 |
||
3115 | 9560 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 9561 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 9562 |
! |
9563 |
||
2952 | 9564 |
line:arg1 col:arg2 character:arg3 |
9565 |
^ self new line:arg1 col:arg2 character:arg3 |
|
9566 |
! |
|
9567 |
||
3115 | 9568 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 9569 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 9570 |
! |
9571 |
||
3235 | 9572 |
line:arg1 col:arg2 characters:arg3 info:info |
9573 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
9574 |
! |
|
9575 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9576 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9577 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9578 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9579 |
|
2952 | 9580 |
line:arg1 col:arg2 string:arg3 |
9581 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 9582 |
! |
9583 |
||
9584 |
line:arg1 col:arg2 string:arg3 info:info |
|
9585 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 9586 |
! |
9587 |
||
9588 |
line:arg1 string:arg3 info:info |
|
9589 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 9590 |
! |
9591 |
||
9592 |
text:arg info:info |
|
9593 |
^ (self new text:arg) info:info |
|
3115 | 9594 |
! ! |
9595 |
||
9596 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
9597 |
||
9598 |
info |
|
9599 |
^ userFriendlyInfo |
|
9600 |
! |
|
9601 |
||
9602 |
info:aString |
|
9603 |
userFriendlyInfo := aString |
|
2952 | 9604 |
! ! |
9605 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9606 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9607 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9608 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9609 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9610 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9611 |
"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
|
9612 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9613 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9614 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9615 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9616 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9617 |
^ false |
5710 | 9618 |
! |
9619 |
||
9620 |
isRestoreSelectionAndCursor |
|
9621 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9622 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9623 |
|
2952 | 9624 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
9625 |
||
3160 | 9626 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 9627 |
"set instance variables (automatically generated)" |
9628 |
||
9629 |
self assert:(line1Arg notNil). |
|
9630 |
self assert:(col1Arg notNil). |
|
9631 |
self assert:(line2Arg notNil). |
|
9632 |
self assert:(col2Arg notNil). |
|
9633 |
||
9634 |
line1 := line1Arg. |
|
9635 |
col1 := col1Arg. |
|
9636 |
line2 := line2Arg. |
|
9637 |
col2 := col2Arg. |
|
9638 |
! ! |
|
9639 |
||
9640 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
9641 |
||
3160 | 9642 |
executeIn:editor |
2952 | 9643 |
editor unselect. |
3160 | 9644 |
editor |
6152 | 9645 |
deleteFromLine:line1 |
9646 |
col:col1 |
|
9647 |
toLine:line2 |
|
9648 |
col:col2. |
|
2952 | 9649 |
editor cursorLine:line1 col:col1. |
9650 |
! ! |
|
9651 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9652 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9653 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9654 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9655 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9656 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9657 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9658 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9659 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9660 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9661 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9662 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9663 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9664 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9665 |
|
3160 | 9666 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9667 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9668 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9669 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9670 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9671 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9672 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9673 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9674 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9675 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9676 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9677 |
|
3160 | 9678 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9679 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9680 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9681 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9682 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9683 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9684 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9685 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9686 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9687 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9688 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9689 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9690 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9691 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9692 |
|
3160 | 9693 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9694 |
"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
|
9695 |
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
|
9696 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9697 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9698 |
previousDeleteAction line == line ifTrue:[ |
6152 | 9699 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
9700 |
^ true |
|
9701 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9702 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9703 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9704 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9705 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9706 |
|
3160 | 9707 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9708 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9709 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9710 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9711 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9712 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9713 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9714 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9715 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9716 |
|
3160 | 9717 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9718 |
editor unselect. |
3160 | 9719 |
editor |
6152 | 9720 |
deleteFromLine:line |
9721 |
col:col1 |
|
9722 |
toLine:line |
|
9723 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9724 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9725 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9726 |
|
3235 | 9727 |
!EditTextView::EditMode class methodsFor:'constants'! |
9728 |
||
9729 |
insertAndSelectMode |
|
9730 |
^ InsertAndSelectMode |
|
9731 |
! |
|
9732 |
||
9733 |
insertMode |
|
9734 |
^ InsertMode |
|
9735 |
! |
|
9736 |
||
9737 |
overwriteMode |
|
9738 |
^ OverwriteMode |
|
9739 |
! ! |
|
9740 |
||
9741 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
9742 |
||
9743 |
isInsertAndSelectMode |
|
9744 |
^ false |
|
9745 |
! |
|
9746 |
||
9747 |
isInsertMode |
|
9748 |
^ false |
|
9749 |
! |
|
9750 |
||
9751 |
symbolicName |
|
9752 |
self subclassResponsibility |
|
9753 |
! ! |
|
9754 |
||
9755 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
9756 |
||
9757 |
infoPrintString |
|
9758 |
^ 'IS' |
|
9759 |
! ! |
|
9760 |
||
9761 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
9762 |
||
9763 |
isInsertAndSelectMode |
|
9764 |
^ true |
|
9765 |
! |
|
9766 |
||
9767 |
isInsertMode |
|
9768 |
^ true |
|
9769 |
! ! |
|
9770 |
||
9771 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
9772 |
||
9773 |
infoPrintString |
|
9774 |
^ 'I' |
|
9775 |
! ! |
|
9776 |
||
9777 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
9778 |
||
9779 |
isInsertMode |
|
9780 |
^ true |
|
9781 |
! ! |
|
9782 |
||
9783 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
9784 |
||
9785 |
infoPrintString |
|
9786 |
^ 'O' |
|
9787 |
! ! |
|
9788 |
||
4048 | 9789 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
9790 |
||
9791 |
lastReplaceIgnoredCase |
|
9792 |
^ lastReplaceIgnoredCase ? false |
|
9793 |
! |
|
9794 |
||
9795 |
lastReplaceIgnoredCase:something |
|
9796 |
lastReplaceIgnoredCase := something. |
|
9797 |
! |
|
9798 |
||
9799 |
lastReplaceWasMatch |
|
9800 |
^ lastReplaceWasMatch ? false |
|
9801 |
! |
|
9802 |
||
9803 |
lastReplaceWasMatch:something |
|
9804 |
lastReplaceWasMatch := something. |
|
9805 |
! |
|
9806 |
||
9807 |
lastReplacement |
|
9808 |
^ lastReplacement |
|
9809 |
! |
|
9810 |
||
9811 |
lastReplacement:something |
|
4053 | 9812 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 9813 |
lastReplacement := something. |
9814 |
! |
|
9815 |
||
9816 |
lastStringToReplace |
|
9817 |
^ lastStringToReplace |
|
9818 |
! |
|
9819 |
||
9820 |
lastStringToReplace:something |
|
9821 |
lastStringToReplace := something. |
|
4818 | 9822 |
! |
9823 |
||
9824 |
previousReplacements |
|
9825 |
^ previousReplacements ? #() |
|
9826 |
! |
|
9827 |
||
9828 |
stillCollectingInput |
|
9829 |
^ stillCollectingInput |
|
9830 |
! |
|
9831 |
||
9832 |
stillCollectingInput:aBoolean |
|
9833 |
stillCollectingInput := aBoolean. |
|
9834 |
! ! |
|
9835 |
||
9836 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9837 |
||
9838 |
rememberReplacement |
|
9839 |
"remember the previous replacement (called when a new one appears). |
|
9840 |
Mostly for the benefit of the code completion..." |
|
9841 |
||
9842 |
|oldString newString| |
|
9843 |
||
9844 |
oldString := lastStringToReplace. |
|
9845 |
newString := lastReplacement. |
|
9846 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
6152 | 9847 |
previousReplacements isNil ifTrue:[ |
9848 |
previousReplacements := OrderedCollection new. |
|
9849 |
]. |
|
9850 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9851 |
previousReplacements addFirst:(oldString -> newString). |
|
9852 |
previousReplacements size > 20 ifTrue:[ |
|
9853 |
previousReplacements removeLast. |
|
9854 |
] |
|
4818 | 9855 |
]. |
4048 | 9856 |
! ! |
9857 |
||
2952 | 9858 |
!EditTextView::PasteString methodsFor:'accessing'! |
9859 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9860 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9861 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9862 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9863 |
"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
|
9864 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9865 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9866 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9867 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9868 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9869 |
"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
|
9870 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9871 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9872 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9873 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9874 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9875 |
"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
|
9876 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9877 |
|
3160 | 9878 |
line:lineArg col:colArg string:stringArg |
2952 | 9879 |
self assert:(lineArg notNil). |
9880 |
self assert:(colArg notNil). |
|
9881 |
self assert:(stringArg notNil). |
|
9882 |
||
9883 |
line := lineArg. |
|
9884 |
col := colArg. |
|
9885 |
string := stringArg. |
|
9886 |
! |
|
9887 |
||
9888 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9889 |
self assert:(lineArg notNil). |
|
9890 |
self assert:(colArg notNil). |
|
9891 |
self assert:(stringArg notNil). |
|
9892 |
||
9893 |
line := lineArg. |
|
9894 |
col := colArg. |
|
9895 |
string := stringArg. |
|
9896 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9897 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9898 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9899 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9900 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9901 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9902 |
"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
|
9903 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9904 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9905 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9906 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9907 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9908 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9909 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9910 |
"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
|
9911 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9912 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9913 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9914 |
"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
|
9915 |
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
|
9916 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9917 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9918 |
previousPasteAction line == line ifTrue:[ |
6152 | 9919 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9920 |
^ true |
|
9921 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9922 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9923 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9924 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9925 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9926 |
"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
|
9927 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9928 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9929 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9930 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9931 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9932 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9933 |
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
|
9934 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9935 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9936 |
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
|
9937 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9938 |
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
|
9939 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9940 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9941 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9942 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9943 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9944 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9945 |
! ! |
9946 |
||
9947 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9948 |
||
3160 | 9949 |
executeIn:editor |
2952 | 9950 |
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
|
9951 |
editor paste:string. |
2952 | 9952 |
selected ~~ true ifTrue:[ |
6152 | 9953 |
editor unselect |
2952 | 9954 |
]. |
9955 |
! ! |
|
9956 |
||
9957 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9958 |
||
3235 | 9959 |
col |
9960 |
^ col |
|
9961 |
! |
|
9962 |
||
9963 |
col1 |
|
9964 |
^ col |
|
9965 |
! |
|
9966 |
||
9967 |
col2 |
|
9968 |
^ col |
|
9969 |
! |
|
9970 |
||
9971 |
line |
|
9972 |
^ line |
|
9973 |
! |
|
9974 |
||
3160 | 9975 |
line:lineArg col:colArg character:characterArg |
2952 | 9976 |
line := lineArg. |
9977 |
col := colArg. |
|
9978 |
character := characterArg. |
|
9979 |
! ! |
|
9980 |
||
9981 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9982 |
||
3160 | 9983 |
executeIn:editor |
9984 |
editor |
|
6152 | 9985 |
replace:character |
9986 |
atLine:line |
|
9987 |
col:col. |
|
2952 | 9988 |
editor cursorLine:line col:col. |
105 | 9989 |
! ! |
9990 |
||
3235 | 9991 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9992 |
||
9993 |
characters |
|
9994 |
^ characters |
|
9995 |
! |
|
9996 |
||
9997 |
col1 |
|
9998 |
^ col1 |
|
9999 |
! |
|
10000 |
||
10001 |
col2 |
|
10002 |
^ col2 |
|
10003 |
! |
|
10004 |
||
10005 |
line |
|
10006 |
^ line |
|
10007 |
! |
|
10008 |
||
10009 |
line:lineArg col:colArg character:characterArg |
|
10010 |
line := lineArg. |
|
10011 |
col1 := col2 := colArg. |
|
10012 |
characters := characterArg asString. |
|
10013 |
! |
|
10014 |
||
10015 |
line:lineArg col:colArg characters:charactersArg |
|
10016 |
line := lineArg. |
|
10017 |
col1 := colArg. |
|
10018 |
characters := charactersArg asString. |
|
10019 |
col2 := col1 + charactersArg size - 1 |
|
10020 |
! ! |
|
10021 |
||
10022 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
10023 |
||
10024 |
canCombineWithNext:anotherAction |
|
10025 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
10026 |
! |
|
10027 |
||
10028 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
10029 |
"I will combine only if we both are single character deletes, |
|
10030 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
10031 |
(i.e. single-character typing)" |
|
10032 |
||
10033 |
previousReplaceAction line == line ifTrue:[ |
|
6152 | 10034 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
10035 |
^ true |
|
10036 |
]. |
|
3235 | 10037 |
]. |
10038 |
||
10039 |
^ false |
|
10040 |
! |
|
10041 |
||
10042 |
combineWithNext:nextReplaceAction |
|
10043 |
self assert:(line == nextReplaceAction line). |
|
10044 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
10045 |
||
10046 |
col2 := nextReplaceAction col2. |
|
10047 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
10048 |
characters := characters , nextReplaceAction characters. |
|
10049 |
! ! |
|
10050 |
||
10051 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
10052 |
||
10053 |
executeIn:editor |
|
10054 |
editor |
|
6152 | 10055 |
replaceString:characters |
10056 |
atLine:line |
|
10057 |
col:col1. |
|
3235 | 10058 |
editor cursorLine:line col:col1. |
10059 |
! ! |
|
10060 |
||
3131 | 10061 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
10062 |
||
10063 |
text:something |
|
10064 |
text := something. |
|
10065 |
! ! |
|
10066 |
||
10067 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
10068 |
||
3160 | 10069 |
executeIn:editor |
3131 | 10070 |
editor contents:text |
10071 |
! ! |
|
10072 |
||
3130 | 10073 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
10074 |
||
3160 | 10075 |
line:lineArg string:stringArg |
3130 | 10076 |
line := lineArg. |
10077 |
text := stringArg. |
|
10078 |
! ! |
|
10079 |
||
10080 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
10081 |
||
3160 | 10082 |
executeIn:editor |
3130 | 10083 |
editor list at:line put:text. |
10084 |
editor invalidateLine:line |
|
10085 |
! ! |
|
10086 |
||
3402 | 10087 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
10088 |
||
10089 |
line:lineArg lines:lineCollectionArg |
|
10090 |
line := lineArg. |
|
10091 |
text := lineCollectionArg. |
|
10092 |
||
10093 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
10094 |
! ! |
|
10095 |
||
10096 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
10097 |
||
10098 |
executeIn:editor |
|
10099 |
|lnr| |
|
10100 |
||
10101 |
lnr := line. |
|
10102 |
text do:[:eachLine | |
|
6152 | 10103 |
editor list at:lnr put:eachLine. |
10104 |
editor invalidateLine:lnr. |
|
10105 |
lnr := lnr + 1. |
|
3402 | 10106 |
]. |
10107 |
||
10108 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
10109 |
! ! |
|
10110 |
||
5689 | 10111 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
10112 |
||
5787 | 10113 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
5689 | 10114 |
cursorLine := cursorLineArg. |
10115 |
cursorCol := cursorColArg. |
|
10116 |
selectionStartLine := selectionStartLineArg. |
|
10117 |
selectionStartCol := selectionStartColArg. |
|
10118 |
selectionEndLine := selectionEndLineArg. |
|
10119 |
selectionEndCol := selectionEndColArg. |
|
10120 |
! |
|
10121 |
||
5787 | 10122 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
6152 | 10123 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
10124 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
10125 |
info:info |
|
5689 | 10126 |
|
10127 |
cursorLine := cursorLineArg. |
|
10128 |
cursorCol := cursorColArg. |
|
10129 |
selectionStartLine := selectionStartLineArg. |
|
10130 |
selectionStartCol := selectionStartColArg. |
|
10131 |
selectionEndLine := selectionEndLineArg. |
|
10132 |
selectionEndCol := selectionEndColArg. |
|
10133 |
userFriendlyInfo := info. |
|
10134 |
||
10135 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
10136 |
! ! |
|
10137 |
||
10138 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
10139 |
||
10140 |
executeIn:editor |
|
10141 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
10142 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
6152 | 10143 |
editor setCursorLine:cursorLine col:cursorCol. |
10144 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
5689 | 10145 |
] ifFalse:[ |
6152 | 10146 |
editor cursorLine:cursorLine col:cursorCol. |
5689 | 10147 |
]. |
10148 |
||
10149 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
10150 |
! ! |
|
10151 |
||
5710 | 10152 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
10153 |
||
10154 |
isRestoreSelectionAndCursor |
|
10155 |
^ true |
|
10156 |
! ! |
|
10157 |
||
865 | 10158 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
10159 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
10160 |
version |
5361 | 10161 |
^ '$Header$' |
3945 | 10162 |
! |
10163 |
||
10164 |
version_CVS |
|
5361 | 10165 |
^ '$Header$' |
0 | 10166 |
! ! |
4481 | 10167 |