author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2017 20:09:30 +0100 | |
changeset 6225 | 0122e4e6c587 |
parent 6210 | e699fa83a3b2 |
child 6226 | b7628412aff5 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
6152 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
5239 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
TextView subclass:#EditTextView |
6154 | 17 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
18 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
19 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
20 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
21 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
22 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
23 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
24 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
25 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
26 |
undoSupport lastStringFromReplaceForNextSearch |
|
27 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
28 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
29 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
30 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Views-Text' |
|
0 | 33 |
! |
34 |
||
2952 | 35 |
Object subclass:#EditAction |
6154 | 36 |
instanceVariableNames:'userFriendlyInfo' |
37 |
classVariableNames:'' |
|
38 |
poolDictionaries:'' |
|
39 |
privateIn:EditTextView |
|
2952 | 40 |
! |
41 |
||
42 |
EditTextView::EditAction subclass:#DeleteRange |
|
6154 | 43 |
instanceVariableNames:'line1 col1 line2 col2' |
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:EditTextView |
|
2952 | 47 |
! |
48 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
EditTextView::EditAction subclass:#DeleteCharacters |
6154 | 50 |
instanceVariableNames:'line col1 col2' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
54 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
55 |
|
3235 | 56 |
Object subclass:#EditMode |
6154 | 57 |
instanceVariableNames:'' |
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:EditTextView |
|
3235 | 61 |
! |
62 |
||
63 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
6154 | 64 |
instanceVariableNames:'' |
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:EditTextView::EditMode |
|
3235 | 68 |
! |
69 |
||
70 |
EditTextView::EditMode subclass:#InsertMode |
|
6154 | 71 |
instanceVariableNames:'' |
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:EditTextView::EditMode |
|
3235 | 75 |
! |
76 |
||
77 |
EditTextView::EditMode subclass:#OverwriteMode |
|
6154 | 78 |
instanceVariableNames:'' |
79 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
80 |
poolDictionaries:'' |
|
81 |
privateIn:EditTextView::EditMode |
|
3235 | 82 |
! |
83 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
84 |
Query subclass:#ExecutingMacroQuery |
6154 | 85 |
instanceVariableNames:'' |
86 |
classVariableNames:'' |
|
87 |
poolDictionaries:'' |
|
88 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
89 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
90 |
|
4048 | 91 |
Object subclass:#LastReplacementInfo |
6154 | 92 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
93 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
94 |
classVariableNames:'' |
|
95 |
poolDictionaries:'' |
|
96 |
privateIn:EditTextView |
|
4048 | 97 |
! |
98 |
||
2952 | 99 |
EditTextView::EditAction subclass:#PasteString |
6154 | 100 |
instanceVariableNames:'line col string selected' |
101 |
classVariableNames:'' |
|
102 |
poolDictionaries:'' |
|
103 |
privateIn:EditTextView |
|
2952 | 104 |
! |
105 |
||
106 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
6154 | 107 |
instanceVariableNames:'line col character' |
108 |
classVariableNames:'' |
|
109 |
poolDictionaries:'' |
|
110 |
privateIn:EditTextView |
|
2952 | 111 |
! |
112 |
||
3235 | 113 |
EditTextView::EditAction subclass:#ReplaceCharacters |
6154 | 114 |
instanceVariableNames:'line col1 col2 characters' |
115 |
classVariableNames:'' |
|
116 |
poolDictionaries:'' |
|
117 |
privateIn:EditTextView |
|
3235 | 118 |
! |
119 |
||
3131 | 120 |
EditTextView::EditAction subclass:#ReplaceContents |
6154 | 121 |
instanceVariableNames:'text' |
122 |
classVariableNames:'' |
|
123 |
poolDictionaries:'' |
|
124 |
privateIn:EditTextView |
|
3131 | 125 |
! |
126 |
||
3130 | 127 |
EditTextView::EditAction subclass:#ReplaceLine |
6154 | 128 |
instanceVariableNames:'line text' |
129 |
classVariableNames:'' |
|
130 |
poolDictionaries:'' |
|
131 |
privateIn:EditTextView |
|
3130 | 132 |
! |
133 |
||
3402 | 134 |
EditTextView::EditAction subclass:#ReplaceLines |
6154 | 135 |
instanceVariableNames:'line text' |
136 |
classVariableNames:'' |
|
137 |
poolDictionaries:'' |
|
138 |
privateIn:EditTextView |
|
3402 | 139 |
! |
140 |
||
5689 | 141 |
EditTextView::EditAction subclass:#RestoreSelectionAndCursor |
6154 | 142 |
instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol |
143 |
selectionEndLine selectionEndCol' |
|
144 |
classVariableNames:'' |
|
145 |
poolDictionaries:'' |
|
146 |
privateIn:EditTextView |
|
5689 | 147 |
! |
148 |
||
865 | 149 |
!EditTextView class methodsFor:'documentation'! |
0 | 150 |
|
33 | 151 |
copyright |
152 |
" |
|
153 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
6152 | 154 |
All Rights Reserved |
33 | 155 |
|
156 |
This software is furnished under a license and may be used |
|
157 |
only in accordance with the terms of that license and with the |
|
158 |
inclusion of the above copyright notice. This software may not |
|
159 |
be provided or otherwise made available to, or used by, any |
|
160 |
other person. No title to or ownership of the software is |
|
161 |
hereby transferred. |
|
162 |
" |
|
163 |
! |
|
164 |
||
0 | 165 |
documentation |
166 |
" |
|
167 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 168 |
Also, it adds accept functionality, and defines a new actionBlock: |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
169 |
acceptAction to be performed for accept |
125 | 170 |
|
171 |
If used with a model, this is informed by sending it a changeMsg with |
|
172 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
173 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 174 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
175 |
Please read the historic notice in the ListView class. |
0 | 176 |
|
586 | 177 |
[Instance variables:] |
0 | 178 |
|
5988 | 179 |
cursorLine <Number> line where cursor sits (1..) |
180 |
||
181 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
182 |
||
183 |
cursorCol <Number> col where cursor sits (1..) |
|
184 |
||
185 |
cursorShown <Boolean> true, if cursor is currently shown |
|
186 |
||
187 |
readOnly <Boolean> true, if text may not be edited |
|
188 |
||
189 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
190 |
cleared on accept. |
|
191 |
||
192 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
193 |
||
194 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
195 |
||
196 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
197 |
if it returns true, the modification will be done anyway. |
|
198 |
if it returns anything else, the modification is not done. |
|
199 |
||
200 |
cursorFgColor <Color> color used for cursor drawing |
|
201 |
cursorBgColor <Color> color used for cursor drawing |
|
202 |
||
203 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
204 |
are #none, #block (solid-block cursor), #ibeam |
|
205 |
(vertical bar at insertion point) |
|
206 |
and #caret (caret below insertion-point). |
|
207 |
see cursorType: for an up-to-date list. |
|
208 |
||
209 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
210 |
nil means: hide the cursor. |
|
211 |
||
212 |
undoAction <Block> block which undoes last cut, paste or replace |
|
213 |
(not yet fully implemented) |
|
214 |
||
215 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
216 |
this affects the next keyPress: if #paste it does not |
|
217 |
replace; otherwise it replaces the selection. |
|
218 |
||
219 |
lastCut <String> last cut or replaced string |
|
220 |
||
221 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
|
222 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
223 |
lastReplacement is the string to replace lastStringToReplace |
|
224 |
||
225 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
226 |
(cleared after a new selection) |
|
227 |
||
228 |
replacing <Boolean> true if entered characters replace last selection |
|
229 |
||
230 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
231 |
when entering one; this is the default. |
|
232 |
||
233 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
234 |
||
235 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
236 |
argument |
|
237 |
||
238 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
239 |
focus to the next field. For editTextViews, this is false |
|
240 |
by default (i.e. tabs can be entered into the text). |
|
241 |
For some subclasses (inputFields), this may be true. |
|
242 |
||
243 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
244 |
removed when editing. |
|
245 |
Also, empty lines are represented as nil in the lines collection. |
|
246 |
Default is true. |
|
247 |
||
248 |
wordWrap <Boolean> Currently not used. |
|
249 |
||
250 |
lockUpdates <Boolean> internal, private |
|
251 |
||
252 |
prevCursorState <Boolean> temporary, private |
|
253 |
||
254 |
cursorMovementWhenUpdating |
|
255 |
<Symbol> defines where the cursor is to be positioned if the |
|
256 |
model changes its value by some outside activity |
|
257 |
(i.e. not by user input into the field). |
|
258 |
Can be one of: |
|
259 |
#keep / nil -> stay where it was |
|
260 |
#endOfText -> cursor to the end |
|
261 |
#endOfLine -> stay in the line, but move to end |
|
262 |
#beginOfText -> cursor to the beginning |
|
263 |
#beginOfLine -> stay in the line, but move to begin |
|
264 |
The default is #beginOfText |
|
265 |
||
266 |
||
267 |
||
268 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 269 |
|
270 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
271 |
userPreference values: |
5988 | 272 |
userPreferences.st80EditMode |
273 |
<Boolean> if true, cursor positioning is |
|
274 |
done as in vi or ST80; i.e. |
|
275 |
wysiwyg mode is somewhat relaxed, |
|
276 |
in that the cursor cannot be |
|
277 |
positioned behind a lines end. |
|
278 |
This is not yet completely implemented. |
|
33 | 279 |
used globals: |
280 |
||
5988 | 281 |
DeleteHistory <Text> last 1000 lines of deleted text |
282 |
(but only if this variable exists already) |
|
586 | 283 |
|
284 |
[styleSheet parameters:] |
|
121 | 285 |
|
5988 | 286 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
287 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
288 |
textCursorNoFocusForegroundColor |
|
289 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
290 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 291 |
|
292 |
[author:] |
|
5988 | 293 |
Claus Gittinger |
586 | 294 |
|
295 |
[see also:] |
|
5988 | 296 |
CodeView Workspace TextView ListView |
297 |
EditField |
|
0 | 298 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
299 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
300 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
301 |
examples |
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 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
304 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
305 |
basic setup: |
6152 | 306 |
[exBegin] |
307 |
|top textView| |
|
308 |
||
309 |
top := StandardSystemView new. |
|
310 |
top extent:300@200. |
|
311 |
||
312 |
textView := EditTextView new. |
|
313 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
314 |
top addSubView:textView. |
|
315 |
||
316 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
317 |
||
318 |
top open. |
|
319 |
[exEnd] |
|
594 | 320 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
321 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
322 |
with vertical scrollbar: |
6152 | 323 |
[exBegin] |
324 |
|top scrollView textView| |
|
325 |
||
326 |
top := StandardSystemView new. |
|
327 |
top extent:300@200. |
|
328 |
||
329 |
scrollView := ScrollableView for:EditTextView. |
|
330 |
textView := scrollView scrolledView. |
|
331 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
332 |
top addSubView:scrollView. |
|
333 |
||
334 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
335 |
||
336 |
top open. |
|
337 |
[exEnd] |
|
594 | 338 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
339 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
340 |
with horizontal & vertical scrollbars: |
6152 | 341 |
[exBegin] |
342 |
|top scrollView textView| |
|
343 |
||
344 |
top := StandardSystemView new. |
|
345 |
top extent:300@200. |
|
346 |
||
347 |
scrollView := HVScrollableView for:EditTextView. |
|
348 |
textView := scrollView scrolledView. |
|
349 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
350 |
top addSubView:scrollView. |
|
351 |
||
352 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
353 |
||
354 |
top open. |
|
355 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
356 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
357 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
358 |
set the action for accept: |
6152 | 359 |
[exBegin] |
360 |
|top textView| |
|
361 |
||
362 |
top := StandardSystemView new. |
|
363 |
top extent:300@200. |
|
364 |
||
365 |
textView := EditTextView new. |
|
366 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
367 |
top addSubView:textView. |
|
368 |
||
369 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
370 |
textView acceptAction:[:contents | |
|
371 |
Transcript showCR:'will not overwrite the file with:'. |
|
372 |
Transcript showCR:contents asString |
|
373 |
]. |
|
374 |
top open. |
|
375 |
[exEnd] |
|
594 | 376 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
377 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
378 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
379 |
non-string (text) items: |
6152 | 380 |
[exBegin] |
381 |
|top textView list| |
|
382 |
||
383 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
384 |
1 to:list size by:2 do:[:nr | |
|
385 |
list at:nr put:(Text string:(list at:nr) |
|
386 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
387 |
]. |
|
388 |
||
389 |
top := StandardSystemView new. |
|
390 |
top extent:300@200. |
|
391 |
||
392 |
textView := EditTextView new. |
|
393 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
394 |
top addSubView:textView. |
|
395 |
||
396 |
textView contents:list. |
|
397 |
top open. |
|
398 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
399 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
400 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
401 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
402 |
MVC operation: |
594 | 403 |
(the examples model here is a plug simulating a real model; |
404 |
real world applications would not use a plug ..) |
|
6152 | 405 |
[exBegin] |
406 |
|top textView model| |
|
407 |
||
408 |
model := Plug new. |
|
409 |
model respondTo:#accepted: |
|
410 |
with:[:newContents | |
|
411 |
Transcript showCR:'will not overwrite the file with:'. |
|
412 |
Transcript showCR:newContents asString |
|
413 |
]. |
|
414 |
model respondTo:#getList |
|
415 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
416 |
||
417 |
||
418 |
top := StandardSystemView new. |
|
419 |
top extent:300@200. |
|
420 |
||
421 |
textView := EditTextView new. |
|
422 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
423 |
top addSubView:textView. |
|
424 |
||
425 |
textView listMessage:#getList; |
|
426 |
model:model; |
|
427 |
changeMessage:#accepted:; |
|
428 |
aspect:#list. |
|
429 |
top open. |
|
430 |
[exEnd] |
|
594 | 431 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
432 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
433 |
two textViews on the same model: |
6152 | 434 |
[exBegin] |
435 |
|top1 textView1 top2 textView2 model currentContents| |
|
436 |
||
437 |
model := Plug new. |
|
438 |
model respondTo:#accepted: |
|
439 |
with:[:newContents | |
|
440 |
Transcript showCR:'accepted:'. |
|
441 |
Transcript showCR:newContents asString. |
|
442 |
currentContents := newContents. |
|
443 |
model changed:#contents |
|
444 |
]. |
|
445 |
model respondTo:#getList |
|
446 |
with:[Transcript showCR:'query'. |
|
447 |
currentContents]. |
|
448 |
||
449 |
||
450 |
top1 := StandardSystemView new. |
|
451 |
top1 extent:300@200. |
|
452 |
||
453 |
textView1 := EditTextView new. |
|
454 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
455 |
top1 addSubView:textView1. |
|
456 |
||
457 |
textView1 listMessage:#getList; |
|
458 |
model:model; |
|
459 |
aspect:#contents; |
|
460 |
changeMessage:#accepted:. |
|
461 |
top1 open. |
|
462 |
||
463 |
top2 := StandardSystemView new. |
|
464 |
top2 extent:300@200. |
|
465 |
||
466 |
textView2 := EditTextView new. |
|
467 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
468 |
top2 addSubView:textView2. |
|
469 |
||
470 |
textView2 listMessage:#getList; |
|
471 |
model:model; |
|
472 |
aspect:#contents; |
|
473 |
changeMessage:#accepted:. |
|
474 |
top2 open. |
|
475 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
476 |
" |
0 | 477 |
! ! |
478 |
||
865 | 479 |
!EditTextView class methodsFor:'defaults'! |
59 | 480 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
481 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
482 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
483 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
484 |
"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
|
485 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
486 |
|
1419 | 487 |
st80Mode |
488 |
"return true, if the st80 editing mode is turned on. |
|
489 |
This setting affects the behavior of the cursor, when positioned |
|
5909 | 490 |
beyond the end of a line or the end of the text. |
491 |
This method is here for backward compatibility, when this flag was stored |
|
492 |
in a class var. It is now in the user's settings. |
|
493 |
Please do not call it, but go to the prefs directly, to make it easier to find those getters." |
|
1419 | 494 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
495 |
^ UserPreferences current st80EditMode |
1419 | 496 |
|
497 |
" |
|
498 |
EditTextView st80Mode:true |
|
499 |
EditTextView st80Mode:false |
|
500 |
" |
|
501 |
||
502 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
503 |
! |
|
504 |
||
505 |
st80Mode:aBoolean |
|
506 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
5909 | 507 |
beyond the end of a line or the last line. |
508 |
This method is here for backward compatibility, when this flag was stored |
|
509 |
in a class var. It is now in the user's settings. |
|
510 |
Please do not call it, but go to the prefs directly, to make it easier to find those setters." |
|
1419 | 511 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
512 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 513 |
|
514 |
" |
|
515 |
EditTextView st80Mode:true |
|
516 |
EditTextView st80Mode:false |
|
517 |
" |
|
518 |
||
519 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
520 |
! |
|
521 |
||
59 | 522 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
523 |
"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
|
524 |
|
1390 | 525 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
6152 | 526 |
#'textCursor.noFocusForegroundColor' |
527 |
#'textCursor.type' |
|
528 |
#'textCursor.typeNoFocus' |
|
529 |
#'editText.st80Mode')> |
|
1355 | 530 |
|
531 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
532 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
533 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
534 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
535 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
536 |
|
1419 | 537 |
" |
538 |
self updateStyleCache |
|
539 |
" |
|
540 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
541 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 542 |
! ! |
543 |
||
3431 | 544 |
!EditTextView class methodsFor:'specs'! |
545 |
||
546 |
searchReplaceDialogSpec |
|
547 |
"This resource specification was automatically generated |
|
548 |
by the UIPainter of ST/X." |
|
549 |
||
550 |
"Do not manually edit this!! If it is corrupted, |
|
551 |
the UIPainter may not be able to read the specification." |
|
552 |
||
553 |
" |
|
554 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
555 |
" |
|
556 |
||
557 |
<resource: #canvas> |
|
558 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
559 |
^ |
3431 | 560 |
#(FullSpec |
6152 | 561 |
name: searchReplaceDialogSpec |
562 |
window: |
|
3431 | 563 |
(WindowSpec |
6152 | 564 |
label: 'String Search and Replace' |
565 |
name: 'String Search and Replace' |
|
566 |
min: (Point 283 196) |
|
567 |
max: (Point 283 196) |
|
568 |
bounds: (Rectangle 0 0 279 192) |
|
569 |
) |
|
570 |
component: |
|
3431 | 571 |
(SpecCollection |
6152 | 572 |
collection: ( |
573 |
(LabelSpec |
|
574 |
label: 'Search Pattern:' |
|
575 |
name: 'label' |
|
576 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
577 |
level: 0 |
|
578 |
translateLabel: true |
|
579 |
adjust: left |
|
580 |
) |
|
581 |
(ComboBoxSpec |
|
582 |
name: 'patternComboBox' |
|
583 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
584 |
tabable: true |
|
585 |
model: searchPattern |
|
586 |
immediateAccept: false |
|
587 |
acceptOnLeave: true |
|
588 |
acceptOnReturn: true |
|
589 |
acceptOnTab: true |
|
590 |
acceptOnLostFocus: true |
|
591 |
acceptOnPointerLeave: false |
|
592 |
autoSelectInitialText: true |
|
593 |
comboList: patternList |
|
594 |
) |
|
595 |
(ComboBoxSpec |
|
596 |
name: 'replaceComboBox' |
|
597 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
598 |
tabable: true |
|
599 |
model: replacePattern |
|
600 |
immediateAccept: false |
|
601 |
acceptOnLeave: true |
|
602 |
acceptOnReturn: true |
|
603 |
acceptOnTab: true |
|
604 |
acceptOnLostFocus: true |
|
605 |
acceptOnPointerLeave: false |
|
606 |
autoSelectInitialText: true |
|
607 |
comboList: patternList |
|
608 |
) |
|
609 |
(CheckBoxSpec |
|
610 |
label: 'Ignore Case' |
|
611 |
name: 'ignoreCaseCheckBox' |
|
612 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
613 |
level: 0 |
|
614 |
tabable: true |
|
615 |
model: ignoreCase |
|
616 |
translateLabel: true |
|
617 |
) |
|
618 |
(VariableVerticalPanelSpec |
|
619 |
name: 'VariableVerticalPanel1' |
|
620 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
621 |
component: |
|
622 |
(SpecCollection |
|
623 |
collection: ( |
|
624 |
(HorizontalPanelViewSpec |
|
625 |
name: 'HorizontalPanel1' |
|
626 |
level: 0 |
|
627 |
horizontalLayout: fitSpace |
|
628 |
verticalLayout: center |
|
629 |
horizontalSpace: 3 |
|
630 |
verticalSpace: 3 |
|
631 |
ignoreInvisibleComponents: true |
|
632 |
reverseOrderIfOKAtLeft: true |
|
633 |
component: |
|
634 |
(SpecCollection |
|
635 |
collection: ( |
|
636 |
(ActionButtonSpec |
|
637 |
label: 'Replace' |
|
638 |
name: 'replaceButton' |
|
639 |
level: 2 |
|
640 |
translateLabel: true |
|
641 |
tabable: true |
|
642 |
model: replaceAction |
|
643 |
extent: (Point 134 21) |
|
644 |
) |
|
645 |
(ActionButtonSpec |
|
646 |
label: 'Replace All' |
|
647 |
name: 'replaceAllButton' |
|
648 |
level: 2 |
|
649 |
borderWidth: 1 |
|
650 |
translateLabel: true |
|
651 |
tabable: true |
|
652 |
model: replaceAllAction |
|
653 |
extent: (Point 134 21) |
|
654 |
) |
|
655 |
) |
|
656 |
||
657 |
) |
|
658 |
) |
|
659 |
(HorizontalPanelViewSpec |
|
660 |
name: 'horizontalPanelView' |
|
661 |
level: 0 |
|
662 |
horizontalLayout: fitSpace |
|
663 |
verticalLayout: center |
|
664 |
horizontalSpace: 3 |
|
665 |
verticalSpace: 3 |
|
666 |
ignoreInvisibleComponents: true |
|
667 |
reverseOrderIfOKAtLeft: true |
|
668 |
component: |
|
669 |
(SpecCollection |
|
670 |
collection: ( |
|
671 |
(ActionButtonSpec |
|
672 |
label: 'Cancel' |
|
673 |
name: 'cancelButton' |
|
674 |
level: 2 |
|
675 |
translateLabel: true |
|
676 |
tabable: true |
|
677 |
model: cancel |
|
678 |
extent: (Point 88 21) |
|
679 |
) |
|
680 |
(ActionButtonSpec |
|
681 |
label: 'Prev' |
|
682 |
name: 'prevButton' |
|
683 |
level: 2 |
|
684 |
translateLabel: true |
|
685 |
tabable: true |
|
686 |
model: prevAction |
|
687 |
extent: (Point 89 21) |
|
688 |
) |
|
689 |
(ActionButtonSpec |
|
690 |
label: 'Next' |
|
691 |
name: 'nextButton' |
|
692 |
level: 2 |
|
693 |
borderWidth: 1 |
|
694 |
translateLabel: true |
|
695 |
tabable: true |
|
696 |
model: nextAction |
|
697 |
isDefault: true |
|
698 |
extent: (Point 88 21) |
|
699 |
) |
|
700 |
) |
|
701 |
||
702 |
) |
|
703 |
) |
|
704 |
) |
|
705 |
||
706 |
) |
|
707 |
handles: (Any 0.5 1.0) |
|
708 |
) |
|
709 |
(LabelSpec |
|
710 |
label: 'Replace By:' |
|
711 |
name: 'ReplaceLabel' |
|
712 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
713 |
level: 0 |
|
714 |
translateLabel: true |
|
715 |
adjust: left |
|
716 |
) |
|
717 |
) |
|
718 |
||
719 |
) |
|
3431 | 720 |
) |
721 |
||
722 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
723 |
! ! |
|
724 |
||
2744 | 725 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
726 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
727 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
728 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
729 |
|
2019 | 730 |
"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
|
731 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
732 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
733 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
734 |
"ignored for now" |
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 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
737 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
738 |
|
1390 | 739 |
cutSelection |
740 |
self cut |
|
741 |
||
742 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
743 |
! |
|
744 |
||
1590 | 745 |
deselect |
746 |
"remove the selection" |
|
747 |
||
748 |
^ self unselect |
|
749 |
||
750 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
751 |
! |
|
752 |
||
2101 | 753 |
enabled:aBoolean |
754 |
||
755 |
self readOnly:aBoolean not |
|
756 |
||
757 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
758 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
759 |
! |
|
760 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
761 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
762 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
763 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
764 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
765 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
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 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
768 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
769 |
"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
|
770 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
771 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
772 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
773 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
774 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
775 |
col < 1 ifTrue:[ |
6152 | 776 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
777 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
778 |
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
|
779 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
780 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
781 |
|top v| |
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 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
784 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
785 |
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
|
786 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
787 |
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
|
788 |
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
|
789 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
790 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
791 |
"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
|
792 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
793 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
794 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
795 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
796 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
797 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
798 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
799 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 800 |
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
|
801 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
802 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 803 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
804 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
805 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
806 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
807 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
808 |
v insertAndSelect:'<- hello there' at:5. |
125 | 809 |
" |
1390 | 810 |
! |
811 |
||
812 |
pasteSelection |
|
813 |
self paste |
|
814 |
||
815 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 816 |
! |
817 |
||
818 |
replaceSelectionWith:aString |
|
819 |
^ self replaceSelectionBy:aString |
|
820 |
||
821 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
822 |
! |
|
823 |
||
824 |
selectAt:pos |
|
825 |
"move the cursor before cursorPosition." |
|
826 |
||
827 |
self cursorToCharacterPosition:pos |
|
828 |
||
829 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
830 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
831 |
! |
|
832 |
||
2101 | 833 |
textHasChanged |
834 |
^ self modified |
|
835 |
||
836 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
837 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
838 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
839 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
840 |
"ST-80 compatibility: set/clear the modified flag." |
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 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
843 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
844 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
845 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
846 |
|
4585 | 847 |
!EditTextView methodsFor:'accessing'! |
848 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
849 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
850 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
851 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
852 |
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
|
853 |
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
|
854 |
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
|
855 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
856 |
"/ Applications should set it explictly, however, to make it behavinh like |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
857 |
"/ 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
|
858 |
^((app := self topView application) notNil and:[app respondsTo: #codeAspect]) |
6152 | 859 |
ifTrue:[app codeAspect] |
860 |
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
|
861 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
862 |
"Created: / 27-09-2013 / 09:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
863 |
! |
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 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
866 |
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
|
867 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
868 |
"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
|
869 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
870 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
871 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
872 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
873 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
874 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
875 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
876 |
completionSupport := anEditTextViewCompletionSupport. |
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 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
880 |
^ self class defaultCompletionSupportClass |
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 |
"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
|
883 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
884 |
|
4609 | 885 |
editedClass |
886 |
|cm| |
|
887 |
||
888 |
cm := self editedMethodOrClass. |
|
889 |
cm isBehavior ifTrue:[^ cm]. |
|
890 |
cm isMethod ifTrue:[^ cm mclass]. |
|
891 |
^ nil |
|
892 |
! |
|
893 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
894 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
895 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
896 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
897 |
"Created: / 18-09-2013 / 14:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
898 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
899 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
900 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
901 |
"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
|
902 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
903 |
"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
|
904 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
905 |
|
4609 | 906 |
editedMethod |
907 |
|cm| |
|
908 |
||
909 |
cm := self editedMethodOrClass. |
|
910 |
cm isMethod ifTrue:[^ cm]. |
|
911 |
cm isBehavior ifTrue:[^ nil]. |
|
912 |
^ nil |
|
913 |
! |
|
914 |
||
915 |
editedMethodOrClass |
|
916 |
^ nil |
|
917 |
! |
|
918 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
919 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
920 |
"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
|
921 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
922 |
"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
|
923 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
924 |
|
4585 | 925 |
hasSelectionOrTextInCursorLine |
926 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
927 |
! |
|
928 |
||
4589 | 929 |
selectionOrTextOfCursorLine |
930 |
^ self selectionOrTextOfCursorLine:true |
|
931 |
! |
|
932 |
||
4585 | 933 |
selectionOrTextOfCursorLine:doSelect |
934 |
|sel lNr line| |
|
935 |
||
936 |
sel := self selectionAsString. |
|
937 |
sel notNil ifTrue:[^ sel]. |
|
938 |
||
939 |
lNr := self cursorLine. |
|
940 |
line := self listAt:lNr. |
|
941 |
line notEmptyOrNil ifTrue:[ |
|
6152 | 942 |
doSelect ifTrue:[ |
943 |
self selectLine:lNr. |
|
944 |
]. |
|
945 |
^ line |
|
4585 | 946 |
]. |
947 |
||
948 |
^ nil |
|
949 |
! ! |
|
950 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
951 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
952 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
953 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
954 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
955 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
956 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
957 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
958 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
959 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
960 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
961 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
962 |
acceptAction := aBlock |
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 |
|
2792 | 965 |
acceptChannel |
966 |
"return the valueHolder holding true if text was accepted. |
|
967 |
By placing a true into this channel, an accept can also be forced." |
|
968 |
||
969 |
^ acceptChannel |
|
970 |
||
971 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
972 |
! |
|
973 |
||
974 |
acceptChannel:aValueHolder |
|
975 |
"set the valueHolder holding true if text was accepted. |
|
976 |
By placing a true into this channel, an accept can also be forced." |
|
977 |
||
978 |
|prev| |
|
979 |
||
980 |
prev := acceptChannel. |
|
981 |
acceptChannel := aValueHolder. |
|
982 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
983 |
||
984 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
985 |
! |
|
986 |
||
1108 | 987 |
acceptEnabled:aBoolean |
988 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
989 |
||
990 |
acceptEnabled := aBoolean |
|
991 |
||
992 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
993 |
! |
|
994 |
||
2792 | 995 |
accepted |
996 |
"return true if text was accepted" |
|
997 |
||
998 |
^ acceptChannel value |
|
999 |
||
1000 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1001 |
! |
|
1002 |
||
1003 |
accepted:aBoolean |
|
1004 |
"set/clear the accepted flag. |
|
1005 |
This may force my current contents to be placed into my model." |
|
1006 |
||
1007 |
acceptChannel value:aBoolean. |
|
1008 |
||
1009 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1010 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1011 |
! |
|
1012 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1013 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1014 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1015 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1016 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1017 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1018 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1019 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1020 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1021 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1022 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1023 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1024 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1025 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1026 |
|
2774 | 1027 |
cursorMovementWhenUpdating |
3160 | 1028 |
"return what is be done with the cursor, |
2774 | 1029 |
when I get a new text (via the model or the #contents/#list) |
1030 |
Allowed arguments are: |
|
6152 | 1031 |
#keep / nil -> stay where it was |
1032 |
#endOfText -> position cursor to the end |
|
1033 |
#beginOfText -> position cursor to the beginning |
|
1034 |
#endOfLine -> position cursor to the current lines end |
|
1035 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1036 |
The default is #beginOfText. |
1037 |
This may be useful for fields which get new values assigned from |
|
1038 |
the program (i.e. not from the user)" |
|
1039 |
||
1040 |
^ cursorMovementWhenUpdating |
|
1041 |
||
1042 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1043 |
! |
|
1044 |
||
2133 | 1045 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1046 |
"define what should be done with the cursor, |
2133 | 1047 |
when I get a new text (via the model or the #contents/#list) |
1048 |
Allowed arguments are: |
|
6152 | 1049 |
#keep / nil -> stay where it was |
1050 |
#endOfText -> position cursor to the end |
|
1051 |
#beginOfText -> position cursor to the beginning |
|
1052 |
#endOfLine -> position cursor to the current lines end |
|
1053 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1054 |
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
|
1055 |
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
|
1056 |
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
|
1057 |
|
2133 | 1058 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1059 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1060 |
"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
|
1061 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1062 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1063 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1064 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1065 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1066 |
|
2438 | 1067 |
dontReplaceSelectionOnInput |
4742 | 1068 |
"remember that the current selection was created by a paste operation |
1069 |
(as opposed to an explicit selection by the user). |
|
1070 |
This selection will not be replaced by followup user input, |
|
1071 |
so multiple pastes will be possible." |
|
1072 |
||
2438 | 1073 |
typeOfSelection := #paste |
1074 |
! |
|
1075 |
||
3235 | 1076 |
editModeHolder |
1077 |
^ editMode. |
|
1078 |
! |
|
1079 |
||
1080 |
editModeInsert |
|
1081 |
editMode value:EditMode insertMode |
|
1082 |
! |
|
1083 |
||
1084 |
editModeInsertAndSelect |
|
1085 |
editMode value:EditMode insertAndSelectMode |
|
1086 |
! |
|
1087 |
||
1088 |
editModeOverwrite |
|
1089 |
editMode value:EditMode overwriteMode |
|
1090 |
! |
|
1091 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1092 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1093 |
"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
|
1094 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1095 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1096 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1097 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1098 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1099 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1100 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1101 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1102 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1103 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1104 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1105 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1106 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1107 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1108 |
readOnly == true ifFalse:[ |
6152 | 1109 |
readOnly := true. |
1110 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1111 |
menu disableAll:#(cut paste replace indent) |
|
1112 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1113 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1114 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1115 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1116 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1117 |
|
5858 | 1118 |
generateTextAfterEndHook:aBlock |
1119 |
"some applications may want to dynamically generate lines below the bottom line, |
|
1120 |
when the cursor is moved there. |
|
1121 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1122 |
which want to automatically generate additional lines lazily, |
|
1123 |
but which cannot afford to generate the whole text in advance |
|
1124 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1125 |
If set, this hook is called whenever the cursor is about to be moved below the |
5859 | 1126 |
last line, getting the new lineNr (i.e > contents size) as argument. |
5858 | 1127 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1128 |
number, into which the cursor should be moved |
1129 |
(eg. if 10 additional lines are generated, it may want to return oldSize+1, |
|
5858 | 1130 |
to make the cursor end in the last line which was inserted)" |
5890 | 1131 |
|
5858 | 1132 |
self setAttribute:#generateTextAfterEndHook to:aBlock |
1133 |
! |
|
1134 |
||
1135 |
generateTextBeforeStartHook:aBlock |
|
1136 |
"some applications may want to dynamically generate lines above the top |
|
1137 |
line, when the cursor is moved there. |
|
1138 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1139 |
which want to automatically generate additional lines lazily, |
|
1140 |
but which cannot afford to generate the whole text in advance |
|
1141 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1142 |
If set, this hook is called whenever the cursor is about to be moved above the |
5859 | 1143 |
top, getting the new lineNr (i.e < 1) as argument. |
5858 | 1144 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1145 |
number, into which the cursor should be moved |
1146 |
(eg. if 10 additional lines are generated, it may want to return 10, to make the |
|
5858 | 1147 |
cursor end in the last line which was inserted)" |
5890 | 1148 |
|
5858 | 1149 |
self setAttribute:#generateTextBeforeStartHook to:aBlock |
1150 |
! |
|
1151 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1152 |
insertMode:aBoolean |
3235 | 1153 |
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
|
1154 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1155 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1156 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1157 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1158 |
insertModeHolder |
3235 | 1159 |
^ BlockValue |
6152 | 1160 |
with:[:m | m isInsertMode] |
1161 |
argument:(editMode). |
|
3465 | 1162 |
|
1163 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1164 |
! |
1165 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1166 |
isInInsertMode |
3235 | 1167 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1168 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1169 |
|
5216 | 1170 |
isNotReadOnly |
1171 |
"return true, if the text is not readonly." |
|
1172 |
||
1173 |
^ self isReadOnly not |
|
1174 |
! |
|
1175 |
||
2792 | 1176 |
isReadOnly |
1177 |
"return true, if the text is readonly." |
|
1178 |
||
1179 |
^ readOnly value |
|
1180 |
||
1181 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1182 |
! |
|
1183 |
||
2796 | 1184 |
modeLabelHolder |
1185 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1186 |
||
3160 | 1187 |
^ BlockValue |
6152 | 1188 |
with:[:e :l | |
1189 |
self isReadOnly ifTrue:[ |
|
1190 |
'' |
|
1191 |
] ifFalse:[ |
|
1192 |
l ifTrue:[ 'L' allBold withColor:#red] |
|
1193 |
ifFalse:[ e infoPrintString]]] |
|
1194 |
argument:(self editModeHolder) |
|
1195 |
argument:(self learnModeHolder). |
|
3465 | 1196 |
|
1197 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1198 |
! |
1199 |
||
2792 | 1200 |
modified |
1201 |
"return true if text was modified" |
|
1202 |
||
1203 |
^ modifiedChannel value |
|
1204 |
! |
|
1205 |
||
1206 |
modified:aBoolean |
|
1207 |
"set/clear the modified flag" |
|
1208 |
||
1209 |
modifiedChannel value:aBoolean |
|
1210 |
||
1211 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1212 |
! |
|
1213 |
||
1214 |
modifiedChannel |
|
1215 |
"return the valueHolder holding true if text was modified" |
|
1216 |
||
1217 |
^ modifiedChannel |
|
1218 |
! |
|
1219 |
||
1220 |
modifiedChannel:aValueHolder |
|
1221 |
"set the valueHolder holding true if text was modified" |
|
1222 |
||
1223 |
|prev| |
|
1224 |
||
1225 |
prev := modifiedChannel. |
|
1226 |
modifiedChannel := aValueHolder. |
|
1227 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1228 |
||
1229 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1230 |
! |
|
1231 |
||
1232 |
readOnly |
|
1233 |
"make the text readonly. |
|
4664 | 1234 |
Obsolete because it is obfuscating (looks like a getter) |
1235 |
- use #readOnly:" |
|
2792 | 1236 |
|
1237 |
<resource:#obsolete> |
|
1238 |
||
1239 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1240 |
self readOnly:true. |
2792 | 1241 |
|
4664 | 1242 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1243 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1244 |
! |
1245 |
||
1246 |
readOnly:aBoolean |
|
1247 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1248 |
The argument may also be a valueHolder." |
|
1249 |
||
1250 |
readOnly := aBoolean |
|
1251 |
||
1252 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1253 |
! |
|
1254 |
||
4782 | 1255 |
reallyModifiedChannel |
1256 |
"return the valueHolder holding true if text was really modified. |
|
1257 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1258 |
||
1259 |
^ self modifiedChannel |
|
1260 |
! |
|
1261 |
||
5909 | 1262 |
st80EditMode |
1263 |
"If on, the cursor wraps at the line end (like in vi or st80); |
|
1264 |
if off, we have the Rand-editor behavior (random access)" |
|
1265 |
||
1266 |
^ st80Mode ? (UserPreferences current st80EditMode) |
|
1267 |
! |
|
1268 |
||
1269 |
st80EditMode:aBooleanOrNil |
|
4192 | 1270 |
"set/clear the st80Mode flag. |
1271 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1272 |
if off, we have the Rand-editor behavior (random access) |
1273 |
if nil, the setting follows the current userPref setting." |
|
1274 |
||
1275 |
st80Mode := aBooleanOrNil |
|
4192 | 1276 |
|
1277 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1278 |
! |
|
1279 |
||
5909 | 1280 |
st80Mode:aBooleanOrNil |
6070 | 1281 |
<resource: #obsolete> |
5909 | 1282 |
self obsoleteMethodWarning. |
1283 |
self st80EditMode:aBooleanOrNil |
|
1284 |
||
1285 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1286 |
! |
|
1287 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1288 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1289 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1290 |
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
|
1291 |
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
|
1292 |
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
|
1293 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1294 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1295 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1296 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1297 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1298 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1299 |
"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
|
1300 |
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
|
1301 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1302 |
|
3160 | 1303 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1304 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1305 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1306 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1307 |
"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
|
1308 |
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
|
1309 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1310 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1311 |
tabRequiresControl := aBoolean |
5909 | 1312 |
! |
1313 |
||
1314 |
trimBlankLines |
|
1315 |
"If on, the blank lines are trimmed to zero size; |
|
1316 |
if nil, the setting follows the current userPref setting." |
|
1317 |
||
1318 |
^ trimBlankLines ? (UserPreferences current trimBlankLines) |
|
1319 |
! |
|
1320 |
||
1321 |
trimBlankLines:aBooleanOrNil |
|
1322 |
"If on, the blank lines are trimmed to zero size; |
|
1323 |
if nil, the setting follows the current userPref setting." |
|
1324 |
||
1325 |
trimBlankLines := aBooleanOrNil. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1326 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1327 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1328 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1329 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1330 |
at:lineNr basicPut:aLine |
5413 | 1331 |
"change a line without change notification. |
1332 |
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
|
1333 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1334 |
(self at:lineNr) = aLine ifFalse:[ |
6152 | 1335 |
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
|
1336 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1337 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1338 |
|
522 | 1339 |
at:lineNr put:aLine |
5413 | 1340 |
"replace a line by something new. |
1341 |
this is not undoably, unless you care for yourself" |
|
1342 |
||
5393 | 1343 |
|oldLine| |
1344 |
||
1345 |
oldLine := (self at:lineNr) ? ''. |
|
1346 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
6152 | 1347 |
super at:lineNr put:aLine. |
1348 |
self textChanged |
|
522 | 1349 |
]. |
1350 |
! |
|
1351 |
||
4700 | 1352 |
characterAfterCursor |
1353 |
"return the character one after the cursor - space if beyond line." |
|
1354 |
||
1355 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1356 |
! |
|
1357 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1358 |
characterBeforeCursor |
4700 | 1359 |
"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
|
1360 |
|
5142 | 1361 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1362 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1363 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1364 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1365 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1366 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1367 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1368 |
characterUnderCursor |
2707 | 1369 |
"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
|
1370 |
For non-block cursors, this is the character immediately to the right |
5787 | 1371 |
of the insertion-bar or caret. |
5413 | 1372 |
For block cursors, this is the highlighted cursor-character" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1373 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1374 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1375 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1376 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1377 |
contents |
2213 | 1378 |
"return the contents as a String or Text (i.e. with emphasis)" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1379 |
|
5988 | 1380 |
|numLines| |
1381 |
||
1382 |
list isNil ifTrue:[^ '']. |
|
1383 |
self trimBlankLines ifTrue:[ |
|
1384 |
self removeTrailingBlankLines. |
|
1385 |
] ifFalse:[ |
|
1386 |
"/ the last line does not count, if the cursor is at |
|
1387 |
"/ the begining |
|
1388 |
cursorCol == 1 ifTrue:[ |
|
1389 |
numLines := list size. |
|
1390 |
cursorLine == numLines ifTrue:[ |
|
1391 |
numLines > 1 ifTrue:[ |
|
1392 |
(self listAt:numLines) isEmptyOrNil ifTrue:[ |
|
1393 |
list grow:numLines-1. |
|
1394 |
]. |
|
1395 |
]. |
|
1396 |
]. |
|
1397 |
]. |
|
1398 |
]. |
|
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1399 |
^ super contents. |
3313 | 1400 |
|
1401 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1402 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1403 |
|
5413 | 1404 |
contents:aStringOrStringCollectionOrNil |
1405 |
"replace the whole contents by something new. |
|
5414 | 1406 |
this is not undoably, unless you care for yourself. |
1407 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1408 |
|
1409 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1410 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1411 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1412 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1413 |
"set the contents and optionally clear the undo history. |
1414 |
The contents-change is not undoable." |
|
1415 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1416 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1417 |
keepUndoHistory ifFalse:[ |
6152 | 1418 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1419 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1420 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1421 |
|
2213 | 1422 |
contentsAsString |
1423 |
"return the contents as a String (i.e. without emphasis)" |
|
1424 |
||
1425 |
list isNil ifTrue:[^ '']. |
|
1426 |
self removeTrailingBlankLines. |
|
1427 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
6152 | 1428 |
ifFalse:[each string] |
1429 |
]) asStringWithCRs |
|
2213 | 1430 |
! |
1431 |
||
5067 | 1432 |
contentsAsStringWithTabs |
1433 |
"return the contents as a String (i.e. without emphasis) |
|
1434 |
and with leading spaces replaced by tab characters |
|
1435 |
(i.e. as would be written to a file)" |
|
1436 |
||
1437 |
list isNil ifTrue:[^ '']. |
|
1438 |
self removeTrailingBlankLines. |
|
5787 | 1439 |
^ (list collect:[:each | |
6152 | 1440 |
each isNil |
1441 |
ifTrue:[''] |
|
1442 |
ifFalse:[each string withTabs] |
|
5067 | 1443 |
]) asStringWithCRs |
1444 |
! |
|
1445 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1446 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1447 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1448 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1449 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1450 |
^ cursorCol |
125 | 1451 |
! |
1452 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1453 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1454 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1455 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1456 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1457 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1458 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1459 |
cursorLine |
3160 | 1460 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1461 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1462 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1463 |
^ cursorLine |
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 |
|
5400 | 1466 |
cursorLineAndColumnLabelHolder |
5399 | 1467 |
"return a valueHolder for the cursors line and column as an info string |
5787 | 1468 |
of the form 'line : col'. |
5399 | 1469 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
1470 |
||
1471 |
^ BlockValue |
|
6152 | 1472 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
1473 |
argument:self cursorLineHolder |
|
1474 |
argument:self cursorColHolder |
|
5399 | 1475 |
! |
1476 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1477 |
cursorLineHolder |
3160 | 1478 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1479 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1480 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1481 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1482 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1483 |
|
4713 | 1484 |
lineStringBeforeCursor |
1485 |
"return the line's string before the cursor. |
|
1486 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1487 |
||
1488 |
|line| |
|
1489 |
||
1490 |
line := ((self at:cursorLine) ? '') string. |
|
1491 |
line size < (cursorCol-1) ifTrue:[ |
|
6152 | 1492 |
^ line paddedTo:(cursorCol-1) |
4713 | 1493 |
]. |
1494 |
^ line copyTo:(cursorCol-1) |
|
1495 |
! |
|
1496 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1497 |
list:something |
5413 | 1498 |
"replace the whole contents by something new. |
1499 |
this is not undoably, unless you care for yourself. |
|
1500 |
position cursor home when setting contents" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1501 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1502 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1503 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1504 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1505 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1506 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1507 |
super list:something. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1508 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1509 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1510 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
6152 | 1511 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1512 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1513 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1514 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
6152 | 1515 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1516 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1517 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1518 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1519 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
6152 | 1520 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1521 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1522 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
6152 | 1523 |
^ 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
|
1524 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1525 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1526 |
"/ 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
|
1527 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1528 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1529 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1530 |
setContents:something |
5787 | 1531 |
"replace the whole contents by something new |
5413 | 1532 |
AND clear the remembered undo actions" |
1533 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1534 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1535 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1536 |
undoSupport resetHistories. |
2955 | 1537 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1538 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1539 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1540 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1541 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1542 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1543 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1544 |
|
4609 | 1545 |
!EditTextView methodsFor:'accessing-dimensions'! |
1546 |
||
1547 |
xOfCursor |
|
4728 | 1548 |
|point| |
1549 |
||
1550 |
cursorVisibleLine isNil ifTrue:[ |
|
6152 | 1551 |
"/ take the end of the selection, if any |
1552 |
(selectionStartLine notNil |
|
1553 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1554 |
ifTrue:[ |
|
1555 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1556 |
]. |
|
5787 | 1557 |
|
1558 |
"/ point := device |
|
4728 | 1559 |
"/ translatePoint:(device pointerPosition) |
1560 |
"/ fromView:nil |
|
1561 |
"/ toView:self. |
|
1562 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1563 |
"/ ^ point x |
|
1564 |
"/ ]. |
|
1565 |
"/ ^ 0 |
|
6152 | 1566 |
^ nil |
4728 | 1567 |
]. |
4609 | 1568 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1569 |
||
1570 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1571 |
! ! |
|
4590 | 1572 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1573 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1574 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1575 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1576 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1577 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1578 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1579 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1580 |
wasOn := self hideCursor. |
5643 | 1581 |
cursorFgColor := color1 onDevice:device. |
1582 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1583 |
wasOn ifTrue:[self showCursor] |
1333 | 1584 |
! |
1585 |
||
1899 | 1586 |
cursorType |
1587 |
"return the style of the text cursor. |
|
4721 | 1588 |
Currently, supported are: #none |
6152 | 1589 |
#block, #frame, #ibeam, #caret, #solidCaret |
1590 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1591 |
|
1592 |
^ cursorType |
|
1593 |
||
1594 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1595 |
! |
|
1596 |
||
1333 | 1597 |
cursorType:aCursorTypeSymbol |
1598 |
"set the style of the text cursor. |
|
4721 | 1599 |
Currently, supported are: #none |
6152 | 1600 |
#block, #frame, #ibeam, #caret, #solidCaret |
1601 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1602 |
|
1334 | 1603 |
cursorType := aCursorTypeSymbol. |
1333 | 1604 |
|
1605 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1606 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1607 |
! |
1608 |
||
1899 | 1609 |
cursorTypeNoFocus |
1610 |
"return the style of the text cursor when the view has no focus. |
|
1611 |
If left unspecified, this is the same as the regular cursorType." |
|
1612 |
||
1613 |
^ cursorTypeNoFocus |
|
1614 |
||
1615 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1616 |
! |
|
1617 |
||
1334 | 1618 |
cursorTypeNoFocus:aCursorTypeSymbol |
1619 |
"set the style of the text cursor when the view has no focus. |
|
1620 |
If left unspecified, this is the same as the regular cursorType." |
|
1621 |
||
1622 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1623 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1624 |
|
4048 | 1625 |
!EditTextView methodsFor:'accessing-replace'! |
1626 |
||
4746 | 1627 |
lastReplacementInfo |
1628 |
^ lastReplacementInfo |
|
1629 |
! |
|
1630 |
||
4048 | 1631 |
lastStringToReplace: aString |
4818 | 1632 |
! |
1633 |
||
1634 |
previousReplacements |
|
1635 |
"accessor for the code completion" |
|
1636 |
||
1637 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1638 |
! ! |
1639 |
||
2119 | 1640 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1641 |
|
125 | 1642 |
accept |
1643 |
"accept the current contents by executing the accept-action and/or |
|
5937 | 1644 |
changeMessage. |
1645 |
Historically, ST/X used a callBack (acceptAction); |
|
1646 |
and ST80/VW used the model, into which the text is stored. |
|
1647 |
We support both; if there is a mode, it gets a value: message, |
|
1648 |
If there is an acceptAction, it is called." |
|
125 | 1649 |
|
1108 | 1650 |
acceptEnabled == false ifTrue:[ |
5937 | 1651 |
self beep. |
1652 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1653 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1654 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
5937 | 1655 |
^ self |
1108 | 1656 |
]. |
1657 |
||
125 | 1658 |
lockUpdates := true. |
1013 | 1659 |
|
1660 |
"/ |
|
1661 |
"/ ST-80 way of doing it |
|
1662 |
"/ |
|
1663 |
model notNil ifTrue:[ |
|
5937 | 1664 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
1665 |
acceptChannel notNil ifTrue:[ |
|
1666 |
acceptChannel value:true withoutNotifying:self. |
|
1667 |
]. |
|
2999 | 1668 |
]. |
1669 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1670 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1671 |
"/ ST/X way of doing things |
5937 | 1672 |
"/ as a historic leftover, |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1673 |
"/ 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
|
1674 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1675 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1676 |
acceptAction notNil ifTrue:[ |
5937 | 1677 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1678 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1679 |
|
125 | 1680 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1681 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1682 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1683 |
! |
1684 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1685 |
argForChangeMessage |
597 | 1686 |
"return the argument to be passed with the change notification. |
1687 |
Defined as separate method for easier subclassability." |
|
1688 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1689 |
^ self contents |
597 | 1690 |
|
1691 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1692 |
! |
1693 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1694 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1695 |
"get my contents from the model. |
597 | 1696 |
Redefined to ignore updates resulting from my own changes |
1697 |
(i.e. if lockUpdates is true)." |
|
121 | 1698 |
|
1699 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1700 |
ignore updates from my own change |
121 | 1701 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1702 |
lockUpdates ifTrue:[ |
6152 | 1703 |
lockUpdates := false. |
1704 |
^ self |
|
121 | 1705 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1706 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1707 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1708 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1709 |
"/ validate the cursorLine |
3160 | 1710 |
(cursorLine notNil |
2310 | 1711 |
and:[ cursorLine > list size ]) ifTrue:[ |
6152 | 1712 |
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
|
1713 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1714 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1715 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1716 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1717 |
changedObject == acceptChannel ifTrue:[ |
6152 | 1718 |
acceptChannel value == true ifTrue:[ |
1719 |
self accept. |
|
1720 |
]. |
|
1721 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1722 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1723 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1724 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1725 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1726 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1727 |
! ! |
1728 |
||
6015 | 1729 |
!EditTextView methodsFor:'commenting'! |
1730 |
||
1731 |
commentFrom:line1 to:line2 commentStrings:commentStrings |
|
1732 |
"helper function to comment out a block. |
|
1733 |
All lines from line1 to line2 get an end-of-line comment |
|
1734 |
in the first col |
|
1735 |
(if no eol comment is available, a bracketing comment is used)." |
|
1736 |
||
1737 |
|eolComment opening closing| |
|
1738 |
||
1739 |
eolComment := commentStrings at:1. |
|
1740 |
eolComment isNil ifTrue:[ |
|
1741 |
opening := (commentStrings at:2) at:1. |
|
1742 |
closing := (commentStrings at:2) at:2. |
|
1743 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1744 |
]. |
|
1745 |
||
1746 |
line1 to:line2 do:[:lineNr | |
|
1747 |
|l| |
|
1748 |
||
1749 |
l := self listAt:lineNr. |
|
1750 |
l isNil ifTrue:[l := '']. |
|
1751 |
eolComment notNil ifTrue:[ |
|
1752 |
l := eolComment , l |
|
1753 |
] ifFalse:[ |
|
1754 |
l := opening , l , closing |
|
1755 |
]. |
|
1756 |
self replaceLine:lineNr with:l. |
|
1757 |
widthOfWidestLine notNil ifTrue:[ |
|
1758 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1759 |
]. |
|
1760 |
]. |
|
1761 |
self textChanged. |
|
1762 |
||
1763 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
|
1764 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1765 |
! |
|
1766 |
||
1767 |
commentSelection:commentStrings |
|
1768 |
"convenient function to comment out a block. |
|
1769 |
All lines from line1 to line2 get an end-of-line comment |
|
1770 |
in the first col." |
|
1771 |
||
1772 |
|e commentPair opening closing| |
|
1773 |
||
1774 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
1775 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
|
1776 |
||
1777 |
self |
|
1778 |
undoableDo:[ |
|
1779 |
selectionStartLine isNil ifTrue:[ |
|
1780 |
self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1781 |
] ifFalse:[ |
|
1782 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1783 |
self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1784 |
] ifFalse:[ |
|
1785 |
commentPair := commentStrings at:2 ifAbsent:nil. |
|
1786 |
commentPair isNil ifTrue:[ |
|
1787 |
self beep. |
|
1788 |
] ifFalse:[ |
|
1789 |
opening := commentPair at:1. |
|
1790 |
closing := commentPair at:2. |
|
1791 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1792 |
||
1793 |
e := selectionEndCol. |
|
1794 |
||
1795 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1796 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
1797 |
||
1798 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
|
1799 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1800 |
toLine:selectionEndLine col:e+closing size. |
|
1801 |
] |
|
1802 |
] |
|
1803 |
]. |
|
1804 |
] |
|
1805 |
info:'Comment'. |
|
1806 |
||
1807 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
|
1808 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
|
1809 |
! |
|
1810 |
||
1811 |
uncommentFrom:line1 to:line2 commentStrings:commentStrings |
|
1812 |
"helper function to comment out a block. |
|
1813 |
All lines from line1 to line2 get an end-of-line comment |
|
1814 |
in the first col. |
|
1815 |
(if no eol comment is available, a bracketing comment is removed)." |
|
1816 |
||
1817 |
|eolComment opening closing rest| |
|
1818 |
||
1819 |
eolComment := commentStrings at:1. |
|
1820 |
eolComment isNil ifTrue:[ |
|
1821 |
opening := (commentStrings at:2) at:1. |
|
1822 |
closing := (commentStrings at:2) at:2. |
|
1823 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1824 |
] ifFalse:[ |
|
1825 |
rest := eolComment size + 1. |
|
1826 |
]. |
|
1827 |
||
1828 |
line1 to:line2 do:[:lineNr | |
|
1829 |
|l| |
|
1830 |
||
1831 |
l := self listAt:lineNr. |
|
1832 |
l notNil ifTrue:[ |
|
1833 |
eolComment notNil ifTrue:[ |
|
1834 |
(l startsWith:eolComment) ifTrue:[ |
|
1835 |
l := l copyFrom:rest |
|
1836 |
] ifFalse:[ |
|
1837 |
(l withoutLeadingSeparators startsWith:eolComment) ifTrue:[ |
|
1838 |
"/ only for single lines? |
|
1839 |
true "line1 = line2" ifTrue:[ |
|
1840 |
|numSpaces| |
|
1841 |
||
1842 |
numSpaces := l indexOfNonSeparator - 1. |
|
1843 |
l := l copyFrom:numSpaces+1+rest. |
|
1844 |
l := (String new:numSpaces),l |
|
1845 |
]. |
|
1846 |
]. |
|
1847 |
] |
|
1848 |
] ifFalse:[ |
|
1849 |
((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[ |
|
1850 |
l := l copyFrom:opening size + 1. |
|
1851 |
l := l copyButLast:closing size. |
|
1852 |
]. |
|
1853 |
]. |
|
1854 |
self replaceLine:lineNr with:l. |
|
1855 |
] |
|
1856 |
]. |
|
1857 |
||
1858 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
1859 |
self textChanged. |
|
1860 |
! |
|
1861 |
||
1862 |
uncommentSelection:commentStrings |
|
1863 |
"convenient function to comment out a block. |
|
1864 |
All lines from line1 to line2 get an end-of-line comment |
|
1865 |
in the first col." |
|
1866 |
||
1867 |
|e commentPair opening closing sz1 sz2 l1 l2 c1 c2| |
|
1868 |
||
1869 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
1870 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
|
1871 |
||
1872 |
self |
|
1873 |
undoableDo:[ |
|
1874 |
selectionStartLine isNil ifTrue:[ |
|
1875 |
self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1876 |
] ifFalse:[ |
|
1877 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1878 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1879 |
] ifFalse:[ |
|
1880 |
commentPair := commentStrings at:2. |
|
1881 |
opening := commentPair at:1. |
|
1882 |
closing := commentPair at:2. |
|
1883 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1884 |
||
1885 |
sz1 := opening size. |
|
1886 |
sz2 := closing size. |
|
1887 |
||
1888 |
((self |
|
1889 |
stringAtLine:selectionStartLine |
|
1890 |
from:selectionStartCol |
|
1891 |
to:selectionStartCol+sz1 - 1) = opening |
|
1892 |
and:[(self |
|
1893 |
stringAtLine:selectionEndLine |
|
1894 |
from:selectionEndCol - sz2 + 1 |
|
1895 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1896 |
||
1897 |
l2 := selectionEndLine. c2 := selectionEndCol. |
|
1898 |
l1 := selectionStartLine. c1 := selectionStartCol. |
|
1899 |
self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2. |
|
1900 |
self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1. |
|
1901 |
||
1902 |
e := c2 - sz2. |
|
1903 |
l1 == l2 ifTrue:[e := e - sz1]. |
|
1904 |
self selectFromLine:l1 col:c1 toLine:l2 col:e. |
|
1905 |
] |
|
1906 |
] |
|
1907 |
]. |
|
1908 |
] |
|
1909 |
info:'Uncomment'. |
|
1910 |
||
1911 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
|
1912 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
|
1913 |
! ! |
|
1914 |
||
121 | 1915 |
!EditTextView methodsFor:'cursor handling'! |
1916 |
||
4820 | 1917 |
basicCursorReturn |
1918 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1919 |
||
1920 |
|wasOn| |
|
1921 |
||
1922 |
self checkForExistingLine:(cursorLine + 1). |
|
1923 |
cursorVisibleLine notNil ifTrue:[ |
|
6152 | 1924 |
nFullLinesShown notNil ifTrue:[ |
1925 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1926 |
] |
|
4820 | 1927 |
]. |
1928 |
||
1929 |
wasOn := self hideCursor. |
|
1930 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1931 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1932 |
||
1933 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1934 |
! |
|
1935 |
||
2406 | 1936 |
characterPositionOfCursor |
1937 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1938 |
! |
|
1939 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1940 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1941 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1942 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1943 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1944 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1945 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1946 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1947 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1948 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1949 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1950 |
|
2822 | 1951 |
(cursorCol == newCol) ifTrue:[^ self]. |
1952 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1953 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1954 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1955 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1956 |
|
1957 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1958 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1959 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1960 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1961 |
"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
|
1962 |
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
|
1963 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1964 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1965 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1966 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1967 |
|
2707 | 1968 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1969 |
cursorLine > list size ifTrue:[ |
6152 | 1970 |
wasOn := self hideCursor. |
1971 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1972 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1973 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1974 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1975 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1976 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1977 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1978 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1979 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1980 |
"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
|
1981 |
|
5857 | 1982 |
|inLastLine wasOn nv nL cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1983 |
|
4595 | 1984 |
(nL := cursorLine) isNil ifTrue:[ |
5857 | 1985 |
nL := firstLineShown |
1986 |
]. |
|
1987 |
||
1988 |
inLastLine := (nL == list size). |
|
5890 | 1989 |
|
5857 | 1990 |
inLastLine ifTrue:[ |
5858 | 1991 |
|generateTextAfterEndHook| |
5857 | 1992 |
|
1993 |
cursorColBefore := cursorCol. |
|
5858 | 1994 |
(generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[ |
5860 | 1995 |
wasOn := self hideCursor. |
1996 |
nL := generateTextAfterEndHook value:(nL + n). |
|
1997 |
self setValidatedCursorLine:nL col:cursorColBefore. |
|
1998 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1999 |
^ self. |
|
5890 | 2000 |
]. |
4595 | 2001 |
]. |
2002 |
||
2003 |
self st80EditMode ifTrue:[ |
|
5857 | 2004 |
nL == list size ifTrue:[ |
2005 |
wasOn := self hideCursor. |
|
2006 |
self setValidatedCursorLine:nL col:(self listAt:nL) size + 1. |
|
2007 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2008 |
self beep. |
|
2009 |
^ self. |
|
2010 |
] |
|
4595 | 2011 |
]. |
2012 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2013 |
cursorVisibleLine notNil ifTrue:[ |
5857 | 2014 |
wasOn := self hideCursor. |
2015 |
nv := cursorVisibleLine + n - 1. |
|
2016 |
(nv >= nFullLinesShown) ifTrue:[ |
|
2017 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
2018 |
]. |
|
2019 |
self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol). |
|
2020 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2021 |
] ifFalse:[ |
5857 | 2022 |
self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol). |
2023 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2024 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2025 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2026 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2027 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2028 |
|
121 | 2029 |
cursorHome |
597 | 2030 |
"scroll to top AND move cursor to first line of text." |
121 | 2031 |
|
674 | 2032 |
self cursorLine:1 col:1 |
2033 |
||
2034 |
"/ |wasOn| |
|
2035 |
"/ |
|
2036 |
"/ wasOn := self hideCursor. |
|
2037 |
"/ self scrollToTop. |
|
2038 |
"/ cursorLine := cursorVisibleLine := 1. |
|
2039 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
2040 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
2041 |
||
2042 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 2043 |
! |
2044 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2045 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2046 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2047 |
|
6207 | 2048 |
|wasOn| |
2049 |
||
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2050 |
(cursorCol ~~ 1) ifTrue:[ |
6207 | 2051 |
wasOn := self hideCursor. |
2052 |
self setValidatedCursorCol:(cursorCol - 1). |
|
2053 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2054 |
"/ self cursorCol:(cursorCol - 1) |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2055 |
] ifFalse:[ |
6152 | 2056 |
cursorLine ~~ 1 ifTrue:[ |
2057 |
self st80EditMode ifTrue:[ |
|
2058 |
self cursorUp. |
|
2059 |
self cursorToEndOfLine. |
|
2060 |
] |
|
2061 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2062 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2063 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
2064 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2065 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2066 |
|
4126 | 2067 |
cursorLeft:n |
2068 |
"move cursor to left" |
|
2069 |
||
2070 |
n timesRepeat:[ |
|
6152 | 2071 |
self cursorLeft |
4126 | 2072 |
]. |
2073 |
! |
|
2074 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2075 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2076 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2077 |
|
5056 | 2078 |
self cursorLine:line col:col makeVisible:true |
2079 |
! |
|
2080 |
||
2081 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
2082 |
"this positions onto physical - not visible - line" |
|
2083 |
||
676 | 2084 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2085 |
|
2822 | 2086 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
2087 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2088 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2089 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2090 |
|
672 | 2091 |
(col < 1) ifTrue:[ |
6152 | 2092 |
newCol := 1 |
672 | 2093 |
] ifFalse:[ |
6152 | 2094 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2095 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2096 |
self st80EditMode ifTrue:[ |
6152 | 2097 |
(cursorLine == list size |
2098 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
2099 |
newCol := (self listAt:(list size)) size + 1. |
|
2100 |
] |
|
1419 | 2101 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2102 |
self setValidatedCursorCol:newCol. |
5056 | 2103 |
makeVisibleBoolean ifTrue:[ |
6152 | 2104 |
self makeCursorVisibleAndShowCursor:wasOn. |
5056 | 2105 |
] ifFalse:[ |
6152 | 2106 |
wasOn ifTrue:[self showCursor] |
5056 | 2107 |
]. |
672 | 2108 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2109 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2110 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2111 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2112 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2113 |
"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
|
2114 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2115 |
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
|
2116 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2117 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2118 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2119 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2120 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2121 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2122 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2123 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2124 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2125 |
"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
|
2126 |
|
4820 | 2127 |
self basicCursorReturn |
259
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 |
|
5529 | 2130 |
cursorReturn:withPossibleAutoIndent |
2131 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2132 |
||
2133 |
self basicCursorReturn |
|
2134 |
! |
|
2135 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2136 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2137 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2139 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2140 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2141 |
self st80EditMode ifTrue:[ |
6210 | 2142 |
self isInputField ifFalse:[ |
2143 |
l := (self listAt:cursorLine). |
|
2144 |
cursorCol >= (l size + 1) ifTrue:[ |
|
2145 |
cursorLine <= list size ifTrue:[ |
|
2146 |
self cursorReturn:false. "/ no autoindent |
|
2147 |
]. |
|
2148 |
^ self |
|
2149 |
] |
|
2150 |
]. |
|
3160 | 2151 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2152 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2153 |
|
6210 | 2154 |
"Modified: / 27-09-2017 / 15:38:26 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2155 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2156 |
|
4126 | 2157 |
cursorRight:n |
2158 |
"move cursor to right" |
|
2159 |
||
2160 |
n timesRepeat:[ |
|
6152 | 2161 |
self cursorRight |
4126 | 2162 |
]. |
2163 |
! |
|
2164 |
||
1833 | 2165 |
cursorShown:aBoolean |
2166 |
"change cursor visibility |
|
2167 |
return true if cursor was visible before." |
|
2168 |
||
2169 |
|oldState| |
|
2170 |
||
4494 | 2171 |
aBoolean == cursorShown ifTrue:[ |
6152 | 2172 |
^ cursorShown |
4494 | 2173 |
]. |
1833 | 2174 |
oldState := cursorShown. |
2175 |
||
2176 |
aBoolean ifTrue:[ |
|
6152 | 2177 |
self drawCursor. |
1833 | 2178 |
] ifFalse:[ |
6152 | 2179 |
(cursorShown and:[shown]) ifTrue: [ |
2180 |
self undrawCursor. |
|
2181 |
]. |
|
1833 | 2182 |
]. |
2183 |
cursorShown := aBoolean. |
|
2184 |
||
2185 |
^ oldState |
|
2186 |
||
2187 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
2188 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
2189 |
! |
|
2190 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2191 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2192 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2193 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2194 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2195 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2196 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2197 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2198 |
"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
|
2199 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2200 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2201 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2202 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2203 |
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
|
2204 |
cursorCol > textStart ifTrue:[ |
6152 | 2205 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2206 |
] ifFalse:[ |
6152 | 2207 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2208 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2209 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2210 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2211 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2212 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2213 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2214 |
"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
|
2215 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2216 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2217 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2218 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2219 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2220 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2221 |
(newTop < 1) ifTrue:[ |
6152 | 2222 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2223 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2224 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2225 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2226 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2227 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2228 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2229 |
|
674 | 2230 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2231 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2232 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2233 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2234 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2235 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2236 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2237 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2238 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2239 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2240 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2241 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2242 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2243 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2244 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2245 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2246 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2247 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2248 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2249 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2250 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2251 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2252 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2253 |
cursorLine >= lineNr ifTrue:[ |
6152 | 2254 |
line := self listAt:cursorLine. |
2255 |
(line isEmptyOrNil) ifTrue:[ |
|
2256 |
^ self |
|
2257 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2258 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2259 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2260 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2261 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2262 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2263 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2264 |
(newTop < 1) ifTrue:[ |
6152 | 2265 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2266 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2267 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2268 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2269 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2270 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2271 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2272 |
|
674 | 2273 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2274 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2275 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2276 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2277 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2278 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2279 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2280 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2281 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2282 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2283 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2284 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2285 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2286 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2287 |
cursorToEndOfText |
4288 | 2288 |
"move cursor to the end of the text (behind the last character in last line)" |
2289 |
||
2290 |
|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
|
2291 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2292 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2293 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2294 |
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
|
2295 |
(newTop < 1) ifTrue:[ |
6152 | 2296 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2297 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2298 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2299 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2300 |
self setValidatedCursorLine:list size. |
4288 | 2301 |
lastLineLength := (self listAt:cursorLine) size. |
2302 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2303 |
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
|
2304 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2305 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2306 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2307 |
"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
|
2308 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2309 |
|
3310 | 2310 |
cursorToEndOfWord |
2311 |
"move the cursor to the end of the word" |
|
2312 |
||
2313 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2314 |
||
2315 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2316 |
:beginLine :beginCol :endLine :endCol :style | |
2317 |
||
2318 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2319 |
] |
2320 |
||
2321 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2322 |
! |
|
2323 |
||
131 | 2324 |
cursorToFirstVisibleLine |
2325 |
"place cursor into the first visible line; do not scroll." |
|
2326 |
||
2327 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2328 |
! |
|
2329 |
||
2330 |
cursorToLastVisibleLine |
|
2331 |
"place cursor into the first visible line; do not scroll." |
|
2332 |
||
2333 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2334 |
! |
|
2335 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2336 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2337 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2338 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2339 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2340 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2341 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2342 |
|
5787 | 2343 |
self |
6152 | 2344 |
wordAtLine:cursorLine col:cursorCol |
2345 |
do:[ |
|
2346 |
:beginLine :beginCol :endLine :endCol :style | |
|
6154 | 2347 |
|lineSize| |
6152 | 2348 |
|
2349 |
line := endLine. |
|
2350 |
col := endCol + 1. |
|
6154 | 2351 |
lineSize := (self listAt:line) size. |
2352 |
(endCol ~= lineSize or:[lineSize == 0]) ifTrue:[ |
|
2353 |
searching := true. |
|
2354 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
|
2355 |
self wordAtLine:line col:col do:[ |
|
2356 |
:beginLine :beginCol :endLine :endCol :style | |
|
2357 |
||
2358 |
(line > list size) ifTrue:[ |
|
2359 |
"break out" |
|
2360 |
searching := false |
|
2361 |
] ifFalse:[ |
|
2362 |
line := endLine. |
|
2363 |
col := endCol + 1. |
|
2364 |
] |
|
6152 | 2365 |
] |
6154 | 2366 |
]. |
6152 | 2367 |
]. |
2368 |
self cursorLine:line col:col |
|
4707 | 2369 |
] |
6154 | 2370 |
|
2371 |
"Modified: / 11-05-2017 / 17:50:47 / stefan" |
|
121 | 2372 |
! |
2373 |
||
499 | 2374 |
cursorToPreviousWord |
2375 |
"move the cursor to the beginning of this or the previous word" |
|
2376 |
||
6154 | 2377 |
|col line searching| |
499 | 2378 |
|
2379 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
6152 | 2380 |
:beginLine :beginCol :endLine :endCol :style | |
2381 |
||
2382 |
line := beginLine. |
|
2383 |
col := beginCol. |
|
2384 |
style == #wordLeft ifTrue:[ |
|
2385 |
col := col + 1 |
|
2386 |
]. |
|
2387 |
||
2388 |
(cursorLine == line |
|
2389 |
and:[cursorCol == col]) ifTrue:[ |
|
2390 |
searching := true. |
|
2391 |
||
2392 |
col > 1 ifTrue:[ |
|
2393 |
col := col - 1. |
|
2394 |
]. |
|
2395 |
||
2396 |
[searching] whileTrue:[ |
|
2397 |
(col == 1) ifTrue:[ |
|
2398 |
line == 1 ifTrue:[ |
|
2399 |
searching := false |
|
2400 |
] ifFalse:[ |
|
2401 |
line := line - 1. |
|
6154 | 2402 |
col := (list at:line) size + 1. |
2403 |
col ~~ 1 ifTrue:[ |
|
2404 |
"at end of word in previous line" |
|
2405 |
searching := false. |
|
2406 |
]. |
|
6152 | 2407 |
] |
2408 |
] ifFalse:[ |
|
2409 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2410 |
self wordAtLine:line col:col do:[ |
|
2411 |
:beginLine :beginCol :endLine :endCol :style | |
|
2412 |
||
2413 |
line := beginLine. |
|
2414 |
col := beginCol. |
|
2415 |
style == #wordLeft ifTrue:[ |
|
2416 |
col := col + 1 |
|
2417 |
]. |
|
2418 |
searching := false. |
|
2419 |
] |
|
2420 |
] ifTrue:[ |
|
2421 |
col := col - 1 |
|
2422 |
] |
|
2423 |
] |
|
2424 |
] |
|
2425 |
]. |
|
2426 |
self cursorLine:line col:col |
|
499 | 2427 |
] |
2428 |
||
6154 | 2429 |
"Created: / 08-03-1996 / 21:52:48 / cg" |
2430 |
"Modified (format): / 11-05-2017 / 17:45:11 / stefan" |
|
499 | 2431 |
! |
2432 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2433 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2434 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2435 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2436 |
self cursorLine:1 col:1 |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2439 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2440 |
"move cursor up; scroll if at start of visible text" |
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 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2443 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2444 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2445 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2446 |
"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
|
2447 |
|
5856 | 2448 |
|wasOn nv nl cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2449 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2450 |
cursorLine isNil ifTrue:[ |
5850 | 2451 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
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 |
nl := cursorLine - n. |
5850 | 2454 |
nl < 1 ifTrue:[ |
5858 | 2455 |
|generateTextBeforeStartHook| |
5890 | 2456 |
|
5856 | 2457 |
cursorColBefore := cursorCol. |
5858 | 2458 |
(generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[ |
2459 |
nl := generateTextBeforeStartHook value:nl |
|
5890 | 2460 |
]. |
5850 | 2461 |
nl := nl max:1 |
2462 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2463 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2464 |
(nl ~~ cursorLine) ifTrue: [ |
5850 | 2465 |
wasOn := self hideCursor. |
2466 |
cursorVisibleLine notNil ifTrue:[ |
|
2467 |
nv := cursorVisibleLine - n. |
|
2468 |
nv < 1 ifTrue:[ |
|
2469 |
self scrollUp:(nv negated + 1) |
|
2470 |
]. |
|
2471 |
]. |
|
5856 | 2472 |
self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol). |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2473 |
"/ wasOn ifTrue:[self showCursor]. |
5850 | 2474 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2475 |
] |
672 | 2476 |
|
674 | 2477 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2478 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2479 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2480 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2481 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2482 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2483 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2484 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2485 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2486 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2487 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2488 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2489 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2490 |
|
676 | 2491 |
newCol := colNr. |
2492 |
(newCol < 1) ifTrue:[ |
|
6152 | 2493 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2494 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2495 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2496 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2497 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2498 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2499 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2500 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2501 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2502 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2503 |
"put cursor to position next to x/y coordinate in view" |
121 | 2504 |
|
2505 |
|line col| |
|
2506 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2507 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2508 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2509 |
self cursorVisibleLine:line col:col. |
121 | 2510 |
! |
2511 |
||
2512 |
drawCursor |
|
2513 |
"draw the cursor if shown and cursor is visible. |
|
2514 |
(but not, if there is a selection - to avoid confusion)" |
|
2515 |
||
2516 |
shown ifTrue:[ |
|
6152 | 2517 |
cursorVisibleLine notNil ifTrue:[ |
2518 |
self hasSelection ifFalse:[ |
|
2519 |
self drawCursorCharacter |
|
2520 |
] |
|
2521 |
] |
|
121 | 2522 |
] |
2523 |
! |
|
2524 |
||
2525 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2526 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2527 |
of cursor should be drawn. |
5787 | 2528 |
Currently, supported are: #none, |
6031 | 2529 |
#block, #frame, #ibeam, #caret, #solidCaret |
2530 |
#bigCaret and #bigSolidCaret" |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2531 |
|
2570 | 2532 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2533 |
|
2534 |
self hasSelection ifTrue:[ |
|
6031 | 2535 |
" |
2536 |
hide cursor, if there is a selection |
|
2537 |
" |
|
2538 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2539 |
]. |
2540 |
||
1334 | 2541 |
cursorType == #none ifTrue:[ |
6031 | 2542 |
^ self |
1334 | 2543 |
]. |
2544 |
||
121 | 2545 |
cursorType == #block ifTrue:[ |
6031 | 2546 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
2547 |
^ self |
|
121 | 2548 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2549 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2550 |
y := self yOfVisibleLine:cursorVisibleLine. |
2551 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2552 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2553 |
cursorType == #frame ifTrue:[ |
6031 | 2554 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2555 |
||
2556 |
char := self characterUnderCursor asString. |
|
6068 | 2557 |
gc paint:bgColor. |
2558 |
gc displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
|
133 | 2559 |
] ifFalse:[ |
6031 | 2560 |
self paint:bgColor. |
2561 |
cursorType == #ibeam ifTrue:[ |
|
2562 |
x1 := x - 1. |
|
2563 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2564 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2565 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
6031 | 2566 |
^ self |
2567 |
]. |
|
2568 |
||
2569 |
cursorType == #Ibeam ifTrue:[ |
|
2570 |
x1 := x - 1. |
|
2571 |
y := y + 1. |
|
2572 |
y2 := y + fontHeight - lineSpacing - 1. |
|
6068 | 2573 |
gc displayLineFromX:x1 y:y toX:x1 y:y2. |
2574 |
gc displayLineFromX:x y:y toX:x y:y2. |
|
2575 |
gc displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2576 |
gc displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
6031 | 2577 |
^ self |
2578 |
]. |
|
2579 |
||
2580 |
y := y + fontHeight - 3. |
|
2581 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2582 |
w := (fontWidth * 2 // 3) max:4. |
|
2583 |
y2 := y + w + (w//2). |
|
2584 |
] ifFalse:[ |
|
2585 |
w := (fontWidth // 2) max:4. |
|
2586 |
y2 := y + w. |
|
2587 |
]. |
|
2588 |
x1 := x - w. |
|
2589 |
x2 := x + w. |
|
2590 |
||
2591 |
oldClip := self clippingBoundsOrNil. |
|
2592 |
self clippingBounds:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2593 |
||
2594 |
cursorType == #caret ifTrue:[ |
|
6068 | 2595 |
gc lineWidth:2. |
2596 |
gc displayLineFromX:x1 y:y2 toX:x y:y. |
|
2597 |
gc displayLineFromX:x y:y toX:x2 y:y2. |
|
6031 | 2598 |
] ifFalse:[ |
2599 |
"anything else: solidCaret" |
|
2600 |
||
6068 | 2601 |
gc fillPolygon:(Array with:(x1 @ y2) |
2602 |
with:(x @ y) |
|
2603 |
with:(x2 @ y2)) |
|
6031 | 2604 |
]. |
2605 |
||
2606 |
self clippingBounds:oldClip |
|
121 | 2607 |
]. |
6068 | 2608 |
gc paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2609 |
|
2088 | 2610 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2611 |
! |
2612 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2613 |
drawCursorCharacter |
3160 | 2614 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2615 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2616 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2617 |
|
3160 | 2618 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2619 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2620 |
and:[self isReadOnly not]]) ifTrue:[ |
6152 | 2621 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2622 |
] ifFalse:[ |
6152 | 2623 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2624 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2625 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2626 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2627 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2628 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2629 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2630 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2631 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2632 |
self hasSelection ifTrue:[ |
6152 | 2633 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2634 |
]. |
2635 |
cursorType == #none ifTrue:[ |
|
6152 | 2636 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2637 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2638 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2639 |
|
2640 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2641 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2642 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2643 |
drawNoFocusCursor |
3160 | 2644 |
"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
|
2645 |
|
1334 | 2646 |
|cType| |
2647 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2648 |
self hasSelection ifTrue:[ |
6152 | 2649 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2650 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2651 |
|
1334 | 2652 |
cType := cursorTypeNoFocus ? cursorType. |
2653 |
cType == #none ifTrue:[ |
|
6152 | 2654 |
^ self undrawCursor |
1334 | 2655 |
]. |
2656 |
||
2657 |
cType == #block ifTrue:[ |
|
6152 | 2658 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2659 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2660 |
|
1334 | 2661 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2662 |
||
2663 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2664 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2665 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2666 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2667 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2668 |
Make certain that this line is visible" |
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 |
self makeLineVisible:aLineNumber. |
2951 | 2671 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2672 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2673 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2674 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2675 |
hideCursor |
1833 | 2676 |
"make cursor invisible if currently invisible" |
2677 |
||
2678 |
^ self cursorShown:false |
|
2679 |
||
2680 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2681 |
! |
2682 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2683 |
makeCursorVisible |
3160 | 2684 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2685 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2686 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2687 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2688 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2689 |
cursorLine notNil ifTrue:[ |
6152 | 2690 |
line := cursorLine. |
2691 |
col := cursorCol. |
|
2692 |
" |
|
2693 |
if there is a selection, its better to |
|
2694 |
have its start being visible, instead of the end |
|
2695 |
" |
|
2696 |
(selectionStartLine notNil |
|
2697 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2698 |
expandingTop ~~ false ifTrue:[ |
|
2699 |
line := selectionStartLine. |
|
2700 |
col := selectionStartCol. |
|
2701 |
] ifFalse:[ |
|
2702 |
line := selectionEndLine. |
|
2703 |
col := selectionEndCol |
|
2704 |
] |
|
2705 |
]. |
|
2706 |
self makeLineVisible:line. |
|
2707 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2708 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2709 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2710 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2711 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2712 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2713 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2714 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2715 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2716 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2717 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2718 |
flag ifTrue:[self showCursor] |
121 | 2719 |
! |
2720 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2721 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2722 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2723 |
|
2815 | 2724 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2725 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2726 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2727 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2728 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2729 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2730 |
|
3303 | 2731 |
"/ self assert:(lineNr notNil). |
2732 |
||
2733 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2734 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2735 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2736 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2737 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2738 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2739 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2740 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2741 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2742 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2743 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2744 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2745 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2746 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2747 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2748 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2749 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2750 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2751 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2752 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2753 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2754 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2755 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2756 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2757 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2758 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2759 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2760 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2761 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2762 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2763 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2764 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2765 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2766 |
|
1833 | 2767 |
^ self cursorShown:true |
2768 |
||
2769 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2770 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2771 |
|
5761 | 2772 |
singleQuoteSelection |
2773 |
"place single quotes around the selected text" |
|
2774 |
||
2775 |
|line1 col1 line2 col2| |
|
2776 |
||
2777 |
line1 := self selectionStartLine. |
|
2778 |
col1 := self selectionStartCol. |
|
2779 |
line2 := self selectionEndLine. |
|
2780 |
col2 := self selectionEndCol. |
|
2781 |
(line1 notNil |
|
6152 | 2782 |
and:[ col1 notNil |
2783 |
and:[ line2 notNil |
|
2784 |
and:[ col2 notNil ]]]) |
|
5761 | 2785 |
ifTrue:[ |
6152 | 2786 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
2787 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2788 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
5761 | 2789 |
] ifFalse:[ |
6152 | 2790 |
self beep. |
5761 | 2791 |
] |
2792 |
||
2793 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2794 |
! |
|
2795 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2796 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2797 |
"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
|
2798 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2799 |
|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
|
2800 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2801 |
cursorVisibleLine notNil ifTrue:[ |
6031 | 2802 |
prevCol := cursorCol - 1. |
2803 |
||
2804 |
"/ if there is any italic stuff in the cursor line, |
|
2805 |
"/ redraw it completely (because characters overlap). |
|
2806 |
cursorCol > 1 ifTrue:[ |
|
2807 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2808 |
line hasChangeOfEmphasis ifTrue:[ |
|
2809 |
line size >= (cursorCol-1) ifTrue:[ |
|
2810 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2811 |
line size >= (cursorCol) ifTrue:[ |
|
2812 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2813 |
line size >= (cursorCol+1) ifTrue:[ |
|
2814 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2815 |
]. |
|
2816 |
]. |
|
2817 |
]. |
|
2818 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2819 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2820 |
] |
|
2821 |
] |
|
2822 |
] |
|
2823 |
]. |
|
2824 |
||
2825 |
((cursorType == #caret) |
|
2826 |
or:[cursorType == #solidCaret |
|
2827 |
or:[cursorType == #bigSolidCaret |
|
2828 |
or:[cursorType == #bigCaret |
|
2829 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2830 |
"caret-cursor touches 4 characters" |
|
2831 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2832 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2833 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2834 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2835 |
] ifFalse:[ |
|
2836 |
"care for left margin" |
|
2837 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2838 |
]. |
|
2839 |
^ self |
|
2840 |
]. |
|
2841 |
||
2842 |
cursorType == #ibeam ifTrue:[ |
|
2843 |
"ibeam-cursor touches 2 characters" |
|
2844 |
cursorCol > 1 ifTrue:[ |
|
2845 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2846 |
] ifFalse:[ |
|
2847 |
"care for left margin" |
|
2848 |
super redrawVisibleLine:cursorVisibleLine. |
|
2849 |
]. |
|
2850 |
^ self |
|
2851 |
]. |
|
2852 |
||
2853 |
"block cursor is simple - just one character under cursor" |
|
2854 |
||
2855 |
"/ however, if italic characters are involved, we must care |
|
2856 |
"/ for the chars before/after the cursor. |
|
2857 |
"/ We redraw the part of the previous character which got |
|
2858 |
"/ detroyed by the block cursor. |
|
2859 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2860 |
||
2861 |
line := self visibleAt:cursorVisibleLine. |
|
2862 |
(line notNil and:[line isText]) ifTrue:[ |
|
2863 |
cursorCol > 1 ifTrue:[ |
|
2864 |
oldClip := self clippingBoundsOrNil. |
|
2865 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2866 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
2867 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
|
2868 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
|
2869 |
self clippingBounds:oldClip. |
|
2870 |
^ self. |
|
2871 |
]. |
|
2872 |
]. |
|
2873 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2874 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2875 |
|
2088 | 2876 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2877 |
! |
2878 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2879 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2880 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2881 |
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
|
2882 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2883 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2884 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2885 |
|
672 | 2886 |
validateCursorCol:col inLine:line |
674 | 2887 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2888 |
Here, no limits are enforced (and col is returned), |
5593 | 2889 |
but it may be redefined in EditFields or views which don't like the |
674 | 2890 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2891 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2892 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2893 |
|
1419 | 2894 |
"/ in ST80 mode, |
2707 | 2895 |
"/ the cursor may not be positioned beyond the |
2896 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2897 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2898 |
self st80EditMode ifTrue:[ |
6152 | 2899 |
l := (self listAt:line). |
2900 |
max := l size + 1. |
|
2901 |
col > max ifTrue:[ |
|
2902 |
^ max |
|
2903 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2904 |
]. |
672 | 2905 |
^ col |
2906 |
||
1419 | 2907 |
"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
|
2908 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2909 |
! |
2910 |
||
2911 |
validateCursorLine:line |
|
6171 | 2912 |
"check if line is a valid cursor line; return a fixed line-nr if not. |
3160 | 2913 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2914 |
redefined in views which don't like the cursor to be positioned |
674 | 2915 |
behind the end of the text (vi/st-80 behavior), or want to |
2916 |
skip reserved regions" |
|
2917 |
||
1419 | 2918 |
"/ |
2919 |
"/ in st80Mode, the cursor may not be positioned |
|
5787 | 2920 |
"/ beyond the last line |
6091 | 2921 |
"/ (but it must be possible to place it on one line below the last one |
5367 | 2922 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
1419 | 2923 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2924 |
self st80EditMode ifTrue:[ |
6091 | 2925 |
^ (line min:(list size + 1)) max:1 |
1419 | 2926 |
]. |
674 | 2927 |
^ line |
2928 |
||
6091 | 2929 |
"Created: / 22-05-1996 / 18:22:23 / cg" |
2930 |
"Modified: / 20-06-1998 / 18:19:26 / cg" |
|
2931 |
"Modified (comment): / 11-02-2017 / 09:12:37 / cg" |
|
6171 | 2932 |
"Modified (comment): / 19-06-2017 / 16:25:27 / mawalch" |
672 | 2933 |
! |
2934 |
||
121 | 2935 |
withCursorOffDo:aBlock |
2936 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2937 |
||
2938 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
6152 | 2939 |
^ aBlock value |
121 | 2940 |
]. |
2941 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2942 |
aBlock ensure:[ |
6152 | 2943 |
self showCursor |
121 | 2944 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2945 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2946 |
|
2589 | 2947 |
!EditTextView methodsFor:'drag & drop'! |
2948 |
||
2949 |
allowDrop:aBoolean |
|
3236 | 2950 |
"enable/disable drop support" |
2951 |
||
2589 | 2952 |
aBoolean ifFalse:[ |
6152 | 2953 |
dropTarget := nil. |
2589 | 2954 |
] ifTrue:[ |
6152 | 2955 |
dropTarget isNil ifTrue:[ |
2956 |
dropTarget := DropTarget |
|
2957 |
receiver:self |
|
2958 |
argument:nil |
|
2959 |
dropSelector:#'drop:' |
|
2960 |
canDropSelector:#'canDrop:' |
|
2961 |
] |
|
3236 | 2962 |
]. |
2963 |
! |
|
2964 |
||
3412 | 2965 |
canDrop:aDropContext |
2966 |
"public from d&d. |
|
2967 |
I accept textObjects and fileObjects only." |
|
2968 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2969 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2970 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2971 |
^ self canDropObjects:aDropContext dropObjects |
|
2972 |
||
2973 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2974 |
! |
|
2975 |
||
2976 |
canDropObjects:aCollectionOfDropObjects |
|
2977 |
"public from d&d. |
|
2978 |
I accept textObjects and fileObjects only." |
|
2589 | 2979 |
|
2980 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2981 |
||
3412 | 2982 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2983 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2984 |
||
2985 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2986 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2987 |
! |
|
2988 |
||
2989 |
drop:aDropContext |
|
2990 |
"public from d&d. |
|
2991 |
drop objects (new API)" |
|
2992 |
||
2993 |
self dropObjects:(aDropContext dropObjects) |
|
2994 |
||
2995 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2996 |
! |
|
2997 |
||
2998 |
dropFileObject:aDropObject |
|
2589 | 2999 |
"drop objects |
3236 | 3000 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
3001 |
||
4136 | 3002 |
|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
|
3003 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3004 |
pasteWhat := #name. |
3412 | 3005 |
|
3006 |
fn := aDropObject asFilename. |
|
3007 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
6152 | 3008 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
3009 |
(enforcedDropMode notNil |
|
3010 |
and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[ |
|
3011 |
pasteWhat := enforcedDropMode. |
|
3012 |
] ifFalse:[ |
|
3013 |
sensor := self sensor. |
|
3014 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
|
3015 |
pasteWhat := #name. |
|
3016 |
] ifFalse:[ |
|
3017 |
(sensor metaDown) ifTrue:[ |
|
3018 |
pasteWhat := #contents. |
|
3019 |
] ifFalse:[ |
|
3020 |
dontAskAgainHolder := false asValue. |
|
3021 |
answer := Dialog |
|
3022 |
confirmWithCancel:(resources |
|
3023 |
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.' |
|
3024 |
with:fn name allBold) |
|
3025 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
|
3026 |
values:#( nil #name #contents ) |
|
3027 |
default:#contents |
|
3028 |
check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder |
|
3029 |
title:(resources string:'Drop What'). |
|
3030 |
answer isNil ifTrue:[ ^ self ]. |
|
3031 |
||
3032 |
dontAskAgainHolder value ifTrue:[ |
|
3033 |
UserPreferences current enforcedDropModeForFiles:#contents |
|
3034 |
]. |
|
3035 |
pasteWhat := answer. |
|
3036 |
] |
|
3037 |
] |
|
3038 |
]. |
|
3886 | 3039 |
]. |
3040 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3041 |
pasteWhat == #name ifTrue:[ |
6152 | 3042 |
text := fn pathName |
3886 | 3043 |
] ifFalse:[ |
6152 | 3044 |
self withWaitCursorDo:[ |
3045 |
text := fn contentsAsString |
|
3046 |
]. |
|
3047 |
(app := self application) notNil ifTrue:[ |
|
3048 |
app droppedFile:fn in:self |
|
3049 |
]. |
|
5787 | 3050 |
]. |
3051 |
||
3052 |
self |
|
6152 | 3053 |
undoablePaste:text |
3054 |
info:'Drop File'. |
|
3412 | 3055 |
|
3056 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 3057 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 3058 |
! |
3059 |
||
3060 |
dropObject:aDropObject |
|
3061 |
"drop objects |
|
3062 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
3063 |
||
3415 | 3064 |
|text| |
3065 |
||
3412 | 3066 |
(aDropObject isFileObject) ifTrue:[ |
6152 | 3067 |
self dropFileObject:aDropObject |
3412 | 3068 |
] ifFalse:[ |
6152 | 3069 |
aDropObject isTextObject ifTrue:[ |
3070 |
text := aDropObject theObject. |
|
3071 |
text isStringCollection ifTrue:[ |
|
3072 |
text := text asStringWithoutFinalCR |
|
3073 |
]. |
|
3074 |
] ifFalse:[ |
|
3075 |
text := aDropObject theObject asString |
|
3076 |
]. |
|
3077 |
self |
|
3078 |
undoablePaste:text |
|
3079 |
info:'Drop'. |
|
3412 | 3080 |
]. |
3081 |
||
3082 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 3083 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 3084 |
! |
3085 |
||
3086 |
dropObjects:aCollectionOfDropObjects |
|
3087 |
"public from d&d. |
|
3088 |
drop objects (old API)" |
|
3089 |
||
3868 | 3090 |
aCollectionOfDropObjects do:[:el | |
6152 | 3091 |
self dropObject:el |
3412 | 3092 |
]. |
3093 |
||
3094 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
3095 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 3096 |
! ! |
3097 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3098 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3099 |
|
5761 | 3100 |
applyConverterToSelection:converter |
3101 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3102 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3103 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3104 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3105 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3106 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3107 |
line1 isNil ifTrue:[ |
6152 | 3108 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
3109 |
line1 notNil ifTrue:[ |
|
3110 |
line2 := line1 |
|
3111 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3112 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3113 |
line1 notNil ifTrue:[ |
6152 | 3114 |
line1 to:line2 do:[:lineNr | |
3115 |
|line col1 col2 newLine| |
|
3116 |
||
3117 |
line := (self listAt:lineNr) copy. |
|
3118 |
line size > 0 ifTrue:[ |
|
3119 |
lineNr == line1 ifTrue:[ |
|
3120 |
col1 := selectionStartCol. |
|
3121 |
] ifFalse:[ |
|
3122 |
col1 := 1. |
|
3123 |
]. |
|
3124 |
lineNr == line2 ifTrue:[ |
|
3125 |
col2 := selectionEndCol. |
|
3126 |
] ifFalse:[ |
|
3127 |
col2 := (self listAt:lineNr) size. |
|
3128 |
]. |
|
3129 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
|
3130 |
self withoutRedrawAt:lineNr put:newLine. |
|
3131 |
self invalidateLine:lineNr. |
|
3132 |
]. |
|
3133 |
]. |
|
5761 | 3134 |
] |
3135 |
||
3136 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
3137 |
! |
|
3138 |
||
3139 |
convertSelectionToLowercase |
|
3140 |
"to-lower selected text" |
|
3141 |
||
3142 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3143 |
col1 to:col2 do:[:col | |
3144 |
|ch| |
|
3145 |
||
3146 |
ch := line at:col. |
|
3147 |
line at:col put:ch asLowercase. |
|
3148 |
]. |
|
3149 |
line. |
|
5761 | 3150 |
]. |
3151 |
||
3152 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
3153 |
! |
|
3154 |
||
3155 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
3156 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
3157 |
||
3158 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
6152 | 3159 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
3160 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
3161 |
||
3162 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
3163 |
col1 to:col2 do:[:col | |
|
3164 |
|ch| |
|
3165 |
||
3166 |
ch := line at:col. |
|
3167 |
ch isUppercase ifTrue:[ |
|
3168 |
isAllLower := false. |
|
3169 |
col == col1 ifTrue:[ |
|
3170 |
isLowerFirst := false. |
|
3171 |
]. |
|
3172 |
] ifFalse:[ |
|
3173 |
ch isLowercase ifTrue:[ |
|
3174 |
isAllUpper := false. |
|
3175 |
col == col1 ifTrue:[ |
|
3176 |
isUpperFirst := false. |
|
3177 |
]. |
|
3178 |
] |
|
3179 |
]. |
|
3180 |
]. |
|
3181 |
||
3182 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
3183 |
isLowerFirst ifTrue:[ |
|
3184 |
makeUppercaseFirst := true. |
|
3185 |
] ifFalse:[ |
|
3186 |
"/ must remember where we come from - otherwise, we end up |
|
3187 |
"/ in upperFirst - lowerFirst cycle. |
|
3188 |
"/ think about a good place to store this state |
|
3189 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
3190 |
makeLowercaseFirst := true. |
|
3191 |
] ifFalse:[ |
|
3192 |
isAllUpper ifTrue:[ |
|
3193 |
makeLowercase := true. |
|
3194 |
] ifFalse:[ |
|
3195 |
makeUppercase := true. |
|
3196 |
] |
|
3197 |
] |
|
3198 |
]. |
|
3199 |
makeUppercaseFirst ifTrue:[ |
|
3200 |
line at:col1 put:(line at:col1) asUppercase. |
|
3201 |
] ifFalse:[ |
|
3202 |
makeLowercaseFirst ifTrue:[ |
|
3203 |
line at:col1 put:(line at:col1) asLowercase. |
|
3204 |
] ifFalse:[ |
|
3205 |
col1 to:col2 do:[:col | |
|
3206 |
|ch| |
|
3207 |
||
3208 |
ch := line at:col. |
|
3209 |
ch := makeLowercase |
|
3210 |
ifTrue:[ ch asLowercase ] |
|
3211 |
ifFalse:[ |
|
3212 |
makeUppercase |
|
3213 |
ifTrue:[ ch asUppercase ] |
|
3214 |
ifFalse:[ |
|
3215 |
col == col1 |
|
3216 |
ifTrue:[ ch asUppercase ] |
|
3217 |
ifFalse:[ ch asLowercase ] |
|
3218 |
] |
|
3219 |
]. |
|
3220 |
line at:col put:ch. |
|
3221 |
]. |
|
3222 |
]. |
|
3223 |
]. |
|
3224 |
line |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3225 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3226 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3227 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 3228 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
3229 |
! |
|
3230 |
||
3231 |
convertSelectionToUppercase |
|
3232 |
"to-upper selected text" |
|
3233 |
||
3234 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3235 |
col1 to:col2 do:[:col | |
3236 |
|ch| |
|
3237 |
||
3238 |
ch := line at:col. |
|
3239 |
line at:col put:ch asUppercase. |
|
3240 |
]. |
|
3241 |
line. |
|
5761 | 3242 |
]. |
3243 |
||
3244 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
3245 |
! |
|
3246 |
||
3247 |
convertSelectionToUppercaseFirst |
|
3248 |
"to-upperFirst selected text" |
|
3249 |
||
3250 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
6152 | 3251 |
|state| |
3252 |
||
3253 |
state := #first. |
|
3254 |
col1 to:col2 do:[:col | |
|
3255 |
|ch| |
|
3256 |
||
3257 |
ch := line at:col. |
|
3258 |
ch isSeparator ifFalse:[ |
|
3259 |
state == #first ifTrue:[ |
|
3260 |
line at:col put:ch asUppercase. |
|
3261 |
state := #skipRest |
|
3262 |
] |
|
3263 |
] ifTrue:[ |
|
3264 |
state := #first |
|
3265 |
] |
|
3266 |
]. |
|
3267 |
line. |
|
5761 | 3268 |
]. |
3269 |
||
3270 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3271 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3272 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3273 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3274 |
"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
|
3275 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3276 |
selectionStartLine notNil ifTrue:[ |
6152 | 3277 |
self setClipboardText:(self selection). |
3278 |
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
|
3279 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3280 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3281 |
"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
|
3282 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3283 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3284 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3285 |
"delete single character under cursor; does not merge lines" |
121 | 3286 |
|
3287 |
|wasOn| |
|
3288 |
||
3289 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3290 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3291 |
wasOn ifTrue:[self showCursor] |
3292 |
! |
|
3293 |
||
827 | 3294 |
deleteCharAtLine:lineNr col:colNr |
3295 |
"delete a single character at colNr in line lineNr" |
|
3296 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3297 |
self st80EditMode ifTrue:[ |
6152 | 3298 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3299 |
| wasOn | |
|
3300 |
wasOn := self hideCursor. |
|
3301 |
self |
|
3302 |
cursorReturn; |
|
3303 |
cursorCol:1; |
|
3304 |
deleteCharBeforeCursor. |
|
3305 |
wasOn ifTrue:[ self showCursor]. |
|
3306 |
^ self. |
|
3307 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3308 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3309 |
|
827 | 3310 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3311 |
! |
|
3312 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3313 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3314 |
"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
|
3315 |
|
4592 | 3316 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3317 |
|
6050 | 3318 |
list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete. |
3319 |
||
121 | 3320 |
wasOn := self hideCursor. |
4814 | 3321 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
6050 | 3322 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
3323 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
|
3324 |
ln size < prevTab ifTrue:[ |
|
3325 |
ln := ln , (String new:prevTab withAll:Character space). |
|
3326 |
]. |
|
3327 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3328 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3329 |
cursorCol > prevTab ifTrue:[ |
|
3330 |
self st80EditMode ifTrue:[ |
|
3331 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3332 |
"/ not allow a cursor position beyond the end of line, |
|
3333 |
"/ so ensure that cursorLine:col: will force us to the beginning of the line |
|
3334 |
originalLine size < prevTab ifTrue:[ |
|
3335 |
self checkForExistingLine:cursorLine. |
|
3336 |
self basicListAt:cursorLine put:ln |
|
3337 |
] |
|
3338 |
]. |
|
3339 |
self cursorLine:cursorLine col:prevTab. |
|
3340 |
wasOn ifTrue:[ self showCursor ]. |
|
3341 |
^ self |
|
3342 |
]. |
|
3343 |
] ifFalse:[ |
|
3344 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
3345 |
self cursorLine:cursorLine col:prevTab. |
|
3346 |
wasOn ifTrue:[ self showCursor ]. |
|
3347 |
^ self. |
|
3348 |
] |
|
3349 |
]. |
|
827 | 3350 |
]. |
3351 |
||
2491 | 3352 |
"/ (autoIndent |
3353 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3354 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3355 |
"/ ifTrue:[ |
3356 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3357 |
"/ |
|
3358 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3359 |
"/ ln := list at:cursorLine. |
|
3360 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3361 |
"/ soCol := 1 |
|
3362 |
"/ ] |
|
3363 |
"/ ] |
|
3364 |
"/ ] ifFalse:[ |
|
6050 | 3365 |
soCol := 1. |
2491 | 3366 |
"/ ]. |
3367 |
||
1419 | 3368 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
6050 | 3369 |
" |
3370 |
somewhere in the middle of a line |
|
3371 |
" |
|
3372 |
self cursorLeft. |
|
3373 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3374 |
] ifFalse:[ |
6050 | 3375 |
" |
3376 |
at begin of line - merge with previous line; |
|
3377 |
except for the very first line. |
|
3378 |
" |
|
3379 |
(cursorLine == 1) ifFalse:[ |
|
3380 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3381 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3382 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3383 |
"/ we are beyond the end of the text. |
|
3384 |
"/ move the cursor to the previous line. |
|
3385 |
self cursorLine:lineNrAboveCursor col:1. |
|
3386 |
] ifFalse:[ |
|
3387 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3388 |
] |
|
3389 |
] |
|
3390 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3391 |
]. |
827 | 3392 |
wasOn ifTrue:[ self showCursor ] |
3393 |
||
1419 | 3394 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 3395 |
! |
3396 |
||
3397 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3398 |
"delete characters from colNr up to the end in line lineNr" |
|
3399 |
||
3400 |
|line| |
|
3401 |
||
3402 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
6152 | 3403 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3404 |
] |
3405 |
||
3406 |
! |
|
3407 |
||
4458 | 3408 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3409 |
"delete characters from startCol to endCol in line lineNr" |
|
3410 |
||
3411 |
|deleted| |
|
3412 |
||
3413 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3414 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3415 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3416 |
! |
|
3417 |
||
827 | 3418 |
deleteCharsAtLine:lineNr toCol:colNr |
3419 |
"delete characters from start up to colNr in line lineNr" |
|
3420 |
||
3421 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3422 |
||
3423 |
||
121 | 3424 |
! |
3425 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3426 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3427 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3428 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3429 |
self deleteLine:cursorLine |
121 | 3430 |
! |
3431 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3432 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3433 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3434 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3435 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3436 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3437 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3438 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3439 |
col1 == 0 ifTrue:[ |
6152 | 3440 |
line1 := line1 - 1. |
3441 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3442 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3443 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3444 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3445 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3446 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3447 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3448 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3449 |
|
2954 | 3450 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3451 |
"delete all text from startLine/startCol to endLine/endCol - |
|
6163 | 3452 |
joining lines if necessary" |
2954 | 3453 |
|
3454 |
|line newLine lineSize nMore| |
|
3455 |
||
3456 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3457 |
list isNil ifTrue:[^ self]. |
|
3458 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3459 |
||
3460 |
(startLine == endLine) ifTrue:[ |
|
6152 | 3461 |
"/ delete chars within a line |
3462 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3463 |
^ self |
|
2954 | 3464 |
]. |
3465 |
||
3466 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
6152 | 3467 |
"/ delete full lines only |
3468 |
endLine > startLine ifTrue:[ |
|
3469 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3470 |
]. |
|
3471 |
^ self |
|
2954 | 3472 |
]. |
3473 |
||
3474 |
"/ delete right rest of 1st line |
|
4786 | 3475 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3476 |
|
3477 |
"/ delete the inner lines ... |
|
3478 |
endLine > (startLine + 1) ifTrue:[ |
|
6152 | 3479 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3480 |
]. |
3481 |
||
3482 |
(endCol ~~ 0) ifTrue:[ |
|
6152 | 3483 |
"/ delete the left rest of the last line |
3484 |
||
3485 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3486 |
||
3487 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3488 |
startLine <= list size ifTrue:[ |
|
3489 |
line := list at:startLine. |
|
3490 |
lineSize := line size. |
|
3491 |
(startCol > lineSize) ifTrue:[ |
|
3492 |
newLine := line. |
|
3493 |
line isNil ifTrue:[ |
|
3494 |
newLine := String new:(startCol - 1) |
|
3495 |
] ifFalse:[ |
|
3496 |
nMore := startCol - 1 - lineSize. |
|
3497 |
nMore > 0 ifTrue:[ |
|
3498 |
newLine := line , (line species new:nMore) |
|
3499 |
] |
|
3500 |
]. |
|
3501 |
newLine ~~ line ifTrue:[ |
|
3502 |
self basicListAt:startLine put:newLine. |
|
3503 |
]. |
|
3504 |
"/ TODO: remember old maxwidth of linerange, |
|
3505 |
"/ only clear widthOfWidestLine, if this max |
|
3506 |
"/ length was (one of) the longest. |
|
3507 |
"/ avoids slow delete with huge texts. |
|
3508 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3509 |
self textChanged. |
|
3510 |
] |
|
3511 |
] |
|
2954 | 3512 |
]. |
3513 |
||
3514 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3515 |
self mergeLine:startLine removeBlanks:false |
|
3516 |
||
4225 | 3517 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3518 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
6163 | 3519 |
"Modified (comment): / 30-05-2017 / 17:34:03 / mawalch" |
2954 | 3520 |
! |
3521 |
||
4458 | 3522 |
deleteFromLine:startLineNr toLine:endLineNr |
3523 |
"delete some lines" |
|
3524 |
||
3525 |
|deleted| |
|
3526 |
||
3527 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3528 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3529 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3530 |
! |
|
3531 |
||
827 | 3532 |
deleteLine:lineNr |
3533 |
"delete line" |
|
3534 |
||
3535 |
self deleteFromLine:lineNr toLine:lineNr |
|
3536 |
||
3537 |
||
3538 |
! |
|
3539 |
||
4458 | 3540 |
deleteLineWithoutRedraw:lineNr |
3541 |
"delete line - no redraw; |
|
3542 |
return true, if something was really deleted" |
|
3543 |
||
3544 |
|deleted ret| |
|
3545 |
||
3546 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3547 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3548 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3549 |
^ ret. |
|
3550 |
! |
|
3551 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3552 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3553 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3554 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3555 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3556 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3557 |
|
4771 | 3558 |
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
|
3559 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3560 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3561 |
(endLine > list size) ifTrue:[ |
6152 | 3562 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3563 |
] ifFalse:[ |
6152 | 3564 |
lastLine := endLine |
4771 | 3565 |
]. |
3566 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3567 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3568 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3569 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3570 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3571 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3572 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3573 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3574 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3575 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3576 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3577 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3578 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3579 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3580 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3581 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3582 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3583 |
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
|
3584 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3585 |
selectionStartLine notNil ifTrue:[ |
6152 | 3586 |
wasOn := self hideCursor. |
3587 |
||
3588 |
startLine := selectionStartLine. |
|
3589 |
startCol := selectionStartCol. |
|
3590 |
endLine := selectionEndLine. |
|
3591 |
endCol := selectionEndCol. |
|
3592 |
self unselectWithoutRedraw. |
|
3593 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3594 |
self setCursorLine:startLine col:startCol. |
|
3595 |
||
3596 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3597 |
] |
121 | 3598 |
! |
3599 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3600 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3601 |
"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
|
3602 |
|
2952 | 3603 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3604 |
|
3799 | 3605 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3606 |
cursorCol <= 1 ifTrue:[ |
6152 | 3607 |
self deleteCharBeforeCursor. |
3608 |
^ self |
|
5361 | 3609 |
]. |
3799 | 3610 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3611 |
wasOn := self hideCursor. |
5787 | 3612 |
self |
6152 | 3613 |
undoableDo:[ |
3614 |
endCol := cursorCol-1. |
|
3615 |
endLine := cursorLine. |
|
3616 |
self cursorToPreviousWord. |
|
3617 |
beginCol := cursorCol. |
|
3618 |
beginLine := cursorLine. |
|
3619 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
3620 |
self cursorLine:cursorLine col:beginCol. |
|
3621 |
] |
|
3622 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3623 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3624 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3625 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3626 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3627 |
|
5761 | 3628 |
indentSelectionBy1 |
3629 |
"indent selected line-range |
|
3630 |
by 1 space (i.e. to the right)" |
|
3631 |
||
3632 |
self indentBy:1 |
|
3633 |
||
3634 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3635 |
! |
|
3636 |
||
4458 | 3637 |
insert:aCharacter atLine:lineNr col:colNr |
3638 |
"insert a single character at lineNr/colNr; |
|
3639 |
set emphasis to character at current position" |
|
3640 |
||
3641 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3642 |
aCharacter ~~ Character cr ifTrue:[ |
|
6152 | 3643 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3644 |
] |
3645 |
! |
|
3646 |
||
121 | 3647 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3648 |
"insert a single character at cursor-position - advance cursor." |
121 | 3649 |
|
3650 |
|wasOn| |
|
3651 |
||
3652 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3653 |
aCharacter == Character tab ifTrue:[ |
6152 | 3654 |
"/ needs special care to advance cursor correctly |
3655 |
self insertTabAtCursor |
|
121 | 3656 |
] ifFalse:[ |
6152 | 3657 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3658 |
aCharacter == (Character cr) ifTrue:[ |
|
3659 |
self basicCursorReturn |
|
3660 |
] ifFalse:[ |
|
3661 |
self cursorRight. |
|
3662 |
]. |
|
121 | 3663 |
]. |
3664 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3665 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3666 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3667 |
! |
3668 |
||
641 | 3669 |
insertLine:aString before:lineNr |
3670 |
"insert the line aString before line lineNr" |
|
3671 |
||
3672 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3673 |
||
3674 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3675 |
! |
|
3676 |
||
155 | 3677 |
insertLines:aStringCollection before:lineNr |
3678 |
"insert a bunch before line lineNr" |
|
3679 |
||
3680 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3681 |
||
3682 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3683 |
! |
|
3684 |
||
4771 | 3685 |
insertLines:someText from:start to:end before:lineNr |
3686 |
"insert a bunch of lines before line lineNr. |
|
3687 |
The cursor position is left unchanged." |
|
3688 |
||
3689 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3690 |
srcY "{ Class: SmallInteger }" |
|
3691 |
dstY "{ Class: SmallInteger }" | |
|
3692 |
||
5357 | 3693 |
"wrong when pasting multiple lines" |
3694 |
false "autoIndent" ifTrue:[ |
|
6152 | 3695 |
indent := self leftIndentForLine:lineNr. |
3696 |
||
3697 |
text := someText |
|
3698 |
collect:[:ln||line| |
|
3699 |
ln notNil ifTrue:[ |
|
3700 |
line := ln withoutLeadingSeparators. |
|
3701 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3702 |
line := (String new:indent), line |
|
3703 |
]. |
|
3704 |
line |
|
3705 |
] ifFalse:[ |
|
3706 |
nil |
|
3707 |
] |
|
3708 |
]. |
|
4771 | 3709 |
] ifFalse:[ |
6152 | 3710 |
text := someText |
4771 | 3711 |
]. |
3712 |
||
3713 |
visLine := self listLineToVisibleLine:lineNr. |
|
3714 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
6152 | 3715 |
self withoutRedrawInsertLines:text |
3716 |
from:start to:end |
|
3717 |
before:lineNr. |
|
4771 | 3718 |
] ifFalse:[ |
6152 | 3719 |
nLines := end - start + 1. |
3720 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3721 |
self withoutRedrawInsertLines:text |
|
3722 |
from:start to:end |
|
3723 |
before:lineNr. |
|
3724 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3725 |
] ifFalse:[ |
|
3726 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3727 |
and:(firstLineShown + nLines + nLinesShown). |
|
3728 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3729 |
dstY := srcY + (nLines * fontHeight). |
|
3730 |
||
3731 |
"/ |
|
3732 |
"/ scroll ... |
|
3733 |
"/ |
|
3734 |
" |
|
3735 |
stupid: must catchExpose before inserting new |
|
3736 |
stuff - since catchExpose may perform redraws |
|
3737 |
" |
|
3738 |
self catchExpose. |
|
3739 |
self withoutRedrawInsertLines:text |
|
3740 |
from:start to:end |
|
3741 |
before:lineNr. |
|
3742 |
self |
|
3743 |
copyFrom:self |
|
3744 |
x:textStartLeft y:srcY |
|
3745 |
toX:textStartLeft y:dstY |
|
3746 |
width:w |
|
3747 |
height:(height - dstY) |
|
3748 |
async:true. |
|
3749 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3750 |
self waitForExpose |
|
3751 |
]. |
|
4771 | 3752 |
]. |
3753 |
widthOfWidestLine notNil ifTrue:[ |
|
6152 | 3754 |
text do:[:line | |
3755 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3756 |
] |
|
4771 | 3757 |
]. |
3758 |
self textChanged. |
|
3759 |
||
3760 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3761 |
! |
|
3762 |
||
654 | 3763 |
insertLines:lines withCR:withCr |
3160 | 3764 |
"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
|
3765 |
Cursor is moved behind insertion. |
641 | 3766 |
If withCr is true, append cr after last line" |
3767 |
||
3768 |
|start end nLines wasOn| |
|
3769 |
||
3770 |
lines notNil ifTrue:[ |
|
6152 | 3771 |
nLines := lines size. |
3772 |
(nLines == 1) ifTrue:[ |
|
3773 |
self insertStringAtCursor:(lines at:1). |
|
3774 |
withCr ifTrue:[ |
|
3775 |
self insertCharAtCursor:(Character cr) |
|
3776 |
] |
|
3777 |
] ifFalse:[ |
|
3778 |
(cursorCol ~~ 1) ifTrue:[ |
|
3779 |
self insertStringAtCursor:(lines at:1). |
|
3780 |
self insertCharAtCursor:(Character cr). |
|
3781 |
start := 2 |
|
3782 |
] ifFalse:[ |
|
3783 |
start := 1 |
|
3784 |
]. |
|
3785 |
withCr ifTrue:[ |
|
3786 |
end := nLines |
|
3787 |
] ifFalse:[ |
|
3788 |
end := nLines - 1 |
|
3789 |
]. |
|
3790 |
(start <= nLines) ifTrue:[ |
|
3791 |
(end >= start) ifTrue:[ |
|
3792 |
wasOn := self hideCursor. |
|
3793 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3794 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3795 |
wasOn ifTrue:[self showCursor]. |
|
3796 |
] |
|
3797 |
]. |
|
3798 |
withCr ifFalse:[ |
|
3799 |
"last line without cr" |
|
3800 |
self insertStringAtCursor:(lines at:nLines) |
|
3801 |
] |
|
3802 |
] |
|
641 | 3803 |
] |
654 | 3804 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3805 |
"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
|
3806 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3807 |
! |
3808 |
||
3809 |
insertLines:lines withCr:withCr |
|
3810 |
"insert a bunch of lines at cursor position. Cursor |
|
3811 |
is moved behind insertion. |
|
3812 |
If withCr is true, append cr after last line" |
|
3813 |
||
2363 | 3814 |
<resource:#obsolete> |
3815 |
||
1292 | 3816 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3817 |
self insertLines:lines withCR:withCr. |
|
3818 |
||
3819 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3820 |
! |
3821 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3822 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3823 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3824 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3825 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3826 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3827 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3828 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3829 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3830 |
self selectFromLine:startLine col:startCol |
6152 | 3831 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3832 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3833 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3834 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3835 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3836 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3837 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3838 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3839 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3840 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3841 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3842 |
col == 0 ifTrue:[ |
6152 | 3843 |
line > 1 ifTrue:[ |
3844 |
line := line - 1. |
|
3845 |
col := (self listAt:line) size + 1. |
|
3846 |
] ifFalse:[ |
|
3847 |
col := 1. |
|
3848 |
] |
|
5060 | 3849 |
]. |
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3850 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3851 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3852 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3853 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3854 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3855 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3856 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3857 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3858 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3859 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3860 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3861 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3862 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3863 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3864 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 3865 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3866 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3867 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3868 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3869 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3870 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3871 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3872 |
[start <= end] whileTrue:[ |
6152 | 3873 |
stop := aString indexOf:(Character cr) startingAt:start. |
3874 |
stop == 0 ifTrue:[ |
|
3875 |
stop := end + 1 |
|
3876 |
]. |
|
3877 |
subString := aString copyFrom:start to:(stop - 1). |
|
3878 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3879 |
(stop <= end) ifTrue:[ |
|
3880 |
c := c + subString size. |
|
3881 |
self insert:(Character cr) atLine:l col:c. |
|
3882 |
l := l + 1. |
|
3883 |
c := 1 |
|
3884 |
]. |
|
3885 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3886 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3887 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3888 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3889 |
! |
3890 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3891 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3892 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3893 |
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
|
3894 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3895 |
aString isNil ifTrue:[ |
6152 | 3896 |
"new:" |
3897 |
self insertCharAtCursor:(Character cr). |
|
3898 |
^ self |
|
105 | 3899 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3900 |
(aString includes:(Character cr)) ifFalse:[ |
6152 | 3901 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3902 |
]. |
3903 |
||
654 | 3904 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3905 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3906 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3907 |
! |
3908 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3909 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3910 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3911 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3912 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3913 |
shown ifTrue:[ |
6152 | 3914 |
gc font hasOverlappingCharacters ifTrue:[ |
3915 |
self invalidateLine:lineNr. |
|
3916 |
] ifFalse:[ |
|
3917 |
self redrawLine:lineNr from:colNr |
|
3918 |
] |
|
4190 | 3919 |
] |
3920 |
||
4191 | 3921 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3922 |
! |
3923 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3924 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3925 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3926 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3927 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3928 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3929 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3930 |
aString size > 0 ifTrue:[ |
6152 | 3931 |
wasOn := self hideCursor. |
3932 |
(aString includes:Character tab) ifTrue:[ |
|
3933 |
self checkForExistingLine:cursorLine. |
|
3934 |
oldLen := (list at:cursorLine) size. |
|
3935 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3936 |
newLen := (list at:cursorLine) size. |
|
3937 |
deltaLen := newLen - oldLen. |
|
3938 |
] ifFalse:[ |
|
3939 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3940 |
deltaLen := aString size. |
|
3941 |
]. |
|
3942 |
self setCursorCol:(cursorCol + deltaLen). |
|
3943 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3944 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3945 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3946 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3947 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3948 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3949 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3950 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3951 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3952 |
|wasOn nextTab| |
105 | 3953 |
|
121 | 3954 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3955 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3956 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3957 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3958 |
! |
3959 |
||
3542 | 3960 |
joinLines |
3890 | 3961 |
"join lines (remove line-break)" |
3962 |
||
3583 | 3963 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3964 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3965 |
self |
6152 | 3966 |
undoableDo:[ |
3967 |
|line col lineLen| |
|
3968 |
||
3969 |
line := cursorLine. |
|
3970 |
col := cursorCol. |
|
3971 |
lineLen := (list at:line) size. |
|
3972 |
col > lineLen ifTrue:[ |
|
3973 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3974 |
] ifFalse:[ |
|
3975 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3976 |
]. |
|
3977 |
self mergeLine:line removeBlanks:true. |
|
3978 |
self cursorLine:line col:col. |
|
3979 |
] |
|
3980 |
info:'Join' |
|
3542 | 3981 |
! |
3982 |
||
2952 | 3983 |
mergeLine:lineNr |
3984 |
"merge line lineNr with line lineNr+1" |
|
3985 |
||
3986 |
self mergeLine:lineNr removeBlanks:true |
|
3987 |
||
3988 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3989 |
! |
|
3990 |
||
4458 | 3991 |
mergeLine:lineNr removeBlanks:removeBlanks |
3992 |
"merge line lineNr with line lineNr+1" |
|
3993 |
||
3994 |
|len| |
|
3995 |
||
3996 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3997 |
||
3998 |
len := (self listAt:lineNr) size. |
|
3999 |
self nonUndoableDo:[ |
|
6152 | 4000 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 4001 |
]. |
4002 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
4003 |
! |
|
4004 |
||
5761 | 4005 |
parenthizeSelection |
6198 | 4006 |
"place parentheses around the selected text. |
5761 | 4007 |
if already parenthized, de-parenthize it" |
4008 |
||
4009 |
self parenthizeSelectionWith:$( and:$) |
|
4010 |
||
4011 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
6198 | 4012 |
"Modified (comment): / 30-08-2017 / 20:17:46 / cg" |
5761 | 4013 |
! |
4014 |
||
2506 | 4015 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 4016 |
"if already parenthized, de-parenthize it" |
4017 |
||
5560 | 4018 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4019 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4020 |
self hasSelection ifFalse:[^ self]. |
5560 | 4021 |
startLine := selectionStartLine. |
4022 |
endLine := selectionEndLine. |
|
4023 |
startCol := selectionStartCol. |
|
4024 |
endCol := selectionEndCol. |
|
5787 | 4025 |
|
5560 | 4026 |
newSelectionEnd := endCol. |
5787 | 4027 |
|
5560 | 4028 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
6152 | 4029 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
4030 |
self deleteCharAtLine:endLine col:endCol. |
|
4031 |
newSelectionEnd := newSelectionEnd-1. |
|
4032 |
]. |
|
4033 |
self deleteCharAtLine:startLine col:startCol. |
|
4034 |
startLine == endLine ifTrue:[ |
|
4035 |
newSelectionEnd := newSelectionEnd-1. |
|
4036 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4037 |
] ifFalse:[ |
6152 | 4038 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4039 |
newSelectionEnd := newSelectionEnd+1. |
|
4040 |
self insert:openingCharacter atLine:startLine col:startCol. |
|
4041 |
startLine == endLine ifTrue:[ |
|
4042 |
newSelectionEnd := newSelectionEnd+1. |
|
4043 |
] |
|
3160 | 4044 |
]. |
4045 |
self |
|
6152 | 4046 |
selectFromLine:startLine col:startCol |
4047 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 4048 |
|
4049 |
"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
|
4050 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4051 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4052 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4053 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4054 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4055 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4056 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4057 |
|
5114 | 4058 |
NoModificationError handle:[:ex | |
6152 | 4059 |
^ self |
5114 | 4060 |
] do:[ |
6152 | 4061 |
lastLine := list size. |
4062 |
finished := false. |
|
4063 |
[finished] whileFalse:[ |
|
4064 |
(lastLine <= 1) ifTrue:[ |
|
4065 |
finished := true |
|
4066 |
] ifFalse:[ |
|
4067 |
line := list at:lastLine. |
|
4068 |
line notNil ifTrue:[ |
|
4069 |
line isBlank ifTrue:[ |
|
4070 |
self basicListAt:lastLine put:nil. |
|
4071 |
line := nil |
|
4072 |
] |
|
4073 |
]. |
|
4074 |
line notNil ifTrue:[ |
|
4075 |
finished := true |
|
4076 |
] ifFalse:[ |
|
4077 |
lastLine := lastLine - 1 |
|
4078 |
] |
|
4079 |
] |
|
4080 |
]. |
|
4081 |
(lastLine ~~ list size) ifTrue:[ |
|
4082 |
list grow:lastLine. |
|
4083 |
"/ self textChanged |
|
4084 |
] |
|
118 | 4085 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4086 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4087 |
|
4458 | 4088 |
replace:aCharacter atLine:lineNr col:colNr |
4089 |
"replace a single character at lineNr/colNr" |
|
4090 |
||
4091 |
|originalChar| |
|
4092 |
||
4093 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
4094 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
4095 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
4096 |
! |
|
4097 |
||
4713 | 4098 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 4099 |
|pattern replacePattern| |
4100 |
||
4101 |
pattern := patternArg string. |
|
4102 |
replacePattern := replacePatternArg string. |
|
4630 | 4103 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
6152 | 4104 |
self rememberSearchPattern:pattern. |
4105 |
self rememberSearchPattern:replacePattern. |
|
4106 |
LastSearchIgnoredCase := ignoreCase. |
|
4107 |
self |
|
4108 |
undoableDo:[ |
|
4109 |
all ifTrue:[ |
|
4110 |
self |
|
4111 |
replaceString:pattern |
|
4112 |
to:replacePattern |
|
4113 |
ignoreCase:ignoreCase |
|
4114 |
] ifFalse:[ |
|
4115 |
(self selectionAsString notNil |
|
4116 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
|
4117 |
ifTrue:[ |
|
4118 |
self replaceSelectionBy:replacePattern. |
|
4119 |
self |
|
4120 |
search:pattern |
|
4121 |
ignoreCase:ignoreCase |
|
4122 |
forward:(lastSearchDirection = #forward). |
|
4123 |
]. |
|
4124 |
] |
|
4125 |
] |
|
4126 |
info:'Replace' |
|
3430 | 4127 |
] |
4128 |
||
4129 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
4130 |
! |
|
4131 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4132 |
replaceCharAtCursor:aCharacter |
5413 | 4133 |
"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
|
4134 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4135 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4136 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4137 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4138 |
aCharacter == (Character cr) ifTrue:[ |
6152 | 4139 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4140 |
] ifFalse:[ |
6152 | 4141 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
4142 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4143 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4144 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4145 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4146 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4147 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4148 |
|
4458 | 4149 |
replaceContentsWith:newContents |
5413 | 4150 |
"undoably replace everything" |
4458 | 4151 |
|
4152 |
|originalContents| |
|
4153 |
||
4154 |
originalContents := self contents. |
|
4155 |
self contents:newContents keepUndoHistory:true. |
|
4156 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
4157 |
! |
|
4158 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4159 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 4160 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4161 |
|
5216 | 4162 |
"/ 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
|
4163 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4164 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4165 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4166 |
|
4458 | 4167 |
replaceLine:lineNr with:newText |
5413 | 4168 |
"undoably replace a line at lineNr" |
4458 | 4169 |
|
4170 |
|originalLine| |
|
4171 |
||
4172 |
originalLine := self listAt:lineNr. |
|
4173 |
originalLine isNil ifTrue:[ |
|
6152 | 4174 |
self checkForExistingLine:lineNr |
4458 | 4175 |
]. |
4176 |
self list at:lineNr put:newText. |
|
4177 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4178 |
self invalidateLine:lineNr. |
|
4179 |
||
4180 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
4181 |
! |
|
4182 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4183 |
replaceLines:lines withCR:withCr |
5413 | 4184 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4185 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4186 |
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
|
4187 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4188 |
|
1809 | 4189 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4190 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4191 |
lines notNil ifTrue:[ |
6152 | 4192 |
wasOn := self hideCursor. |
4193 |
nLines := lines size. |
|
4194 |
line := cursorLine. |
|
4195 |
col := cursorCol. |
|
4196 |
lines keysAndValuesDo:[:i :l | |
|
4197 |
self replaceString:(l ? '') atLine:line col:col. |
|
4198 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
4199 |
line := line + 1. |
|
4200 |
col := 1. |
|
4201 |
] ifFalse:[ |
|
4202 |
col := col + (l size). |
|
4203 |
] |
|
4204 |
]. |
|
4205 |
self cursorLine:line col:col. |
|
4206 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
4207 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4208 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4209 |
|
4661 | 4210 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
4211 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4212 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4213 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4214 |
replaceSelectionBy:something |
5413 | 4215 |
"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
|
4216 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4217 |
|
4666 | 4218 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 4219 |
! |
4220 |
||
4221 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 4222 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 4223 |
leave cursor after insertion or leave it, depending on keep" |
4224 |
||
4666 | 4225 |
self replaceSelectionBy:something keepCursor:keep select:false |
4226 |
||
4227 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
4228 |
! |
|
4229 |
||
4230 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 4231 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 4232 |
leave cursor after insertion or leave it, depending on keep. |
4233 |
If selectNewText is true, select the new text; otherwise deselect" |
|
4234 |
||
4235 |
|sel l c selStartLine selStartCol| |
|
105 | 4236 |
|
4237 |
l := cursorLine. |
|
4238 |
c := cursorCol. |
|
4239 |
||
4818 | 4240 |
sel := self selectionAsString. |
4666 | 4241 |
sel isNil ifTrue:[ |
6152 | 4242 |
selStartLine := l. |
4243 |
selStartCol := c. |
|
4666 | 4244 |
] ifFalse:[ |
6152 | 4245 |
selStartLine := selectionStartLine. |
4246 |
selStartCol := selectionStartCol. |
|
4247 |
||
4248 |
self setLastStringToReplace: sel. |
|
4249 |
||
4250 |
self deleteSelection. |
|
4251 |
replacing := true. |
|
4252 |
lastReplacementInfo rememberReplacement. |
|
4253 |
lastReplacementInfo lastReplacement: ''. |
|
4254 |
lastReplacementInfo stillCollectingInput:true. |
|
4255 |
undoSupport actionInfo:'replace'. |
|
3161 | 4256 |
]. |
4257 |
||
4258 |
something isCharacter ifTrue:[ |
|
6152 | 4259 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4260 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
|
4261 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
|
4262 |
]. |
|
4263 |
]. |
|
4264 |
self isInInsertMode ifTrue:[ |
|
4265 |
self insertCharAtCursor:something |
|
4266 |
] ifFalse:[ |
|
4267 |
self replaceCharAtCursor:something |
|
4268 |
] |
|
105 | 4269 |
] ifFalse:[ |
6152 | 4270 |
something isString ifTrue:[ |
4271 |
lastReplacementInfo lastReplacement: something. |
|
4272 |
self isInInsertMode ifTrue:[ |
|
4273 |
self insertStringAtCursor:something |
|
4274 |
] ifFalse:[ |
|
4275 |
self replaceStringAtCursor:something |
|
4276 |
] |
|
4277 |
] ifFalse:[ |
|
4278 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4279 |
]. |
|
105 | 4280 |
]. |
4281 |
keep ifTrue:[ |
|
6152 | 4282 |
self cursorLine:l col:c |
4666 | 4283 |
]. |
4284 |
selectNewText ifTrue:[ |
|
6152 | 4285 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
105 | 4286 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4287 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4288 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4289 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4290 |
|
4458 | 4291 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4292 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4293 |
This is not prepared to encounter special chars (except TAB) in the string." |
4294 |
||
4295 |
|originalString| |
|
4296 |
||
4297 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4298 |
||
4299 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4300 |
||
4301 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4302 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4303 |
! |
|
4304 |
||
4713 | 4305 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4306 |
|continue count| |
4307 |
||
4308 |
self cursorToTop. |
|
4309 |
self selectFromBeginning. |
|
4310 |
count := 0. |
|
4311 |
continue := true. |
|
4312 |
[ continue ] whileTrue:[ |
|
6152 | 4313 |
(self selectionAsString notNil |
4314 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4315 |
ifTrue:[ |
|
4316 |
self replaceSelectionBy:aNewString. |
|
4317 |
count := count + 1. |
|
4318 |
]. |
|
4319 |
self |
|
4320 |
searchFwd:aString |
|
4321 |
ignoreCase:ignoreCase |
|
4322 |
ifAbsent:[ |
|
4323 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4324 |
bindWith:aString with:aNewString with:count). |
|
4325 |
continue := false. |
|
4326 |
]. |
|
3549 | 4327 |
]. |
3430 | 4328 |
|
4329 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4330 |
! |
|
4331 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4332 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4333 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4334 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4335 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4336 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4337 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4338 |
(aString includes:Character tab) ifTrue:[ |
6152 | 4339 |
"/ need special care for TAB (to move cursor correctly) |
4340 |
i1 := 1. |
|
4341 |
[i1 ~~ 0] whileTrue:[ |
|
4342 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4343 |
i2 ~~ 0 ifTrue:[ |
|
4344 |
i1 ~~ i2 ifTrue:[ |
|
4345 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4346 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4347 |
]. |
|
4348 |
self replaceTABAtCursor. |
|
4349 |
i2 := i2 + 1. |
|
4350 |
] ifFalse:[ |
|
4351 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4352 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4353 |
]. |
|
4354 |
i1 := i2. |
|
4355 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4356 |
] ifFalse:[ |
6152 | 4357 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
4358 |
self setValidatedCursorCol:(cursorCol + aString size). |
|
4359 |
"/ self cursorCol:(cursorCol + aString size). |
|
5325 | 4360 |
]. |
4361 |
wasOn ifTrue:[ |
|
6152 | 4362 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
4363 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
5325 | 4364 |
]. |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4365 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4366 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4367 |
"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
|
4368 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4369 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4370 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4371 |
"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
|
4372 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4373 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4374 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4375 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4376 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4377 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4378 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4379 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4380 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4381 |
! |
4382 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4383 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4384 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4385 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4386 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4387 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4388 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4389 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4390 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4391 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4392 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4393 |
self cursorToPreviousWord. |
5787 | 4394 |
beginCol := cursorCol. |
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4395 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4396 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4397 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4398 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4399 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4400 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4401 |
|
4458 | 4402 |
splitLine:lineNr before:colNr |
4403 |
"split the line linNr before colNr; the right part (from colNr) |
|
4404 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4405 |
||
4406 |
self basicSplitLine:lineNr before:colNr. |
|
4407 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4408 |
! |
|
4409 |
||
5761 | 4410 |
toggleTabSetting |
4411 |
"toggle between 4-col |
|
4412 |
and 8-col tabs" |
|
4413 |
||
4414 |
(tabPositions == self class tab4Positions) |
|
6152 | 4415 |
ifTrue:[self setTab8] |
4416 |
ifFalse:[self setTab4] |
|
5761 | 4417 |
|
4418 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4419 |
! |
|
4420 |
||
4421 |
undentSelectionBy1 |
|
4422 |
"undent selected line-range |
|
4423 |
by 1 space (i.e. to the left)" |
|
4424 |
||
4425 |
self undentBy:1 |
|
4426 |
||
4427 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4428 |
! |
|
4429 |
||
5146 | 4430 |
withAutoIndent:aBoolean do:aBlock |
4431 |
|sav| |
|
4432 |
||
4433 |
sav := autoIndent. |
|
4434 |
autoIndent := aBoolean. |
|
4435 |
aBlock ensure:[ autoIndent := sav ]. |
|
4436 |
! |
|
4437 |
||
4458 | 4438 |
withoutRedrawAt:lineNr put:aString |
4439 |
"replace a line at lineNr" |
|
4440 |
||
4441 |
|originalLine| |
|
4442 |
||
4443 |
originalLine := self listAt:lineNr. |
|
4444 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4445 |
super withoutRedrawAt:lineNr put:aString. |
|
4446 |
! |
|
4447 |
||
4448 |
withoutRedrawInsertLine:aString before:lineNr |
|
4449 |
"insert the argument, aString before line lineNr; the string |
|
4450 |
becomes line lineNr; everything else is moved down; the view |
|
4451 |
is not redrawn" |
|
4452 |
||
4771 | 4453 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4454 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4455 |
! |
|
4456 |
||
4457 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4458 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4459 |
||
4460 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4461 |
self isReadOnly ifFalse:[ |
|
6152 | 4462 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4463 |
]. |
4464 |
! |
|
4465 |
||
4466 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4467 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4468 |
||
4469 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4470 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4471 |
! |
|
4472 |
||
3890 | 4473 |
wrapLines |
4474 |
"wrap lines (insert line-break)" |
|
4475 |
||
4476 |
|lineLength answerString string| |
|
4477 |
||
4478 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4479 |
||
4480 |
self hasSelection ifFalse:[ |
|
6152 | 4481 |
self selectLine:cursorLine. |
3890 | 4482 |
]. |
4483 |
string := self selectionAsString. |
|
4484 |
string isEmptyOrNil ifTrue:[ |
|
6152 | 4485 |
Dialog information:(resources string:'Nothing selected.'). |
4486 |
^ self. |
|
3890 | 4487 |
]. |
4488 |
||
4489 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4490 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4491 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4492 |
lineLength < 1 ifTrue:[ |
6152 | 4493 |
lineLength := 1. |
3890 | 4494 |
]. |
4495 |
||
4496 |
self |
|
6152 | 4497 |
undoableDo:[ |
4498 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4499 |
||
4500 |
line := selectionStartLine. |
|
4501 |
col := selectionStartCol. |
|
4502 |
||
4503 |
self cutSelection. |
|
4504 |
self cursorLine:line col:col. |
|
4505 |
||
4506 |
lastGoodCol := col. |
|
4507 |
||
4508 |
inStream := string readStream. |
|
4509 |
[ inStream atEnd ] whileFalse:[ |
|
4510 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4511 |
word := CharacterWriteStream new. |
|
4512 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4513 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4514 |
self insertCharAtCursor:(Character cr). |
|
4515 |
col := 1. |
|
4516 |
] ifFalse:[ |
|
4517 |
col ~~ 1 ifTrue:[ |
|
4518 |
self insertStringAtCursor:' '. |
|
4519 |
col := col + 1. |
|
4520 |
] |
|
4521 |
]. |
|
4522 |
self insertStringAtCursor:word contents. |
|
4523 |
col := col + word size. |
|
4524 |
]. |
|
4525 |
] |
|
4526 |
info:'Wrap' |
|
4388 | 4527 |
|
4528 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4529 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4530 |
|
2752 | 4531 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4532 |
|
2952 | 4533 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4534 |
"delete characters from startCol to endCol in line lineNr" |
4535 |
||
6207 | 4536 |
|line lineSize newLine start stop |
4537 |
prevWidth newWidth newCol| |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4538 |
|
4673 | 4539 |
self unselect. |
4540 |
||
4541 |
cursorLine == lineNr ifTrue:[ |
|
5909 | 4542 |
cursorCol >= startCol ifTrue:[ |
4543 |
cursorCol >= endCol ifTrue:[ |
|
6207 | 4544 |
newCol := startCol. |
5909 | 4545 |
] ifFalse:[ |
6207 | 4546 |
newCol := cursorCol - (endCol - startCol + 1). |
5909 | 4547 |
"/ self assert:(cursorCol >= 0). |
6207 | 4548 |
newCol := newCol max:1. |
4549 |
]. |
|
4550 |
self setCursorCol:newCol. |
|
5909 | 4551 |
]. |
4673 | 4552 |
]. |
4553 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4554 |
line := self listAt:lineNr. |
827 | 4555 |
|
4673 | 4556 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4557 |
||
4558 |
lineSize := line size. |
|
4559 |
||
4560 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4561 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4562 |
||
4563 |
stop >= start ifTrue:[ |
|
5909 | 4564 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
4565 |
ifFalse:[ newLine := '' ]. |
|
4566 |
||
4567 |
stop == lineSize ifFalse:[ |
|
4568 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4569 |
newLine := line string species fromString:newLine. |
|
4570 |
]. |
|
4571 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
4572 |
]. |
|
4573 |
||
4574 |
(self trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4575 |
newLine := nil |
|
4576 |
]. |
|
4577 |
||
4578 |
prevWidth := self widthOfLine:lineNr. |
|
4579 |
||
4580 |
self basicListAt:lineNr put:newLine. |
|
4581 |
||
4582 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4583 |
"/ remember old width of this line, |
|
4584 |
"/ only clear widthOfWidestLine, if this lines |
|
4585 |
"/ length was (one of) the longest. |
|
4586 |
"/ avoids slow delete with huge texts. |
|
4587 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4588 |
||
4589 |
"/ scroll left if reqiured |
|
4590 |
viewOrigin x > 0 ifTrue:[ |
|
4591 |
newWidth := self widthOfLine:lineNr. |
|
4592 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4593 |
self scrollHorizontalTo:(newWidth |
|
4594 |
- width |
|
4595 |
+ margin + margin |
|
4596 |
+ (gc font widthOf:' ')) |
|
4597 |
] |
|
4598 |
]. |
|
4599 |
self textChanged. |
|
4600 |
] ifFalse:[ |
|
4601 |
self textChanged "/ textChangedButNoSizeChange |
|
4602 |
]. |
|
4603 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4604 |
self invalidateLine:lineNr. |
|
4605 |
] ifFalse:[ |
|
4606 |
self redrawLine:lineNr from:start. |
|
4607 |
]. |
|
4673 | 4608 |
]. |
827 | 4609 |
|
4191 | 4610 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4611 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4612 |
|
2952 | 4613 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4614 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4615 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4616 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4617 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4618 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4619 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4620 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4621 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4622 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4623 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4624 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4625 |
startLineNr <= list size ifTrue:[ |
6152 | 4626 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4627 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4628 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4629 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4630 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4631 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4632 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4633 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4634 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4635 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4636 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4637 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4638 |
(firstLineShown >= nLines) ifTrue:[ |
6152 | 4639 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4640 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4641 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4642 |
|
4226 | 4643 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4644 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4645 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4646 |
|
2952 | 4647 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4648 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4649 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4650 |
|
2952 | 4651 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4652 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4653 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4654 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4655 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4656 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4657 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4658 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4659 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4660 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4661 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4662 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4663 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4664 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4665 |
|
2952 | 4666 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4667 |
"insert a single character at lineNr/colNr; |
827 | 4668 |
set emphasis to character at current position" |
4669 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4670 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4671 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4672 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4673 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4674 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4675 |
self splitLine:lineNr before:colNr. |
4676 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4677 |
]. |
827 | 4678 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4679 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4680 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4681 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4682 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4683 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4684 |
self st80EditMode ifFalse:[ |
5909 | 4685 |
(self trimBlankLines |
4686 |
and:[colNr > lineSize |
|
4687 |
and:[aCharacter == Character space]]) ifTrue:[ |
|
4688 |
^ self |
|
4689 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4690 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4691 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4692 |
(lineSize == 0) ifTrue:[ |
5909 | 4693 |
newLine := aCharacter asString species new:colNr. |
4694 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4695 |
] ifFalse: [ |
5909 | 4696 |
(colNr > lineSize) ifTrue: [ |
4697 |
colNr == (lineSize +1) ifTrue:[ |
|
4698 |
attribute := line emphasisAt:lineSize |
|
4699 |
]. |
|
4700 |
newLine := line species new:colNr. |
|
4701 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4702 |
drawCharacterOnly := true |
|
4703 |
] ifFalse: [ |
|
4704 |
attribute := line emphasisAt:colNr. |
|
4705 |
newLine := line species new:(lineSize + 1). |
|
4706 |
||
4707 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4708 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
4709 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4710 |
]. |
827 | 4711 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4712 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
5909 | 4713 |
newLine := aCharacter asString species fromString:newLine. |
4714 |
line isText ifTrue:[ |
|
4715 |
newLine := newLine asText |
|
4716 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4717 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4718 |
newLine at:colNr put:aCharacter. |
827 | 4719 |
|
4720 |
attribute notNil ifTrue:[ |
|
5909 | 4721 |
newLine emphasisAt:colNr put:attribute. |
827 | 4722 |
]. |
4723 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4724 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4725 |
newLine := self withTabsExpanded:newLine. |
4726 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4727 |
]. |
827 | 4728 |
|
4771 | 4729 |
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
|
4730 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4731 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4732 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4733 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4734 |
shown ifTrue:[ |
5909 | 4735 |
"/ care for italic text - in this case, we must also |
4736 |
"/ redraw the character before the insertion in order |
|
4737 |
"/ to fix the slanted piece of the character. |
|
4738 |
"/ (but we must clip, to avoid destoying the character before) |
|
4739 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
4740 |
colNr > 1 ifTrue:[ |
|
4741 |
cursorVisibleLine notNil ifTrue:[ |
|
6031 | 4742 |
oldClip := self clippingBoundsOrNil. |
5909 | 4743 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
4744 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4745 |
||
4746 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4747 |
self invalidateLine:lineNr. |
|
4748 |
] ifFalse:[ |
|
4749 |
drawCharacterOnly ifTrue:[ |
|
6031 | 4750 |
self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)). |
5909 | 4751 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4752 |
] ifFalse:[ |
|
6031 | 4753 |
self clippingBounds:(x@y extent:((width - x) @ fontHeight)). |
5909 | 4754 |
self redrawLine:lineNr from:colNr-1 |
4755 |
]. |
|
6031 | 4756 |
self clippingBounds:oldClip. |
5909 | 4757 |
]. |
4758 |
]. |
|
4759 |
^ self. |
|
4760 |
]. |
|
4761 |
]. |
|
4762 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4763 |
self invalidateLine:lineNr. |
|
4764 |
] ifFalse:[ |
|
4765 |
drawCharacterOnly ifTrue:[ |
|
4766 |
self redrawLine:lineNr col:colNr |
|
4767 |
] ifFalse:[ |
|
4768 |
self redrawLine:lineNr from:colNr |
|
4769 |
] |
|
4770 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4771 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4772 |
|
4191 | 4773 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4774 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4775 |
|
4771 | 4776 |
basicListAt:lineNr put:newLine |
4777 |
"redefinable for special subclasses (with virtual list)" |
|
4778 |
||
4779 |
list at:lineNr put:newLine. |
|
4780 |
! |
|
4781 |
||
4782 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4783 |
"redefinable for special subclasses (with virtual list)" |
|
4784 |
||
4785 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4786 |
! |
|
4787 |
||
2952 | 4788 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4789 |
"merge line lineNr with line lineNr+1" |
4790 |
||
827 | 4791 |
|leftPart rightPart bothParts nextLineNr i| |
4792 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4793 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
5909 | 4794 |
"/ empty list or beyond end of text |
4795 |
^ self |
|
827 | 4796 |
]. |
4797 |
leftPart := self listAt:lineNr. |
|
4798 |
||
4799 |
leftPart isNil ifTrue:[ |
|
5909 | 4800 |
leftPart := ''. |
4801 |
autoIndent ifTrue:[ |
|
6147 | 4802 |
"/ cg: only do this, if the second line has no indent |
4803 |
(i := self leftIndentOfLine:(lineNr+1)) == 0 ifTrue:[ |
|
4804 |
leftPart := String new:(self leftIndentForLine:lineNr) |
|
5909 | 4805 |
] |
4806 |
] |
|
827 | 4807 |
]. |
4808 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4809 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4810 |
||
4811 |
nextLineNr > (list size) ifFalse:[ |
|
5909 | 4812 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4813 |
rightPart := '' |
|
4814 |
] ifFalse:[ |
|
4815 |
removeBlanks ifTrue:[ |
|
4816 |
rightPart := rightPart withoutLeadingSeparators. |
|
4817 |
] |
|
4818 |
]. |
|
4819 |
||
4820 |
bothParts := leftPart , rightPart. |
|
4821 |
(self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4822 |
self basicListAt:lineNr put:bothParts. |
|
4823 |
self redrawLine:lineNr. |
|
4824 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4825 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4826 |
|
6147 | 4827 |
"Created: / 09-09-1997 / 09:27:38 / cg" |
4828 |
"Modified: / 25-04-2017 / 12:41:20 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4829 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4830 |
|
2952 | 4831 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4832 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4833 |
|
5045 | 4834 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4835 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4836 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4837 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4838 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4839 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4840 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4841 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4842 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4843 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4844 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4845 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4846 |
|
5909 | 4847 |
(self trimBlankLines |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4848 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4849 |
and:[aCharacter == Character space]]) ifTrue:[ |
5909 | 4850 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4851 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4852 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4853 |
(lineSize == 0) ifTrue:[ |
5909 | 4854 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4855 |
] ifFalse: [ |
5909 | 4856 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4857 |
newLineSpecies := aCharacter stringSpecies |
|
4858 |
] ifFalse:[ |
|
4859 |
newLineSpecies := line species |
|
4860 |
]. |
|
4861 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4862 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4863 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4864 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4865 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4866 |
newLine := self withTabsExpanded:newLine. |
4867 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4868 |
]. |
4771 | 4869 |
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
|
4870 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4871 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4872 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4873 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4874 |
shown ifTrue:[ |
5909 | 4875 |
gc font hasOverlappingCharacters ifTrue:[ |
4876 |
self invalidateLine:lineNr. |
|
4877 |
] ifFalse:[ |
|
4878 |
drawCharacterOnly ifTrue:[ |
|
4879 |
self redrawLine:lineNr col:colNr |
|
4880 |
] ifFalse:[ |
|
4881 |
self redrawLine:lineNr from:colNr |
|
4882 |
] |
|
4883 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4884 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4885 |
|
4190 | 4886 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4887 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4888 |
! |
4889 |
||
3235 | 4890 |
basicReplaceString:aString atLine:lineNr col:colNr |
4891 |
"replace multiple characters starting at lineNr/colNr. |
|
4892 |
This is not prepared to encounter special chars (except TAB) |
|
4893 |
in the string." |
|
4894 |
||
5045 | 4895 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4896 |
|
4897 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4898 |
||
4899 |
self checkForExistingLine:lineNr. |
|
4900 |
line := list at:lineNr. |
|
4901 |
lineSize := line size. |
|
4902 |
||
4903 |
endCol := colNr + aString size - 1. |
|
4904 |
(lineSize == 0) ifTrue:[ |
|
6152 | 4905 |
newLine := aString species new:endCol. |
3235 | 4906 |
] ifFalse: [ |
6152 | 4907 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4908 |
newLineSpecies := aString stringSpecies |
|
4909 |
] ifFalse:[ |
|
4910 |
newLineSpecies := line species |
|
4911 |
]. |
|
4912 |
||
4913 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4914 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4915 |
]. |
4916 |
newLine replaceFrom:colNr with:aString. |
|
4917 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 4918 |
newLine := self withTabsExpanded:newLine. |
3235 | 4919 |
]. |
4771 | 4920 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4921 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 4922 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4923 |
]. |
4924 |
self textChanged. |
|
4925 |
shown ifTrue:[ |
|
6152 | 4926 |
gc font hasOverlappingCharacters ifTrue:[ |
4927 |
self invalidateLine:lineNr. |
|
4928 |
] ifFalse:[ |
|
4929 |
self redrawLine:lineNr from:colNr |
|
4930 |
] |
|
3235 | 4931 |
] |
4932 |
||
4190 | 4933 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4934 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4935 |
! |
4936 |
||
2952 | 4937 |
basicSplitLine:lineNr before:colNr |
4938 |
"split the line linNr before colNr; the right part (from colNr) |
|
4939 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4940 |
||
3160 | 4941 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4942 |
srcY "{ Class: SmallInteger }" | |
4943 |
||
3027 | 4944 |
list isNil ifTrue:[ ^ self ]. |
4945 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4946 |
||
4947 |
(colNr == 1) ifTrue:[ |
|
5909 | 4948 |
self nonUndoableDo:[ |
4949 |
self insertLine:nil before:lineNr. |
|
4950 |
]. |
|
4951 |
^ self |
|
3027 | 4952 |
]. |
4953 |
||
4954 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4955 |
line notNil ifTrue:[ |
5909 | 4956 |
lineSize := line size. |
4957 |
(colNr <= lineSize) ifTrue:[ |
|
4958 |
rightRest := line copyFrom:colNr to:lineSize. |
|
4959 |
(colNr > 1) ifTrue:[ |
|
4960 |
leftRest := line copyTo:(colNr - 1) |
|
4961 |
] |
|
4962 |
] ifFalse:[ |
|
4963 |
leftRest := line |
|
4964 |
] |
|
3027 | 4965 |
]. |
4966 |
leftRest notNil ifTrue:[ |
|
5909 | 4967 |
(self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4968 |
]. |
4771 | 4969 |
self basicListAt:lineNr put:leftRest. |
3027 | 4970 |
self nonUndoableDo:[ |
5909 | 4971 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4972 |
]. |
4973 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4974 |
visLine notNil ifTrue:[ |
|
5909 | 4975 |
w := self widthForScrollBetween:lineNr |
4976 |
and:(firstLineShown + nLinesShown). |
|
4977 |
srcY := topMargin + (visLine * fontHeight). |
|
4978 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
4979 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
4980 |
self catchExpose. |
|
4981 |
self |
|
4982 |
copyFrom:self |
|
4983 |
x:textStartLeft y:srcY |
|
4984 |
toX:textStartLeft y:(srcY + fontHeight) |
|
4985 |
width:w |
|
4986 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
4987 |
async:true. |
|
4988 |
]. |
|
4989 |
self redrawLine:lineNr. |
|
4990 |
self redrawLine:(lineNr + 1). |
|
4991 |
mustWait ifTrue:[self waitForExpose] |
|
3027 | 4992 |
]. |
4993 |
widthOfWidestLine := nil. "/ unknown |
|
4994 |
self textChanged. |
|
2952 | 4995 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4996 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4997 |
! |
4998 |
||
2954 | 4999 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 5000 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
5001 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5002 |
because the text might have been pasted from an alien view." |
|
2954 | 5003 |
|
5004 |
|newLine newLines nLines| |
|
5005 |
||
5006 |
nLines := end - start + 1. |
|
5007 |
newLines := Array new:(lines size). |
|
5008 |
start to:end do:[:index | |
|
6152 | 5009 |
newLine := lines at:index. |
5010 |
newLine notNil ifTrue:[ |
|
5011 |
newLine isString ifTrue:[ |
|
5012 |
newLine isBlank ifTrue:[ |
|
5013 |
newLine := nil |
|
5014 |
] ifFalse:[ |
|
5015 |
(newLine includes:(Character tab)) ifTrue:[ |
|
5016 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
5017 |
] |
|
5018 |
] |
|
5019 |
] |
|
5020 |
]. |
|
5021 |
newLines at:index put:newLine |
|
2954 | 5022 |
]. |
5023 |
list isNil ifTrue: [ |
|
6152 | 5024 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 5025 |
] ifFalse: [ |
6152 | 5026 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 5027 |
]. |
5028 |
||
5029 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 5030 |
overlapping copy - if it didn't, we had to use:" |
5031 |
" |
|
5032 |
index := list size. |
|
5033 |
[index > lineNr] whileTrue: [ |
|
6152 | 5034 |
pIndex := index - 1. |
5035 |
list at:index put:(list at:pIndex). |
|
5036 |
index := pIndex |
|
2954 | 5037 |
]. |
5038 |
" |
|
5039 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
5040 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
5041 |
self contentsChanged |
|
5042 |
||
4328 | 5043 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 5044 |
! |
5045 |
||
5046 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 5047 |
"insert aString (which has no crs) at lineNr/colNr. |
5048 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5049 |
because the text might have been pasted from an alien view." |
|
2954 | 5050 |
|
4360 | 5051 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 5052 |
|
4623 | 5053 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 5054 |
|
5055 |
strLen := aString size. |
|
5056 |
self checkForExistingLine:lineNr. |
|
5057 |
||
5058 |
stringType := aString string species. |
|
5059 |
isText := aString isText. |
|
5060 |
line := list at:lineNr. |
|
5061 |
||
5062 |
line notNil ifTrue:[ |
|
6152 | 5063 |
lineSize := line size. |
5064 |
line isString ifFalse:[ |
|
5065 |
stringType := line species |
|
5066 |
] ifTrue:[ |
|
5067 |
lineCharWidth := line bitsPerCharacter. |
|
5068 |
stringCharWidth := aString bitsPerCharacter. |
|
5069 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
5070 |
stringType := line string species |
|
5071 |
] ifFalse:[ |
|
5072 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
5073 |
stringType := aString string species |
|
5074 |
] |
|
5075 |
]. |
|
5076 |
line isText ifTrue:[ isText := true ] |
|
5077 |
]. |
|
2954 | 5078 |
] ifFalse:[ |
6152 | 5079 |
lineSize := 0 |
2954 | 5080 |
]. |
5081 |
||
5082 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
6152 | 5083 |
newLine := aString |
2954 | 5084 |
] ifFalse:[ |
6152 | 5085 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
5086 |
sz := colNr + strLen - 1 |
|
5087 |
] ifFalse:[ |
|
5088 |
sz := lineSize + strLen |
|
5089 |
]. |
|
5090 |
||
5091 |
newLine := stringType new:sz. |
|
5092 |
isText ifTrue:[ |
|
5093 |
newLine := Text string:newLine |
|
5094 |
]. |
|
5095 |
||
5096 |
(lineSize ~~ 0) ifTrue: [ |
|
5097 |
(colNr > lineSize) ifTrue: [ |
|
5098 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
5099 |
] ifFalse: [ |
|
5100 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
5101 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
5102 |
] |
|
5103 |
]. |
|
5104 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 5105 |
]. |
5106 |
||
5107 |
(aString includes:(Character tab)) ifTrue:[ |
|
6152 | 5108 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 5109 |
]. |
5110 |
||
4771 | 5111 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 5112 |
widthOfWidestLine notNil ifTrue:[ |
6152 | 5113 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 5114 |
]. |
5115 |
self textChanged. |
|
5116 |
||
4360 | 5117 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5118 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5119 |
|
2752 | 5120 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5121 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5122 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5123 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5124 |
|
5216 | 5125 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 5126 |
dragIsActive := false. |
5127 |
||
5787 | 5128 |
completionSupport notNil ifTrue:[ |
6152 | 5129 |
"/ also give that guy a chance to close its popup view |
5130 |
completionSupport buttonPress:button x:x y:y |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5131 |
]. |
4609 | 5132 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
5133 |
cursorShown ifTrue: [ |
6152 | 5134 |
self drawCursor |
5787 | 5135 |
]. |
5136 |
||
5137 |
"On X11, be nice and paste PRIMARY when middle click. |
|
4420 | 5138 |
Note, that middle button on X11 is translated to button |
5139 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 5140 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
6152 | 5141 |
self undoableDo:[ |
5142 |
self paste: (self getClipboardText:#selection). |
|
5143 |
]. |
|
5144 |
^self. |
|
4420 | 5145 |
]. |
5146 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5147 |
(button == 1) ifTrue:[ |
6152 | 5148 |
self hideCursor |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5149 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5150 |
"/ some very old code from times, when a right-click was a paste in X11 |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5151 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5152 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5153 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5154 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5155 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5156 |
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
|
5157 |
|
4420 | 5158 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
5159 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 5160 |
! |
5161 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5162 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5163 |
"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
|
5164 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
5165 |
|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
|
5166 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5167 |
(button == 1) ifTrue:[ |
5882 | 5168 |
typeOfSelection := nil. |
5169 |
||
5170 |
dragIsActive ifTrue:[ |
|
5171 |
self unselect |
|
5172 |
]. |
|
5173 |
selectionStartLine isNil ifTrue:[ |
|
5174 |
clickCol notNil ifTrue:[ |
|
5175 |
self cursorMovementAllowed ifTrue:[ |
|
5176 |
newCursorCol := clickCol. |
|
5177 |
||
5178 |
cursorType ~~ #block ifTrue:[ |
|
5179 |
clickPos notNil ifTrue:[ |
|
5180 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
6096 | 5181 |
"/ (i.e. if it's an ibeam). |
5882 | 5182 |
"/ adjust clickCol if the user clicked in the right third of a character. |
5183 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
5184 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
5185 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
5186 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
5187 |
]. |
|
5188 |
]. |
|
5189 |
"/ the following fixes the ugly select behavior when double clicking on |
|
5190 |
"/ a partially visible last line (where the first click used to |
|
5191 |
"/ scroll the text so that the second click was handled on another |
|
5192 |
"/ line. An alternative (possibly better) solution would be to |
|
5193 |
"/ remember the last click position and adjust in the double click |
|
5194 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
5195 |
"/ Time will show, if this hack works. |
|
5196 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
|
5197 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
5198 |
Processor |
|
5199 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
5200 |
after:0.3 seconds. |
|
5201 |
] ifFalse:[ |
|
5202 |
self cursorLine:clickLine col:newCursorCol. |
|
5203 |
]. |
|
5204 |
]. |
|
5205 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
|
5206 |
list notEmptyOrNil ifTrue:[ |
|
5207 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
|
5208 |
(clickLine >= list size) ifTrue:[ |
|
5209 |
(clickLine > (self list size + 2) |
|
5210 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
|
5211 |
self selectAll |
|
5212 |
]. |
|
5213 |
]. |
|
5214 |
] |
|
5215 |
] |
|
5216 |
] |
|
5217 |
] |
|
5218 |
] ifFalse:[ |
|
5219 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
|
5220 |
]. |
|
5221 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5222 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5223 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
5224 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5225 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
6096 | 5226 |
"Modified (format): / 13-02-2017 / 20:10:18 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5227 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5228 |
|
2580 | 5229 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5230 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5231 |
|
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5232 |
|n| |
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5233 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5234 |
self changeTypeOfSelectionTo:nil. |
2580 | 5235 |
|
5236 |
(key == #CursorRight) ifTrue:[ |
|
6137 | 5237 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5238 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5239 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
|
5240 |
expandingTop := false. |
|
5241 |
self validateNewSelection. |
|
5242 |
self setPrimarySelection. |
|
5243 |
self selectionChanged. |
|
5244 |
self redrawLine:selectionStartLine. |
|
5245 |
^ self. |
|
5246 |
]. |
|
5247 |
||
5248 |
selectionStartLine notNil ifTrue:[ |
|
5249 |
self cursorMovementAllowed ifTrue:[ |
|
5250 |
"/ |
|
5251 |
"/ treat the whole selection as cursor |
|
5252 |
"/ |
|
5253 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5254 |
selectionEndCol == 0 ifTrue:[ |
|
5255 |
selectionEndCol := 1. |
|
5256 |
]. |
|
5257 |
self setCursorCol:selectionEndCol. |
|
5258 |
shifted ifTrue:[ |
|
5259 |
self expandSelectionRight. |
|
5260 |
^ self |
|
5261 |
]. |
|
5262 |
self unselect; makeCursorVisible. |
|
5263 |
"/ cursorCol == 1 ifTrue:[^ self]. |
|
5264 |
]. |
|
5265 |
]. |
|
5266 |
self cursorRight. |
|
5267 |
^ self |
|
2580 | 5268 |
]. |
5269 |
(key == #CursorDown) ifTrue:[ |
|
6137 | 5270 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5271 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
|
5272 |
selectionStartCol := clickStartCol := selectionEndCol := cursorCol. |
|
5273 |
selectionEndCol == 1 ifTrue:[ |
|
5274 |
selectionEndCol := 0. |
|
5275 |
]. |
|
5276 |
self validateNewSelection. |
|
5277 |
self selectionChanged. |
|
5278 |
self redrawLine:selectionStartLine. |
|
5279 |
expandingTop := false. |
|
5280 |
self redrawLine:selectionEndLine. |
|
5281 |
^ self |
|
5282 |
]. |
|
5283 |
||
5284 |
selectionStartLine notNil ifTrue:[ |
|
5285 |
self cursorMovementAllowed ifTrue:[ |
|
5286 |
"/ |
|
5287 |
"/ treat the whole selection as cursor |
|
5288 |
"/ |
|
5289 |
self setCursorLine:(selectionEndLine ? selectionStartLine). |
|
5290 |
self setCursorCol:selectionStartCol. |
|
5291 |
(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
|
5292 |
self setCursorCol:1. |
|
5293 |
self setCursorLine:(cursorLine - 1). |
|
5294 |
]. |
|
5295 |
self makeCursorVisible. |
|
5296 |
||
5297 |
shifted ifTrue:[ |
|
5298 |
clickLine := cursorLine. |
|
5299 |
clickCol := cursorCol. |
|
5300 |
self expandSelectionDown. |
|
5301 |
^ self |
|
5302 |
]. |
|
5303 |
self unselect. |
|
5304 |
]. |
|
5305 |
]. |
|
5306 |
||
5307 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
|
5308 |
self cursorDown:n. |
|
5309 |
"/ |
|
5310 |
"/ flush keyboard to avoid runaway cursor |
|
5311 |
"/ |
|
5312 |
self sensor flushKeyboardFor:self. |
|
5313 |
^ self |
|
2580 | 5314 |
]. |
5315 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
6137 | 5316 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
5317 |
expandingTop := true. |
|
5318 |
key == #CursorLeft ifTrue:[ |
|
5319 |
cursorCol > 1 ifTrue:[ |
|
5320 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
|
5321 |
selectionEndCol := clickStartCol := cursorCol-1. |
|
5322 |
selectionStartCol := cursorCol-1. |
|
5323 |
self validateNewSelection. |
|
5324 |
self selectionChanged. |
|
5325 |
self redrawLine:selectionStartLine. |
|
5326 |
^ self |
|
5327 |
] |
|
5328 |
] ifFalse:[ |
|
5329 |
cursorLine > 1 ifTrue:[ |
|
5330 |
selectionEndLine := clickStartLine := cursorLine. |
|
5331 |
selectionEndCol := selectionStartCol := clickStartCol := cursorCol. |
|
5332 |
selectionStartLine := cursorLine - 1. |
|
5333 |
selectionEndCol == 1 ifTrue:[ |
|
5334 |
selectionEndCol := 0. |
|
5335 |
]. |
|
5336 |
self validateNewSelection. |
|
5337 |
self selectionChanged. |
|
5338 |
self redrawFromLine:selectionStartLine to:cursorLine. |
|
5339 |
^ self |
|
5340 |
] |
|
5341 |
] |
|
5342 |
]. |
|
5343 |
||
5344 |
selectionStartLine notNil ifTrue:[ |
|
5345 |
self cursorMovementAllowed ifTrue:[ |
|
5346 |
"/ |
|
5347 |
"/ treat the whole selection as cursor |
|
5348 |
"/ |
|
5349 |
self setCursorLine:selectionStartLine. |
|
5350 |
self setCursorCol:selectionStartCol. |
|
5351 |
(key == #CursorLeft) ifTrue:[ |
|
5352 |
self setCursorCol:(cursorCol+1). "/ compensate for followup crsr-left |
|
5353 |
]. |
|
5354 |
self makeCursorVisible. |
|
5355 |
||
5356 |
shifted ifTrue:[ |
|
5357 |
(key == #CursorUp) ifTrue:[ |
|
5358 |
clickLine := cursorLine. |
|
5359 |
self expandSelectionUp. |
|
5360 |
] ifFalse:[ |
|
5361 |
self expandSelectionLeft. |
|
5362 |
]. |
|
5363 |
^ self |
|
5364 |
]. |
|
5365 |
self unselect. |
|
5366 |
]. |
|
5367 |
]. |
|
5368 |
(key == #CursorLeft) ifTrue:[ |
|
5369 |
self cursorLeft. ^self |
|
5370 |
]. |
|
5371 |
(key == #CursorUp) ifTrue:[ |
|
5372 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
|
5373 |
self cursorUp:n. |
|
5374 |
"/ |
|
5375 |
"/ flush keyboard to avoid runaway cursor |
|
5376 |
"/ |
|
5377 |
self sensor flushKeyboardFor:self. |
|
5378 |
^ self |
|
5379 |
]. |
|
2580 | 5380 |
]. |
4420 | 5381 |
|
5382 |
"Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6137 | 5383 |
"Modified: / 19-03-2017 / 10:08:54 / cg" |
2580 | 5384 |
! |
5385 |
||
2952 | 5386 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5387 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5388 |
|
4521 | 5389 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
6147 | 5390 |
#Replace #Undo #Redo #Accept |
5391 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
|
5392 |
#DeleteSpaces #Join |
|
5393 |
#SearchMatchingParent #SelectMatchingParents |
|
5394 |
#SelectWord #ExpandSelectionByWord |
|
5395 |
#SelectToEnd #SelectFromBeginning |
|
5396 |
#SelectLine #ExpandSelectionByLine |
|
5397 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
|
5398 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5399 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5400 |
#GotoLine #BeginOfText #EndOfText |
|
5401 |
#InsertLine #DeleteLine |
|
5402 |
#SelectLineFromBeginning |
|
5403 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5404 |
#OpenSpecialCharacterWindow #InsertUUID |
|
5405 |
#'F*' #'f*')> |
|
2017 | 5406 |
|
4730 | 5407 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5408 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5409 |
|
5410 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5411 |
|
4701 | 5412 |
"/ experimental |
4818 | 5413 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
5787 | 5414 |
(immediateCompletion |
4818 | 5415 |
or:[currentUserPrefs codeCompletionOnControlKey |
5416 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
6147 | 5417 |
completionSupport isNil ifTrue:[ |
5418 |
self initializeCompletionSupport. |
|
5419 |
]. |
|
5787 | 5420 |
]. |
5421 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5422 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5423 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5424 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5425 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5426 |
completionSupport notNil ifTrue:[ |
6147 | 5427 |
completionSupport stopCompletionProcess. |
5428 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5429 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5430 |
|
4818 | 5431 |
key isSymbol ifTrue:[ |
6147 | 5432 |
(device modifierKeys includes:key) ifFalse:[ |
5433 |
lastReplacementInfo stillCollectingInput:false. |
|
5434 |
] |
|
4818 | 5435 |
]. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5436 |
(key == #LearnKeyboardMacro) ifTrue:[ |
6147 | 5437 |
lastReplacementInfo stillCollectingInput:false. |
5438 |
self toggleLearnMode. |
|
5439 |
^ self |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5440 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5441 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
6147 | 5442 |
lastReplacementInfo stillCollectingInput:false. |
5443 |
self executeLearnedKeyboardMacro. |
|
5444 |
^ self. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5445 |
]. |
3799 | 5446 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5447 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5448 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5449 |
self learnMode ifTrue:[ |
6147 | 5450 |
event := WindowGroup lastEventQuerySignal query. |
5451 |
learnedMacro add:event. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5452 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5453 |
|
4238 | 5454 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
6147 | 5455 |
"the macro named key exists" |
5456 |
^ self |
|
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5457 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5458 |
|
4482 | 5459 |
key isSymbol ifFalse:[ |
6147 | 5460 |
"the usual case: key is a character, but maybe a string also (in X11)" |
5461 |
self handleNonCommandKey:key. |
|
5462 |
^ self |
|
4482 | 5463 |
]. |
5464 |
||
5465 |
event isNil ifTrue:[ |
|
6147 | 5466 |
event := WindowGroup lastEventQuerySignal query. |
4482 | 5467 |
]. |
5468 |
shiftPressed := event hasShift. |
|
5469 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5470 |
rawKey := event rawKey. |
4482 | 5471 |
|
5133 | 5472 |
key == #InsertUUID ifTrue:[ |
6147 | 5473 |
self insertUUID. |
5474 |
^ self. |
|
5133 | 5475 |
]. |
5476 |
||
4253 | 5477 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
6147 | 5478 |
self deleteWordBeforeCursor. |
5479 |
^ self. |
|
4253 | 5480 |
]. |
5481 |
||
5119 | 5482 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
6147 | 5483 |
selectionStartLine notNil ifTrue:[ |
5484 |
((key == #BasicBackspace) |
|
5485 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
|
5486 |
ifTrue:[ |
|
5487 |
self deleteSelection. |
|
5488 |
] ifFalse: [ |
|
5489 |
self copyAndDeleteSelection. |
|
5490 |
]. |
|
5491 |
] ifFalse:[ |
|
5492 |
self makeCursorVisible. |
|
4609 | 5493 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
5494 |
"/ self deleteWordBeforeCursor. |
|
5495 |
"/ ] ifFalse:[ |
|
6147 | 5496 |
self deleteCharBeforeCursor. |
4609 | 5497 |
"/ ]. |
6147 | 5498 |
]. |
5499 |
true "immediateCompletion" ifTrue:[ |
|
5500 |
completionSupport notNil ifTrue:[ |
|
5501 |
completionSupport postKeyPress:key |
|
5502 |
]. |
|
5503 |
]. |
|
5504 |
^ self |
|
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5505 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5506 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5507 |
(key == #ToggleAutoIndent) ifTrue:[ |
6147 | 5508 |
self autoIndent:(autoIndent not). |
5509 |
^ self. |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5510 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5511 |
|
3235 | 5512 |
key == #ToggleInsertMode ifTrue:[ |
6147 | 5513 |
self insertMode:(editMode value == EditMode insertMode) not. |
5514 |
^ self. |
|
3160 | 5515 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5516 |
|
4162 | 5517 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
6147 | 5518 |
CharacterSetView notNil ifTrue:[ |
5519 |
self specialCharacters. |
|
5520 |
^ self. |
|
5521 |
] |
|
4162 | 5522 |
]. |
5523 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5524 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5525 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5526 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5527 |
Fn pastes a key-sequence (but only if not overlayed with |
6147 | 5528 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5529 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5530 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5531 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5532 |
(key at:1) asLowercase == $f ifTrue:[ |
6147 | 5533 |
(('[fF][0-9]' match:key) |
5534 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5535 |
shiftPressed ifFalse:[ |
|
5536 |
fKeyMacros := currentUserPrefs functionKeySequences. |
|
5537 |
fKeyMacros notNil ifTrue:[ |
|
5538 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5539 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5540 |
^ self |
|
5541 |
] |
|
5542 |
] |
|
5543 |
] |
|
5544 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5545 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5546 |
|
2506 | 5547 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
6147 | 5548 |
self parenthizeSelectionWith:$( and:$). |
5549 |
^ self. |
|
2506 | 5550 |
]. |
5551 |
(key == #'Ctrl2') ifTrue:[ |
|
6147 | 5552 |
self parenthizeSelectionWith:$" and:$". |
5553 |
^ self. |
|
2506 | 5554 |
]. |
5555 |
(key == #'Ctrl#') ifTrue:[ |
|
6147 | 5556 |
self parenthizeSelectionWith:$' and:$'. |
5557 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5558 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5559 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
6147 | 5560 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
5561 |
^ self. |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5562 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5563 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5564 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5565 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5566 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5567 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5568 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5569 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5570 |
|
3542 | 5571 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5572 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5573 |
(key == #ExpandSelectionByWord) ifTrue:[ |
6147 | 5574 |
self makeCursorVisible. |
5575 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5576 |
^ self |
|
4707 | 5577 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5578 |
(key == #SelectWord) ifTrue:[ |
6147 | 5579 |
self makeCursorVisible. |
5580 |
self selectWordUnderCursor. |
|
5581 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5582 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5583 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5584 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5585 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5586 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5587 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5588 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5589 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5590 |
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
|
5591 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5592 |
(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
|
5593 |
(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
|
5594 |
(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
|
5595 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5596 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5597 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5598 |
(key == #BeginOfLine) ifTrue:[ |
6147 | 5599 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5600 |
"/ some shifted key to selectFromBeginOfLine |
|
5601 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5602 |
"/ see code below. |
|
5603 |
false "shiftPressed" ifTrue: [ |
|
5604 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5605 |
"/ self unselect. |
|
5606 |
"/ self cursorHome. |
|
5607 |
"Jan's modification" |
|
5608 |
"/ self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
|
5609 |
"/ Jan's modification modified by his own request ;-)) |
|
5610 |
self selectFromBeginOfLine. |
|
5611 |
] ifFalse: [ |
|
5612 |
self unselect. |
|
5613 |
ctrlPressed ifTrue:[ |
|
5614 |
self cursorHome. |
|
5615 |
] ifFalse:[ |
|
5616 |
self cursorToBeginOfLine. |
|
5617 |
] |
|
5618 |
]. |
|
5619 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5620 |
]. |
5226 | 5621 |
(key == #BSelectFromeginOfLine) ifTrue:[ |
6147 | 5622 |
self selectFromBeginOfLine. |
5623 |
^ self |
|
5226 | 5624 |
]. |
5625 |
||
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5626 |
(key == #EndOfLine) ifTrue:[ |
6147 | 5627 |
"/ cg: this is complete rubbish - you have to define a mapping from |
5628 |
"/ some shifted key to selectFromBeginOfLine |
|
5629 |
"/ (otherwise, no shifted key could ever be mapped to BegnOfLine) |
|
5630 |
"/ see code below. |
|
5631 |
false "shiftPressed" ifTrue:[ |
|
5632 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5633 |
"/ self unselect. |
|
5634 |
"/ self cursorToBottom |
|
5635 |
" Jan's modification" |
|
5636 |
"/ self addToSelectionAfter:[ self cursorToEndOfLine ] . |
|
5637 |
"/ Jan's modification modified by his own request ;-)) |
|
5638 |
self selectToEndOfLine. |
|
5639 |
] ifFalse:[ |
|
5640 |
self unselect. |
|
5641 |
ctrlPressed ifTrue:[ |
|
5642 |
self cursorToBottom |
|
5643 |
] ifFalse:[ |
|
5644 |
self cursorToEndOfLine. |
|
5645 |
] |
|
5646 |
]. |
|
5647 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5648 |
]. |
5226 | 5649 |
|
5650 |
(key == #SelectToEndOfLine) ifTrue:[ |
|
6147 | 5651 |
self selectToEndOfLine. |
5652 |
^ self |
|
5226 | 5653 |
]. |
5654 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5655 |
(key == #NextWord) ifTrue:[self cursorToNextWord. ^self]. |
3310 | 5656 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
499 | 5657 |
(key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5658 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5659 |
|
5119 | 5660 |
(rawKey == #CursorRight |
5661 |
or:[rawKey == #CursorDown |
|
5662 |
or:[rawKey == #CursorLeft |
|
5663 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
6147 | 5664 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
5665 |
^ self. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5666 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5667 |
|
5119 | 5668 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
6147 | 5669 |
self unselect. self cursorReturn. |
5670 |
^ self |
|
3257 | 5671 |
]. |
5672 |
||
5673 |
(key == #Return) ifTrue:[ |
|
6147 | 5674 |
shiftPressed ifTrue:[ |
5675 |
self unselect. self cursorReturn. |
|
5676 |
^ self |
|
5677 |
]. |
|
5678 |
||
5679 |
self isReadOnly ifTrue:[ |
|
5680 |
self unselect; makeCursorVisible. |
|
5681 |
self cursorReturn |
|
5682 |
] ifFalse:[ |
|
5683 |
self isInInsertMode ifFalse:[ |
|
5684 |
self cursorReturn:true. |
|
5685 |
autoIndent == true ifTrue:[ |
|
5686 |
i := self leftIndentForLine:(cursorLine + 1). |
|
5687 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
|
5688 |
self cursorCol:(i+1 max:1) |
|
5689 |
] |
|
5690 |
] |
|
5691 |
] ifTrue:[ |
|
5692 |
|left right oldIndent| |
|
5693 |
||
5694 |
"/ old version just unselected ... |
|
5695 |
"/ self unselect; makeCursorVisible. |
|
5696 |
||
5697 |
"/ new version deletes ... |
|
5698 |
typeOfSelection == #paste ifTrue:[ |
|
5699 |
self unselect; makeCursorVisible. |
|
5700 |
] ifFalse:[ |
|
5701 |
self copyAndDeleteSelection. |
|
5702 |
]. |
|
5703 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
|
5704 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
5705 |
self insertCharAtCursor:(Character cr). |
|
5706 |
||
5707 |
autoIndent == true ifTrue:[ |
|
5708 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
|
5709 |
"/ nothing to do. |
|
5710 |
] ifFalse:[ |
|
5711 |
((self listAt:cursorLine) isEmptyOrNil |
|
5712 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
|
5713 |
i := (self leftIndentForLine:cursorLine). |
|
5714 |
left := left withoutSeparators. |
|
5715 |
right := right withoutSeparators. |
|
5716 |
(left endsWith:'[') ifTrue:[ |
|
4823 | 5717 |
"/ i := i + 4. |
6147 | 5718 |
] ifFalse:[ |
5719 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
|
5720 |
i := i - 4. |
|
5721 |
]. |
|
5722 |
]. |
|
5723 |
oldIndent := self leftIndentOfLine:cursorLine. |
|
5724 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5725 |
self st80EditMode ifTrue:[ |
|
5726 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5727 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5728 |
]. |
|
5729 |
]. |
|
5730 |
self cursorCol:(i+1 max:1) |
|
5731 |
]. |
|
5732 |
] |
|
5733 |
]. |
|
5734 |
]. |
|
5735 |
]. |
|
5736 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5737 |
]. |
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
|
5738 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5739 |
(key == #NonInsertingTab) ifTrue:[ |
6150 | 5740 |
((rawKey == #ShiftTab) |
5741 |
and:[self hasSelection |
|
5742 |
and:[selectStyle == #line]] |
|
5743 |
) ifTrue:[ |
|
5744 |
self executekeyboardMacroNamed:#UndentBy4. |
|
5745 |
^ self. |
|
5746 |
]. |
|
6147 | 5747 |
self unselect. self cursorTab. |
5748 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5749 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5750 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
6147 | 5751 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5752 |
||
5753 |
self hasSelection ifTrue:[ |
|
5754 |
selectStyle == #line ifTrue:[ |
|
5755 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
|
5756 |
macroName := #IndentBy4. |
|
5757 |
] ifFalse:[ |
|
5758 |
macroName := #UndentBy4. |
|
5759 |
]. |
|
5760 |
macroName notNil ifTrue:[ |
|
5761 |
self executekeyboardMacroNamed:macroName. |
|
6150 | 5762 |
^ self. |
6147 | 5763 |
]. |
5764 |
] |
|
5765 |
]. |
|
5766 |
||
5767 |
self unselect. |
|
5768 |
(key == #Tab) ifTrue:[ |
|
5769 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5770 |
self cursorTab. |
|
5771 |
^ self |
|
5772 |
]. |
|
5773 |
self insertTabAtCursor. |
|
5774 |
^ self |
|
5775 |
]. |
|
5776 |
self cursorBacktab. |
|
5777 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5778 |
]. |
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
|
5779 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5780 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5781 |
(rawKey == #Delete) ifTrue:[ |
6147 | 5782 |
shiftPressed ifTrue:[ |
5783 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5784 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5785 |
self makeCursorVisible. |
|
5786 |
self deleteCharAtCursor. |
|
5787 |
]. |
|
5788 |
^ self |
|
5789 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5790 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5791 |
|
5119 | 5792 |
(rawKey == #Delete |
870 | 5793 |
or:[key == #BasicDelete]) ifTrue:[ |
6147 | 5794 |
selectionStartLine notNil ifTrue:[ |
4130 | 5795 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5796 |
"/ To remove text repetetively, use Cut instead. |
|
5797 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5798 |
"/ lastReplacementInfo lastReplacement: nil. |
|
6147 | 5799 |
((key == #BasicDelete) |
5800 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
|
5801 |
self deleteSelection. |
|
5802 |
] ifFalse:[ |
|
5803 |
self copyAndDeleteSelection. |
|
5804 |
]. |
|
5805 |
^ self |
|
5806 |
]. |
|
5807 |
self makeCursorVisible. |
|
5808 |
self deleteCharAtCursor. |
|
5809 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5810 |
]. |
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
|
5811 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5812 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
6147 | 5813 |
self unselect. |
5814 |
cursorVisibleLine == 1 ifTrue:[ |
|
5815 |
self cursorHome. |
|
5816 |
] ifFalse:[ |
|
5817 |
self cursorToFirstVisibleLine |
|
5818 |
]. |
|
5819 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5820 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5821 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
6147 | 5822 |
self unselect. |
5823 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5824 |
self cursorToBottom. |
|
5825 |
] ifFalse:[ |
|
5826 |
self cursorToLastVisibleLine |
|
5827 |
]. |
|
5828 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5829 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5830 |
((key == #Escape) |
3257 | 5831 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
6147 | 5832 |
self makeCursorVisible. |
5833 |
self unselect. self selectCursorLineFromBeginning. |
|
5834 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5835 |
]. |
3257 | 5836 |
(key == #SelectLine) ifTrue:[ |
6147 | 5837 |
self makeCursorVisible. |
5838 |
self unselect. self selectCursorLine. |
|
5839 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5840 |
]. |
3257 | 5841 |
(key == #ExpandSelectionByLine) ifTrue:[ |
6147 | 5842 |
"/ self makeCursorVisible. |
5843 |
self selectExpandCursorLine. |
|
5844 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5845 |
]. |
3257 | 5846 |
(key == #DeleteLine) ifTrue:[ |
6147 | 5847 |
self makeCursorVisible. |
5848 |
self unselect. self deleteCursorLine. |
|
5849 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5850 |
]. |
3257 | 5851 |
(key == #InsertLine) ifTrue:[ |
6147 | 5852 |
self makeCursorVisible. |
5853 |
self unselect. self insertLine:nil before:cursorLine. |
|
5854 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5855 |
]. |
3781 | 5856 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5857 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5858 |
|
3310 | 5859 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5860 |
"Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6152 | 5861 |
"Modified: / 28-04-2017 / 09:25:22 / cg" |
121 | 5862 |
! |
5863 |
||
2952 | 5864 |
executeKeyboardMacro:cmdMacro |
5865 |
Error handle:[:ex | |
|
6152 | 5866 |
self warn:'Error in keyboard macro: ' , ex description. |
5867 |
ex return. |
|
2952 | 5868 |
] do:[ |
6152 | 5869 |
AbortOperationRequest handle:[:ex | |
5870 |
self warn:'Keyboard macro aborted'. |
|
5871 |
ex return. |
|
5872 |
] do:[ |
|
5873 |
Parser |
|
5874 |
evaluate:cmdMacro asString |
|
5875 |
receiver:self |
|
5876 |
notifying:nil |
|
5877 |
compile:false. |
|
5878 |
]. |
|
2952 | 5879 |
]. |
5880 |
! |
|
5881 |
||
5882 |
handleNonCommandKey:keyArg |
|
4700 | 5883 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5884 |
|
5885 |
self isReadOnly ifTrue:[ |
|
6152 | 5886 |
self flashReadOnly. |
5887 |
^ self. |
|
2952 | 5888 |
]. |
5889 |
||
5890 |
key := keyArg. |
|
5891 |
||
5892 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 5893 |
"pasted selection will NOT be replaced by keystroke" |
5894 |
self unselect |
|
2952 | 5895 |
]. |
5896 |
||
4700 | 5897 |
selStartLineBefore := selectionStartLine. |
5898 |
selStartColBefore := self selectionStartCol. |
|
5899 |
selEndLineBefore := selectionEndLine. |
|
5900 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5901 |
|
4940 | 5902 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
6152 | 5903 |
key isCharacter ifTrue:[ |
5904 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
|
5905 |
] ifFalse:[ |
|
5906 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
|
5907 |
]. |
|
2952 | 5908 |
]. |
5909 |
||
5910 |
"replace selection by what is typed in - |
|
3235 | 5911 |
if word was selected with a space, keep it. |
4700 | 5912 |
if there was no selection, the key's character is inserted" |
3235 | 5913 |
|
5914 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
6152 | 5915 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5916 |
]. |
2952 | 5917 |
|
5918 |
(selectStyle == #wordLeft) ifTrue:[ |
|
6152 | 5919 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5920 |
] ifFalse:[ |
6152 | 5921 |
(selectStyle == #wordRight) ifTrue:[ |
5922 |
self replaceSelectionBy:(key asString , ' '). |
|
5923 |
self cursorLeft |
|
5924 |
] ifFalse:[ |
|
5925 |
self replaceSelectionBy:key |
|
5926 |
] |
|
3160 | 5927 |
]. |
2952 | 5928 |
selectStyle := nil. |
5929 |
||
3235 | 5930 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 5931 |
selectionStartLine := selStartLineBefore. |
5932 |
selectionStartCol := selStartColBefore. |
|
5933 |
selectionEndLine := selEndLineBefore. |
|
5934 |
selectionEndCol := selEndColBefore. |
|
3235 | 5935 |
]. |
5936 |
||
2952 | 5937 |
showMatchingParenthesis ifTrue:[ |
6152 | 5938 |
"emacs style parenthesis shower" |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5939 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
6152 | 5940 |
"claus: only do it for closing parenthesis - |
5941 |
otherwise its too anoying. |
|
5942 |
" |
|
2952 | 5943 |
" |
6152 | 5944 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5945 |
" |
6152 | 5946 |
(')]}' includes:key) ifTrue:[ |
5947 |
self |
|
5948 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
|
5949 |
ifFound:[:line :col | |
|
5950 |
|savLine savCol sensor| |
|
5951 |
||
5952 |
self withCursor:Cursor eye do:[ |
|
5953 |
savLine := cursorLine. |
|
5954 |
savCol := cursorCol. |
|
5955 |
self cursorLine:line col:col. |
|
5956 |
self flush. |
|
5957 |
||
5958 |
"/ want to wait 200ms, but not if another keyPress |
|
5959 |
"/ arrives in the meantime ... |
|
5960 |
||
5961 |
sensor := self sensor. |
|
5962 |
5 timesRepeat:[ |
|
5963 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
|
5964 |
Processor activeProcess millisecondDelay:40. |
|
5965 |
] |
|
5966 |
]. |
|
5967 |
self cursorLine:savLine col:savCol |
|
5968 |
] |
|
5969 |
] |
|
5970 |
ifNotFound:[self showNotFound] |
|
5971 |
onError:[self beep] |
|
5972 |
]. |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5973 |
] |
2952 | 5974 |
]. |
5975 |
||
5976 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5977 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5978 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5979 |
"/ |
|
5980 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5981 |
"/ self selection. |
|
5982 |
"/ typeOfSelection := #paste. |
|
3160 | 5983 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5984 |
"/ ]. |
3235 | 5985 |
editMode value isInsertAndSelectMode ifTrue:[ |
6152 | 5986 |
selectionStartLine isNil ifTrue:[ |
5987 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
|
5988 |
] ifFalse:[ |
|
5989 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
|
5990 |
]. |
|
3235 | 5991 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5992 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5993 |
|
5994 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
2952 | 5995 |
! |
5996 |
||
5997 |
keyPress:key x:x y:y |
|
5998 |
"handle keyboard input" |
|
5999 |
||
4771 | 6000 |
|wasOn| |
6001 |
||
6002 |
wasOn := cursorShown. |
|
6003 |
||
5787 | 6004 |
NoModificationError |
6152 | 6005 |
handle:[:ex | |
6006 |
self flashReadOnly. |
|
6007 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
6008 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6009 |
]. |
|
6010 |
] |
|
6011 |
do:[ |
|
6012 |
self undoableDo:[ |
|
6013 |
self doKeyPress:key x:x y:y |
|
6014 |
]. |
|
6015 |
]. |
|
5689 | 6016 |
|
4242 | 6017 |
self repairDamage |
6018 |
||
6019 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 6020 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 6021 |
! |
6022 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6023 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6024 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6025 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6026 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6027 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6028 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6029 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6030 |
requestAutoAccept |
5068 | 6031 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
6032 |
This forces my value to be accepted into my model. |
|
6033 |
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
|
6034 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6035 |
acceptEnabled == false ifTrue:[ |
6152 | 6036 |
"/ nope - |
6037 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6038 |
]. |
5404 | 6039 |
"/ cg: only do this if modified. |
6040 |
"/ otherwise, users would have to make sure that the contents is |
|
6041 |
"/ always correct (which they don't). If you change this back, |
|
6042 |
"/ please check the expecco file-save or file-reimport dialog, |
|
6043 |
"/ which has a problem with that behavior. |
|
6044 |
self modified ifTrue:[ |
|
6152 | 6045 |
self accept. |
5404 | 6046 |
]. |
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6047 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6048 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6049 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6050 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6051 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6052 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6053 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6054 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6055 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6056 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6057 |
cv notNil ifTrue:[ |
6152 | 6058 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6059 |
] |
4967 | 6060 |
! |
6061 |
||
6062 |
unmapped |
|
6063 |
super unmapped. |
|
6064 |
||
6065 |
completionSupport notNil ifTrue:[ |
|
6152 | 6066 |
completionSupport release. |
4967 | 6067 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6068 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6069 |
|
1807 | 6070 |
!EditTextView methodsFor:'focus handling'! |
6071 |
||
4818 | 6072 |
focusOut |
6073 |
super focusOut. |
|
6074 |
||
6075 |
completionSupport notNil ifTrue:[ |
|
6152 | 6076 |
completionSupport release. |
4818 | 6077 |
]. |
6078 |
! |
|
6079 |
||
1807 | 6080 |
hasKeyboardFocus:aBoolean |
6081 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
6082 |
(otherwise, I would not know about this)" |
|
6083 |
||
6084 |
hasKeyboardFocus := aBoolean. |
|
4609 | 6085 |
|
3160 | 6086 |
(cursorShown |
6087 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6088 |
and:[self isReadOnly not]]) ifTrue:[ |
5890 | 6089 |
self drawCursor |
4609 | 6090 |
]. |
6091 |
||
6092 |
hasKeyboardFocus ifFalse:[ |
|
5890 | 6093 |
completionSupport notNil ifTrue:[ |
6094 |
"/ this is a hack for Windows: |
|
6095 |
"/ on windows, an activate:false event is first sent to my textView, |
|
6096 |
"/ then an activate is sent to the completion popup. |
|
6097 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
6098 |
"/ therefore, allow for the activate of the completionMenu and its button event to be processed. |
|
6099 |
"/ before forcing it to be closed... |
|
6100 |
completionSupport startTimeoutForEditViewLostFocus. |
|
6101 |
]. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6102 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6103 |
|
4821 | 6104 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 6105 |
! |
6106 |
||
6107 |
showFocus:explicit |
|
6108 |
"in addition to however my superclass thinks how a focusView is to be |
|
6109 |
displayed, show the cursor when I got the focus" |
|
6110 |
||
5239 | 6111 |
self hasKeyboardFocus:true. |
1807 | 6112 |
self showCursor. |
6113 |
super showFocus:explicit |
|
6114 |
||
6115 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6116 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6117 |
|
4967 | 6118 |
showNoFocus:explicit |
5787 | 6119 |
"the view lost the keyboard focus |
4967 | 6120 |
(either explicit, via tabbing; or implicit, by pointer movement) |
6121 |
- change any display attributes as req'd." |
|
6122 |
||
6123 |
super showNoFocus:explicit. |
|
5149 | 6124 |
|
6125 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
6126 |
"/ not when the focus is lost normally (because this also happens when |
|
6127 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
6128 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
6129 |
explicit ifTrue:[ |
|
6152 | 6130 |
completionSupport notNil ifTrue:[ |
6131 |
completionSupport release. |
|
6132 |
]. |
|
4818 | 6133 |
]. |
6134 |
! |
|
6135 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6136 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6137 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6138 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6139 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6140 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6141 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6142 |
and:[self enabled |
4781 | 6143 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6144 |
) ifTrue:[ |
6152 | 6145 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6146 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6147 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6148 |
^ false |
1807 | 6149 |
! ! |
6150 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6151 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6152 |
|
4237 | 6153 |
executekeyboardMacroNamed:macroName |
5787 | 6154 |
"try to execute the keyboard macro; |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6155 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6156 |
|
4482 | 6157 |
|cmdMacro| |
6158 |
||
6159 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6160 |
self |
6152 | 6161 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
6162 |
info: macroName. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6163 |
^ true |
4238 | 6164 |
|
6165 |
" |
|
4483 | 6166 |
EditTextView open |
6152 | 6167 |
contents:'bla'; |
6168 |
selectAll; |
|
6169 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6170 |
EditTextView open |
6152 | 6171 |
contents:'bla'; |
6172 |
selectAll; |
|
6173 |
executekeyboardMacroNamed:#blabla. |
|
4238 | 6174 |
" |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6175 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6176 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6177 |
! |
6178 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6179 |
indent |
3221 | 6180 |
"indent a line-range - this is done by searching for the |
6181 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6182 |
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
|
6183 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6184 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6185 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6186 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6187 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6188 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6189 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6190 |
(selectionEndCol == 0) ifTrue:[ |
6152 | 6191 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6192 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6193 |
self unselect. |
3160 | 6194 |
self |
6152 | 6195 |
undoableDo:[self indentFromLine:start toLine:end] |
6196 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6197 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6198 |
|
4237 | 6199 |
indentBy4 |
5050 | 6200 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6201 |
||
6202 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6203 |
! |
|
6204 |
||
6205 |
indentBy8 |
|
6206 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6207 |
|
6208 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6209 |
! |
|
6210 |
||
5050 | 6211 |
indentBy:n |
6212 |
|line1 line2| |
|
6213 |
||
6214 |
line1 := self selectionStartLine. |
|
6215 |
line2 := self selectionEndLine. |
|
6216 |
line1 isNil ifTrue:[ |
|
5833 | 6217 |
line1 := self cursorLine. |
6218 |
line1 notNil ifTrue:[ |
|
6219 |
line2 := line1 |
|
6220 |
] |
|
5769 | 6221 |
] ifFalse:[ |
5833 | 6222 |
line2 notNil ifTrue:[ |
6223 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
6224 |
]. |
|
5787 | 6225 |
]. |
5050 | 6226 |
line1 notNil ifTrue:[ |
5833 | 6227 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6228 |
] |
6229 |
! |
|
6230 |
||
6231 |
indentByTab |
|
6232 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6233 |
! |
|
6234 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6235 |
indentFromLine:start toLine:end |
3221 | 6236 |
"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
|
6237 |
last non-empty line before start, and change the indent |
4742 | 6238 |
of the selected line-range based on that line's indent." |
6239 |
||
4811 | 6240 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6241 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6242 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6243 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6244 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6245 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6246 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6247 |
self indentFromLine:start toLine:end by:delta |
6248 |
! |
|
6249 |
||
6250 |
indentFromLine:start toLine:end by:delta |
|
6251 |
"indent a line-range - this is done by searching for the |
|
6252 |
last non-empty line before start, and change the indent |
|
6253 |
of the selected line-range based on that line's indent." |
|
6254 |
||
6255 |
|d line spaces anyChange| |
|
6256 |
||
6257 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6258 |
(delta > 0) ifTrue:[ |
6152 | 6259 |
spaces := String new:delta |
4742 | 6260 |
]. |
6261 |
||
6262 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6263 |
start to:end do:[:lineNr | |
6152 | 6264 |
line := self listAt:lineNr. |
6265 |
line notNil ifTrue:[ |
|
6266 |
line isBlank ifTrue:[ |
|
6267 |
self basicListAt:lineNr put:nil |
|
6268 |
] ifFalse:[ |
|
6269 |
(delta > 0) ifTrue:[ |
|
6270 |
line := spaces , line. |
|
6271 |
widthOfWidestLine notNil ifTrue:[ |
|
6272 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6273 |
] |
|
6274 |
] ifFalse:[ |
|
6275 |
"check if deletion is ok" |
|
6276 |
d := delta negated + 1. |
|
6277 |
||
6278 |
line size > d ifTrue:[ |
|
6279 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
6280 |
line := line copyFrom:d |
|
6281 |
] |
|
6282 |
]. |
|
6283 |
widthOfWidestLine := nil |
|
6284 |
]. |
|
6285 |
self replaceLine:lineNr with:line. |
|
6286 |
anyChange := true. |
|
6287 |
] |
|
6288 |
] |
|
4742 | 6289 |
]. |
6290 |
||
6291 |
anyChange ifTrue:[ self textChanged ]. |
|
6292 |
||
3221 | 6293 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6294 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6295 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6296 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6297 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6298 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6299 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6300 |
this is done by searching for the last non-empty line before it |
4823 | 6301 |
and returning its indent. |
6302 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6303 |
|
827 | 6304 |
"SHOULD GO TO ListView" |
6305 |
||
6306 |
|line lnr indent| |
|
6307 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6308 |
lnr := lineNr. |
6147 | 6309 |
[lnr > 1] whileTrue:[ |
6310 |
lnr := lnr - 1. |
|
6311 |
line := self listAt:lnr. |
|
6312 |
||
6313 |
line notEmptyOrNil ifTrue:[ |
|
6314 |
indent := (line indexOfNonSeparatorStartingAt:1) - 1. |
|
6315 |
indent >= 0 ifTrue:[ |
|
6316 |
(self editedLanguage isNil or:[self editedLanguage isSmalltalk]) ifTrue:[ |
|
6317 |
(line endsWith:$[) ifTrue:[ |
|
6318 |
^ indent + 4 |
|
6319 |
]. |
|
6320 |
(line endsWith:']') ifTrue:[ |
|
6321 |
^ indent - 4 |
|
6322 |
]. |
|
6323 |
]. |
|
6324 |
^ indent |
|
6325 |
] |
|
6326 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6327 |
]. |
827 | 6328 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6329 |
|
6147 | 6330 |
"Created: / 05-03-1996 / 14:58:53 / cg" |
6331 |
"Modified (format): / 25-04-2017 / 12:57:44 / cg" |
|
4237 | 6332 |
! |
6333 |
||
6334 |
undentBy4 |
|
5050 | 6335 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6336 |
||
6337 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6338 |
! |
|
6339 |
||
6340 |
undentBy8 |
|
6341 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6342 |
|
6343 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6344 |
! |
6345 |
||
6346 |
undentBy:n |
|
6347 |
self indentBy:(n negated) |
|
6348 |
! |
|
6349 |
||
6350 |
undentByTab |
|
6351 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6352 |
! ! |
6353 |
||
0 | 6354 |
!EditTextView methodsFor:'initialization'! |
6355 |
||
941 | 6356 |
fetchDeviceResources |
6357 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6358 |
||
6359 |
super fetchDeviceResources. |
|
6360 |
||
5643 | 6361 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6362 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6363 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6364 |
|
6365 |
"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
|
6366 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6367 |
! |
6368 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6369 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6370 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6371 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6372 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6373 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6374 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6375 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6376 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6377 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6378 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6379 |
super initStyle. |
4576 | 6380 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6381 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6382 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6383 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6384 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6385 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6386 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6387 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6388 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6152 | 6389 |
cursorTypeNoFocus := cursorType. |
6390 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6391 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6392 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6393 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6394 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6395 |
cursorNoFocusFgColor isNil ifTrue:[ |
6152 | 6396 |
cursorType ~~ #block ifTrue:[ |
6397 |
cursorNoFocusFgColor := cursorBgColor |
|
6398 |
] ifFalse:[ |
|
6399 |
cursorNoFocusFgColor := cursorFgColor |
|
6400 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6401 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6402 |
|
2088 | 6403 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6404 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6405 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6406 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6407 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6408 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6409 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6410 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6411 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6412 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6413 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6414 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6415 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6416 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6417 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6418 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6419 |
cursorCol := 1. |
5251 | 6420 |
cursorLineHolder := ValueHolder with:1. |
6421 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6422 |
modifiedChannel := ValueHolder with:false. |
6423 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6424 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6425 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6426 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6427 |
tabMeansNextField := false. |
5106 | 6428 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6429 |
autoIndent := false. |
|
5251 | 6430 |
editMode := ValueHolder with:EditMode insertMode. |
6431 |
learnMode := ValueHolder with:false. |
|
2131 | 6432 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6433 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6434 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6435 |
"/ enable drop by default |
2589 | 6436 |
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
|
6437 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6438 |
undoSupport := UndoSupport for:self. |
5251 | 6439 |
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
|
6440 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6441 |
"Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6442 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6443 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6444 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6445 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6446 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6447 |
completionSupport isNil ifTrue:[ |
6152 | 6448 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
6449 |
completionSupport := supportClass for:self. |
|
6450 |
]. |
|
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6451 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6452 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6453 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6454 |
! |
6455 |
||
6456 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6457 |
completionSupport notNil ifTrue:[ |
6152 | 6458 |
completionSupport release |
4771 | 6459 |
]. |
6460 |
super release |
|
0 | 6461 |
! ! |
6462 |
||
2580 | 6463 |
!EditTextView methodsFor:'macros'! |
6464 |
||
6465 |
executeLearnedKeyboardMacro |
|
4673 | 6466 |
"replay the characters as learned previously" |
6467 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6468 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
6152 | 6469 |
ExecutingMacroQuery |
6470 |
answer:true |
|
6471 |
do:[ |
|
6472 |
learnedMacro do:[:event | |
|
6473 |
WindowGroup lastEventQuerySignal answer:event |
|
6474 |
do:[ |
|
6475 |
self |
|
6476 |
dispatchEvent:event |
|
6477 |
withFocusOn:nil |
|
6478 |
delegate:false |
|
6479 |
] |
|
6480 |
] |
|
6481 |
]. |
|
2580 | 6482 |
] ifFalse:[ |
6152 | 6483 |
self flash:'no macro'. |
2580 | 6484 |
]. |
6485 |
! |
|
6486 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6487 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6488 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6489 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6490 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6491 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6492 |
|
2580 | 6493 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6494 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6495 |
|
2580 | 6496 |
|fg bg| |
6497 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6498 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6499 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6500 |
aBoolean ifTrue:[ |
5795 | 6501 |
learnedMacro := OrderedCollection new. |
6502 |
fg := self whiteColor. |
|
6503 |
bg := self blackColor. |
|
2580 | 6504 |
] ifFalse:[ |
5795 | 6505 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6506 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6507 |
]. |
6508 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6509 |
! |
|
6510 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6511 |
learnModeHolder |
4673 | 6512 |
"a holder returning true, if in learn mode" |
6513 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6514 |
learnMode isNil ifTrue:[ |
6152 | 6515 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6516 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6517 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6518 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6519 |
|
4673 | 6520 |
rememberLearnedMacroAs: nameString |
6521 |
Macros isNil ifTrue:[ |
|
6152 | 6522 |
Macros := Dictionary new. |
4673 | 6523 |
]. |
6524 |
Macros at:nameString put:learnedMacro |
|
6525 |
! |
|
6526 |
||
2580 | 6527 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6528 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6529 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6530 |
self learnMode:(self learnMode not). |
2580 | 6531 |
! ! |
6532 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6533 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6534 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6535 |
babelFishTranslate:fromToModeString |
5962 | 6536 |
"translate the selected text and paste it after the selection. |
6537 |
This is now obsolete, as that web service no longer exists (sigh)" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6538 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6539 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6540 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6541 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6542 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6543 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6544 |
self withWaitCursorDo:[ |
5962 | 6545 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
6546 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
6547 |
] do:[ |
|
6548 |
translated := SOAP::BabelFishClient new |
|
6549 |
translate:original mode:fromToModeString. |
|
6550 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6551 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6552 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6553 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6554 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6555 |
self unselect. |
5787 | 6556 |
self |
5962 | 6557 |
undoablePaste:translated |
6558 |
info:'Translate' |
|
3495 | 6559 |
|
6560 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6561 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6562 |
|
5689 | 6563 |
copySelection |
6564 |
"copy contents into smalltalk copybuffer. |
|
6565 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6566 |
||
6567 |
self hasSelection ifTrue:[ |
|
6152 | 6568 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
5689 | 6569 |
]. |
6570 |
super copySelection. |
|
6571 |
||
6572 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6573 |
! |
|
6574 |
||
121 | 6575 |
cut |
6576 |
"cut selection into copybuffer" |
|
6577 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6578 |
self deleteCopyToClipboard:true |
121 | 6579 |
! |
6580 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6581 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6582 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6583 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6584 |
cursorLine notNil ifTrue:[ |
6152 | 6585 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6586 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6587 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6588 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6589 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6590 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6591 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6592 |
|
4129 | 6593 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6594 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6595 |
(self checkModificationsAllowed) ifFalse:[ |
6152 | 6596 |
self flashReadOnly. |
6597 |
^ self |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6598 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6599 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6600 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6601 |
sel notNil ifTrue:[ |
6152 | 6602 |
self setLastStringToReplace: sel. |
6603 |
||
6604 |
line := selectionStartLine. |
|
6605 |
col := selectionStartCol. |
|
6606 |
||
6607 |
toClipboard ifTrue:[ |
|
6608 |
" |
|
6609 |
remember in CopyBuffer |
|
6610 |
" |
|
6611 |
self setClipboardText:sel. "/ lastString. |
|
6612 |
]. |
|
6613 |
||
6614 |
" |
|
6615 |
append to DeleteHistory (if there is one) |
|
6616 |
" |
|
6617 |
history := Smalltalk at:#DeleteHistory. |
|
6618 |
history notNil ifTrue:[ |
|
6619 |
history addAll:(sel asStringCollection). |
|
6620 |
history size > 1000 ifTrue:[ |
|
6621 |
history := history copyFrom:(history size - 1000) |
|
6622 |
]. |
|
6623 |
]. |
|
6624 |
||
6625 |
" |
|
6626 |
now, delete it |
|
6627 |
" |
|
6628 |
self |
|
6629 |
undoableDo:[self deleteSelection] |
|
6630 |
info:'Delete'. |
|
6631 |
lastReplacementInfo lastReplacement: nil |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6632 |
] ifFalse:[ |
6152 | 6633 |
" |
6634 |
a cut without selection will search&cut again |
|
6635 |
" |
|
6636 |
self undoableDo:[ |
|
6637 |
self again |
|
6638 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6639 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6640 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6641 |
"Modified: / 5.4.1998 / 16:51:53 / cg" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6642 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6643 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6644 |
editMenu |
5977 | 6645 |
"return the view's middleButtonMenu" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6646 |
|
5787 | 6647 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 6648 |
#Find #GotoLine #SaveAs #Print |
6649 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
|
6650 |
#ToggleAutoIndent #ToggleInsertMode |
|
6651 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
|
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6652 |
<resource: #programMenu> |
1054 | 6653 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6654 |
|items m sub translateItems sortItems miscItems toolItems subSub toolSub |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6655 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6656 |
|
2460 | 6657 |
items := #( |
5826 | 6658 |
('Redo' redo Redo ) |
6659 |
('Again (for All)' multipleAgain AgainForAll ) |
|
6660 |
('-' ) |
|
6661 |
('Search...' search Find ) |
|
6662 |
('Goto Line...' gotoLine GotoLine ) |
|
6663 |
('-' ) |
|
6664 |
('Tools' tools ) |
|
6665 |
('Font...' changeFont ) |
|
6666 |
('Insert Unicode...' insertUnicode ) |
|
6667 |
). |
|
4213 | 6668 |
CharacterSetView notNil ifTrue:[ |
5826 | 6669 |
items := items , |
6670 |
#( |
|
6671 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6672 |
). |
|
4213 | 6673 |
]. |
6674 |
items := items , #( |
|
5826 | 6675 |
('-' ) |
6676 |
('Save As...' save SaveAs ) |
|
6677 |
('Print' doPrint Print ) |
|
6678 |
('=' ) |
|
6679 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 6680 |
|
2866 | 6681 |
miscItems := #( |
5826 | 6682 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6683 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
6684 |
('-' ) |
|
6134 | 6685 |
('Copy Box' copySelectionBox CopyBox ) |
6686 |
('Paste Box' pasteOrReplaceBox PasteBox ) |
|
5826 | 6687 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
6688 |
('Join Lines' joinLines Join ) |
|
6689 |
('Wrap Lines...' wrapLines Wrap ) |
|
6690 |
('-' ) |
|
6691 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
6692 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
6693 |
('-' ) |
|
6694 |
('Insert File...' insertFile ) |
|
6695 |
('Insert URL Contents...' insertURL ) |
|
6696 |
('Insert new UUID' insertUUID ) |
|
6697 |
('Insert Date && Time' insertDateAndTime ) |
|
6698 |
('-' ) |
|
6699 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6700 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
6701 |
). |
|
4213 | 6702 |
"/ CharacterSetView notNil ifTrue:[ |
6703 |
"/ miscItems := miscItems , |
|
6704 |
"/ #( |
|
5529 | 6705 |
"/ ('-' ) |
4213 | 6706 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6707 |
"/ ('Font...' changeFont ) |
4213 | 6708 |
"/ ). |
5529 | 6709 |
"/ ] ifFalse:[ |
6710 |
"/ miscItems := miscItems , |
|
6711 |
"/ #( |
|
6712 |
"/ ('Font...' changeFont ) |
|
6713 |
"/"/ ('Encoding...' changeEncoding ) |
|
6714 |
"/ ). |
|
5787 | 6715 |
"/ ]. |
2866 | 6716 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6717 |
translateItems := #( |
5826 | 6718 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6719 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6720 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6721 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6722 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6723 |
('-' ) |
|
6724 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6725 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6726 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6727 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6728 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6729 |
). |
|
3221 | 6730 |
|
6731 |
sortItems := #( |
|
5826 | 6732 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6733 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
6734 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
6735 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6736 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
6737 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
6738 |
('-' ) |
|
6739 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
6740 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6741 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6742 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
6743 |
('-' ) |
|
6744 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6745 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
6746 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6747 |
|
2762 | 6748 |
toolItems := #( |
5826 | 6749 |
('Indent' indent ) |
6750 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6751 |
('Sort' sort ) |
|
6752 |
('Split...' splitLinesAtCharacterOrString ) |
|
6753 |
('-' ) |
|
6754 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6755 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
6756 |
('Translate' babelFishTranslate ) |
|
6757 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6758 |
('Compare with File...' compareWithFile ) |
|
6759 |
). |
|
2762 | 6760 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6761 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 6762 |
toolItems := toolItems , #( |
6763 |
('-' ) |
|
6764 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6765 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6766 |
('Inspect Selected String' inspectSelectedString ) |
|
6767 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6768 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6769 |
|
2460 | 6770 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6771 |
sub receiver:self. |
2460 | 6772 |
|
2919 | 6773 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6774 |
toolSub receiver:self. |
|
6775 |
sub subMenuAt:#tools put:toolSub. |
|
6776 |
||
3495 | 6777 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6778 |
transSub receiver:self. |
|
6779 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6780 |
||
6781 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6782 |
sortSub receiver:self. |
|
6783 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6784 |
|
2866 | 6785 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6786 |
subSub receiver:self. |
|
2952 | 6787 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6788 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6789 |
subSub checkToggleAt:#learnMode: put:(self learnModeHolder value). |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
6790 |
|
2866 | 6791 |
sub subMenuAt:#misc put:subSub. |
6792 |
||
3495 | 6793 |
mainItems := #( |
5826 | 6794 |
('Undo' undo Undo ) |
6795 |
('Again' again Again ) |
|
6796 |
('-' ) |
|
6134 | 6797 |
('Cut' cut Cut )). |
6798 |
self sensor metaDown ifTrue:[ |
|
6799 |
mainItems := mainItems , #( |
|
6800 |
('Copy Box' copySelectionBox CopyBox ) |
|
6801 |
('Paste Box' pasteOrReplaceBox PasteBox )) |
|
6802 |
] ifFalse:[ |
|
6803 |
mainItems := mainItems , #( |
|
5826 | 6804 |
('Copy' copySelection Copy ) |
6134 | 6805 |
('Paste' pasteOrReplace Paste )) |
6806 |
]. |
|
6807 |
mainItems := mainItems , #( |
|
5826 | 6808 |
('-' ) |
6809 |
('Accept' accept Accept ) |
|
6810 |
('=' ) |
|
6134 | 6811 |
('More' others Ctrl )). |
6812 |
||
3495 | 6813 |
main := PopUpMenu itemList:mainItems resources:resources. |
6814 |
main subMenuAt:#others put:sub. |
|
6815 |
||
6816 |
sensor := self sensor. |
|
6817 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6818 |
sensor shiftDown ifTrue:[ |
|
5826 | 6819 |
m := subSub |
6820 |
] ifFalse:[ |
|
6821 |
m := sub |
|
6822 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6823 |
] ifFalse:[ |
5826 | 6824 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6825 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6826 |
|
4742 | 6827 |
"/ the 'Smalltalk at:' code is here to |
6828 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6829 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 6830 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6831 |
m disable:#googleSpellingSuggestion |
|
2676 | 6832 |
]. |
4742 | 6833 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 6834 |
m disable:#internalSpellingSuggestion |
4742 | 6835 |
]. |
2676 | 6836 |
|
3811 | 6837 |
HTTPInterface isNil ifTrue:[ |
5826 | 6838 |
m disableAll:#(insertURL) |
3811 | 6839 |
]. |
6840 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6841 |
self isReadOnly ifTrue:[ |
5826 | 6842 |
m disableAll:#(accept undo again multipleAgain redo |
6134 | 6843 |
paste pasteOrReplace pasteOrReplaceBox pasteOrReplaceFromHistory |
5826 | 6844 |
cut indent autoIndent: insertMode: |
6845 |
insertFile insertFileAsStringLiteral insertURL |
|
6846 |
babelFishTranslate googleSpellingSuggestion sort |
|
6847 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
6848 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
|
6849 |
insertUnicode specialCharacters) |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6850 |
]. |
2817 | 6851 |
self hasSelectionForCopy ifFalse:[ |
5826 | 6852 |
m disable:#copySelection. |
6134 | 6853 |
m disable:#copySelectionBox. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6854 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6855 |
self hasSelection ifFalse:[ |
5826 | 6856 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
6857 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString). |
|
2762 | 6858 |
] ifTrue:[ |
5826 | 6859 |
(Error handle:[:ex | |
6860 |
ex return:false |
|
6861 |
] do:[ |
|
6862 |
|fn| |
|
6863 |
fn := self selectionAsString. |
|
6864 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
6865 |
]) ifFalse:[ |
|
6866 |
m disableAll:#(openFileBrowserOnIt). |
|
6867 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6868 |
]. |
2569 | 6869 |
self hasUndoAction ifFalse:[ |
5826 | 6870 |
m disable:#undo. |
3115 | 6871 |
] ifTrue:[ |
5826 | 6872 |
what := undoSupport undoActionInfo. |
6873 |
what notNil ifTrue:[ |
|
6874 |
undoIdx := m indexOf:#undo. |
|
6875 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6876 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6877 |
]. |
2952 | 6878 |
self hasRedoAction ifFalse:[ |
5826 | 6879 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6880 |
] ifTrue:[ |
5826 | 6881 |
what := undoSupport redoActionInfo. |
6882 |
what notNil ifTrue:[ |
|
6883 |
redoIdx := sub indexOf:#redo. |
|
6884 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6885 |
] |
|
2952 | 6886 |
]. |
5216 | 6887 |
self canAccept ifFalse:[ |
5826 | 6888 |
m disable:#accept |
1108 | 6889 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6890 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6891 |
|
6134 | 6892 |
"Modified: / 14-03-2017 / 16:30:44 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6893 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6894 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6895 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6896 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6897 |
|
5643 | 6898 |
history := device getCopyBufferHistory copy. |
3160 | 6899 |
list := history collect:[:entry | |
6152 | 6900 |
|text shown| |
6901 |
||
6902 |
text := entry asString string asCollectionOfLines. |
|
6903 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
|
6904 |
text size > 1 ifTrue:[ |
|
6905 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
|
6906 |
]. |
|
6907 |
shown |
|
6908 |
]. |
|
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6909 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6910 |
box := ListSelectionBox |
6152 | 6911 |
title:(resources string:'Clipboard History') |
6912 |
okText:(resources string:'Paste') |
|
6913 |
abortText:(resources string:'Cancel') |
|
6914 |
list:list |
|
6915 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
|
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6916 |
box label:(resources string:'Select Previous Copybuffer String'). |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6917 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6918 |
box show. |
3160 | 6919 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6920 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6921 |
"Modified: / 25-08-2010 / 22:02:14 / cg" |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6922 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6923 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6924 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6925 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6926 |
self sensor shiftDown ifTrue:[ |
6152 | 6927 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6928 |
]. |
2724 | 6929 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6930 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6931 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6932 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6933 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6934 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6935 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6936 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6937 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6938 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6939 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6940 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6941 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6942 |
"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
|
6943 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6944 |
|
2676 | 6945 |
googleSpellingSuggestion |
6946 |
"insert the google-spelling suggestion for the selected text. |
|
6947 |
Requires that the SOAP stuff is loaded and working." |
|
6948 |
||
2677 | 6949 |
|text suggestion| |
2676 | 6950 |
|
6951 |
self withWaitCursorDo:[ |
|
6152 | 6952 |
text := self selection asString string withoutSeparators. |
6953 |
text size == 0 ifTrue:[^ self]. |
|
6954 |
||
6955 |
"/ the 'Smalltalk at:' code is here to |
|
6956 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6957 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
6958 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
|
6959 |
^ self. |
|
6960 |
] do:[ |
|
6961 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
|
6962 |
]. |
|
6963 |
suggestion size == 0 ifTrue:[ |
|
6964 |
self information:('No spelling suggestion from Google for: ' , text). |
|
6965 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
6966 |
^ self. |
|
6967 |
]. |
|
5787 | 6968 |
]. |
6969 |
self |
|
6152 | 6970 |
undoablePaste:suggestion |
6971 |
info:'Spelling Suggestion'. |
|
3495 | 6972 |
|
6973 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6974 |
! |
6975 |
||
3595 | 6976 |
insertDateAndTime |
6977 |
"insert the curent date and time string" |
|
6978 |
||
6979 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6980 |
self |
6152 | 6981 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
6982 |
info:'Paste Date and Time' |
|
3595 | 6983 |
! |
6984 |
||
2676 | 6985 |
insertFile |
3160 | 6986 |
"insert contents of a file |
2676 | 6987 |
- ask user for filename using a fileSelectionBox." |
6988 |
||
3731 | 6989 |
self insertFileAsStringLiteral:false |
6990 |
! |
|
6991 |
||
6992 |
insertFileAsStringLiteral |
|
6993 |
"insert a file's contents as a string literal. |
|
6994 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6995 |
to make it a legal string literal" |
|
6996 |
||
6997 |
self insertFileAsStringLiteral:true |
|
6998 |
! |
|
6999 |
||
7000 |
insertFileAsStringLiteral:asStringLiteral |
|
7001 |
"insert contents of a file; either as-is or as a string literal. |
|
7002 |
- ask user for filename using a fileSelectionBox." |
|
7003 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7004 |
|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
|
7005 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7006 |
((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
|
7007 |
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
|
7008 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7009 |
ifTrue:[ |
6152 | 7010 |
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
|
7011 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7012 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7013 |
[ |
6152 | 7014 |
|why| |
7015 |
||
7016 |
file := Dialog |
|
7017 |
requestFileName:(resources string:'Insert Contents Of:') |
|
7018 |
default:initial |
|
7019 |
ok:(resources string:'Insert') |
|
7020 |
abort:(resources string:'Cancel') |
|
7021 |
pattern:nil |
|
7022 |
fromDirectory:directoryForFileDialog. |
|
7023 |
file isNil ifTrue:[ |
|
7024 |
"cancel" |
|
7025 |
^ self. |
|
7026 |
]. |
|
7027 |
file := file asFilename. |
|
7028 |
directoryForFileDialog := file. |
|
7029 |
||
7030 |
ok := file isReadable and:[file isDirectory not]. |
|
7031 |
ok ifFalse:[ |
|
7032 |
file isReadable ifFalse:[ |
|
7033 |
why := '%1 is unreadable.\\Please try again.' |
|
7034 |
] ifTrue:[ |
|
7035 |
why := '%1 is a directory.\\Please try again.' |
|
7036 |
]. |
|
7037 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
7038 |
]. |
|
2909 | 7039 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7040 |
|
5063 | 7041 |
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
|
7042 |
self |
6152 | 7043 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
7044 |
info:'Paste File' |
|
3495 | 7045 |
|
7046 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
7047 |
! |
|
7048 |
||
3811 | 7049 |
insertURL |
7050 |
"insert contents of a URL |
|
7051 |
- ask user for URL using a dialog." |
|
7052 |
||
7053 |
self insertURLAsStringLiteral:false |
|
7054 |
! |
|
7055 |
||
7056 |
insertURLAsStringLiteral:asStringLiteral |
|
7057 |
"insert contents of a file; either as-is or as a string literal. |
|
7058 |
- ask user for filename using a fileSelectionBox." |
|
7059 |
||
7060 |
|sel url text response initial| |
|
7061 |
||
7062 |
(sel := self selectionAsString) notEmptyOrNil |
|
7063 |
ifTrue:[ |
|
6152 | 7064 |
initial := sel. |
3811 | 7065 |
]. |
7066 |
||
7067 |
url := Dialog |
|
6152 | 7068 |
request:(resources string:'Insert Contents of URL:') |
7069 |
initialAnswer:initial |
|
7070 |
okLabel:(resources string:'Insert') |
|
7071 |
title:(resources string:'URL'). |
|
3811 | 7072 |
url isNil ifTrue:[ |
6152 | 7073 |
"cancel" |
7074 |
^ self. |
|
3811 | 7075 |
]. |
7076 |
response := HTTPInterface get:url. |
|
7077 |
response isErrorResponse ifTrue:[ |
|
6152 | 7078 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
7079 |
^ self. |
|
3811 | 7080 |
]. |
7081 |
text := response data asString. |
|
7082 |
||
7083 |
self |
|
6152 | 7084 |
undoableDo:[ |
7085 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
7086 |
] |
|
7087 |
info:'Insert Contents of URL' |
|
3811 | 7088 |
! |
7089 |
||
3495 | 7090 |
insertUUID |
7091 |
"insert a new UUID's string" |
|
7092 |
||
7093 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7094 |
self |
6152 | 7095 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
7096 |
info:'Paste New UUID' |
|
3495 | 7097 |
|
7098 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 7099 |
! |
7100 |
||
4940 | 7101 |
insertUnicode |
7102 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
7103 |
||
7104 |
|unicodePoint unicodeChar unicodeString| |
|
7105 |
||
5904 | 7106 |
unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):'). |
4940 | 7107 |
unicodeString size < 2 ifTrue:[ |
5904 | 7108 |
^ self. |
4940 | 7109 |
]. |
7110 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
5904 | 7111 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
4940 | 7112 |
] ifFalse:[ |
5904 | 7113 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
5787 | 7114 |
]. |
7115 |
||
4940 | 7116 |
unicodeChar := Character value:unicodePoint. |
7117 |
self keyPress:unicodeChar x:0 y:0. |
|
7118 |
self keyRelease:unicodeChar x:0 y:0. |
|
7119 |
! |
|
7120 |
||
5331 | 7121 |
inspectSelectedString |
7122 |
"inspect the selected text" |
|
7123 |
||
7124 |
self selectionAsString inspect. |
|
7125 |
! |
|
7126 |
||
4742 | 7127 |
internalSpellingSuggestion |
7128 |
"insert the internal-spelling suggestion for the selected text. |
|
7129 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7130 |
||
7131 |
|text suggestions best| |
|
7132 |
||
7133 |
self withWaitCursorDo:[ |
|
6152 | 7134 |
text := self selection asString string withoutSeparators. |
7135 |
text size == 0 ifTrue:[^ self]. |
|
7136 |
||
7137 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7138 |
suggestions size == 0 ifTrue:[ |
|
7139 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7140 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7141 |
^ self. |
|
7142 |
]. |
|
7143 |
Transcript showCR:suggestions. |
|
7144 |
best := suggestions first. |
|
5787 | 7145 |
]. |
7146 |
self |
|
6152 | 7147 |
undoablePaste:best |
7148 |
info:'Spelling Suggestion'. |
|
4742 | 7149 |
! |
7150 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7151 |
paste |
1289 | 7152 |
"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
|
7153 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7154 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7155 |
self checkModificationsAllowed ifTrue:[ |
6152 | 7156 |
self withSelfAndTextForPasteDo:[:me :text | |
7157 |
me unselect. |
|
7158 |
me undoablePaste:text |
|
7159 |
] |
|
2952 | 7160 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7161 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7162 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7163 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7164 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7165 |
|
3825 | 7166 |
self paste:someText withCR:false |
7167 |
! |
|
7168 |
||
7169 |
paste:someText withCR:withCR |
|
7170 |
"paste someText at cursor" |
|
7171 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7172 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7173 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7174 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7175 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7176 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7177 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7178 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7179 |
CharacterEncoderError handle:[:ex | |
6152 | 7180 |
|code msg| |
7181 |
||
7182 |
code := ex parameter. |
|
7183 |
codingErrorReported ifFalse:[ |
|
7184 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
|
7185 |
code notNil ifTrue:[ |
|
7186 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7187 |
]. |
|
7188 |
Dialog warn:(resources stringWithCRs:msg). |
|
7189 |
codingErrorReported := true. |
|
7190 |
]. |
|
7191 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7192 |
] do:[ |
6152 | 7193 |
s isString ifTrue:[ |
7194 |
s encoding ~~ gc characterEncoding ifTrue:[ |
|
7195 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7196 |
]. |
|
7197 |
||
7198 |
s := s asStringCollection. |
|
7199 |
(someText endsWith:Character cr) ifTrue:[ |
|
7200 |
"/ s := s copyWith:nil. |
|
7201 |
s := s copyWith:'' "/ an empty line at the end |
|
7202 |
||
7203 |
] |
|
7204 |
] ifFalse:[ |
|
7205 |
s isStringCollection ifTrue:[ |
|
7206 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
7207 |
] ifFalse:[ |
|
7208 |
(self |
|
7209 |
confirm:(resources |
|
7210 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7211 |
with:s class name)) ifFalse:[^ self]. |
|
7212 |
s := StringCollection with:s storeString . |
|
7213 |
"/ ^ self |
|
7214 |
]. |
|
7215 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7216 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7217 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7218 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7219 |
(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
|
7220 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7221 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7222 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7223 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7224 |
startCol := c1 := cursorCol. |
3180 | 7225 |
|
5787 | 7226 |
"do not autoindent here. |
7227 |
It does make things very ugly, in the inspector |
|
5194 | 7228 |
(try inspecting a multiline string)..." |
7229 |
self withAutoIndent:false do:[ |
|
6152 | 7230 |
"do not expand tabs into spaces here - |
7231 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7232 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7233 |
||
7234 |
self insertLines:s withCR:withCR. |
|
5194 | 7235 |
]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7236 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7237 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7238 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7239 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7240 |
|
4328 | 7241 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7242 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7243 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7244 |
|
3731 | 7245 |
pasteAsStringLiteral |
7246 |
"insert clipboard string as a string literal. |
|
7247 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7248 |
to make it a legal string literal" |
|
7249 |
||
7250 |
typeOfSelection := nil. |
|
7251 |
self |
|
6152 | 7252 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
7253 |
info:'Paste as String Literal' |
|
3731 | 7254 |
! |
7255 |
||
6134 | 7256 |
pasteBox |
7257 |
"paste the copybuffer as a box; |
|
7258 |
if there is a selection, unselect first. |
|
7259 |
Then paste at cursor position." |
|
7260 |
||
7261 |
self checkModificationsAllowed ifTrue:[ |
|
7262 |
self withSelfAndTextForPasteDo:[:me :text | |
|
7263 |
me unselect. |
|
7264 |
me undoablePasteBox:text |
|
7265 |
] |
|
7266 |
] |
|
7267 |
||
7268 |
"Created: / 14-03-2017 / 16:34:16 / cg" |
|
7269 |
! |
|
7270 |
||
7271 |
pasteBox:someText |
|
7272 |
"paste someText at cursor" |
|
7273 |
||
7274 |
self pasteBox:someText withCR:false |
|
7275 |
||
7276 |
"Created: / 14-03-2017 / 16:35:08 / cg" |
|
7277 |
! |
|
7278 |
||
7279 |
pasteBox:someText withCR:withCR |
|
7280 |
"paste someText at cursor" |
|
7281 |
||
7282 |
|lines nLines startLine startCol l1 l2 c1 c2| |
|
7283 |
||
7284 |
self checkModificationsAllowed ifFalse:[^ self]. |
|
7285 |
||
7286 |
lines := someText asStringCollection. |
|
7287 |
||
7288 |
(nLines := lines size) == 0 ifTrue:[^ self]. |
|
7289 |
(nLines == 1 and:[(lines at:1) size == 0]) ifTrue:[^ self]. |
|
7290 |
||
7291 |
typeOfSelection := #paste. |
|
7292 |
||
7293 |
startLine := l1 := cursorLine. |
|
7294 |
startCol := c1 := cursorCol. |
|
7295 |
||
7296 |
"do not autoindent here. |
|
7297 |
It does make things very ugly, in the inspector |
|
7298 |
(try inspecting a multiline string)..." |
|
7299 |
self withAutoIndent:false do:[ |
|
7300 |
"do not expand tabs into spaces here - |
|
7301 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7302 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7303 |
||
7304 |
lines do:[:eachLine | |
|
7305 |
self insertString:eachLine atLine:l1 col:startCol. |
|
7306 |
l1 := l1 + 1. |
|
7307 |
]. |
|
7308 |
]. |
|
7309 |
l2 := cursorLine. |
|
7310 |
c2 := (cursorCol - 1). |
|
7311 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
|
7312 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
|
7313 |
||
7314 |
"Created: / 14-03-2017 / 16:39:11 / cg" |
|
7315 |
! |
|
7316 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7317 |
pasteOrReplace |
1289 | 7318 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7319 |
otherwise paste at cursor position. |
7320 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7321 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7322 |
|
2724 | 7323 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7324 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7325 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7326 |
pasteOrReplace:someText |
1289 | 7327 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7328 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7329 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7330 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7331 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7332 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7333 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7334 |
self undoableDo:[ |
6152 | 7335 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7336 |
self replace:someText |
|
7337 |
] ifFalse:[ |
|
7338 |
self paste:someText. |
|
7339 |
] |
|
3542 | 7340 |
] info:'Paste/Replace'. |
1289 | 7341 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7342 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7343 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7344 |
|
6134 | 7345 |
pasteOrReplaceBox |
7346 |
"paste the copybuffer as a box; |
|
7347 |
if there is a selection, unselect first. |
|
7348 |
Then paste at cursor position." |
|
7349 |
||
7350 |
self pasteBox |
|
7351 |
||
7352 |
"Created: / 14-03-2017 / 16:40:08 / cg" |
|
7353 |
! |
|
7354 |
||
5387 | 7355 |
pasteOrReplaceByKeyPress |
7356 |
"paste a previous item from the copybuffer history. |
|
7357 |
(i.e. repaste some previously deleted or copied text)" |
|
7358 |
||
7359 |
|text| |
|
7360 |
||
7361 |
self checkModificationsAllowed ifFalse:[ |
|
6152 | 7362 |
self flashReadOnly. |
7363 |
^ self |
|
5387 | 7364 |
]. |
7365 |
text := self getClipboardText:#clipboard. |
|
7366 |
text notNil ifTrue:[ |
|
6152 | 7367 |
self pasteOrReplace:text |
5387 | 7368 |
] |
7369 |
! |
|
7370 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7371 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7372 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7373 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7374 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7375 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7376 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7377 |
self checkModificationsAllowed ifFalse:[ |
6152 | 7378 |
self flashReadOnly. |
7379 |
^ self |
|
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7380 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7381 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7382 |
text notNil ifTrue:[ |
6152 | 7383 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7384 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7385 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7386 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7387 |
replace |
1289 | 7388 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7389 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7390 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7391 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7392 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7393 |
self withSelfAndTextForPasteDo:[:me :text | |
6152 | 7394 |
me undoableDo:[ me replace:text ] |
7395 |
info:'Replace' |
|
2952 | 7396 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7397 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7398 |
|
121 | 7399 |
replace:someText |
1289 | 7400 |
"replace the selection by someText" |
121 | 7401 |
|
3160 | 7402 |
|selected selectedString |
7403 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7404 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7405 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7406 |
|
3130 | 7407 |
self undoableDo:[ |
6152 | 7408 |
selected := self selection. |
7409 |
selected isNil ifTrue:[ |
|
7410 |
^ self paste:someText |
|
7411 |
]. |
|
7412 |
||
7413 |
self deleteSelection. |
|
7414 |
||
7415 |
"take care, if we replace a selection without space by a word selected |
|
7416 |
with one - in this case we usually do not want the space. |
|
7417 |
But, if we replace a word-selected selection by something without a |
|
7418 |
space, we DO want the space added." |
|
7419 |
||
7420 |
selected size == 1 ifTrue:[ |
|
7421 |
selectedString := selected at:1. |
|
7422 |
]. |
|
7423 |
||
7424 |
someText size == 1 ifTrue:[ |
|
7425 |
|cutOffSpace addSpace replacement replacementString| |
|
7426 |
||
7427 |
cutOffSpace := false. |
|
7428 |
addSpace := false. |
|
7429 |
replacement := someText copyFrom:1. |
|
7430 |
||
7431 |
selectedString notNil ifTrue:[ |
|
7432 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7433 |
"selection has no space" |
|
7434 |
||
7435 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7436 |
cutOffSpace := true |
|
7437 |
] |
|
7438 |
] ifTrue:[ |
|
7439 |
addSpace := true |
|
7440 |
] |
|
7441 |
]. |
|
7442 |
replacementString := replacement at:1. |
|
7443 |
cutOffSpace ifTrue:[ |
|
7444 |
(replacementString startsWith:' ') ifTrue:[ |
|
7445 |
replacementString := replacementString withoutSpaces |
|
7446 |
]. |
|
7447 |
] ifFalse:[ |
|
7448 |
selectStyle == #wordLeft ifTrue:[ |
|
7449 |
"want a space at left" |
|
7450 |
(replacementString startsWith:' ') ifFalse:[ |
|
7451 |
replacementString := replacementString withoutSpaces. |
|
7452 |
replacementString := ' ' , replacementString |
|
7453 |
] |
|
7454 |
]. |
|
7455 |
selectStyle == #wordRight ifTrue:[ |
|
7456 |
"want a space at right" |
|
7457 |
||
7458 |
(replacementString endsWith:' ') ifFalse:[ |
|
7459 |
replacementString := replacementString withoutSpaces. |
|
7460 |
replacementString := replacementString , ' ' |
|
7461 |
] |
|
7462 |
]. |
|
7463 |
]. |
|
7464 |
replacement at:1 put: replacementString. |
|
7465 |
self paste:replacement. |
|
7466 |
] ifFalse:[ |
|
7467 |
self paste:someText |
|
7468 |
]. |
|
7469 |
self setLastStringToReplace: selectedString. |
|
7470 |
||
7471 |
lastReplacementInfo lastReplacement: someText. |
|
7472 |
||
7473 |
selStartLine := selectionStartLine. |
|
7474 |
selStartCol := self selectionStartCol. |
|
7475 |
selEndLine := selectionEndLine. |
|
7476 |
selEndCol := self selectionEndCol. |
|
3130 | 7477 |
] |
3542 | 7478 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7479 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7480 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7481 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7482 |
! |
7483 |
||
3430 | 7484 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7485 |
"search for a string - show a box to enter searchpattern |
3430 | 7486 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7487 |
- 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
|
7488 |
|
3430 | 7489 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7490 |
||
7491 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7492 |
lastSearchDirection := #forward. |
|
7493 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7494 |
caseHolder := ValueHolder with:ign. |
7495 |
patternHolder := ValueHolder with:''. |
|
7496 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7497 |
lastSearchPattern notNil ifTrue:[ |
6152 | 7498 |
initialString := lastSearchPattern |
3430 | 7499 |
]. |
7500 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
6152 | 7501 |
initialString := self selectionAsString |
3430 | 7502 |
]. |
7503 |
initialString isNil ifTrue:[ |
|
6152 | 7504 |
LastSearchPatterns size > 0 ifTrue:[ |
7505 |
initialString := LastSearchPatterns first |
|
7506 |
] |
|
3430 | 7507 |
]. |
7508 |
initialString notNil ifTrue:[ |
|
6152 | 7509 |
patternHolder value:initialString. |
7510 |
replacePatternHolder value:initialString. |
|
3430 | 7511 |
]. |
7512 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7513 |
search := [:fwd | |
6152 | 7514 |
self |
7515 |
search:patternHolder value |
|
7516 |
ignoreCase:caseHolder value |
|
7517 |
forward:fwd. |
|
7518 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7519 |
replace := [:all | |
6152 | 7520 |
self |
7521 |
replace:patternHolder value |
|
7522 |
by:replacePatternHolder value |
|
7523 |
all:all |
|
7524 |
ignoreCase:caseHolder value |
|
7525 |
]. |
|
3430 | 7526 |
bindings := IdentityDictionary new. |
7527 |
bindings at:#searchPattern put:patternHolder. |
|
7528 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7529 |
modal ifTrue:[ |
|
6152 | 7530 |
bindings at:#nextAction |
7531 |
put:[ |
|
7532 |
flag := true. |
|
7533 |
action := search. |
|
7534 |
searchBox doAccept. |
|
7535 |
]. |
|
7536 |
bindings at:#prevAction |
|
7537 |
put:[ |
|
7538 |
flag := false. |
|
7539 |
action := search. |
|
7540 |
searchBox doAccept. |
|
7541 |
]. |
|
7542 |
bindings at:#replaceAction |
|
7543 |
put:[ |
|
7544 |
flag := false. |
|
7545 |
action := replace. |
|
7546 |
searchBox doAccept. |
|
7547 |
]. |
|
7548 |
bindings at:#replaceAllAction |
|
7549 |
put:[ |
|
7550 |
flag := true. |
|
7551 |
action := replace. |
|
7552 |
searchBox doAccept. |
|
7553 |
]. |
|
3430 | 7554 |
] ifFalse:[ |
6152 | 7555 |
bindings at:#nextAction put:[ search value:true. ]. |
7556 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7557 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7558 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7559 |
]. |
7560 |
bindings at:#ignoreCase put:caseHolder. |
|
7561 |
bindings at:#patternList put:LastSearchPatterns. |
|
7562 |
modal ifTrue:[ |
|
6152 | 7563 |
searchBox := SimpleDialog new. |
3430 | 7564 |
] ifFalse:[ |
6152 | 7565 |
searchBox := ApplicationModel new. |
7566 |
searchBox createBuilder. |
|
3430 | 7567 |
]. |
7568 |
searchBox resources:(self resources). |
|
7569 |
bldr := searchBox builder. |
|
7570 |
bldr addBindings:bindings. |
|
7571 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7572 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7573 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7574 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7575 |
modal ifTrue:[ |
|
6152 | 7576 |
searchBox openDialog. |
7577 |
searchBox accepted ifTrue:[ |
|
7578 |
action value:flag |
|
7579 |
]. |
|
3430 | 7580 |
] ifFalse:[ |
6152 | 7581 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7582 |
(bldr componentAt:#cancelButton) |
|
7583 |
label:(resources string:'Close'); |
|
7584 |
action:[ searchBox closeRequest ]. |
|
7585 |
||
7586 |
"/ searchBox masterApplication:self application. |
|
7587 |
||
7588 |
self topView beMaster. |
|
7589 |
(searchBox window) |
|
7590 |
beSlave; |
|
7591 |
openInGroup:(self windowGroup). |
|
7592 |
||
7593 |
"/ searchBox window open. |
|
7594 |
||
7595 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
|
3430 | 7596 |
] |
7597 |
||
7598 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7599 |
! |
|
7600 |
||
121 | 7601 |
showDeleted |
7602 |
"open a readonly editor on all deleted text" |
|
7603 |
||
7604 |
|v| |
|
7605 |
||
7606 |
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
|
7607 |
v readOnly:true. |
121 | 7608 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7609 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7610 |
|
3221 | 7611 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7612 |
"sort/reorder the selected lines. |
7613 |
how: |
|
6152 | 7614 |
#lines |
7615 |
#linesByFirstWord |
|
7616 |
#linesByNthWord |
|
7617 |
#linesByNthNumber |
|
7618 |
#linesByNthHexNumber |
|
7619 |
#words |
|
7620 |
#linesByLength |
|
7621 |
#reverse |
|
4763 | 7622 |
" |
7623 |
||
7624 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7625 |
|
7626 |
lineWise := true. |
|
7627 |
||
4763 | 7628 |
how == #reverse ifTrue:[ |
6152 | 7629 |
operation := [:lines | lines reverse]. |
4763 | 7630 |
] ifFalse:[ |
6152 | 7631 |
operation := [:linesOrWords | |
7632 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7633 |
]. |
|
7634 |
||
7635 |
how == #linesByLength ifTrue:[ |
|
7636 |
fetcher := [:l | l size]. |
|
7637 |
] ifFalse:[ |
|
7638 |
how == #lines ifTrue:[ |
|
7639 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7640 |
] ifFalse:[ |
|
7641 |
how == #linesByFirstWord ifTrue:[ |
|
7642 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7643 |
] ifFalse:[ |
|
7644 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7645 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7646 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7647 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7648 |
LastColumnNumberForSort := n. |
|
7649 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7650 |
how == #linesByNthNumber ifTrue:[ |
|
7651 |
innerExtractor := extractor. |
|
7652 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7653 |
] ifFalse:[ |
|
7654 |
how == #linesByNthHexNumber ifTrue:[ |
|
7655 |
innerExtractor := extractor. |
|
7656 |
extractor := [:l | |
|
7657 |
|s| |
|
7658 |
s := innerExtractor value:l. |
|
7659 |
(s startsWith:'16r') ifTrue:[ |
|
7660 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7661 |
] ifFalse:[ |
|
7662 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7663 |
] |
|
7664 |
] |
|
7665 |
] |
|
7666 |
]. |
|
7667 |
] ifFalse:[ |
|
7668 |
how == #words ifTrue:[ |
|
7669 |
lineWise := false. |
|
7670 |
extractor := [:w | w]. |
|
7671 |
] ifFalse:[ |
|
7672 |
self error:'unknown sort criteria: ', how printString. |
|
7673 |
] |
|
7674 |
] |
|
7675 |
] |
|
7676 |
]. |
|
7677 |
ignoreCase ifTrue:[ |
|
7678 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7679 |
] ifFalse:[ |
|
7680 |
fetcher := extractor. |
|
7681 |
]. |
|
7682 |
]. |
|
3221 | 7683 |
]. |
7684 |
||
7685 |
lineWise ifTrue:[ |
|
6152 | 7686 |
"process the lines of the selection (aka a collection of lines)" |
7687 |
start == end ifTrue:[^ self ]. |
|
7688 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
7689 |
lines := operation value:lines. |
|
7690 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
|
4763 | 7691 |
] ifFalse:[ |
6152 | 7692 |
"process the whole selection as a string" |
7693 |
s := self selectionAsString. |
|
7694 |
words := s asCollectionOfWords. |
|
7695 |
words := operation value:words. |
|
7696 |
s := words asStringCollection asStringWith:Character space. |
|
7697 |
self replace:s. |
|
4763 | 7698 |
]. |
3221 | 7699 |
self textChanged. |
4373 | 7700 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7701 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7702 |
! |
7703 |
||
7704 |
sortSelection:how ignoreCase:ignoreCase |
|
7705 |
"sort the selected lines" |
|
7706 |
||
7707 |
|start end| |
|
7708 |
||
7709 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7710 |
||
7711 |
start := selectionStartLine. |
|
7712 |
end := selectionEndLine. |
|
7713 |
(selectionEndCol == 0) ifTrue:[ |
|
6152 | 7714 |
end := end - 1 |
3221 | 7715 |
]. |
7716 |
||
7717 |
self |
|
6152 | 7718 |
undoableDo:[ |
7719 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7720 |
] |
|
7721 |
info:'Sort' |
|
4373 | 7722 |
|
7723 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7724 |
! |
7725 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7726 |
specialCharacters |
2915 | 7727 |
CharacterSetView |
6152 | 7728 |
openAsInputFor:self |
7729 |
label:'Special Character Input' |
|
7730 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7731 |
! |
7732 |
||
5370 | 7733 |
splitLinesAtCharacterOrString |
7734 |
"ask user for the character and split after it" |
|
7735 |
||
7736 |
|sel in out separator record| |
|
7737 |
||
7738 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7739 |
||
7740 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7741 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7742 |
||
7743 |
sel := self selectionAsString. |
|
7744 |
in := sel readStream. |
|
5887 | 7745 |
out := CharacterWriteStream on:''. |
5370 | 7746 |
[in atEnd] whileFalse:[ |
5887 | 7747 |
record := in throughAll:separator. |
7748 |
out nextPutLine:record. |
|
5370 | 7749 |
]. |
7750 |
self |
|
5887 | 7751 |
undoableDo:[ |
7752 |
self replaceSelectionBy:(out contents). |
|
7753 |
] |
|
7754 |
info:'Split Selection' |
|
5370 | 7755 |
! |
7756 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7757 |
undoablePaste:someText |
3495 | 7758 |
self undoablePaste:someText info:nil. |
7759 |
||
7760 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7761 |
! |
|
7762 |
||
7763 |
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
|
7764 |
self |
6152 | 7765 |
undoableDo:[ |
7766 |
self paste:someText. |
|
7767 |
] |
|
7768 |
info:infoOrNil |
|
3495 | 7769 |
|
7770 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7771 |
! |
|
7772 |
||
6134 | 7773 |
undoablePasteBox:someText |
7774 |
self undoablePasteBox:someText info:nil. |
|
7775 |
||
7776 |
"Created: / 14-03-2017 / 16:34:31 / cg" |
|
7777 |
! |
|
7778 |
||
7779 |
undoablePasteBox:someText info:infoOrNil |
|
7780 |
self |
|
7781 |
undoableDo:[ |
|
7782 |
self pasteBox:someText. |
|
7783 |
] |
|
7784 |
info:infoOrNil |
|
7785 |
||
7786 |
"Created: / 14-03-2017 / 16:34:55 / cg" |
|
7787 |
! |
|
7788 |
||
3495 | 7789 |
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
|
7790 |
self |
6152 | 7791 |
undoableDo:[ |
7792 |
self pasteOrReplace:someText. |
|
7793 |
] |
|
7794 |
info:infoOrNil |
|
3495 | 7795 |
|
7796 |
"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
|
7797 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7798 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7799 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7800 |
self |
6152 | 7801 |
undoableDo:[ |
7802 |
self selectAll. |
|
7803 |
self pasteOrReplace:someText. |
|
7804 |
] |
|
7805 |
info:infoOrNil |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7806 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7807 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7808 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7809 |
|
2724 | 7810 |
withSelfAndTextForPasteDo:aBlock |
7811 |
"common code for paste/replace of the copybuffer" |
|
7812 |
||
7813 |
|sel| |
|
7814 |
||
7815 |
self checkModificationsAllowed ifFalse:[ |
|
6152 | 7816 |
self flashReadOnly. |
7817 |
^ self |
|
2724 | 7818 |
]. |
7819 |
||
7820 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7821 |
sel notNil ifTrue:[ |
|
6152 | 7822 |
aBlock value:self value:sel. |
2724 | 7823 |
] |
105 | 7824 |
! ! |
7825 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7826 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7827 |
|
3880 | 7828 |
beep |
5244 | 7829 |
"output an audible beep or bell on my screen device" |
7830 |
||
5787 | 7831 |
UserPreferences current beepInEditor ifTrue:[ |
6152 | 7832 |
super beep |
3880 | 7833 |
] |
7834 |
! |
|
7835 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7836 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7837 |
"check if the text can be modified (i.e. is not readOnly). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7838 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7839 |
This block should be provided by the application or user of the textView, |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7840 |
and may show a warnBox or whatever." |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7841 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7842 |
self isReadOnly ifTrue: [ |
6152 | 7843 |
exceptionBlock isNil ifTrue:[ |
7844 |
^ false |
|
7845 |
]. |
|
7846 |
||
7847 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7848 |
^ false |
|
7849 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7850 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7851 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7852 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7853 |
"Modified: / 17.6.1998 / 15:51:10 / cg" |
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7854 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7855 |
|
2596 | 7856 |
currentSelectionBgColor |
7857 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 7858 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
5787 | 7859 |
]. |
7860 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
|
2596 | 7861 |
^ super currentSelectionBgColor |
7862 |
||
7863 |
" |
|
7864 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7865 |
" |
|
7866 |
! |
|
7867 |
||
7868 |
currentSelectionFgColor |
|
7869 |
typeOfSelection == #paste ifTrue:[ |
|
6152 | 7870 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7871 |
]. |
7872 |
^ super currentSelectionFgColor |
|
7873 |
! |
|
7874 |
||
3996 | 7875 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7876 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7877 |
|
7878 |
super resetVariablesBeforeNewSearch. |
|
7879 |
||
7880 |
"/ new search invalidates remembered string |
|
4048 | 7881 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7882 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7883 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7884 |
! |
7885 |
||
4053 | 7886 |
setLastStringToReplace: aString |
7887 |
||
7888 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7889 |
||
7890 |
|lastReplaceIgnoredCase| |
|
7891 |
||
4064 | 7892 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7893 |
self clearSearchAction. |
|
7894 |
||
4053 | 7895 |
lastReplacementInfo lastStringToReplace: aString. |
7896 |
lastStringFromReplaceForNextSearch := aString. |
|
7897 |
||
7898 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
5787 | 7899 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
6152 | 7900 |
ifTrue: [lastSearchIgnoredCase] |
7901 |
ifFalse: [nil]. |
|
4053 | 7902 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7903 |
! |
|
7904 |
||
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7905 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7906 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7907 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7908 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7909 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7910 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7911 |
textChanged |
522 | 7912 |
"my text was modified (internally). |
7913 |
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
|
7914 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7915 |
is used to notify scrollers, other views etc.). |
7916 |
||
5979 | 7917 |
As some authors of this code have been very sloppy in the past |
4635 | 7918 |
(not sending contentsChanged, but textChanged), |
7919 |
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
|
7920 |
|
641 | 7921 |
self contentsChanged. |
1015 | 7922 |
self modified:true. |
5774 | 7923 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7924 |
contentsWasSaved := false |
641 | 7925 |
|
1015 | 7926 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7927 |
! |
7928 |
||
2617 | 7929 |
textChangedButNoSizeChange |
2207 | 7930 |
"my text was modified (internally). |
7931 |
Sent whenever text has been edited (not to confuse with |
|
7932 |
contentsChanged, which is triggered when the size has changed, and |
|
7933 |
is used to notify scrollers, other views etc.)" |
|
7934 |
||
7935 |
self modified:true. |
|
7936 |
contentsWasSaved := false |
|
7937 |
||
7938 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7939 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7940 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7941 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7942 |
|
5216 | 7943 |
canAccept |
7944 |
"true if text can be accepts. |
|
7945 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7946 |
||
7947 |
^ acceptEnabled ~~ false |
|
7948 |
! |
|
7949 |
||
7950 |
canCut |
|
7951 |
"true if there is a selection possibly to be cut. |
|
7952 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7953 |
||
7954 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7955 |
^ self hasSelection |
|
7956 |
! |
|
7957 |
||
7958 |
canDoAgain |
|
7959 |
"true if there is a possible repeat last edit operation. |
|
7960 |
Used to disable the menu if there is nothing" |
|
7961 |
||
7962 |
self isReadOnly ifTrue:[ ^ false ]. |
|
5972 | 7963 |
^ lastReplacementInfo lastStringToReplace notNil |
7964 |
||
7965 |
"Modified: / 19-11-2016 / 20:19:02 / cg" |
|
5216 | 7966 |
! |
7967 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7968 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7969 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7970 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7971 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7972 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7973 |
"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
|
7974 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7975 |
|
4064 | 7976 |
hasSearchActionSelection |
7977 |
||
7978 |
^ typeOfSelection == #searchAction |
|
7979 |
! |
|
7980 |
||
1878 | 7981 |
isKeyboardConsumer |
7982 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 7983 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 7984 |
|
3476 | 7985 |
^ self isReadOnly not |
1878 | 7986 |
! |
7987 |
||
997 | 7988 |
specClass |
1390 | 7989 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7990 |
||
997 | 7991 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7992 |
^ super specClass |
7993 |
||
1390 | 7994 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7995 |
! |
7996 |
||
324 | 7997 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7998 |
"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
|
7999 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8000 |
"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
|
8001 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8002 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 8003 |
|
8004 |
"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
|
8005 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8006 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8007 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8008 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8009 |
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
|
8010 |
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
|
8011 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8012 |
|
697 | 8013 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8014 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8015 |
w := super widthOfContents. |
5643 | 8016 |
(dev := device ) isNil ifTrue:[ |
6152 | 8017 |
"/ really don't know ... |
8018 |
dev := Screen current |
|
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
8019 |
]. |
4889 | 8020 |
^ w + (gc font widthOn:dev) |
697 | 8021 |
|
8022 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8023 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8024 |
|
1588 | 8025 |
!EditTextView methodsFor:'realization'! |
8026 |
||
8027 |
realize |
|
8028 |
"make the view visible - scroll to make the cursor visible." |
|
8029 |
||
8030 |
super realize. |
|
8031 |
||
8032 |
self makeCursorVisible. |
|
5643 | 8033 |
cursorFgColor := cursorFgColor onDevice:device. |
8034 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 8035 |
|
8036 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
8037 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
8038 |
! ! |
|
8039 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8040 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8041 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8042 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8043 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8044 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8045 |
cursorShown ifTrue:[ |
6152 | 8046 |
cursorVisibleLine notNil ifTrue:[ |
8047 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
8048 |
self drawCursorCharacter |
|
8049 |
] |
|
8050 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8051 |
] |
105 | 8052 |
! |
8053 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8054 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8055 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8056 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8057 |
cursorShown ifTrue:[ |
6152 | 8058 |
(visLine == cursorVisibleLine) ifTrue:[ |
8059 |
self drawCursorCharacter |
|
8060 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8061 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8062 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8063 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8064 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8065 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8066 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8067 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8068 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8069 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8070 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8071 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8072 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8073 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8074 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8075 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8076 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8077 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8078 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8079 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8080 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8081 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8082 |
cursorShown ifTrue:[ |
6152 | 8083 |
(visLine == cursorVisibleLine) ifTrue:[ |
8084 |
(colNr == cursorCol) ifTrue:[ |
|
8085 |
self drawCursorCharacter. |
|
8086 |
^ self |
|
8087 |
] |
|
8088 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8089 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8090 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8091 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8092 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8093 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8094 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8095 |
"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
|
8096 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8097 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 8098 |
cursorShown ifTrue:[ |
6152 | 8099 |
self redrawCursorIfInVisibleLine:visLine |
4494 | 8100 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8101 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8102 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8103 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8104 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8105 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8106 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8107 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8108 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8109 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8110 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8111 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8112 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8113 |
"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
|
8114 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8115 |
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
|
8116 |
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
|
8117 |
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
|
8118 |
|
4889 | 8119 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8120 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8121 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8122 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8123 |
"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
|
8124 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8125 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8126 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8127 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8128 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8129 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8130 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8131 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8132 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8133 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8134 |
"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
|
8135 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8136 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8137 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8138 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8139 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8140 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8141 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8142 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8143 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8144 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8145 |
"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
|
8146 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8147 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8148 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8149 |
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
|
8150 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
8151 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8152 |
prevCursorState ifTrue:[ |
6152 | 8153 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8154 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8155 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8156 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8157 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8158 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8159 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8160 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8161 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8162 |
prevCursorState := cursorShown. |
1601 | 8163 |
"/ cursorShown := false. |
1591 | 8164 |
cursorShown ifTrue:[ |
6152 | 8165 |
self hideCursor |
1591 | 8166 |
] |
8167 |
||
1601 | 8168 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8169 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8170 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8171 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8172 |
"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
|
8173 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8174 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8175 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8176 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8177 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8178 |
super pageDown. |
6184 | 8179 |
prevCursorLine notNil ifTrue:[ |
8180 |
"https://expeccoalm.exept.de/D204551" |
|
8181 |
self cursorVisibleLine:prevCursorLine col:cursorCol. |
|
8182 |
]. |
|
8183 |
||
8184 |
"Modified: / 18-07-2017 / 12:31:47 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8185 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8186 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8187 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8188 |
"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
|
8189 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8190 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8191 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8192 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8193 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8194 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8195 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8196 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8197 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8198 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8199 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8200 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8201 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8202 |
|
2822 | 8203 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8204 |
! |
8205 |
||
8206 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8207 |
"do a backward search" |
|
8208 |
||
8209 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8210 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8211 |
! |
8212 |
||
8213 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8214 |
"do a backward search" |
|
8215 |
||
8216 |
cursorLine isNil ifTrue:[^ self]. |
|
8217 |
||
3160 | 8218 |
self |
6152 | 8219 |
searchBackwardFor:pattern |
8220 |
ignoreCase:ign |
|
8221 |
startingAtLine:startLine col:startCol |
|
8222 |
ifFound:[:line :col :endColOrNil | |
|
8223 |
self cursorMovementAllowed ifTrue:[ |
|
8224 |
self cursorLine:line col:col. |
|
8225 |
]. |
|
8226 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
|
1339 | 8227 |
"/ self makeLineVisible:cursorLine |
6152 | 8228 |
typeOfSelection := #search] |
8229 |
ifAbsent:aBlock |
|
1339 | 8230 |
|
8231 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8232 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8233 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8234 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8235 |
"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
|
8236 |
|
2554 | 8237 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8238 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8239 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8240 |
searchForMatchingParenthesis |
3160 | 8241 |
"search for a matching parenthesis starting at cursor position. |
6096 | 8242 |
Search for the corresponding character is done forward if it's an opening, |
8243 |
backwards if it's a closing parenthesis. |
|
8244 |
Positions the cursor if found, beeps if not" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8245 |
|
2822 | 8246 |
self cursorMovementAllowed ifFalse:[^ self]. |
8247 |
||
3160 | 8248 |
self |
6096 | 8249 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8250 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8251 |
ifNotFound:[self showNotFound] |
|
8252 |
onError:[self beep] |
|
8253 |
||
8254 |
"Modified: / 09-10-1997 / 12:56:30 / cg" |
|
8255 |
"Modified (comment): / 13-02-2017 / 20:10:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8256 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8257 |
|
3967 | 8258 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8259 |
"do a forward search" |
8260 |
||
8261 |
cursorLine isNil ifTrue:[^ self]. |
|
5787 | 8262 |
self |
6152 | 8263 |
searchForwardFor:pattern |
8264 |
ignoreCase:ign |
|
8265 |
match: match |
|
8266 |
startingAtLine:startLine col:startCol |
|
8267 |
ifFound:[:line :col :endColOrNil| |
|
8268 |
self cursorMovementAllowed ifTrue:[ |
|
8269 |
self cursorLine:line col:col. |
|
8270 |
]. |
|
8271 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
|
1339 | 8272 |
"/ self makeLineVisible:cursorLine |
6152 | 8273 |
typeOfSelection := #search |
8274 |
] |
|
8275 |
ifAbsent:aBlock |
|
1339 | 8276 |
|
8277 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8278 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8279 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8280 |
|
3967 | 8281 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8282 |
"do a forward search" |
|
8283 |
||
8284 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8285 |
! |
|
8286 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8287 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8288 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8289 |
|
2822 | 8290 |
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
|
8291 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8292 |
|
3982 | 8293 |
searchPatternForSearchBar |
8294 |
||
8295 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8296 |
||
8297 |
|searchPattern| |
|
8298 |
||
4138 | 8299 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
5787 | 8300 |
searchPattern isNil |
6152 | 8301 |
ifTrue: [searchPattern := lastSearchPattern] |
8302 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
3982 | 8303 |
^ searchPattern |
8304 |
! |
|
8305 |
||
3578 | 8306 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8307 |
"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
|
8308 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8309 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8310 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8311 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8312 |
"/ |
3967 | 8313 |
"/ 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
|
8314 |
"/ original string (for search after again) |
4121 | 8315 |
"/ 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
|
8316 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8317 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8318 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8319 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8320 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8321 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8322 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8323 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8324 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8325 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8326 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8327 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8328 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8329 |
"/ 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
|
8330 |
"/ if there was a previous search, only take the selection if |
3967 | 8331 |
"/ 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
|
8332 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8333 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8334 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8335 |
sel notNil ifTrue:[ |
6152 | 8336 |
(lastSearchPattern isNil |
8337 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
|
8338 |
) ifTrue:[ |
|
8339 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8340 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8341 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8342 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8343 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8344 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8345 |
"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
|
8346 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8347 |
|
5717 | 8348 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8349 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8350 |
typeOfSelection := #search. |
8351 |
! |
|
8352 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8353 |
startPositionForSearchBackward |
2822 | 8354 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8355 |
! |
|
8356 |
||
8357 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8358 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8359 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8360 |
selectionStartLine notNil ifTrue:[ |
6152 | 8361 |
startLine := selectionStartLine. |
8362 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8363 |
] ifFalse:[ |
6152 | 8364 |
cursorLine isNil ifTrue:[ |
8365 |
startLine := list size. |
|
8366 |
startCol := self listAt:startLine size. |
|
8367 |
] ifFalse:[ |
|
8368 |
startLine := cursorLine min:list size. |
|
8369 |
startCol := cursorCol |
|
8370 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8371 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8372 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8373 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8374 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8375 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8376 |
startPositionForSearchForward |
2822 | 8377 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8378 |
! |
|
8379 |
||
8380 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8381 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8382 |
|
3160 | 8383 |
"/ 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
|
8384 |
"/ 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
|
8385 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8386 |
self hasSelection ifTrue:[ |
6152 | 8387 |
^ selectionEndCol @ selectionEndLine. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8388 |
] ifFalse:[ |
6152 | 8389 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8390 |
startCol := 0 |
|
8391 |
]. |
|
8392 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8393 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8394 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8395 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8396 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8397 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8398 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8399 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8400 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8401 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8402 |
addToSelectionAfter:aBlock |
5145 | 8403 |
<resource: #obsolete> |
8404 |
||
8405 |
"evaluate aBlock while unselected. |
|
8406 |
Restore the previous selection afterwards. |
|
8407 |
CG: I am not sure, if this is a leftover and is still used at all. |
|
6152 | 8408 |
It is therefore temporarily marked as obsolete. Please check |
8409 |
and let me know." |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8410 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8411 |
|startLine startCol endLine endCol | |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8412 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8413 |
self hasSelection ifTrue: [ |
6152 | 8414 |
startLine := selectionStartLine . |
8415 |
startCol := selectionStartCol . |
|
8416 |
endLine := selectionEndLine . |
|
8417 |
endCol := selectionEndCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8418 |
] ifFalse: [ |
6152 | 8419 |
startLine := endLine := cursorLine . |
8420 |
startCol := endCol := cursorCol . |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8421 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8422 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8423 |
"deselectim a provedu presun kurzoru..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8424 |
self unselect . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8425 |
aBlock value . |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8426 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8427 |
"funguje dost mizerne, jen na jednom radku..." |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8428 |
(startCol - cursorCol) abs <= (endCol - cursorCol) abs |
6152 | 8429 |
ifTrue: [ |
8430 |
startCol := cursorCol. |
|
8431 |
] ifFalse: [ |
|
8432 |
endCol := cursorCol - 1. |
|
8433 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8434 |
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
|
8435 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8436 |
|
1850 | 8437 |
autoMoveCursorToEndOfSelection |
8438 |
"return true, if the cursor should be automatically moved to the |
|
8439 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8440 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8441 |
not be affected by selecting" |
8442 |
||
8443 |
^ true |
|
8444 |
! |
|
8445 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8446 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8447 |
typeOfSelection ~~ newType ifTrue:[ |
6152 | 8448 |
typeOfSelection := newType. |
8449 |
selectionStartLine notNil ifTrue:[ |
|
8450 |
self |
|
8451 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8452 |
toLine:selectionEndLine col:selectionEndCol |
|
8453 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8454 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8455 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8456 |
|
4707 | 8457 |
findNextWordAfterSelectionAndAddToSelection |
8458 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8459 |
||
8460 |
selectionStartCol isNil ifTrue:[ |
|
6152 | 8461 |
self selectWordUnderCursor. |
8462 |
^ self |
|
4707 | 8463 |
]. |
8464 |
||
8465 |
selStartCol := selectionStartCol. |
|
8466 |
selEndCol := selectionEndCol. |
|
8467 |
selStartLine := selectionStartLine. |
|
8468 |
selEndLine := selectionEndLine. |
|
8469 |
||
8470 |
self cursorToNextWord. |
|
8471 |
self selectWordUnderCursor. |
|
8472 |
||
8473 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8474 |
! |
|
8475 |
||
4138 | 8476 |
searchPatternFromUserSelectionOrReplace |
8477 |
||
8478 |
|sel searchPattern| |
|
8479 |
||
8480 |
"/ |
|
8481 |
"/ if the last operation was a replace, set pattern to last |
|
8482 |
"/ original string (for search after again) |
|
8483 |
"/ |
|
8484 |
(lastStringFromReplaceForNextSearch notNil |
|
8485 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
6152 | 8486 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
8487 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8488 |
] ifFalse:[ |
|
8489 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8490 |
]. |
|
8491 |
^ searchPattern |
|
4138 | 8492 |
]. |
8493 |
||
8494 |
"/ |
|
8495 |
"/ if there is a selection: |
|
8496 |
"/ if there was no previous search, take it as search pattern. |
|
8497 |
"/ if there was a previous search, only take the selection if |
|
8498 |
"/ it did not result from a paste. |
|
8499 |
"/ (to allow search-paste to be repeated) |
|
8500 |
"/ |
|
8501 |
sel := self selection. |
|
8502 |
sel notNil ifTrue:[ |
|
6152 | 8503 |
typeOfSelection ~~ #search ifTrue:[ |
8504 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8505 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8506 |
searchPattern := sel asStringWithoutFinalCR. |
|
8507 |
] |
|
8508 |
]. |
|
4138 | 8509 |
]. |
8510 |
||
8511 |
^ searchPattern |
|
8512 |
! |
|
8513 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8514 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8515 |
"select the whole text. |
5593 | 8516 |
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
|
8517 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8518 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8519 |
list isNil ifTrue:[ |
6152 | 8520 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8521 |
] ifFalse:[ |
6152 | 8522 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8523 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8524 |
] |
1082 | 8525 |
|
8526 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8527 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8528 |
|
4117 | 8529 |
selectAllInitially |
8530 |
"select the whole text. This is called only once during the initialization |
|
8531 |
for editFields which are shown in a table or tree. |
|
8532 |
The selectAll is called via this method to allow for easier redefinition and |
|
8533 |
to distinguish auto-select from user-initiated selects." |
|
8534 |
||
8535 |
self selectAll |
|
8536 |
! |
|
8537 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8538 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8539 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8540 |
|
3160 | 8541 |
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
|
8542 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8543 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8544 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8545 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8546 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8547 |
cursorCol > 1 ifTrue:[ |
6152 | 8548 |
self selectFromLine:cursorLine col:1 |
8549 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8550 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8551 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8552 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8553 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8554 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8555 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8556 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8557 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8558 |
selectionStartLine isNil ifTrue:[ |
6152 | 8559 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8560 |
] ifFalse:[ |
6152 | 8561 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8562 |
toLine:cursorLine+1 col:0. |
|
8563 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8564 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8565 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8566 |
|
4257 | 8567 |
selectFromBeginOfLine |
8568 |
"select the text from the beginning of the current line to the current cursor position." |
|
8569 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8570 |
| newCursorCol ln | |
4271 | 8571 |
|
4257 | 8572 |
list isNil ifTrue:[ |
6152 | 8573 |
self unselect |
4257 | 8574 |
] ifFalse:[ |
6152 | 8575 |
cursorCol > 1 ifTrue:[ |
8576 |
ln := list at: cursorLine. |
|
8577 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
|
8578 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
|
6207 | 8579 |
"/ cursorCol := newCursorCol. |
8580 |
self setCursorCol:newCursorCol. |
|
6152 | 8581 |
typeOfSelection := nil |
8582 |
] |
|
4257 | 8583 |
] |
8584 |
||
8585 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8586 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8587 |
! |
8588 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8589 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8590 |
"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
|
8591 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8592 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8593 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8594 |
list isNil ifTrue:[ |
6152 | 8595 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8596 |
] ifFalse:[ |
6152 | 8597 |
cursorCol == 0 ifTrue:[ |
8598 |
col := 0 |
|
8599 |
] ifFalse:[ |
|
8600 |
col := cursorCol - 1 |
|
8601 |
]. |
|
8602 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8603 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8604 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8605 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8606 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8607 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8608 |
"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
|
8609 |
for easier editing. Also typeOfSelection is nilled here." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8610 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8611 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
1850 | 8612 |
(selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
6152 | 8613 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
1198 | 8614 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8615 |
typeOfSelection := nil |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8616 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8617 |
|
4257 | 8618 |
selectToEndOfLine |
8619 |
"select the text from the current cursor position to the end of the current line" |
|
8620 |
||
4271 | 8621 |
| newCursorCol line | |
8622 |
||
4257 | 8623 |
list isNil ifTrue:[ |
6152 | 8624 |
self unselect |
4257 | 8625 |
] ifFalse:[ |
6152 | 8626 |
cursorCol >= 1 ifTrue:[ |
8627 |
line := list at: cursorLine. |
|
8628 |
newCursorCol := line size. |
|
8629 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8630 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8631 |
||
8632 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
6207 | 8633 |
"/ cursorCol := newCursorCol. |
8634 |
self setCursorCol:newCursorCol. |
|
6152 | 8635 |
typeOfSelection := nil |
8636 |
] |
|
4257 | 8637 |
] |
8638 |
||
8639 |
"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
|
8640 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8641 |
! |
8642 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8643 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8644 |
"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
|
8645 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8646 |
list isNil ifTrue:[ |
6152 | 8647 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8648 |
] ifFalse:[ |
6152 | 8649 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8650 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8651 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8652 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8653 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8654 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8655 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8656 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8657 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8658 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8659 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8660 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8661 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8662 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8663 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8664 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8665 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8666 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8667 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8668 |
wasOn ifTrue:[self showCursor] |
105 | 8669 |
! ! |
8670 |
||
8671 |
!EditTextView methodsFor:'undo & again'! |
|
8672 |
||
2952 | 8673 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8674 |
^ undoSupport addUndo:action. |
2952 | 8675 |
! |
8676 |
||
105 | 8677 |
again |
8678 |
"repeat the last action (which was a cut or replace). |
|
8679 |
If current selection is not last string, search forward to |
|
3160 | 8680 |
next occurrence of it before repeating the last operation." |
105 | 8681 |
|
5787 | 8682 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8683 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8684 |
|
8685 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8686 |
lastStringToReplace isNil ifTrue:[ |
6152 | 8687 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8688 |
]. |
4048 | 8689 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8690 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8691 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8692 |
self undoableDo:[ |
6152 | 8693 |
s := lastStringToReplace asString. |
8694 |
"remove final cr" |
|
8695 |
(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
|
8696 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8697 |
|
6152 | 8698 |
"set lastStringToReplace as the next search string |
8699 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
8700 |
lastStringFromReplaceForNextSearch := s. |
|
8701 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
|
8702 |
||
8703 |
savedSelectStyle := selectStyle. |
|
8704 |
selectStyle := nil. |
|
8705 |
||
8706 |
sel := self selection. |
|
8707 |
||
6156 | 8708 |
"if we are already there (after a find), omit search" |
6152 | 8709 |
|
8710 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
|
8711 |
l := selectionStartLine "cursorLine". |
|
8712 |
c := selectionStartCol "cursorCol". |
|
8713 |
self deleteSelection. |
|
8714 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
8715 |
self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false. |
|
8716 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
|
8717 |
typeOfSelection := #paste |
|
8718 |
]. |
|
8719 |
selectStyle := savedSelectStyle. |
|
8720 |
^ true |
|
8721 |
]. |
|
8722 |
||
8723 |
sel isEmptyOrNil ifTrue:[ |
|
8724 |
startColForSearch := cursorCol - 1 |
|
8725 |
] ifFalse:[ |
|
8726 |
startColForSearch := selectionEndCol ? (cursorCol - 1) |
|
8727 |
]. |
|
8728 |
self |
|
8729 |
searchForwardFor:s |
|
8730 |
ignoreCase: lastReplaceIgnoredCase |
|
8731 |
match: lastReplaceWasMatch |
|
8732 |
startingAtLine:cursorLine col:startColForSearch |
|
8733 |
ifFound: |
|
8734 |
[ |
|
8735 |
:line :col | |
|
8736 |
||
8737 |
|repl| |
|
8738 |
||
8739 |
self selectFromLine:line col:col |
|
8740 |
toLine:line col:(col + s size - 1). |
|
8741 |
self makeLineVisible:line. |
|
8742 |
||
8743 |
self deleteSelection. |
|
8744 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
|
8745 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8746 |
repl := lastReplacementInfo lastReplacement asString "withoutSpaces" |
|
8747 |
] ifTrue:[ |
|
8748 |
repl := lastReplacementInfo lastReplacement "withoutSpaces". |
|
8749 |
]. |
|
8750 |
self insertLines:repl asStringCollection withCR:false. |
|
8751 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
|
8752 |
undoSupport actionInfo:'replace'. |
|
8753 |
]. |
|
8754 |
selectStyle := savedSelectStyle. |
|
8755 |
typeOfSelection := #paste. |
|
8756 |
^ true |
|
8757 |
] |
|
8758 |
ifAbsent: |
|
8759 |
[ |
|
8760 |
self sensor compressKeyPressEventsWithKey:#Again. |
|
8761 |
self showNotFound. |
|
8762 |
selectStyle := savedSelectStyle. |
|
8763 |
^ false |
|
8764 |
]. |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8765 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8766 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8767 |
^ true. |
501 | 8768 |
|
6156 | 8769 |
"Modified: / 09-10-1996 / 16:14:11 / cg" |
8770 |
"Modified (comment): / 17-05-2017 / 16:19:32 / mawalch" |
|
105 | 8771 |
! |
8772 |
||
2952 | 8773 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8774 |
^ undoSupport hasRedoAction. |
2952 | 8775 |
! |
8776 |
||
8777 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8778 |
^ undoSupport hasUndoAction. |
2952 | 8779 |
! |
8780 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8781 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8782 |
"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
|
8783 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8784 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8785 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8786 |
|
2952 | 8787 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8788 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8789 |
! |
8790 |
||
8791 |
redo |
|
3780 | 8792 |
"undo the last undo" |
8793 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8794 |
undoSupport hasRedoAction ifFalse:[ |
6152 | 8795 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8796 |
] ifTrue:[ |
6152 | 8797 |
undoSupport redo. |
2952 | 8798 |
] |
8799 |
! |
|
8800 |
||
121 | 8801 |
undo |
3780 | 8802 |
"undo the last edit operation" |
8803 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8804 |
undoSupport hasUndoAction ifFalse:[ |
5834 | 8805 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8806 |
] ifTrue:[ |
5834 | 8807 |
undoSupport undo. |
8808 |
self makeSelectionVisible. |
|
8809 |
self makeCursorVisible. |
|
121 | 8810 |
] |
2952 | 8811 |
! |
8812 |
||
8813 |
undoableDo:aBlock |
|
3495 | 8814 |
self undoableDo:aBlock info:nil. |
8815 |
||
8816 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8817 |
! |
8818 |
||
8819 |
undoableDo:aBlock info:aString |
|
5689 | 8820 |
|selectionRestore| |
8821 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8822 |
self checkModificationsAllowed ifFalse:[ |
6152 | 8823 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8824 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8825 |
] ifTrue:[ |
6152 | 8826 |
undoSupport isInTransaction ifFalse:[ |
8827 |
selectionRestore := RestoreSelectionAndCursor new |
|
8828 |
cursorLine:cursorLine cursorCol:cursorCol |
|
8829 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
8830 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
8831 |
info:nil. |
|
8832 |
]. |
|
8833 |
undoSupport |
|
8834 |
undoableDo:[ |
|
8835 |
aBlock value. |
|
8836 |
selectionRestore notNil ifTrue:[ |
|
8837 |
undoSupport transactionNotEmpty ifTrue:[ |
|
8838 |
undoSupport addUndoFirst:selectionRestore |
|
8839 |
]. |
|
8840 |
]. |
|
8841 |
] |
|
8842 |
info:aString. |
|
5689 | 8843 |
]. |
8844 |
||
8845 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 8846 |
! ! |
8847 |
||
8848 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8849 |
||
8850 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8851 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8852 |
! |
|
8853 |
||
3115 | 8854 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8855 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8856 |
! |
8857 |
||
2952 | 8858 |
line:arg1 col:arg2 character:arg3 |
8859 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8860 |
! |
|
8861 |
||
3115 | 8862 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8863 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8864 |
! |
8865 |
||
3235 | 8866 |
line:arg1 col:arg2 characters:arg3 info:info |
8867 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8868 |
! |
|
8869 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8870 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8871 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8872 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8873 |
|
2952 | 8874 |
line:arg1 col:arg2 string:arg3 |
8875 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8876 |
! |
8877 |
||
8878 |
line:arg1 col:arg2 string:arg3 info:info |
|
8879 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8880 |
! |
8881 |
||
8882 |
line:arg1 string:arg3 info:info |
|
8883 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8884 |
! |
8885 |
||
8886 |
text:arg info:info |
|
8887 |
^ (self new text:arg) info:info |
|
3115 | 8888 |
! ! |
8889 |
||
8890 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8891 |
||
8892 |
info |
|
8893 |
^ userFriendlyInfo |
|
8894 |
! |
|
8895 |
||
8896 |
info:aString |
|
8897 |
userFriendlyInfo := aString |
|
2952 | 8898 |
! ! |
8899 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8900 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8901 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8902 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8903 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8904 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8905 |
"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
|
8906 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8907 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8908 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8909 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8910 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8911 |
^ false |
5710 | 8912 |
! |
8913 |
||
8914 |
isRestoreSelectionAndCursor |
|
8915 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8916 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8917 |
|
2952 | 8918 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8919 |
||
3160 | 8920 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8921 |
"set instance variables (automatically generated)" |
8922 |
||
8923 |
self assert:(line1Arg notNil). |
|
8924 |
self assert:(col1Arg notNil). |
|
8925 |
self assert:(line2Arg notNil). |
|
8926 |
self assert:(col2Arg notNil). |
|
8927 |
||
8928 |
line1 := line1Arg. |
|
8929 |
col1 := col1Arg. |
|
8930 |
line2 := line2Arg. |
|
8931 |
col2 := col2Arg. |
|
8932 |
! ! |
|
8933 |
||
8934 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8935 |
||
3160 | 8936 |
executeIn:editor |
2952 | 8937 |
editor unselect. |
3160 | 8938 |
editor |
6152 | 8939 |
deleteFromLine:line1 |
8940 |
col:col1 |
|
8941 |
toLine:line2 |
|
8942 |
col:col2. |
|
2952 | 8943 |
editor cursorLine:line1 col:col1. |
8944 |
! ! |
|
8945 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8946 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8947 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8948 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8949 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8950 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8951 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8952 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8953 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8954 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8955 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8956 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8957 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8958 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8959 |
|
3160 | 8960 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8961 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8962 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8963 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8964 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8965 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8966 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8967 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8968 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8969 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8970 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8971 |
|
3160 | 8972 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8973 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8974 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8975 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8976 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8977 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8978 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8979 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8980 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8981 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8982 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8983 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8984 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8985 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8986 |
|
3160 | 8987 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8988 |
"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
|
8989 |
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
|
8990 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8991 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8992 |
previousDeleteAction line == line ifTrue:[ |
6152 | 8993 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8994 |
^ true |
|
8995 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8996 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8997 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8998 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8999 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9000 |
|
3160 | 9001 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9002 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9003 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9004 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9005 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9006 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9007 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9008 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9009 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9010 |
|
3160 | 9011 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9012 |
editor unselect. |
3160 | 9013 |
editor |
6152 | 9014 |
deleteFromLine:line |
9015 |
col:col1 |
|
9016 |
toLine:line |
|
9017 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9018 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9019 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9020 |
|
3235 | 9021 |
!EditTextView::EditMode class methodsFor:'constants'! |
9022 |
||
9023 |
insertAndSelectMode |
|
9024 |
^ InsertAndSelectMode |
|
9025 |
! |
|
9026 |
||
9027 |
insertMode |
|
9028 |
^ InsertMode |
|
9029 |
! |
|
9030 |
||
9031 |
overwriteMode |
|
9032 |
^ OverwriteMode |
|
9033 |
! ! |
|
9034 |
||
9035 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
9036 |
||
9037 |
isInsertAndSelectMode |
|
9038 |
^ false |
|
9039 |
! |
|
9040 |
||
9041 |
isInsertMode |
|
9042 |
^ false |
|
9043 |
! |
|
9044 |
||
9045 |
symbolicName |
|
9046 |
self subclassResponsibility |
|
9047 |
! ! |
|
9048 |
||
9049 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
9050 |
||
9051 |
infoPrintString |
|
9052 |
^ 'IS' |
|
9053 |
! ! |
|
9054 |
||
9055 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
9056 |
||
9057 |
isInsertAndSelectMode |
|
9058 |
^ true |
|
9059 |
! |
|
9060 |
||
9061 |
isInsertMode |
|
9062 |
^ true |
|
9063 |
! ! |
|
9064 |
||
9065 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
9066 |
||
9067 |
infoPrintString |
|
9068 |
^ 'I' |
|
9069 |
! ! |
|
9070 |
||
9071 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
9072 |
||
9073 |
isInsertMode |
|
9074 |
^ true |
|
9075 |
! ! |
|
9076 |
||
9077 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
9078 |
||
9079 |
infoPrintString |
|
9080 |
^ 'O' |
|
9081 |
! ! |
|
9082 |
||
4048 | 9083 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
9084 |
||
9085 |
lastReplaceIgnoredCase |
|
9086 |
^ lastReplaceIgnoredCase ? false |
|
9087 |
! |
|
9088 |
||
9089 |
lastReplaceIgnoredCase:something |
|
9090 |
lastReplaceIgnoredCase := something. |
|
9091 |
! |
|
9092 |
||
9093 |
lastReplaceWasMatch |
|
9094 |
^ lastReplaceWasMatch ? false |
|
9095 |
! |
|
9096 |
||
9097 |
lastReplaceWasMatch:something |
|
9098 |
lastReplaceWasMatch := something. |
|
9099 |
! |
|
9100 |
||
9101 |
lastReplacement |
|
9102 |
^ lastReplacement |
|
9103 |
! |
|
9104 |
||
9105 |
lastReplacement:something |
|
4053 | 9106 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 9107 |
lastReplacement := something. |
9108 |
! |
|
9109 |
||
9110 |
lastStringToReplace |
|
9111 |
^ lastStringToReplace |
|
9112 |
! |
|
9113 |
||
9114 |
lastStringToReplace:something |
|
9115 |
lastStringToReplace := something. |
|
4818 | 9116 |
! |
9117 |
||
9118 |
previousReplacements |
|
9119 |
^ previousReplacements ? #() |
|
9120 |
! |
|
9121 |
||
9122 |
stillCollectingInput |
|
9123 |
^ stillCollectingInput |
|
9124 |
! |
|
9125 |
||
9126 |
stillCollectingInput:aBoolean |
|
9127 |
stillCollectingInput := aBoolean. |
|
9128 |
! ! |
|
9129 |
||
9130 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9131 |
||
9132 |
rememberReplacement |
|
9133 |
"remember the previous replacement (called when a new one appears). |
|
9134 |
Mostly for the benefit of the code completion..." |
|
9135 |
||
9136 |
|oldString newString| |
|
9137 |
||
9138 |
oldString := lastStringToReplace. |
|
9139 |
newString := lastReplacement. |
|
9140 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
6152 | 9141 |
previousReplacements isNil ifTrue:[ |
9142 |
previousReplacements := OrderedCollection new. |
|
9143 |
]. |
|
9144 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9145 |
previousReplacements addFirst:(oldString -> newString). |
|
9146 |
previousReplacements size > 20 ifTrue:[ |
|
9147 |
previousReplacements removeLast. |
|
9148 |
] |
|
4818 | 9149 |
]. |
4048 | 9150 |
! ! |
9151 |
||
2952 | 9152 |
!EditTextView::PasteString methodsFor:'accessing'! |
9153 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9154 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9155 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9156 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9157 |
"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
|
9158 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9159 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9160 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9161 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9162 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9163 |
"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
|
9164 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9165 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9166 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9167 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9168 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9169 |
"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
|
9170 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9171 |
|
3160 | 9172 |
line:lineArg col:colArg string:stringArg |
2952 | 9173 |
self assert:(lineArg notNil). |
9174 |
self assert:(colArg notNil). |
|
9175 |
self assert:(stringArg notNil). |
|
9176 |
||
9177 |
line := lineArg. |
|
9178 |
col := colArg. |
|
9179 |
string := stringArg. |
|
9180 |
! |
|
9181 |
||
9182 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9183 |
self assert:(lineArg notNil). |
|
9184 |
self assert:(colArg notNil). |
|
9185 |
self assert:(stringArg notNil). |
|
9186 |
||
9187 |
line := lineArg. |
|
9188 |
col := colArg. |
|
9189 |
string := stringArg. |
|
9190 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9191 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9192 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9193 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9194 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9195 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9196 |
"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
|
9197 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9198 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9199 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9200 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9201 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9202 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9203 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9204 |
"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
|
9205 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9206 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9207 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9208 |
"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
|
9209 |
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
|
9210 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9211 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9212 |
previousPasteAction line == line ifTrue:[ |
6152 | 9213 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9214 |
^ true |
|
9215 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9216 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9217 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9218 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9219 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9220 |
"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
|
9221 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9222 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9223 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9224 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9225 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9226 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9227 |
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
|
9228 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9229 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9230 |
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
|
9231 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9232 |
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
|
9233 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9234 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9235 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9236 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9237 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9238 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9239 |
! ! |
9240 |
||
9241 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9242 |
||
3160 | 9243 |
executeIn:editor |
2952 | 9244 |
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
|
9245 |
editor paste:string. |
2952 | 9246 |
selected ~~ true ifTrue:[ |
6152 | 9247 |
editor unselect |
2952 | 9248 |
]. |
9249 |
! ! |
|
9250 |
||
9251 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9252 |
||
3235 | 9253 |
col |
9254 |
^ col |
|
9255 |
! |
|
9256 |
||
9257 |
col1 |
|
9258 |
^ col |
|
9259 |
! |
|
9260 |
||
9261 |
col2 |
|
9262 |
^ col |
|
9263 |
! |
|
9264 |
||
9265 |
line |
|
9266 |
^ line |
|
9267 |
! |
|
9268 |
||
3160 | 9269 |
line:lineArg col:colArg character:characterArg |
2952 | 9270 |
line := lineArg. |
9271 |
col := colArg. |
|
9272 |
character := characterArg. |
|
9273 |
! ! |
|
9274 |
||
9275 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9276 |
||
3160 | 9277 |
executeIn:editor |
9278 |
editor |
|
6152 | 9279 |
replace:character |
9280 |
atLine:line |
|
9281 |
col:col. |
|
2952 | 9282 |
editor cursorLine:line col:col. |
105 | 9283 |
! ! |
9284 |
||
3235 | 9285 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9286 |
||
9287 |
characters |
|
9288 |
^ characters |
|
9289 |
! |
|
9290 |
||
9291 |
col1 |
|
9292 |
^ col1 |
|
9293 |
! |
|
9294 |
||
9295 |
col2 |
|
9296 |
^ col2 |
|
9297 |
! |
|
9298 |
||
9299 |
line |
|
9300 |
^ line |
|
9301 |
! |
|
9302 |
||
9303 |
line:lineArg col:colArg character:characterArg |
|
9304 |
line := lineArg. |
|
9305 |
col1 := col2 := colArg. |
|
9306 |
characters := characterArg asString. |
|
9307 |
! |
|
9308 |
||
9309 |
line:lineArg col:colArg characters:charactersArg |
|
9310 |
line := lineArg. |
|
9311 |
col1 := colArg. |
|
9312 |
characters := charactersArg asString. |
|
9313 |
col2 := col1 + charactersArg size - 1 |
|
9314 |
! ! |
|
9315 |
||
9316 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9317 |
||
9318 |
canCombineWithNext:anotherAction |
|
9319 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9320 |
! |
|
9321 |
||
9322 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9323 |
"I will combine only if we both are single character deletes, |
|
9324 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9325 |
(i.e. single-character typing)" |
|
9326 |
||
9327 |
previousReplaceAction line == line ifTrue:[ |
|
6152 | 9328 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9329 |
^ true |
|
9330 |
]. |
|
3235 | 9331 |
]. |
9332 |
||
9333 |
^ false |
|
9334 |
! |
|
9335 |
||
9336 |
combineWithNext:nextReplaceAction |
|
9337 |
self assert:(line == nextReplaceAction line). |
|
9338 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9339 |
||
9340 |
col2 := nextReplaceAction col2. |
|
9341 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9342 |
characters := characters , nextReplaceAction characters. |
|
9343 |
! ! |
|
9344 |
||
9345 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9346 |
||
9347 |
executeIn:editor |
|
9348 |
editor |
|
6152 | 9349 |
replaceString:characters |
9350 |
atLine:line |
|
9351 |
col:col1. |
|
3235 | 9352 |
editor cursorLine:line col:col1. |
9353 |
! ! |
|
9354 |
||
3131 | 9355 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9356 |
||
9357 |
text:something |
|
9358 |
text := something. |
|
9359 |
! ! |
|
9360 |
||
9361 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9362 |
||
3160 | 9363 |
executeIn:editor |
3131 | 9364 |
editor contents:text |
9365 |
! ! |
|
9366 |
||
3130 | 9367 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9368 |
||
3160 | 9369 |
line:lineArg string:stringArg |
3130 | 9370 |
line := lineArg. |
9371 |
text := stringArg. |
|
9372 |
! ! |
|
9373 |
||
9374 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9375 |
||
3160 | 9376 |
executeIn:editor |
3130 | 9377 |
editor list at:line put:text. |
9378 |
editor invalidateLine:line |
|
9379 |
! ! |
|
9380 |
||
3402 | 9381 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9382 |
||
9383 |
line:lineArg lines:lineCollectionArg |
|
9384 |
line := lineArg. |
|
9385 |
text := lineCollectionArg. |
|
9386 |
||
9387 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9388 |
! ! |
|
9389 |
||
9390 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9391 |
||
9392 |
executeIn:editor |
|
9393 |
|lnr| |
|
9394 |
||
9395 |
lnr := line. |
|
9396 |
text do:[:eachLine | |
|
6152 | 9397 |
editor list at:lnr put:eachLine. |
9398 |
editor invalidateLine:lnr. |
|
9399 |
lnr := lnr + 1. |
|
3402 | 9400 |
]. |
9401 |
||
9402 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9403 |
! ! |
|
9404 |
||
5689 | 9405 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9406 |
||
5787 | 9407 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
5689 | 9408 |
cursorLine := cursorLineArg. |
9409 |
cursorCol := cursorColArg. |
|
9410 |
selectionStartLine := selectionStartLineArg. |
|
9411 |
selectionStartCol := selectionStartColArg. |
|
9412 |
selectionEndLine := selectionEndLineArg. |
|
9413 |
selectionEndCol := selectionEndColArg. |
|
9414 |
! |
|
9415 |
||
5787 | 9416 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
6152 | 9417 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
9418 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9419 |
info:info |
|
5689 | 9420 |
|
9421 |
cursorLine := cursorLineArg. |
|
9422 |
cursorCol := cursorColArg. |
|
9423 |
selectionStartLine := selectionStartLineArg. |
|
9424 |
selectionStartCol := selectionStartColArg. |
|
9425 |
selectionEndLine := selectionEndLineArg. |
|
9426 |
selectionEndCol := selectionEndColArg. |
|
9427 |
userFriendlyInfo := info. |
|
9428 |
||
9429 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9430 |
! ! |
|
9431 |
||
9432 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9433 |
||
9434 |
executeIn:editor |
|
9435 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9436 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
6152 | 9437 |
editor setCursorLine:cursorLine col:cursorCol. |
9438 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
5689 | 9439 |
] ifFalse:[ |
6152 | 9440 |
editor cursorLine:cursorLine col:cursorCol. |
5689 | 9441 |
]. |
9442 |
||
9443 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9444 |
! ! |
|
9445 |
||
5710 | 9446 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9447 |
||
9448 |
isRestoreSelectionAndCursor |
|
9449 |
^ true |
|
9450 |
! ! |
|
9451 |
||
865 | 9452 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9453 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9454 |
version |
5361 | 9455 |
^ '$Header$' |
3945 | 9456 |
! |
9457 |
||
9458 |
version_CVS |
|
5361 | 9459 |
^ '$Header$' |
0 | 9460 |
! ! |
4481 | 9461 |