author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 25 Aug 2016 11:41:41 +0100 | |
branch | jv |
changeset 5838 | 940ce0413cb2 |
parent 5828 | 990b7b5c4a94 |
parent 5833 | 584a6e4d283a |
child 5839 | 2cdb82875bf2 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4823 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
12 |
"{ Package: 'stx:libwidg' }" |
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
13 |
|
5239 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
TextView subclass:#EditTextView |
4826 | 17 |
instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown |
18 |
prevCursorState readOnly modifiedChannel fixedSize exceptionBlock |
|
19 |
cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType |
|
20 |
cursorTypeNoFocus typeOfSelection lastAction replacing |
|
21 |
showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates |
|
22 |
tabMeansNextField autoIndent insertMode editMode trimBlankLines |
|
23 |
wordWrap replacementWordSelectStyle acceptChannel acceptEnabled |
|
24 |
st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode |
|
25 |
learnedMacro cursorLineHolder cursorColHolder tabRequiresControl |
|
26 |
undoSupport lastStringFromReplaceForNextSearch |
|
27 |
lastReplacementInfo completionSupport codeAspectHolder' |
|
28 |
classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor |
|
29 |
DefaultCursorType DefaultCursorNoFocusForegroundColor |
|
30 |
DefaultCursorTypeNoFocus LastColumnNumberForSort Macros' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Views-Text' |
|
0 | 33 |
! |
34 |
||
2952 | 35 |
Object subclass:#EditAction |
4826 | 36 |
instanceVariableNames:'userFriendlyInfo' |
37 |
classVariableNames:'' |
|
38 |
poolDictionaries:'' |
|
39 |
privateIn:EditTextView |
|
2952 | 40 |
! |
41 |
||
42 |
EditTextView::EditAction subclass:#DeleteRange |
|
4826 | 43 |
instanceVariableNames:'line1 col1 line2 col2' |
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:EditTextView |
|
2952 | 47 |
! |
48 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
49 |
EditTextView::EditAction subclass:#DeleteCharacters |
4826 | 50 |
instanceVariableNames:'line col1 col2' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:EditTextView |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
54 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
55 |
|
3235 | 56 |
Object subclass:#EditMode |
4826 | 57 |
instanceVariableNames:'' |
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:EditTextView |
|
3235 | 61 |
! |
62 |
||
63 |
EditTextView::EditMode subclass:#InsertAndSelectMode |
|
4826 | 64 |
instanceVariableNames:'' |
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:EditTextView::EditMode |
|
3235 | 68 |
! |
69 |
||
70 |
EditTextView::EditMode subclass:#InsertMode |
|
4826 | 71 |
instanceVariableNames:'' |
72 |
classVariableNames:'' |
|
73 |
poolDictionaries:'' |
|
74 |
privateIn:EditTextView::EditMode |
|
3235 | 75 |
! |
76 |
||
77 |
EditTextView::EditMode subclass:#OverwriteMode |
|
4826 | 78 |
instanceVariableNames:'' |
79 |
classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode' |
|
80 |
poolDictionaries:'' |
|
81 |
privateIn:EditTextView::EditMode |
|
3235 | 82 |
! |
83 |
||
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
84 |
Query subclass:#ExecutingMacroQuery |
4826 | 85 |
instanceVariableNames:'' |
86 |
classVariableNames:'' |
|
87 |
poolDictionaries:'' |
|
88 |
privateIn:EditTextView |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
89 |
! |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
90 |
|
4048 | 91 |
Object subclass:#LastReplacementInfo |
4826 | 92 |
instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch |
93 |
lastReplaceIgnoredCase stillCollectingInput previousReplacements' |
|
94 |
classVariableNames:'' |
|
95 |
poolDictionaries:'' |
|
96 |
privateIn:EditTextView |
|
4048 | 97 |
! |
98 |
||
2952 | 99 |
EditTextView::EditAction subclass:#PasteString |
4826 | 100 |
instanceVariableNames:'line col string selected' |
101 |
classVariableNames:'' |
|
102 |
poolDictionaries:'' |
|
103 |
privateIn:EditTextView |
|
2952 | 104 |
! |
105 |
||
106 |
EditTextView::EditAction subclass:#ReplaceCharacter |
|
4826 | 107 |
instanceVariableNames:'line col character' |
108 |
classVariableNames:'' |
|
109 |
poolDictionaries:'' |
|
110 |
privateIn:EditTextView |
|
2952 | 111 |
! |
112 |
||
3235 | 113 |
EditTextView::EditAction subclass:#ReplaceCharacters |
4826 | 114 |
instanceVariableNames:'line col1 col2 characters' |
115 |
classVariableNames:'' |
|
116 |
poolDictionaries:'' |
|
117 |
privateIn:EditTextView |
|
3235 | 118 |
! |
119 |
||
3131 | 120 |
EditTextView::EditAction subclass:#ReplaceContents |
4826 | 121 |
instanceVariableNames:'text' |
122 |
classVariableNames:'' |
|
123 |
poolDictionaries:'' |
|
124 |
privateIn:EditTextView |
|
3131 | 125 |
! |
126 |
||
3130 | 127 |
EditTextView::EditAction subclass:#ReplaceLine |
4826 | 128 |
instanceVariableNames:'line text' |
129 |
classVariableNames:'' |
|
130 |
poolDictionaries:'' |
|
131 |
privateIn:EditTextView |
|
3130 | 132 |
! |
133 |
||
3402 | 134 |
EditTextView::EditAction subclass:#ReplaceLines |
4826 | 135 |
instanceVariableNames:'line text' |
136 |
classVariableNames:'' |
|
137 |
poolDictionaries:'' |
|
138 |
privateIn:EditTextView |
|
3402 | 139 |
! |
140 |
||
5689 | 141 |
EditTextView::EditAction subclass:#RestoreSelectionAndCursor |
142 |
instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol |
|
143 |
selectionEndLine selectionEndCol' |
|
144 |
classVariableNames:'' |
|
145 |
poolDictionaries:'' |
|
146 |
privateIn:EditTextView |
|
147 |
! |
|
148 |
||
865 | 149 |
!EditTextView class methodsFor:'documentation'! |
0 | 150 |
|
33 | 151 |
copyright |
152 |
" |
|
153 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4823 | 154 |
All Rights Reserved |
33 | 155 |
|
156 |
This software is furnished under a license and may be used |
|
157 |
only in accordance with the terms of that license and with the |
|
158 |
inclusion of the above copyright notice. This software may not |
|
159 |
be provided or otherwise made available to, or used by, any |
|
160 |
other person. No title to or ownership of the software is |
|
161 |
hereby transferred. |
|
162 |
" |
|
163 |
! |
|
164 |
||
0 | 165 |
documentation |
166 |
" |
|
167 |
a view for editable text - adds editing functionality to TextView |
|
3160 | 168 |
Also, it adds accept functionality, and defines a new actionBlock: |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
169 |
acceptAction to be performed for accept |
125 | 170 |
|
171 |
If used with a model, this is informed by sending it a changeMsg with |
|
172 |
the current contents as argument. |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
173 |
(however, it is possible to define both changeMsg and acceptAction) |
125 | 174 |
|
309
b5c9d68e95e1
new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents:
297
diff
changeset
|
175 |
Please read the historic notice in the ListView class. |
0 | 176 |
|
586 | 177 |
[Instance variables:] |
0 | 178 |
|
4010 | 179 |
cursorLine <Number> line where cursor sits (1..) |
180 |
||
181 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
182 |
||
183 |
cursorCol <Number> col where cursor sits (1..) |
|
184 |
||
185 |
cursorShown <Boolean> true, if cursor is currently shown |
|
186 |
||
187 |
readOnly <Boolean> true, if text may not be edited |
|
188 |
||
189 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
190 |
cleared on accept. |
|
191 |
||
192 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
193 |
||
194 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
195 |
||
196 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
197 |
if it returns true, the modification will be done anyway. |
|
198 |
if it returns anything else, the modification is not done. |
|
199 |
||
200 |
cursorFgColor <Color> color used for cursor drawing |
|
201 |
cursorBgColor <Color> color used for cursor drawing |
|
202 |
||
203 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
4721 | 204 |
are #none, #block (solid-block cursor), #ibeam |
4010 | 205 |
(vertical bar at insertion point) |
4721 | 206 |
and #caret (caret below insertion-point). |
207 |
see cursorType: for an up-to-date list. |
|
4010 | 208 |
|
209 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
210 |
nil means: hide the cursor. |
|
211 |
||
212 |
undoAction <Block> block which undoes last cut, paste or replace |
|
213 |
(not yet fully implemented) |
|
214 |
||
215 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
216 |
this affects the next keyPress: if #paste it does not |
|
217 |
replace; otherwise it replaces the selection. |
|
218 |
||
219 |
lastCut <String> last cut or replaced string |
|
220 |
||
4053 | 221 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
222 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
223 |
lastReplacement is the string to replace lastStringToReplace |
|
224 |
||
225 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
|
226 |
(cleared after a new selection) |
|
4010 | 227 |
|
228 |
replacing <Boolean> true if entered characters replace last selection |
|
229 |
||
230 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
231 |
when entering one; this is the default. |
|
232 |
||
233 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
234 |
||
235 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
236 |
argument |
|
237 |
||
238 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
239 |
focus to the next field. For editTextViews, this is false |
|
240 |
by default (i.e. tabs can be entered into the text). |
|
241 |
For some subclasses (inputFields), this may be true. |
|
242 |
||
243 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
244 |
removed when editing. |
|
245 |
Default is true. |
|
246 |
||
247 |
wordWrap <Boolean> Currently not used. |
|
248 |
||
249 |
lockUpdates <Boolean> internal, private |
|
250 |
||
251 |
prevCursorState <Boolean> temporary, private |
|
252 |
||
253 |
cursorMovementWhenUpdating |
|
254 |
<Symbol> defines where the cursor is to be positioned if the |
|
255 |
model changes its value by some outside activity |
|
256 |
(i.e. not by user input into the field). |
|
257 |
Can be one of: |
|
258 |
#keep / nil -> stay where it was |
|
259 |
#endOfText -> cursor to the end |
|
260 |
#endOfLine -> stay in the line, but move to end |
|
261 |
#beginOfText -> cursor to the beginning |
|
262 |
#beginOfLine -> stay in the line, but move to begin |
|
263 |
The default is #beginOfText |
|
264 |
||
265 |
||
266 |
||
267 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 268 |
|
269 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
270 |
userPreference values: |
4010 | 271 |
userPreferences.st80EditMode |
272 |
<Boolean> if true, cursor positioning is |
|
273 |
done as in vi or ST80; i.e. |
|
274 |
wysiwyg mode is somewhat relaxed, |
|
275 |
in that the cursor cannot be |
|
276 |
positioned behind a lines end. |
|
277 |
This is not yet completely implemented. |
|
33 | 278 |
used globals: |
279 |
||
4010 | 280 |
DeleteHistory <Text> last 1000 lines of deleted text |
281 |
(but only if this variable exists already) |
|
586 | 282 |
|
283 |
[styleSheet parameters:] |
|
121 | 284 |
|
4010 | 285 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
286 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
287 |
textCursorNoFocusForegroundColor |
|
288 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
289 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 290 |
|
291 |
[author:] |
|
4010 | 292 |
Claus Gittinger |
586 | 293 |
|
294 |
[see also:] |
|
4010 | 295 |
CodeView Workspace TextView ListView |
296 |
EditField |
|
0 | 297 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
298 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
299 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
300 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
301 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
302 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
303 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
304 |
basic setup: |
4823 | 305 |
[exBegin] |
306 |
|top textView| |
|
307 |
||
308 |
top := StandardSystemView new. |
|
309 |
top extent:300@200. |
|
310 |
||
311 |
textView := EditTextView new. |
|
312 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
313 |
top addSubView:textView. |
|
314 |
||
315 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
316 |
||
317 |
top open. |
|
318 |
[exEnd] |
|
594 | 319 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
320 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
321 |
with vertical scrollbar: |
4823 | 322 |
[exBegin] |
323 |
|top scrollView textView| |
|
324 |
||
325 |
top := StandardSystemView new. |
|
326 |
top extent:300@200. |
|
327 |
||
328 |
scrollView := ScrollableView for:EditTextView. |
|
329 |
textView := scrollView scrolledView. |
|
330 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
331 |
top addSubView:scrollView. |
|
332 |
||
333 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
334 |
||
335 |
top open. |
|
336 |
[exEnd] |
|
594 | 337 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
338 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
339 |
with horizontal & vertical scrollbars: |
4823 | 340 |
[exBegin] |
341 |
|top scrollView textView| |
|
342 |
||
343 |
top := StandardSystemView new. |
|
344 |
top extent:300@200. |
|
345 |
||
346 |
scrollView := HVScrollableView for:EditTextView. |
|
347 |
textView := scrollView scrolledView. |
|
348 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
349 |
top addSubView:scrollView. |
|
350 |
||
351 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
352 |
||
353 |
top open. |
|
354 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
355 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
356 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
357 |
set the action for accept: |
4823 | 358 |
[exBegin] |
359 |
|top textView| |
|
360 |
||
361 |
top := StandardSystemView new. |
|
362 |
top extent:300@200. |
|
363 |
||
364 |
textView := EditTextView new. |
|
365 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
366 |
top addSubView:textView. |
|
367 |
||
368 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
369 |
textView acceptAction:[:contents | |
|
370 |
Transcript showCR:'will not overwrite the file with:'. |
|
371 |
Transcript showCR:contents asString |
|
372 |
]. |
|
373 |
top open. |
|
374 |
[exEnd] |
|
594 | 375 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
376 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
377 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
378 |
non-string (text) items: |
4823 | 379 |
[exBegin] |
380 |
|top textView list| |
|
381 |
||
382 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
383 |
1 to:list size by:2 do:[:nr | |
|
384 |
list at:nr put:(Text string:(list at:nr) |
|
385 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
386 |
]. |
|
387 |
||
388 |
top := StandardSystemView new. |
|
389 |
top extent:300@200. |
|
390 |
||
391 |
textView := EditTextView new. |
|
392 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
393 |
top addSubView:textView. |
|
394 |
||
395 |
textView contents:list. |
|
396 |
top open. |
|
397 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
398 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
399 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
400 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
401 |
MVC operation: |
594 | 402 |
(the examples model here is a plug simulating a real model; |
403 |
real world applications would not use a plug ..) |
|
4823 | 404 |
[exBegin] |
405 |
|top textView model| |
|
406 |
||
407 |
model := Plug new. |
|
408 |
model respondTo:#accepted: |
|
409 |
with:[:newContents | |
|
410 |
Transcript showCR:'will not overwrite the file with:'. |
|
411 |
Transcript showCR:newContents asString |
|
412 |
]. |
|
413 |
model respondTo:#getList |
|
414 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
415 |
||
416 |
||
417 |
top := StandardSystemView new. |
|
418 |
top extent:300@200. |
|
419 |
||
420 |
textView := EditTextView new. |
|
421 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
422 |
top addSubView:textView. |
|
423 |
||
424 |
textView listMessage:#getList; |
|
425 |
model:model; |
|
426 |
changeMessage:#accepted:; |
|
427 |
aspect:#list. |
|
428 |
top open. |
|
429 |
[exEnd] |
|
594 | 430 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
431 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
432 |
two textViews on the same model: |
4823 | 433 |
[exBegin] |
434 |
|top1 textView1 top2 textView2 model currentContents| |
|
435 |
||
436 |
model := Plug new. |
|
437 |
model respondTo:#accepted: |
|
438 |
with:[:newContents | |
|
439 |
Transcript showCR:'accepted:'. |
|
440 |
Transcript showCR:newContents asString. |
|
441 |
currentContents := newContents. |
|
442 |
model changed:#contents |
|
443 |
]. |
|
444 |
model respondTo:#getList |
|
445 |
with:[Transcript showCR:'query'. |
|
446 |
currentContents]. |
|
447 |
||
448 |
||
449 |
top1 := StandardSystemView new. |
|
450 |
top1 extent:300@200. |
|
451 |
||
452 |
textView1 := EditTextView new. |
|
453 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
454 |
top1 addSubView:textView1. |
|
455 |
||
456 |
textView1 listMessage:#getList; |
|
457 |
model:model; |
|
458 |
aspect:#contents; |
|
459 |
changeMessage:#accepted:. |
|
460 |
top1 open. |
|
461 |
||
462 |
top2 := StandardSystemView new. |
|
463 |
top2 extent:300@200. |
|
464 |
||
465 |
textView2 := EditTextView new. |
|
466 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
467 |
top2 addSubView:textView2. |
|
468 |
||
469 |
textView2 listMessage:#getList; |
|
470 |
model:model; |
|
471 |
aspect:#contents; |
|
472 |
changeMessage:#accepted:. |
|
473 |
top2 open. |
|
474 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
475 |
" |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
476 |
! |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
477 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
478 |
selection_and_cursor_movement |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
479 |
" |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
480 |
Changes done to implement 'standard' behaviour (that's how vast majority of widgets used in todays desktops behaves) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
481 |
as opposed to 'traditional' which is what how it was in St/X 'ever since' |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
482 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
483 |
* Numerous off-by-one bugs |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
484 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
485 |
* Extending selection by dragging: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
486 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
487 |
1. Select & drag to expand beggining of the selection (i.e., drag from 'end' to 'beggining' |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
488 |
2. Stop dragging |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
489 |
3. Press Shift-Left / Shift-Right (to refine selection) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
490 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
491 |
Traditional ST/X: end of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
492 |
Standard: beginning of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
493 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
494 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
495 |
* Extending selection by Shift-Home / Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
496 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
497 |
1. Position cursor in the middle of the line |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
498 |
2. Press Shift-Home (line for beginning should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
499 |
3. Press Shift-Right (to refine selection) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
500 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
501 |
Traditional ST/X: end of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
502 |
Standard: beginning of selection is moved |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
503 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
504 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
505 |
* Selection flip by Shift-Home / Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
506 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
507 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
508 |
2. Press Shift-Home (line from beginning should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
509 |
2. Press Shift-End |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
510 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
511 |
Traditional ST/X: end of selection is moved so whole line is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
512 |
Standard: Selection 'flips' so part of line from column C to the end is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
513 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
514 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
515 |
Scenario B: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
516 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
517 |
2. Press Shift-End (column C to the end of line should be selected) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
518 |
2. Press Shift-Home |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
519 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
520 |
Traditional ST/X: beginning of selection is moved so whole line is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
521 |
Standard: Selection 'flips' so part of line from the beginning to column C is selected |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
522 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
523 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
524 |
NOTE: This could be controlled by |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
525 |
UserPreferences current selectionExtensionMode |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
526 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
527 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
528 |
* Extending selection with Ctrl-Shift-Left / Ctrl-Shift-Right |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
529 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
530 |
1. Position cursor in the middle of the line to column C |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
531 |
2. Select word |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
532 |
3. Press Ctrl-Shift-Right, Ctrl-Shift-Right |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
533 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
534 |
Traditional ST/X: nothing happens at all |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
535 |
Standard: Selection is extended to include a space (first press) and a word right to previously selected one |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
536 |
(checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox) |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
537 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
538 |
" |
0 | 539 |
! ! |
540 |
||
865 | 541 |
!EditTextView class methodsFor:'defaults'! |
59 | 542 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
543 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
544 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
545 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
546 |
"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
|
547 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
548 |
|
1419 | 549 |
st80Mode |
550 |
"return true, if the st80 editing mode is turned on. |
|
551 |
This setting affects the behavior of the cursor, when positioned |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
552 |
beyond the end of a line or the end of the text." |
1419 | 553 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
554 |
^ UserPreferences current st80EditMode |
1419 | 555 |
|
556 |
" |
|
557 |
EditTextView st80Mode:true |
|
558 |
EditTextView st80Mode:false |
|
559 |
" |
|
560 |
||
561 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
562 |
! |
|
563 |
||
564 |
st80Mode:aBoolean |
|
565 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
2707 | 566 |
beyond the end of a line or the last line" |
1419 | 567 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
568 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 569 |
|
570 |
" |
|
571 |
EditTextView st80Mode:true |
|
572 |
EditTextView st80Mode:false |
|
573 |
" |
|
574 |
||
575 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
576 |
! |
|
577 |
||
59 | 578 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
579 |
"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
|
580 |
|
1390 | 581 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 582 |
#'textCursor.noFocusForegroundColor' |
583 |
#'textCursor.type' |
|
584 |
#'textCursor.typeNoFocus' |
|
585 |
#'editText.st80Mode')> |
|
1355 | 586 |
|
587 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
588 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
589 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
590 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
591 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
592 |
|
1419 | 593 |
" |
594 |
self updateStyleCache |
|
595 |
" |
|
596 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
597 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 598 |
! ! |
599 |
||
3431 | 600 |
!EditTextView class methodsFor:'specs'! |
601 |
||
602 |
searchReplaceDialogSpec |
|
603 |
"This resource specification was automatically generated |
|
604 |
by the UIPainter of ST/X." |
|
605 |
||
606 |
"Do not manually edit this!! If it is corrupted, |
|
607 |
the UIPainter may not be able to read the specification." |
|
608 |
||
609 |
" |
|
610 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
611 |
" |
|
612 |
||
613 |
<resource: #canvas> |
|
614 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
615 |
^ |
3431 | 616 |
#(FullSpec |
4823 | 617 |
name: searchReplaceDialogSpec |
618 |
window: |
|
3431 | 619 |
(WindowSpec |
4823 | 620 |
label: 'String Search and Replace' |
621 |
name: 'String Search and Replace' |
|
622 |
min: (Point 283 196) |
|
623 |
max: (Point 283 196) |
|
624 |
bounds: (Rectangle 0 0 279 192) |
|
625 |
) |
|
626 |
component: |
|
3431 | 627 |
(SpecCollection |
4823 | 628 |
collection: ( |
629 |
(LabelSpec |
|
630 |
label: 'Search Pattern:' |
|
631 |
name: 'label' |
|
632 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
633 |
level: 0 |
|
634 |
translateLabel: true |
|
635 |
adjust: left |
|
636 |
) |
|
637 |
(ComboBoxSpec |
|
638 |
name: 'patternComboBox' |
|
639 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
640 |
tabable: true |
|
641 |
model: searchPattern |
|
642 |
immediateAccept: false |
|
643 |
acceptOnLeave: true |
|
644 |
acceptOnReturn: true |
|
645 |
acceptOnTab: true |
|
646 |
acceptOnLostFocus: true |
|
647 |
acceptOnPointerLeave: false |
|
648 |
autoSelectInitialText: true |
|
649 |
comboList: patternList |
|
650 |
) |
|
651 |
(ComboBoxSpec |
|
652 |
name: 'replaceComboBox' |
|
653 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
654 |
tabable: true |
|
655 |
model: replacePattern |
|
656 |
immediateAccept: false |
|
657 |
acceptOnLeave: true |
|
658 |
acceptOnReturn: true |
|
659 |
acceptOnTab: true |
|
660 |
acceptOnLostFocus: true |
|
661 |
acceptOnPointerLeave: false |
|
662 |
autoSelectInitialText: true |
|
663 |
comboList: patternList |
|
664 |
) |
|
665 |
(CheckBoxSpec |
|
666 |
label: 'Ignore Case' |
|
667 |
name: 'ignoreCaseCheckBox' |
|
668 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
669 |
level: 0 |
|
670 |
tabable: true |
|
671 |
model: ignoreCase |
|
672 |
translateLabel: true |
|
673 |
) |
|
674 |
(VariableVerticalPanelSpec |
|
675 |
name: 'VariableVerticalPanel1' |
|
676 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
677 |
component: |
|
678 |
(SpecCollection |
|
679 |
collection: ( |
|
680 |
(HorizontalPanelViewSpec |
|
681 |
name: 'HorizontalPanel1' |
|
682 |
level: 0 |
|
683 |
horizontalLayout: fitSpace |
|
684 |
verticalLayout: center |
|
685 |
horizontalSpace: 3 |
|
686 |
verticalSpace: 3 |
|
687 |
ignoreInvisibleComponents: true |
|
688 |
reverseOrderIfOKAtLeft: true |
|
689 |
component: |
|
690 |
(SpecCollection |
|
691 |
collection: ( |
|
692 |
(ActionButtonSpec |
|
693 |
label: 'Replace' |
|
694 |
name: 'replaceButton' |
|
695 |
level: 2 |
|
696 |
translateLabel: true |
|
697 |
tabable: true |
|
698 |
model: replaceAction |
|
699 |
extent: (Point 134 21) |
|
700 |
) |
|
701 |
(ActionButtonSpec |
|
702 |
label: 'Replace All' |
|
703 |
name: 'replaceAllButton' |
|
704 |
level: 2 |
|
705 |
borderWidth: 1 |
|
706 |
translateLabel: true |
|
707 |
tabable: true |
|
708 |
model: replaceAllAction |
|
709 |
extent: (Point 134 21) |
|
710 |
) |
|
711 |
) |
|
712 |
||
713 |
) |
|
714 |
) |
|
715 |
(HorizontalPanelViewSpec |
|
716 |
name: 'horizontalPanelView' |
|
717 |
level: 0 |
|
718 |
horizontalLayout: fitSpace |
|
719 |
verticalLayout: center |
|
720 |
horizontalSpace: 3 |
|
721 |
verticalSpace: 3 |
|
722 |
ignoreInvisibleComponents: true |
|
723 |
reverseOrderIfOKAtLeft: true |
|
724 |
component: |
|
725 |
(SpecCollection |
|
726 |
collection: ( |
|
727 |
(ActionButtonSpec |
|
728 |
label: 'Cancel' |
|
729 |
name: 'cancelButton' |
|
730 |
level: 2 |
|
731 |
translateLabel: true |
|
732 |
tabable: true |
|
733 |
model: cancel |
|
734 |
extent: (Point 88 21) |
|
735 |
) |
|
736 |
(ActionButtonSpec |
|
737 |
label: 'Prev' |
|
738 |
name: 'prevButton' |
|
739 |
level: 2 |
|
740 |
translateLabel: true |
|
741 |
tabable: true |
|
742 |
model: prevAction |
|
743 |
extent: (Point 89 21) |
|
744 |
) |
|
745 |
(ActionButtonSpec |
|
746 |
label: 'Next' |
|
747 |
name: 'nextButton' |
|
748 |
level: 2 |
|
749 |
borderWidth: 1 |
|
750 |
translateLabel: true |
|
751 |
tabable: true |
|
752 |
model: nextAction |
|
753 |
isDefault: true |
|
754 |
extent: (Point 88 21) |
|
755 |
) |
|
756 |
) |
|
757 |
||
758 |
) |
|
759 |
) |
|
760 |
) |
|
761 |
||
762 |
) |
|
763 |
handles: (Any 0.5 1.0) |
|
764 |
) |
|
765 |
(LabelSpec |
|
766 |
label: 'Replace By:' |
|
767 |
name: 'ReplaceLabel' |
|
768 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
769 |
level: 0 |
|
770 |
translateLabel: true |
|
771 |
adjust: left |
|
772 |
) |
|
773 |
) |
|
774 |
||
775 |
) |
|
3431 | 776 |
) |
777 |
||
778 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
779 |
! ! |
|
780 |
||
2744 | 781 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
782 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
783 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
784 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
785 |
|
2019 | 786 |
"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
|
787 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
788 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
789 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
790 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
791 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
792 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
793 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
794 |
|
1390 | 795 |
cutSelection |
796 |
self cut |
|
797 |
||
798 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
799 |
! |
|
800 |
||
1590 | 801 |
deselect |
802 |
"remove the selection" |
|
803 |
||
804 |
^ self unselect |
|
805 |
||
806 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
807 |
! |
|
808 |
||
2101 | 809 |
enabled:aBoolean |
810 |
||
811 |
self readOnly:aBoolean not |
|
812 |
||
813 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
814 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
815 |
! |
|
816 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
817 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
818 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
819 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
820 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
821 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
822 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
823 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
824 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
825 |
"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
|
826 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
827 |
|line col| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
828 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
829 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
830 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
831 |
col < 1 ifTrue:[ |
4823 | 832 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
833 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
834 |
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
|
835 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
836 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
837 |
|top v| |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
838 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
839 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
840 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
841 |
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
|
842 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
843 |
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
|
844 |
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
|
845 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
846 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
847 |
"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
|
848 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
849 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
850 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
851 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
852 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
853 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
854 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
855 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 856 |
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
|
857 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
858 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 859 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
860 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
861 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
862 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
863 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
864 |
v insertAndSelect:'<- hello there' at:5. |
125 | 865 |
" |
1390 | 866 |
! |
867 |
||
868 |
pasteSelection |
|
869 |
self paste |
|
870 |
||
871 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 872 |
! |
873 |
||
874 |
replaceSelectionWith:aString |
|
875 |
^ self replaceSelectionBy:aString |
|
876 |
||
877 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
878 |
! |
|
879 |
||
880 |
selectAt:pos |
|
881 |
"move the cursor before cursorPosition." |
|
882 |
||
883 |
self cursorToCharacterPosition:pos |
|
884 |
||
885 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
886 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
887 |
! |
|
888 |
||
2101 | 889 |
textHasChanged |
890 |
^ self modified |
|
891 |
||
892 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
893 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
894 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
895 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
896 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
897 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
898 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
899 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
900 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
901 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
902 |
|
4585 | 903 |
!EditTextView methodsFor:'accessing'! |
904 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
905 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
906 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
907 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
908 |
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
|
909 |
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
|
910 |
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
|
911 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
912 |
"/ 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
|
913 |
"/ 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
|
914 |
^((app := self topView application) notNil and:[app respondsTo: #codeAspect]) |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
915 |
ifTrue:[app codeAspect] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
916 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
917 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
918 |
"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
|
919 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
920 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
921 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
922 |
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
|
923 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
924 |
"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
|
925 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
926 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
927 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
928 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
929 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
930 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
931 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
932 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
933 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
934 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
935 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
936 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
937 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
938 |
"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
|
939 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
940 |
|
4609 | 941 |
editedClass |
942 |
|cm| |
|
943 |
||
944 |
cm := self editedMethodOrClass. |
|
945 |
cm isBehavior ifTrue:[^ cm]. |
|
946 |
cm isMethod ifTrue:[^ cm mclass]. |
|
947 |
^ nil |
|
948 |
! |
|
949 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
950 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
951 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
952 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
953 |
"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
|
954 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
955 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
956 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
957 |
"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
|
958 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
959 |
"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
|
960 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
961 |
|
4609 | 962 |
editedMethod |
963 |
|cm| |
|
964 |
||
965 |
cm := self editedMethodOrClass. |
|
966 |
cm isMethod ifTrue:[^ cm]. |
|
967 |
cm isBehavior ifTrue:[^ nil]. |
|
968 |
^ nil |
|
969 |
! |
|
970 |
||
971 |
editedMethodOrClass |
|
972 |
^ nil |
|
973 |
! |
|
974 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
975 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
976 |
"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
|
977 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
978 |
"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
|
979 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
980 |
|
4585 | 981 |
hasSelectionOrTextInCursorLine |
982 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
983 |
! |
|
984 |
||
4589 | 985 |
selectionOrTextOfCursorLine |
986 |
^ self selectionOrTextOfCursorLine:true |
|
987 |
! |
|
988 |
||
4585 | 989 |
selectionOrTextOfCursorLine:doSelect |
990 |
|sel lNr line| |
|
991 |
||
992 |
sel := self selectionAsString. |
|
993 |
sel notNil ifTrue:[^ sel]. |
|
994 |
||
995 |
lNr := self cursorLine. |
|
996 |
line := self listAt:lNr. |
|
997 |
line notEmptyOrNil ifTrue:[ |
|
998 |
doSelect ifTrue:[ |
|
999 |
self selectLine:lNr. |
|
1000 |
]. |
|
1001 |
^ line |
|
1002 |
]. |
|
1003 |
||
1004 |
^ nil |
|
1005 |
! ! |
|
1006 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1007 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1008 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1009 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1010 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1011 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1012 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1013 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1014 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1015 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1016 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1017 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1018 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1019 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1020 |
|
2792 | 1021 |
acceptChannel |
1022 |
"return the valueHolder holding true if text was accepted. |
|
1023 |
By placing a true into this channel, an accept can also be forced." |
|
1024 |
||
1025 |
^ acceptChannel |
|
1026 |
||
1027 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
1028 |
! |
|
1029 |
||
1030 |
acceptChannel:aValueHolder |
|
1031 |
"set the valueHolder holding true if text was accepted. |
|
1032 |
By placing a true into this channel, an accept can also be forced." |
|
1033 |
||
1034 |
|prev| |
|
1035 |
||
1036 |
prev := acceptChannel. |
|
1037 |
acceptChannel := aValueHolder. |
|
1038 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1039 |
||
1040 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
1041 |
! |
|
1042 |
||
1108 | 1043 |
acceptEnabled:aBoolean |
1044 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
1045 |
||
1046 |
acceptEnabled := aBoolean |
|
1047 |
||
1048 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
1049 |
! |
|
1050 |
||
2792 | 1051 |
accepted |
1052 |
"return true if text was accepted" |
|
1053 |
||
1054 |
^ acceptChannel value |
|
1055 |
||
1056 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1057 |
! |
|
1058 |
||
1059 |
accepted:aBoolean |
|
1060 |
"set/clear the accepted flag. |
|
1061 |
This may force my current contents to be placed into my model." |
|
1062 |
||
1063 |
acceptChannel value:aBoolean. |
|
1064 |
||
1065 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1066 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1067 |
! |
|
1068 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1069 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1070 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1071 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1072 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1073 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1074 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1075 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1076 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1077 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1078 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1079 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1080 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1081 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1082 |
|
2774 | 1083 |
cursorMovementWhenUpdating |
3160 | 1084 |
"return what is be done with the cursor, |
2774 | 1085 |
when I get a new text (via the model or the #contents/#list) |
1086 |
Allowed arguments are: |
|
4823 | 1087 |
#keep / nil -> stay where it was |
1088 |
#endOfText -> position cursor to the end |
|
1089 |
#beginOfText -> position cursor to the beginning |
|
1090 |
#endOfLine -> position cursor to the current lines end |
|
1091 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1092 |
The default is #beginOfText. |
1093 |
This may be useful for fields which get new values assigned from |
|
1094 |
the program (i.e. not from the user)" |
|
1095 |
||
1096 |
^ cursorMovementWhenUpdating |
|
1097 |
||
1098 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1099 |
! |
|
1100 |
||
2133 | 1101 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1102 |
"define what should be done with the cursor, |
2133 | 1103 |
when I get a new text (via the model or the #contents/#list) |
1104 |
Allowed arguments are: |
|
4823 | 1105 |
#keep / nil -> stay where it was |
1106 |
#endOfText -> position cursor to the end |
|
1107 |
#beginOfText -> position cursor to the beginning |
|
1108 |
#endOfLine -> position cursor to the current lines end |
|
1109 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1110 |
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
|
1111 |
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
|
1112 |
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
|
1113 |
|
2133 | 1114 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1115 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1116 |
"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
|
1117 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1118 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1119 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1120 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1121 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1122 |
|
2438 | 1123 |
dontReplaceSelectionOnInput |
4742 | 1124 |
"remember that the current selection was created by a paste operation |
1125 |
(as opposed to an explicit selection by the user). |
|
1126 |
This selection will not be replaced by followup user input, |
|
1127 |
so multiple pastes will be possible." |
|
1128 |
||
5342
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1129 |
self hasSelection ifTrue:[ |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1130 |
typeOfSelection := #paste |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1131 |
]. |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1132 |
|
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1133 |
"Modified: / 02-05-2015 / 21:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2438 | 1134 |
! |
1135 |
||
3235 | 1136 |
editModeHolder |
1137 |
^ editMode. |
|
1138 |
! |
|
1139 |
||
1140 |
editModeInsert |
|
1141 |
editMode value:EditMode insertMode |
|
1142 |
! |
|
1143 |
||
1144 |
editModeInsertAndSelect |
|
1145 |
editMode value:EditMode insertAndSelectMode |
|
1146 |
! |
|
1147 |
||
1148 |
editModeOverwrite |
|
1149 |
editMode value:EditMode overwriteMode |
|
1150 |
! |
|
1151 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1152 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1153 |
"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
|
1154 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1155 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1156 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1157 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1158 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1159 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1160 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1161 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1162 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1163 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1164 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1165 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1166 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1167 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1168 |
readOnly == true ifFalse:[ |
4823 | 1169 |
readOnly := true. |
1170 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1171 |
menu disableAll:#(cut paste replace indent) |
|
1172 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1173 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1174 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1175 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1176 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1177 |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1178 |
insertMode:aBoolean |
3235 | 1179 |
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
|
1180 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1181 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1182 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1183 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1184 |
insertModeHolder |
3235 | 1185 |
^ BlockValue |
4823 | 1186 |
with:[:m | m isInsertMode] |
1187 |
argument:(editMode). |
|
3465 | 1188 |
|
1189 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1190 |
! |
1191 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1192 |
isInInsertMode |
3235 | 1193 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1194 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1195 |
|
5216 | 1196 |
isNotReadOnly |
1197 |
"return true, if the text is not readonly." |
|
1198 |
||
1199 |
^ self isReadOnly not |
|
1200 |
! |
|
1201 |
||
2792 | 1202 |
isReadOnly |
1203 |
"return true, if the text is readonly." |
|
1204 |
||
1205 |
^ readOnly value |
|
1206 |
||
1207 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1208 |
! |
|
1209 |
||
2796 | 1210 |
modeLabelHolder |
1211 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1212 |
||
3160 | 1213 |
^ BlockValue |
4041 | 1214 |
with:[:e :l | |
1215 |
self isReadOnly ifTrue:[ |
|
1216 |
'' |
|
1217 |
] ifFalse:[ |
|
5724 | 1218 |
l ifTrue:[ 'L' allBold withColor:#red] |
4041 | 1219 |
ifFalse:[ e infoPrintString]]] |
1220 |
argument:(self editModeHolder) |
|
1221 |
argument:(self learnModeHolder). |
|
3465 | 1222 |
|
1223 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1224 |
! |
1225 |
||
2792 | 1226 |
modified |
1227 |
"return true if text was modified" |
|
1228 |
||
1229 |
^ modifiedChannel value |
|
1230 |
! |
|
1231 |
||
1232 |
modified:aBoolean |
|
1233 |
"set/clear the modified flag" |
|
1234 |
||
1235 |
modifiedChannel value:aBoolean |
|
1236 |
||
1237 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1238 |
! |
|
1239 |
||
1240 |
modifiedChannel |
|
1241 |
"return the valueHolder holding true if text was modified" |
|
1242 |
||
1243 |
^ modifiedChannel |
|
1244 |
! |
|
1245 |
||
1246 |
modifiedChannel:aValueHolder |
|
1247 |
"set the valueHolder holding true if text was modified" |
|
1248 |
||
1249 |
|prev| |
|
1250 |
||
1251 |
prev := modifiedChannel. |
|
1252 |
modifiedChannel := aValueHolder. |
|
1253 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1254 |
||
1255 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1256 |
! |
|
1257 |
||
1258 |
readOnly |
|
1259 |
"make the text readonly. |
|
4664 | 1260 |
Obsolete because it is obfuscating (looks like a getter) |
1261 |
- use #readOnly:" |
|
2792 | 1262 |
|
1263 |
<resource:#obsolete> |
|
1264 |
||
1265 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1266 |
self readOnly:true. |
2792 | 1267 |
|
4664 | 1268 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1269 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1270 |
! |
1271 |
||
1272 |
readOnly:aBoolean |
|
1273 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1274 |
The argument may also be a valueHolder." |
|
1275 |
||
1276 |
readOnly := aBoolean |
|
1277 |
||
1278 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1279 |
! |
|
1280 |
||
4782 | 1281 |
reallyModifiedChannel |
1282 |
"return the valueHolder holding true if text was really modified. |
|
1283 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1284 |
||
1285 |
^ self modifiedChannel |
|
1286 |
! |
|
1287 |
||
5255 | 1288 |
st80Mode:aBooleanOrNil |
4192 | 1289 |
"set/clear the st80Mode flag. |
1290 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1291 |
if off, we have the Rand-editor behavior (random access) |
1292 |
if nil, the setting follows the current userPref setting." |
|
1293 |
||
1294 |
st80Mode := aBooleanOrNil |
|
4192 | 1295 |
|
1296 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1297 |
! |
|
1298 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1299 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1300 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1301 |
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
|
1302 |
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
|
1303 |
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
|
1304 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1305 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1306 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1307 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1308 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1309 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1310 |
"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
|
1311 |
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
|
1312 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1313 |
|
3160 | 1314 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1315 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1316 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1317 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1318 |
"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
|
1319 |
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
|
1320 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1321 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1322 |
tabRequiresControl := aBoolean |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1323 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1324 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1325 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1326 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1327 |
at:lineNr basicPut:aLine |
5413 | 1328 |
"change a line without change notification. |
1329 |
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
|
1330 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1331 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1332 |
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
|
1333 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1334 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1335 |
|
522 | 1336 |
at:lineNr put:aLine |
5413 | 1337 |
"replace a line by something new. |
1338 |
this is not undoably, unless you care for yourself" |
|
1339 |
||
5393 | 1340 |
|oldLine| |
1341 |
||
1342 |
oldLine := (self at:lineNr) ? ''. |
|
1343 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
4823 | 1344 |
super at:lineNr put:aLine. |
1345 |
self textChanged |
|
522 | 1346 |
]. |
1347 |
! |
|
1348 |
||
4700 | 1349 |
characterAfterCursor |
1350 |
"return the character one after the cursor - space if beyond line." |
|
1351 |
||
1352 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1353 |
! |
|
1354 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1355 |
characterBeforeCursor |
4700 | 1356 |
"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
|
1357 |
|
5142 | 1358 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1359 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1360 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1361 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1362 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1363 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1364 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1365 |
characterUnderCursor |
2707 | 1366 |
"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
|
1367 |
For non-block cursors, this is the character immediately to the right |
5413 | 1368 |
of the insertion-bar or caret. |
1369 |
For block cursors, this is the highlighted cursor-character" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1370 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1371 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1372 |
! |
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 |
contents |
2213 | 1375 |
"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
|
1376 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1377 |
list isNil ifTrue:[^ '']. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1378 |
self removeTrailingBlankLines. |
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1379 |
^ super contents. |
3313 | 1380 |
|
1381 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1382 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1383 |
|
5413 | 1384 |
contents:aStringOrStringCollectionOrNil |
1385 |
"replace the whole contents by something new. |
|
5414 | 1386 |
this is not undoably, unless you care for yourself. |
1387 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1388 |
|
1389 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1390 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1391 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1392 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1393 |
"set the contents and optionally clear the undo history. |
1394 |
The contents-change is not undoable." |
|
1395 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1396 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1397 |
keepUndoHistory ifFalse:[ |
4823 | 1398 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1399 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1400 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1401 |
|
2213 | 1402 |
contentsAsString |
1403 |
"return the contents as a String (i.e. without emphasis)" |
|
1404 |
||
1405 |
list isNil ifTrue:[^ '']. |
|
1406 |
self removeTrailingBlankLines. |
|
1407 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1408 |
ifFalse:[each string] |
1409 |
]) asStringWithCRs |
|
2213 | 1410 |
! |
1411 |
||
5067 | 1412 |
contentsAsStringWithTabs |
1413 |
"return the contents as a String (i.e. without emphasis) |
|
1414 |
and with leading spaces replaced by tab characters |
|
1415 |
(i.e. as would be written to a file)" |
|
1416 |
||
1417 |
list isNil ifTrue:[^ '']. |
|
1418 |
self removeTrailingBlankLines. |
|
1419 |
^ (list collect:[:each | |
|
1420 |
each isNil |
|
1421 |
ifTrue:[''] |
|
1422 |
ifFalse:[each string withTabs] |
|
1423 |
]) asStringWithCRs |
|
1424 |
! |
|
1425 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1426 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1427 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1428 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1429 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1430 |
^ cursorCol |
125 | 1431 |
! |
1432 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1433 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1434 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1435 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1436 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1437 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1438 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1439 |
cursorLine |
3160 | 1440 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1441 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1442 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1443 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1444 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1445 |
|
5400 | 1446 |
cursorLineAndColumnLabelHolder |
5399 | 1447 |
"return a valueHolder for the cursors line and column as an info string |
1448 |
of the form 'line : col'. |
|
1449 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
|
1450 |
||
1451 |
^ BlockValue |
|
1452 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
|
1453 |
argument:self cursorLineHolder |
|
1454 |
argument:self cursorColHolder |
|
1455 |
! |
|
1456 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1457 |
cursorLineHolder |
3160 | 1458 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1459 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1460 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1461 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1462 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1463 |
|
4713 | 1464 |
lineStringBeforeCursor |
1465 |
"return the line's string before the cursor. |
|
1466 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1467 |
||
1468 |
|line| |
|
1469 |
||
1470 |
line := ((self at:cursorLine) ? '') string. |
|
1471 |
line size < (cursorCol-1) ifTrue:[ |
|
1472 |
^ line paddedTo:(cursorCol-1) |
|
1473 |
]. |
|
1474 |
^ line copyTo:(cursorCol-1) |
|
1475 |
! |
|
1476 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1477 |
list:something |
5413 | 1478 |
"replace the whole contents by something new. |
1479 |
this is not undoably, unless you care for yourself. |
|
1480 |
position cursor home when setting contents" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1481 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1482 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1483 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1484 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1485 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1486 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1487 |
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
|
1488 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1489 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1490 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1491 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1492 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1493 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1494 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1495 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1496 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1497 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1498 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1499 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1500 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1501 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1502 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1503 |
^ 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
|
1504 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1505 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1506 |
"/ 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
|
1507 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1508 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1509 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1510 |
setContents:something |
5413 | 1511 |
"replace the whole contents by something new |
1512 |
AND clear the remembered undo actions" |
|
1513 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1514 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1515 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1516 |
undoSupport resetHistories. |
2955 | 1517 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1518 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1519 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1520 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1521 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1522 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1523 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1524 |
|
4609 | 1525 |
!EditTextView methodsFor:'accessing-dimensions'! |
1526 |
||
1527 |
xOfCursor |
|
4728 | 1528 |
|point| |
1529 |
||
1530 |
cursorVisibleLine isNil ifTrue:[ |
|
1531 |
"/ take the end of the selection, if any |
|
1532 |
(selectionStartLine notNil |
|
1533 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1534 |
ifTrue:[ |
|
1535 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1536 |
]. |
|
1537 |
||
1538 |
"/ point := device |
|
1539 |
"/ translatePoint:(device pointerPosition) |
|
1540 |
"/ fromView:nil |
|
1541 |
"/ toView:self. |
|
1542 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1543 |
"/ ^ point x |
|
1544 |
"/ ]. |
|
1545 |
"/ ^ 0 |
|
1546 |
^ nil |
|
1547 |
]. |
|
4609 | 1548 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1549 |
||
1550 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1551 |
! ! |
|
4590 | 1552 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1553 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1554 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1555 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1556 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1557 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1558 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1559 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1560 |
wasOn := self hideCursor. |
5643 | 1561 |
cursorFgColor := color1 onDevice:device. |
1562 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1563 |
wasOn ifTrue:[self showCursor] |
1333 | 1564 |
! |
1565 |
||
1899 | 1566 |
cursorType |
1567 |
"return the style of the text cursor. |
|
4721 | 1568 |
Currently, supported are: #none |
1569 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1570 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1571 |
|
1572 |
^ cursorType |
|
1573 |
||
1574 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1575 |
! |
|
1576 |
||
1333 | 1577 |
cursorType:aCursorTypeSymbol |
1578 |
"set the style of the text cursor. |
|
4721 | 1579 |
Currently, supported are: #none |
1580 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1581 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1582 |
|
1334 | 1583 |
cursorType := aCursorTypeSymbol. |
1333 | 1584 |
|
1585 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1586 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1587 |
! |
1588 |
||
1899 | 1589 |
cursorTypeNoFocus |
1590 |
"return the style of the text cursor when the view has no focus. |
|
1591 |
If left unspecified, this is the same as the regular cursorType." |
|
1592 |
||
1593 |
^ cursorTypeNoFocus |
|
1594 |
||
1595 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1596 |
! |
|
1597 |
||
1334 | 1598 |
cursorTypeNoFocus:aCursorTypeSymbol |
1599 |
"set the style of the text cursor when the view has no focus. |
|
1600 |
If left unspecified, this is the same as the regular cursorType." |
|
1601 |
||
1602 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1603 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1604 |
|
4048 | 1605 |
!EditTextView methodsFor:'accessing-replace'! |
1606 |
||
4746 | 1607 |
lastReplacementInfo |
1608 |
^ lastReplacementInfo |
|
1609 |
! |
|
1610 |
||
4048 | 1611 |
lastStringToReplace: aString |
4818 | 1612 |
! |
1613 |
||
1614 |
previousReplacements |
|
1615 |
"accessor for the code completion" |
|
1616 |
||
1617 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1618 |
! ! |
1619 |
||
2119 | 1620 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1621 |
|
125 | 1622 |
accept |
1623 |
"accept the current contents by executing the accept-action and/or |
|
1624 |
changeMessage." |
|
1625 |
||
1108 | 1626 |
acceptEnabled == false ifTrue:[ |
3945 | 1627 |
self beep. |
1628 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1629 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1630 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
3945 | 1631 |
^ self |
1108 | 1632 |
]. |
1633 |
||
125 | 1634 |
lockUpdates := true. |
1013 | 1635 |
|
1636 |
"/ |
|
1637 |
"/ ST-80 way of doing it |
|
1638 |
"/ |
|
1639 |
model notNil ifTrue:[ |
|
4142 | 1640 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
5525 | 1641 |
acceptChannel notNil ifTrue:[ |
1642 |
acceptChannel value:true withoutNotifying:self. |
|
1643 |
]. |
|
2999 | 1644 |
]. |
1645 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1646 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1647 |
"/ ST/X way of doing things |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1648 |
"/ as a historic (and temporary) leftover, |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1649 |
"/ 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
|
1650 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1651 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1652 |
acceptAction notNil ifTrue:[ |
3945 | 1653 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1654 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1655 |
|
125 | 1656 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1657 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1658 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1659 |
! |
1660 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1661 |
argForChangeMessage |
597 | 1662 |
"return the argument to be passed with the change notification. |
1663 |
Defined as separate method for easier subclassability." |
|
1664 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1665 |
^ self contents |
597 | 1666 |
|
1667 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1668 |
! |
1669 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1670 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1671 |
"get my contents from the model. |
597 | 1672 |
Redefined to ignore updates resulting from my own changes |
1673 |
(i.e. if lockUpdates is true)." |
|
121 | 1674 |
|
1675 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1676 |
ignore updates from my own change |
121 | 1677 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1678 |
lockUpdates ifTrue:[ |
4823 | 1679 |
lockUpdates := false. |
1680 |
^ self |
|
121 | 1681 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1682 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1683 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1684 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1685 |
"/ validate the cursorLine |
3160 | 1686 |
(cursorLine notNil |
2310 | 1687 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1688 |
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
|
1689 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1690 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1691 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1692 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1693 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1694 |
acceptChannel value == true ifTrue:[ |
1695 |
self accept. |
|
1696 |
]. |
|
1697 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1698 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1699 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1700 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1701 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1702 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1703 |
! ! |
1704 |
||
1705 |
!EditTextView methodsFor:'cursor handling'! |
|
1706 |
||
4820 | 1707 |
basicCursorReturn |
1708 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1709 |
||
1710 |
|wasOn| |
|
1711 |
||
1712 |
self checkForExistingLine:(cursorLine + 1). |
|
1713 |
cursorVisibleLine notNil ifTrue:[ |
|
1714 |
nFullLinesShown notNil ifTrue:[ |
|
1715 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1716 |
] |
|
1717 |
]. |
|
1718 |
||
1719 |
wasOn := self hideCursor. |
|
1720 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1721 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1722 |
||
1723 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
1724 |
! |
|
1725 |
||
2406 | 1726 |
characterPositionOfCursor |
1727 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
1728 |
! |
|
1729 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1730 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1731 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1732 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1733 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1734 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1735 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1736 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1737 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1738 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1739 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1740 |
|
2822 | 1741 |
(cursorCol == newCol) ifTrue:[^ self]. |
1742 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1743 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1744 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1745 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1746 |
|
1747 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1748 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1749 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1750 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1751 |
"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
|
1752 |
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
|
1753 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1754 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1755 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1756 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1757 |
|
2707 | 1758 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1759 |
cursorLine > list size ifTrue:[ |
4595 | 1760 |
wasOn := self hideCursor. |
1761 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
1762 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1763 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1764 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
1765 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1766 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1767 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1768 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1769 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1770 |
"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
|
1771 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1772 |
|wasOn nv nL| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1773 |
|
4595 | 1774 |
(nL := cursorLine) isNil ifTrue:[ |
1775 |
nL := firstLineShown |
|
1776 |
]. |
|
1777 |
||
1778 |
self st80EditMode ifTrue:[ |
|
1779 |
nL == list size ifTrue:[ |
|
1780 |
wasOn := self hideCursor. |
|
1781 |
self setValidatedCursorLine:(list size) col:(self listAt:list size) size + 1. |
|
1782 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1783 |
self beep. |
|
1784 |
^ self. |
|
1785 |
] |
|
1786 |
]. |
|
1787 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1788 |
cursorVisibleLine notNil ifTrue:[ |
4595 | 1789 |
wasOn := self hideCursor. |
1790 |
nv := cursorVisibleLine + n - 1. |
|
1791 |
(nv >= nFullLinesShown) ifTrue:[ |
|
1792 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
1793 |
]. |
|
1794 |
self setValidatedCursorLine:(cursorLine + n) col:cursorCol. |
|
1795 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1796 |
] ifFalse:[ |
4595 | 1797 |
self setValidatedCursorLine:(nL + n) col:cursorCol. |
1798 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1799 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
1800 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
1801 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1802 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1803 |
|
121 | 1804 |
cursorHome |
597 | 1805 |
"scroll to top AND move cursor to first line of text." |
121 | 1806 |
|
674 | 1807 |
self cursorLine:1 col:1 |
1808 |
||
1809 |
"/ |wasOn| |
|
1810 |
"/ |
|
1811 |
"/ wasOn := self hideCursor. |
|
1812 |
"/ self scrollToTop. |
|
1813 |
"/ cursorLine := cursorVisibleLine := 1. |
|
1814 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
1815 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
1816 |
||
1817 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 1818 |
! |
1819 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1820 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1821 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1822 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1823 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 1824 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1825 |
] ifFalse:[ |
4823 | 1826 |
cursorLine ~~ 1 ifTrue:[ |
1827 |
self st80EditMode ifTrue:[ |
|
1828 |
self cursorUp. |
|
1829 |
self cursorToEndOfLine. |
|
1830 |
] |
|
1831 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1832 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1833 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
1834 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1835 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1836 |
|
4126 | 1837 |
cursorLeft:n |
1838 |
"move cursor to left" |
|
1839 |
||
1840 |
n timesRepeat:[ |
|
1841 |
self cursorLeft |
|
1842 |
]. |
|
1843 |
! |
|
1844 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1845 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1846 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1847 |
|
5056 | 1848 |
self cursorLine:line col:col makeVisible:true |
1849 |
! |
|
1850 |
||
1851 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
1852 |
"this positions onto physical - not visible - line" |
|
1853 |
||
676 | 1854 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1855 |
|
2822 | 1856 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
1857 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1858 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1859 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1860 |
|
672 | 1861 |
(col < 1) ifTrue:[ |
4823 | 1862 |
newCol := 1 |
672 | 1863 |
] ifFalse:[ |
4823 | 1864 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1865 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
1866 |
self st80EditMode ifTrue:[ |
4823 | 1867 |
(cursorLine == list size |
1868 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
1869 |
newCol := (self listAt:(list size)) size + 1. |
|
1870 |
] |
|
1419 | 1871 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1872 |
self setValidatedCursorCol:newCol. |
5056 | 1873 |
makeVisibleBoolean ifTrue:[ |
1874 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1875 |
] ifFalse:[ |
|
1876 |
wasOn ifTrue:[self showCursor] |
|
1877 |
]. |
|
672 | 1878 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1879 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1880 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1881 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1882 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1883 |
"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
|
1884 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1885 |
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
|
1886 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1887 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1888 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1889 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1890 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1891 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1892 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
1893 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1894 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1895 |
"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
|
1896 |
|
4820 | 1897 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1898 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1899 |
|
5529 | 1900 |
cursorReturn:withPossibleAutoIndent |
1901 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1902 |
||
1903 |
self basicCursorReturn |
|
1904 |
! |
|
1905 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1906 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1907 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1908 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1909 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1910 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
1911 |
self st80EditMode ifTrue:[ |
4823 | 1912 |
l := (self listAt:cursorLine). |
1913 |
cursorCol >= (l size + 1) ifTrue:[ |
|
5529 | 1914 |
cursorLine <= list size ifTrue:[ |
1915 |
self cursorReturn:false. "/ no autoindent |
|
4823 | 1916 |
]. |
1917 |
^ self |
|
1918 |
] |
|
3160 | 1919 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1920 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1921 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
1922 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1923 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1924 |
|
4126 | 1925 |
cursorRight:n |
1926 |
"move cursor to right" |
|
1927 |
||
1928 |
n timesRepeat:[ |
|
1929 |
self cursorRight |
|
1930 |
]. |
|
1931 |
! |
|
1932 |
||
1833 | 1933 |
cursorShown:aBoolean |
1934 |
"change cursor visibility |
|
1935 |
return true if cursor was visible before." |
|
1936 |
||
1937 |
|oldState| |
|
1938 |
||
4494 | 1939 |
aBoolean == cursorShown ifTrue:[ |
1940 |
^ cursorShown |
|
1941 |
]. |
|
1833 | 1942 |
oldState := cursorShown. |
1943 |
||
1944 |
aBoolean ifTrue:[ |
|
4494 | 1945 |
self drawCursor. |
1833 | 1946 |
] ifFalse:[ |
4494 | 1947 |
(cursorShown and:[shown]) ifTrue: [ |
1948 |
self undrawCursor. |
|
1949 |
]. |
|
1833 | 1950 |
]. |
1951 |
cursorShown := aBoolean. |
|
1952 |
||
1953 |
^ oldState |
|
1954 |
||
1955 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
1956 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
1957 |
! |
|
1958 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1959 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1960 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1961 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1962 |
self cursorCol:(self nextTabAfter:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1963 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1964 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1965 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1966 |
"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
|
1967 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1968 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1969 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1970 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1971 |
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
|
1972 |
cursorCol > textStart ifTrue:[ |
4823 | 1973 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1974 |
] ifFalse:[ |
4823 | 1975 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1976 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1977 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
1978 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1979 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1980 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1981 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1982 |
"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
|
1983 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1984 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1985 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1986 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1987 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1988 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1989 |
(newTop < 1) ifTrue:[ |
4823 | 1990 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1991 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1992 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1993 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1994 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1995 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1996 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 1997 |
|
674 | 1998 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1999 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2000 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2001 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2002 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2003 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2004 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2005 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2006 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2007 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2008 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2009 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2010 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2011 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2012 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2013 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2014 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2015 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2016 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2017 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2018 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2019 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2020 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2021 |
cursorLine >= lineNr ifTrue:[ |
4823 | 2022 |
line := self listAt:cursorLine. |
2023 |
(line isEmptyOrNil) ifTrue:[ |
|
2024 |
^ self |
|
2025 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2026 |
]. |
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 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2029 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2030 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2031 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2032 |
(newTop < 1) ifTrue:[ |
4823 | 2033 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2034 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2035 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2036 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2037 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2038 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2039 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2040 |
|
674 | 2041 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2042 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2043 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2044 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2045 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2046 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2047 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2048 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2049 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2050 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2051 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2052 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2053 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2054 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2055 |
cursorToEndOfText |
4288 | 2056 |
"move cursor to the end of the text (behind the last character in last line)" |
2057 |
||
2058 |
|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
|
2059 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2060 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2061 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2062 |
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
|
2063 |
(newTop < 1) ifTrue:[ |
4288 | 2064 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2065 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2066 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2067 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2068 |
self setValidatedCursorLine:list size. |
4288 | 2069 |
lastLineLength := (self listAt:cursorLine) size. |
2070 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2071 |
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
|
2072 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2073 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2074 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2075 |
"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
|
2076 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2077 |
|
3310 | 2078 |
cursorToEndOfWord |
2079 |
"move the cursor to the end of the word" |
|
2080 |
||
2081 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2082 |
||
2083 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2084 |
:beginLine :beginCol :endLine :endCol :style | |
2085 |
||
2086 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2087 |
] |
2088 |
||
2089 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2090 |
! |
|
2091 |
||
131 | 2092 |
cursorToFirstVisibleLine |
2093 |
"place cursor into the first visible line; do not scroll." |
|
2094 |
||
2095 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2096 |
! |
|
2097 |
||
2098 |
cursorToLastVisibleLine |
|
2099 |
"place cursor into the first visible line; do not scroll." |
|
2100 |
||
2101 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2102 |
! |
|
2103 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2104 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2105 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2106 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2107 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2108 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2109 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2110 |
|
3890 | 2111 |
self |
4707 | 2112 |
wordAtLine:cursorLine col:cursorCol |
2113 |
do:[ |
|
3890 | 2114 |
:beginLine :beginCol :endLine :endCol :style | |
2115 |
||
2116 |
line := endLine. |
|
2117 |
col := endCol + 1. |
|
2118 |
searching := true. |
|
4707 | 2119 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2120 |
self wordAtLine:line col:col do:[ |
2121 |
:beginLine :beginCol :endLine :endCol :style | |
|
2122 |
||
2123 |
(line > list size) ifTrue:[ |
|
2124 |
"break out" |
|
2125 |
searching := false |
|
2126 |
] ifFalse:[ |
|
2127 |
line := endLine. |
|
2128 |
col := endCol + 1. |
|
2129 |
] |
|
2130 |
] |
|
2131 |
]. |
|
2132 |
self cursorLine:line col:col |
|
4707 | 2133 |
] |
121 | 2134 |
! |
2135 |
||
499 | 2136 |
cursorToPreviousWord |
2137 |
"move the cursor to the beginning of this or the previous word" |
|
2138 |
||
2139 |
|col line searching l| |
|
2140 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2141 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2142 |
|
2143 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2144 |
:beginLine :beginCol :endLine :endCol :style | |
2145 |
||
2146 |
line := beginLine. |
|
2147 |
col := beginCol. |
|
2148 |
style == #wordLeft ifTrue:[ |
|
2149 |
col := col + 1 |
|
2150 |
]. |
|
2151 |
||
2152 |
(cursorLine == line |
|
2153 |
and:[cursorCol == col]) ifTrue:[ |
|
2154 |
searching := true. |
|
2155 |
||
2156 |
col > 1 ifTrue:[ |
|
2157 |
col := col - 1. |
|
2158 |
]. |
|
2159 |
||
2160 |
[searching] whileTrue:[ |
|
2161 |
(col == 1) ifTrue:[ |
|
2162 |
line == 1 ifTrue:[ |
|
2163 |
searching := false |
|
2164 |
] ifFalse:[ |
|
2165 |
line := line - 1. |
|
2166 |
l := list at:line. |
|
2167 |
col := l size + 1. |
|
2168 |
] |
|
2169 |
] ifFalse:[ |
|
2170 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2171 |
self wordAtLine:line col:col do:[ |
|
2172 |
:beginLine :beginCol :endLine :endCol :style | |
|
2173 |
||
2174 |
line := beginLine. |
|
2175 |
col := beginCol. |
|
2176 |
style == #wordLeft ifTrue:[ |
|
2177 |
col := col + 1 |
|
2178 |
]. |
|
2179 |
searching := false. |
|
2180 |
] |
|
2181 |
] ifTrue:[ |
|
2182 |
col := col - 1 |
|
2183 |
] |
|
2184 |
] |
|
2185 |
] |
|
2186 |
]. |
|
2187 |
self cursorLine:line col:col |
|
499 | 2188 |
] |
2189 |
||
2190 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2191 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2192 |
! |
|
2193 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2194 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2195 |
"move cursor to absolute home" |
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 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2198 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2199 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2200 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2201 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2202 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2203 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2204 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2205 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2206 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2207 |
"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
|
2208 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2209 |
|wasOn nv nl| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2210 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2211 |
cursorLine isNil ifTrue:[ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2212 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2213 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2214 |
nl := cursorLine - n. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2215 |
nl < 1 ifTrue:[nl := 1]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2216 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2217 |
(nl ~~ cursorLine) ifTrue: [ |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2218 |
wasOn := self hideCursor. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2219 |
cursorVisibleLine notNil ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2220 |
nv := cursorVisibleLine - n. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2221 |
nv < 1 ifTrue:[ |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2222 |
self scrollUp:(nv negated + 1) |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2223 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2224 |
]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2225 |
self setValidatedCursorLine:nl col:cursorCol. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2226 |
"/ wasOn ifTrue:[self showCursor]. |
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2227 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2228 |
] |
672 | 2229 |
|
674 | 2230 |
"Modified: 22.5.1996 / 18:28:11 / 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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2233 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2234 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2235 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2236 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2237 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2238 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2239 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2240 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2241 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2242 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2243 |
|
676 | 2244 |
newCol := colNr. |
2245 |
(newCol < 1) ifTrue:[ |
|
4823 | 2246 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2247 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2248 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2249 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2250 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2251 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2252 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2253 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2254 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2255 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2256 |
"put cursor to position next to x/y coordinate in view" |
121 | 2257 |
|
2258 |
|line col| |
|
2259 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2260 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2261 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2262 |
self cursorVisibleLine:line col:col. |
121 | 2263 |
! |
2264 |
||
2265 |
drawCursor |
|
2266 |
"draw the cursor if shown and cursor is visible. |
|
2267 |
(but not, if there is a selection - to avoid confusion)" |
|
2268 |
||
2269 |
shown ifTrue:[ |
|
4823 | 2270 |
cursorVisibleLine notNil ifTrue:[ |
2271 |
self hasSelection ifFalse:[ |
|
2272 |
self drawCursorCharacter |
|
2273 |
] |
|
2274 |
] |
|
121 | 2275 |
] |
2276 |
! |
|
2277 |
||
2278 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2279 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2280 |
of cursor should be drawn. |
4721 | 2281 |
Currently, supported are: #none, |
2282 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2283 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2284 |
|
2570 | 2285 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2286 |
|
2287 |
self hasSelection ifTrue:[ |
|
4580 | 2288 |
" |
2289 |
hide cursor, if there is a selection |
|
2290 |
" |
|
2291 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2292 |
]. |
2293 |
||
1334 | 2294 |
cursorType == #none ifTrue:[ |
4580 | 2295 |
^ self |
1334 | 2296 |
]. |
2297 |
||
121 | 2298 |
cursorType == #block ifTrue:[ |
4829 | 2299 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2300 |
^ self |
121 | 2301 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2302 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2303 |
y := self yOfVisibleLine:cursorVisibleLine. |
2304 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2305 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2306 |
cursorType == #frame ifTrue:[ |
4580 | 2307 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2308 |
||
2309 |
char := self characterUnderCursor asString. |
|
4829 | 2310 |
self paint:bgColor. |
4889 | 2311 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2312 |
] ifFalse:[ |
4580 | 2313 |
self paint:bgColor. |
2314 |
cursorType == #ibeam ifTrue:[ |
|
2315 |
x1 := x - 1. |
|
5581 | 2316 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2317 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2318 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2319 |
^ self |
|
2320 |
]. |
|
2321 |
||
2322 |
cursorType == #Ibeam ifTrue:[ |
|
2323 |
x1 := x - 1. |
|
2324 |
y := y + 1. |
|
5581 | 2325 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2326 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2327 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2328 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2329 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2330 |
^ self |
|
2331 |
]. |
|
2332 |
||
2333 |
y := y + fontHeight - 3. |
|
2334 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2335 |
w := (fontWidth * 2 // 3) max:4. |
|
2336 |
y2 := y + w + (w//2). |
|
2337 |
] ifFalse:[ |
|
2338 |
w := (fontWidth // 2) max:4. |
|
2339 |
y2 := y + w. |
|
2340 |
]. |
|
2341 |
x1 := x - w. |
|
2342 |
x2 := x + w. |
|
2343 |
||
2344 |
oldClip := self clippingRectangleOrNil. |
|
2345 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2346 |
||
2347 |
cursorType == #caret ifTrue:[ |
|
2348 |
self lineWidth:2. |
|
2349 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2350 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2351 |
] ifFalse:[ |
|
2352 |
"anything else: solidCaret" |
|
2353 |
||
2354 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2355 |
with:(x @ y) |
|
2356 |
with:(x2 @ y2)) |
|
2357 |
]. |
|
2358 |
||
2359 |
self clippingRectangle:oldClip |
|
121 | 2360 |
]. |
133 | 2361 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2362 |
|
2088 | 2363 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2364 |
! |
2365 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2366 |
drawCursorCharacter |
3160 | 2367 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2368 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2369 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2370 |
|
3160 | 2371 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2372 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2373 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2374 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2375 |
] ifFalse:[ |
4823 | 2376 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2377 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2378 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2379 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2380 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2381 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2382 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2383 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2384 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2385 |
self hasSelection ifTrue:[ |
5260 | 2386 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2387 |
]. |
2388 |
cursorType == #none ifTrue:[ |
|
4823 | 2389 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2390 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2391 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2392 |
|
2393 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2394 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2395 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2396 |
drawNoFocusCursor |
3160 | 2397 |
"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
|
2398 |
|
1334 | 2399 |
|cType| |
2400 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2401 |
self hasSelection ifTrue:[ |
4823 | 2402 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2403 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2404 |
|
1334 | 2405 |
cType := cursorTypeNoFocus ? cursorType. |
2406 |
cType == #none ifTrue:[ |
|
4823 | 2407 |
^ self undrawCursor |
1334 | 2408 |
]. |
2409 |
||
2410 |
cType == #block ifTrue:[ |
|
4823 | 2411 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2412 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2413 |
|
1334 | 2414 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2415 |
||
2416 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2417 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2418 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2419 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2420 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2421 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2422 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2423 |
self makeLineVisible:aLineNumber. |
2951 | 2424 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2425 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2426 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2427 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2428 |
hideCursor |
1833 | 2429 |
"make cursor invisible if currently invisible" |
2430 |
||
2431 |
^ self cursorShown:false |
|
2432 |
||
2433 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2434 |
! |
2435 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2436 |
makeCursorVisible |
3160 | 2437 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2438 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2439 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2440 |
|line col| |
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 |
cursorLine notNil ifTrue:[ |
4823 | 2443 |
line := cursorLine. |
2444 |
col := cursorCol. |
|
2445 |
" |
|
2446 |
if there is a selection, its better to |
|
2447 |
have its start being visible, instead of the end |
|
2448 |
" |
|
2449 |
(selectionStartLine notNil |
|
2450 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2451 |
expandingTop ~~ false ifTrue:[ |
|
2452 |
line := selectionStartLine. |
|
2453 |
col := selectionStartCol. |
|
2454 |
] ifFalse:[ |
|
2455 |
line := selectionEndLine. |
|
2456 |
col := selectionEndCol |
|
2457 |
] |
|
2458 |
]. |
|
2459 |
self makeLineVisible:line. |
|
2460 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2461 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2462 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2463 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2464 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2465 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2466 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2467 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2468 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2469 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2470 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2471 |
flag ifTrue:[self showCursor] |
121 | 2472 |
! |
2473 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2474 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2475 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2476 |
|
2815 | 2477 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2478 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2479 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2480 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2481 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2482 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2483 |
|
3303 | 2484 |
"/ self assert:(lineNr notNil). |
2485 |
||
2486 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2487 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2488 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2489 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2490 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2491 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2492 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2493 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2494 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2495 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2496 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2497 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2498 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2499 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2500 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2501 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2502 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2503 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2504 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2505 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2506 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2507 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2508 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2509 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2510 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2511 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2512 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2513 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2514 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2515 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2516 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2517 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2518 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2519 |
|
1833 | 2520 |
^ self cursorShown:true |
2521 |
||
2522 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2523 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2524 |
|
5761 | 2525 |
singleQuoteSelection |
2526 |
"place single quotes around the selected text" |
|
2527 |
||
2528 |
|line1 col1 line2 col2| |
|
2529 |
||
2530 |
line1 := self selectionStartLine. |
|
2531 |
col1 := self selectionStartCol. |
|
2532 |
line2 := self selectionEndLine. |
|
2533 |
col2 := self selectionEndCol. |
|
2534 |
(line1 notNil |
|
2535 |
and:[ col1 notNil |
|
2536 |
and:[ line2 notNil |
|
2537 |
and:[ col2 notNil ]]]) |
|
2538 |
ifTrue:[ |
|
2539 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
|
2540 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2541 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
2542 |
] ifFalse:[ |
|
2543 |
self beep. |
|
2544 |
] |
|
2545 |
||
2546 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2547 |
! |
|
2548 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2549 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2550 |
"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
|
2551 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2552 |
|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
|
2553 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2554 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2555 |
prevCol := cursorCol - 1. |
2556 |
||
2557 |
"/ if there is any italic stuff in the cursor line, |
|
2558 |
"/ redraw it completely (because characters overlap). |
|
2559 |
cursorCol > 1 ifTrue:[ |
|
2560 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2561 |
line hasChangeOfEmphasis ifTrue:[ |
|
2562 |
line size >= (cursorCol-1) ifTrue:[ |
|
2563 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2564 |
line size >= (cursorCol) ifTrue:[ |
|
2565 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2566 |
line size >= (cursorCol+1) ifTrue:[ |
|
2567 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2568 |
]. |
|
2569 |
]. |
|
2570 |
]. |
|
2571 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2572 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2573 |
] |
|
2574 |
] |
|
2575 |
] |
|
2576 |
]. |
|
2577 |
||
2578 |
((cursorType == #caret) |
|
2579 |
or:[cursorType == #solidCaret |
|
2580 |
or:[cursorType == #bigSolidCaret |
|
2581 |
or:[cursorType == #bigCaret |
|
2582 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2583 |
"caret-cursor touches 4 characters" |
|
2584 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2585 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2586 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2587 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2588 |
] ifFalse:[ |
|
2589 |
"care for left margin" |
|
2590 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2591 |
]. |
|
2592 |
^ self |
|
2593 |
]. |
|
2594 |
||
2595 |
cursorType == #ibeam ifTrue:[ |
|
2596 |
"ibeam-cursor touches 2 characters" |
|
2597 |
cursorCol > 1 ifTrue:[ |
|
2598 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2599 |
] ifFalse:[ |
|
2600 |
"care for left margin" |
|
2601 |
super redrawVisibleLine:cursorVisibleLine. |
|
2602 |
]. |
|
2603 |
^ self |
|
2604 |
]. |
|
2605 |
||
2606 |
"block cursor is simple - just one character under cursor" |
|
2607 |
||
2608 |
"/ however, if italic characters are involved, we must care |
|
2609 |
"/ for the chars before/after the cursor. |
|
2610 |
"/ We redraw the part of the previous character which got |
|
2611 |
"/ detroyed by the block cursor. |
|
2612 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2613 |
||
2614 |
line := self visibleAt:cursorVisibleLine. |
|
2615 |
(line notNil and:[line isText]) ifTrue:[ |
|
2616 |
cursorCol > 1 ifTrue:[ |
|
2617 |
oldClip := self clippingRectangleOrNil. |
|
2618 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2619 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2620 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2621 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2622 |
self clippingRectangle:oldClip. |
|
2623 |
^ self. |
|
2624 |
]. |
|
2625 |
]. |
|
2626 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2627 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2628 |
|
2088 | 2629 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2630 |
! |
2631 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2632 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2633 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2634 |
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
|
2635 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2636 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2637 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2638 |
|
672 | 2639 |
validateCursorCol:col inLine:line |
674 | 2640 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2641 |
Here, no limits are enforced (and col is returned), |
5593 | 2642 |
but it may be redefined in EditFields or views which don't like the |
674 | 2643 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2644 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2645 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2646 |
|
1419 | 2647 |
"/ in ST80 mode, |
2707 | 2648 |
"/ the cursor may not be positioned beyond the |
2649 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2650 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2651 |
self st80EditMode ifTrue:[ |
4823 | 2652 |
l := (self listAt:line). |
2653 |
max := l size + 1. |
|
2654 |
col > max ifTrue:[ |
|
2655 |
^ max |
|
2656 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2657 |
]. |
672 | 2658 |
^ col |
2659 |
||
1419 | 2660 |
"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
|
2661 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2662 |
! |
2663 |
||
2664 |
validateCursorLine:line |
|
2665 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2666 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2667 |
redefined in views which don't like the cursor to be positioned |
674 | 2668 |
behind the end of the text (vi/st-80 behavior), or want to |
2669 |
skip reserved regions" |
|
2670 |
||
1419 | 2671 |
"/ |
2672 |
"/ in st80Mode, the cursor may not be positioned |
|
5367 | 2673 |
"/ beyond the last line |
2674 |
"/ (but it must be posible to place it on one line below the last one |
|
2675 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
|
1419 | 2676 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2677 |
self st80EditMode ifTrue:[ |
5367 | 2678 |
^ (line min:(list size + 1)) max:1 |
1419 | 2679 |
]. |
674 | 2680 |
^ line |
2681 |
||
1419 | 2682 |
"Created: / 22.5.1996 / 18:22:23 / cg" |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2683 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2684 |
! |
2685 |
||
121 | 2686 |
withCursorOffDo:aBlock |
2687 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2688 |
||
2689 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2690 |
^ aBlock value |
121 | 2691 |
]. |
2692 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2693 |
aBlock ensure:[ |
4823 | 2694 |
self showCursor |
121 | 2695 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2696 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2697 |
|
2589 | 2698 |
!EditTextView methodsFor:'drag & drop'! |
2699 |
||
2700 |
allowDrop:aBoolean |
|
3236 | 2701 |
"enable/disable drop support" |
2702 |
||
2589 | 2703 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2704 |
dropTarget := nil. |
2589 | 2705 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2706 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2707 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2708 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2709 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2710 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2711 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2712 |
] |
3236 | 2713 |
]. |
2714 |
! |
|
2715 |
||
3412 | 2716 |
canDrop:aDropContext |
2717 |
"public from d&d. |
|
2718 |
I accept textObjects and fileObjects only." |
|
2719 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
2720 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 2721 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
2722 |
^ self canDropObjects:aDropContext dropObjects |
|
2723 |
||
2724 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
2725 |
! |
|
2726 |
||
2727 |
canDropObjects:aCollectionOfDropObjects |
|
2728 |
"public from d&d. |
|
2729 |
I accept textObjects and fileObjects only." |
|
2589 | 2730 |
|
2731 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
2732 |
||
3412 | 2733 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
2734 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
2735 |
||
2736 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
2737 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
2738 |
! |
|
2739 |
||
2740 |
drop:aDropContext |
|
2741 |
"public from d&d. |
|
2742 |
drop objects (new API)" |
|
2743 |
||
2744 |
self dropObjects:(aDropContext dropObjects) |
|
2745 |
||
2746 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
2747 |
! |
|
2748 |
||
2749 |
dropFileObject:aDropObject |
|
2589 | 2750 |
"drop objects |
3236 | 2751 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
2752 |
||
4136 | 2753 |
|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
|
2754 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2755 |
pasteWhat := #name. |
3412 | 2756 |
|
2757 |
fn := aDropObject asFilename. |
|
2758 |
(fn exists and:[fn isRegularFile]) ifTrue:[ |
|
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2759 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2760 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2761 |
and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2762 |
pasteWhat := enforcedDropMode. |
3886 | 2763 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2764 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2765 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2766 |
pasteWhat := #name. |
3886 | 2767 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2768 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2769 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2770 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2771 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2772 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2773 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2774 |
stringWithCRs:'Drop the Filename (%1)\or its Contents ?\\Hint: bypass this dialog by pressing SHIFT/CTRL or ALT during the next drop.\SHIFT/CTRL to drop the name, ALT for the contents.' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2775 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2776 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2777 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2778 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2779 |
check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2780 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2781 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2782 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2783 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2784 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2785 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2786 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2787 |
] |
3886 | 2788 |
] |
2789 |
]. |
|
2790 |
]. |
|
2791 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
2792 |
pasteWhat == #name ifTrue:[ |
3886 | 2793 |
text := fn pathName |
2794 |
] ifFalse:[ |
|
2795 |
self withWaitCursorDo:[ |
|
5063 | 2796 |
text := fn contentsAsString |
4136 | 2797 |
]. |
2798 |
(app := self application) notNil ifTrue:[ |
|
2799 |
app droppedFile:fn in:self |
|
2800 |
]. |
|
3886 | 2801 |
]. |
2802 |
||
3799 | 2803 |
self |
2804 |
undoablePaste:text |
|
2805 |
info:'Drop File'. |
|
3412 | 2806 |
|
2807 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 2808 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 2809 |
! |
2810 |
||
2811 |
dropObject:aDropObject |
|
2812 |
"drop objects |
|
2813 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
2814 |
||
3415 | 2815 |
|text| |
2816 |
||
3412 | 2817 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 2818 |
self dropFileObject:aDropObject |
3412 | 2819 |
] ifFalse:[ |
3799 | 2820 |
aDropObject isTextObject ifTrue:[ |
2821 |
text := aDropObject theObject. |
|
2822 |
text isStringCollection ifTrue:[ |
|
2823 |
text := text asStringWithoutFinalCR |
|
2824 |
]. |
|
2825 |
] ifFalse:[ |
|
2826 |
text := aDropObject theObject asString |
|
2827 |
]. |
|
2828 |
self |
|
2829 |
undoablePaste:text |
|
2830 |
info:'Drop'. |
|
3412 | 2831 |
]. |
2832 |
||
2833 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 2834 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 2835 |
! |
2836 |
||
2837 |
dropObjects:aCollectionOfDropObjects |
|
2838 |
"public from d&d. |
|
2839 |
drop objects (old API)" |
|
2840 |
||
3868 | 2841 |
aCollectionOfDropObjects do:[:el | |
2842 |
self dropObject:el |
|
3412 | 2843 |
]. |
2844 |
||
2845 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
2846 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 2847 |
! ! |
2848 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2849 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2850 |
|
5761 | 2851 |
applyConverterToSelection:converter |
2852 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2853 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2854 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2855 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2856 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2857 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2858 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2859 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2860 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2861 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2862 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2863 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2864 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2865 |
line1 to:line2 do:[:lineNr | |
5761 | 2866 |
|line col1 col2 newLine| |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2867 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2868 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2869 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2870 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2871 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2872 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2873 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2874 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2875 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2876 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2877 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2878 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2879 |
]. |
5761 | 2880 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
2881 |
self withoutRedrawAt:lineNr put:newLine. |
|
2882 |
self invalidateLine:lineNr. |
|
2883 |
]. |
|
2884 |
]. |
|
2885 |
] |
|
2886 |
||
2887 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
2888 |
! |
|
2889 |
||
2890 |
convertSelectionToLowercase |
|
2891 |
"to-lower selected text" |
|
2892 |
||
2893 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
2894 |
col1 to:col2 do:[:col | |
|
2895 |
|ch| |
|
2896 |
||
2897 |
ch := line at:col. |
|
2898 |
line at:col put:ch asLowercase. |
|
2899 |
]. |
|
2900 |
line. |
|
2901 |
]. |
|
2902 |
||
2903 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
2904 |
! |
|
2905 |
||
2906 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
2907 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
2908 |
||
2909 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
2910 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
|
2911 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
2912 |
||
2913 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
2914 |
col1 to:col2 do:[:col | |
|
2915 |
|ch| |
|
2916 |
||
2917 |
ch := line at:col. |
|
2918 |
ch isUppercase ifTrue:[ |
|
2919 |
isAllLower := false. |
|
2920 |
col == col1 ifTrue:[ |
|
2921 |
isLowerFirst := false. |
|
2922 |
]. |
|
2923 |
] ifFalse:[ |
|
2924 |
ch isLowercase ifTrue:[ |
|
2925 |
isAllUpper := false. |
|
2926 |
col == col1 ifTrue:[ |
|
2927 |
isUpperFirst := false. |
|
2928 |
]. |
|
2929 |
] |
|
2930 |
]. |
|
2931 |
]. |
|
2932 |
||
2933 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
2934 |
isLowerFirst ifTrue:[ |
|
2935 |
makeUppercaseFirst := true. |
|
2936 |
] ifFalse:[ |
|
2937 |
"/ must remember where we come from - otherwise, we end up |
|
2938 |
"/ in upperFirst - lowerFirst cycle. |
|
2939 |
"/ think about a good place to store this state |
|
2940 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
2941 |
makeLowercaseFirst := true. |
|
2942 |
] ifFalse:[ |
|
2943 |
isAllUpper ifTrue:[ |
|
2944 |
makeLowercase := true. |
|
2945 |
] ifFalse:[ |
|
2946 |
makeUppercase := true. |
|
2947 |
] |
|
2948 |
] |
|
2949 |
]. |
|
2950 |
makeUppercaseFirst ifTrue:[ |
|
2951 |
line at:col1 put:(line at:col1) asUppercase. |
|
2952 |
] ifFalse:[ |
|
2953 |
makeLowercaseFirst ifTrue:[ |
|
2954 |
line at:col1 put:(line at:col1) asLowercase. |
|
2955 |
] ifFalse:[ |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2956 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2957 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2958 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2959 |
ch := line at:col. |
5761 | 2960 |
ch := makeLowercase |
2961 |
ifTrue:[ ch asLowercase ] |
|
2962 |
ifFalse:[ |
|
2963 |
makeUppercase |
|
2964 |
ifTrue:[ ch asUppercase ] |
|
2965 |
ifFalse:[ |
|
2966 |
col == col1 |
|
2967 |
ifTrue:[ ch asUppercase ] |
|
2968 |
ifFalse:[ ch asLowercase ] |
|
2969 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2970 |
]. |
5761 | 2971 |
line at:col put:ch. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2972 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2973 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2974 |
]. |
5761 | 2975 |
line |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2976 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2977 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
2978 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 2979 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
2980 |
! |
|
2981 |
||
2982 |
convertSelectionToUppercase |
|
2983 |
"to-upper selected text" |
|
2984 |
||
2985 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
2986 |
col1 to:col2 do:[:col | |
|
2987 |
|ch| |
|
2988 |
||
2989 |
ch := line at:col. |
|
2990 |
line at:col put:ch asUppercase. |
|
2991 |
]. |
|
2992 |
line. |
|
2993 |
]. |
|
2994 |
||
2995 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
2996 |
! |
|
2997 |
||
2998 |
convertSelectionToUppercaseFirst |
|
2999 |
"to-upperFirst selected text" |
|
3000 |
||
3001 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3002 |
|state| |
|
3003 |
||
3004 |
state := #first. |
|
3005 |
col1 to:col2 do:[:col | |
|
3006 |
|ch| |
|
3007 |
||
3008 |
ch := line at:col. |
|
3009 |
ch isSeparator ifFalse:[ |
|
3010 |
state == #first ifTrue:[ |
|
3011 |
line at:col put:ch asUppercase. |
|
3012 |
state := #skipRest |
|
3013 |
] |
|
3014 |
] ifTrue:[ |
|
3015 |
state := #first |
|
3016 |
] |
|
3017 |
]. |
|
3018 |
line. |
|
3019 |
]. |
|
3020 |
||
3021 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3022 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3023 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3024 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3025 |
"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
|
3026 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3027 |
selectionStartLine notNil ifTrue:[ |
4823 | 3028 |
self setClipboardText:(self selection). |
3029 |
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
|
3030 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3031 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3032 |
"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
|
3033 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3034 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3035 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3036 |
"delete single character under cursor; does not merge lines" |
121 | 3037 |
|
3038 |
|wasOn| |
|
3039 |
||
3040 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3041 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3042 |
wasOn ifTrue:[self showCursor] |
3043 |
! |
|
3044 |
||
827 | 3045 |
deleteCharAtLine:lineNr col:colNr |
3046 |
"delete a single character at colNr in line lineNr" |
|
3047 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3048 |
self st80EditMode ifTrue:[ |
4823 | 3049 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3050 |
| wasOn | |
|
3051 |
wasOn := self hideCursor. |
|
3052 |
self |
|
3053 |
cursorReturn; |
|
3054 |
cursorCol:1; |
|
3055 |
deleteCharBeforeCursor. |
|
3056 |
wasOn ifTrue:[ self showCursor]. |
|
3057 |
^ self. |
|
3058 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3059 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3060 |
|
827 | 3061 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3062 |
! |
|
3063 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3064 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3065 |
"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
|
3066 |
|
4592 | 3067 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3068 |
|
3069 |
wasOn := self hideCursor. |
|
4814 | 3070 |
(autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[ |
4592 | 3071 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
4966 | 3072 |
ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''. |
4592 | 3073 |
ln size < prevTab ifTrue:[ |
3074 |
ln := ln , (String new:prevTab withAll:Character space). |
|
3075 |
]. |
|
3076 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3077 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3078 |
cursorCol > prevTab ifTrue:[ |
|
3079 |
self st80EditMode ifTrue:[ |
|
3080 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3081 |
"/ not allow a cursor position beyond the end of line, |
|
5742 | 3082 |
"/ so ensure that cursorLine:col: will force us to the beginning of the line |
4592 | 3083 |
originalLine size < prevTab ifTrue:[ |
5742 | 3084 |
self checkForExistingLine:cursorLine. |
4771 | 3085 |
self basicListAt:cursorLine put:ln |
4592 | 3086 |
] |
3087 |
]. |
|
3088 |
self cursorLine:cursorLine col:prevTab. |
|
3089 |
wasOn ifTrue:[ self showCursor ]. |
|
3090 |
^ self |
|
3091 |
]. |
|
3092 |
] ifFalse:[ |
|
3093 |
self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
|
3094 |
self cursorLine:cursorLine col:prevTab. |
|
3095 |
wasOn ifTrue:[ self showCursor ]. |
|
3096 |
^ self. |
|
3097 |
] |
|
3098 |
]. |
|
827 | 3099 |
]. |
3100 |
||
2491 | 3101 |
"/ (autoIndent |
3102 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3103 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3104 |
"/ ifTrue:[ |
3105 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3106 |
"/ |
|
3107 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3108 |
"/ ln := list at:cursorLine. |
|
3109 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3110 |
"/ soCol := 1 |
|
3111 |
"/ ] |
|
3112 |
"/ ] |
|
3113 |
"/ ] ifFalse:[ |
|
4592 | 3114 |
soCol := 1. |
2491 | 3115 |
"/ ]. |
3116 |
||
1419 | 3117 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 3118 |
" |
3119 |
somewhere in the middle of a line |
|
3120 |
" |
|
3121 |
self cursorLeft. |
|
3122 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3123 |
] ifFalse:[ |
4592 | 3124 |
" |
3125 |
at begin of line - merge with previous line; |
|
3126 |
except for the very first line. |
|
3127 |
" |
|
3128 |
(cursorLine == 1) ifFalse:[ |
|
3129 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3130 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3131 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3132 |
"/ we are beyond the end of the text. |
|
3133 |
"/ move the cursor to the previous line. |
|
3134 |
self cursorLine:lineNrAboveCursor col:1. |
|
3135 |
] ifFalse:[ |
|
3136 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3137 |
] |
|
3138 |
] |
|
3139 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3140 |
]. |
827 | 3141 |
wasOn ifTrue:[ self showCursor ] |
3142 |
||
1419 | 3143 |
"Modified: / 16.1.1998 / 22:33:04 / cg" |
827 | 3144 |
! |
3145 |
||
3146 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3147 |
"delete characters from colNr up to the end in line lineNr" |
|
3148 |
||
3149 |
|line| |
|
3150 |
||
3151 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 3152 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3153 |
] |
3154 |
||
3155 |
! |
|
3156 |
||
4458 | 3157 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3158 |
"delete characters from startCol to endCol in line lineNr" |
|
3159 |
||
3160 |
|deleted| |
|
3161 |
||
3162 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3163 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3164 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3165 |
! |
|
3166 |
||
827 | 3167 |
deleteCharsAtLine:lineNr toCol:colNr |
3168 |
"delete characters from start up to colNr in line lineNr" |
|
3169 |
||
3170 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3171 |
||
3172 |
||
121 | 3173 |
! |
3174 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3175 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3176 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3177 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3178 |
self deleteLine:cursorLine |
121 | 3179 |
! |
3180 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3181 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3182 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3183 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3184 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3185 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3186 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3187 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3188 |
col1 == 0 ifTrue:[ |
4823 | 3189 |
line1 := line1 - 1. |
3190 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3191 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3192 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3193 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3194 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3195 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3196 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3197 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3198 |
|
2954 | 3199 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3200 |
"delete all text from startLine/startCol to endLine/endCol - |
|
3201 |
joining lines if nescessary" |
|
3202 |
||
3203 |
|line newLine lineSize nMore| |
|
3204 |
||
3205 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3206 |
list isNil ifTrue:[^ self]. |
|
3207 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3208 |
||
3209 |
(startLine == endLine) ifTrue:[ |
|
4225 | 3210 |
"/ delete chars within a line |
3211 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3212 |
^ self |
|
2954 | 3213 |
]. |
3214 |
||
3215 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3216 |
"/ delete full lines only |
3217 |
endLine > startLine ifTrue:[ |
|
3218 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3219 |
]. |
|
3220 |
^ self |
|
2954 | 3221 |
]. |
3222 |
||
3223 |
"/ delete right rest of 1st line |
|
4786 | 3224 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3225 |
|
3226 |
"/ delete the inner lines ... |
|
3227 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3228 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3229 |
]. |
3230 |
||
3231 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3232 |
"/ delete the left rest of the last line |
3233 |
||
3234 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3235 |
||
3236 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3237 |
startLine <= list size ifTrue:[ |
|
3238 |
line := list at:startLine. |
|
3239 |
lineSize := line size. |
|
3240 |
(startCol > lineSize) ifTrue:[ |
|
3241 |
newLine := line. |
|
3242 |
line isNil ifTrue:[ |
|
3243 |
newLine := String new:(startCol - 1) |
|
3244 |
] ifFalse:[ |
|
3245 |
nMore := startCol - 1 - lineSize. |
|
3246 |
nMore > 0 ifTrue:[ |
|
3247 |
newLine := line , (line species new:nMore) |
|
3248 |
] |
|
3249 |
]. |
|
3250 |
newLine ~~ line ifTrue:[ |
|
4771 | 3251 |
self basicListAt:startLine put:newLine. |
4225 | 3252 |
]. |
3253 |
"/ TODO: remember old maxwidth of linerange, |
|
3254 |
"/ only clear widthOfWidestLine, if this max |
|
3255 |
"/ length was (one of) the longest. |
|
3256 |
"/ avoids slow delete with huge texts. |
|
3257 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3258 |
self textChanged. |
|
3259 |
] |
|
3260 |
] |
|
2954 | 3261 |
]. |
3262 |
||
3263 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3264 |
self mergeLine:startLine removeBlanks:false |
|
3265 |
||
4225 | 3266 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3267 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3268 |
! |
3269 |
||
4458 | 3270 |
deleteFromLine:startLineNr toLine:endLineNr |
3271 |
"delete some lines" |
|
3272 |
||
3273 |
|deleted| |
|
3274 |
||
3275 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3276 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3277 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3278 |
! |
|
3279 |
||
827 | 3280 |
deleteLine:lineNr |
3281 |
"delete line" |
|
3282 |
||
3283 |
self deleteFromLine:lineNr toLine:lineNr |
|
3284 |
||
3285 |
||
3286 |
! |
|
3287 |
||
4458 | 3288 |
deleteLineWithoutRedraw:lineNr |
3289 |
"delete line - no redraw; |
|
3290 |
return true, if something was really deleted" |
|
3291 |
||
3292 |
|deleted ret| |
|
3293 |
||
3294 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3295 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3296 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3297 |
^ ret. |
|
3298 |
! |
|
3299 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3300 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3301 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3302 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3303 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3304 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3305 |
|
4771 | 3306 |
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
|
3307 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3308 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3309 |
(endLine > list size) ifTrue:[ |
4771 | 3310 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3311 |
] ifFalse:[ |
4771 | 3312 |
lastLine := endLine |
3313 |
]. |
|
3314 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3315 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3316 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3317 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3318 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3319 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3320 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3321 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3322 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3323 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3324 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3325 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3326 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3327 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3328 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3329 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3330 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3331 |
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
|
3332 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3333 |
selectionStartLine notNil ifTrue:[ |
4823 | 3334 |
wasOn := self hideCursor. |
3335 |
||
3336 |
startLine := selectionStartLine. |
|
3337 |
startCol := selectionStartCol. |
|
3338 |
endLine := selectionEndLine. |
|
3339 |
endCol := selectionEndCol. |
|
3340 |
self unselectWithoutRedraw. |
|
3341 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3342 |
self setCursorLine:startLine col:startCol. |
|
3343 |
||
3344 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3345 |
] |
121 | 3346 |
! |
3347 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3348 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3349 |
"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
|
3350 |
|
2952 | 3351 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3352 |
|
3799 | 3353 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3354 |
cursorCol <= 1 ifTrue:[ |
3355 |
self deleteCharBeforeCursor. |
|
3356 |
^ self |
|
3357 |
]. |
|
3799 | 3358 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3359 |
wasOn := self hideCursor. |
3799 | 3360 |
self |
3361 |
undoableDo:[ |
|
3362 |
endCol := cursorCol-1. |
|
3363 |
endLine := cursorLine. |
|
3364 |
self cursorToPreviousWord. |
|
3365 |
beginCol := cursorCol. |
|
3366 |
beginLine := cursorLine. |
|
3367 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5361 | 3368 |
self cursorLine:cursorLine col:beginCol. |
3799 | 3369 |
] |
3370 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3371 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3372 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3373 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3374 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3375 |
|
5761 | 3376 |
indentSelectionBy1 |
3377 |
"indent selected line-range |
|
3378 |
by 1 space (i.e. to the right)" |
|
3379 |
||
3380 |
self indentBy:1 |
|
3381 |
||
3382 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3383 |
! |
|
3384 |
||
4458 | 3385 |
insert:aCharacter atLine:lineNr col:colNr |
3386 |
"insert a single character at lineNr/colNr; |
|
3387 |
set emphasis to character at current position" |
|
3388 |
||
3389 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3390 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3391 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3392 |
] |
3393 |
! |
|
3394 |
||
121 | 3395 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3396 |
"insert a single character at cursor-position - advance cursor." |
121 | 3397 |
|
3398 |
|wasOn| |
|
3399 |
||
3400 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3401 |
aCharacter == Character tab ifTrue:[ |
4820 | 3402 |
"/ needs special care to advance cursor correctly |
3403 |
self insertTabAtCursor |
|
121 | 3404 |
] ifFalse:[ |
4820 | 3405 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3406 |
aCharacter == (Character cr) ifTrue:[ |
|
3407 |
self basicCursorReturn |
|
3408 |
] ifFalse:[ |
|
3409 |
self cursorRight. |
|
3410 |
]. |
|
121 | 3411 |
]. |
3412 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3413 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3414 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3415 |
! |
3416 |
||
641 | 3417 |
insertLine:aString before:lineNr |
3418 |
"insert the line aString before line lineNr" |
|
3419 |
||
3420 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3421 |
||
3422 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3423 |
! |
|
3424 |
||
155 | 3425 |
insertLines:aStringCollection before:lineNr |
3426 |
"insert a bunch before line lineNr" |
|
3427 |
||
3428 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3429 |
||
3430 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3431 |
! |
|
3432 |
||
4771 | 3433 |
insertLines:someText from:start to:end before:lineNr |
3434 |
"insert a bunch of lines before line lineNr. |
|
3435 |
The cursor position is left unchanged." |
|
3436 |
||
3437 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3438 |
srcY "{ Class: SmallInteger }" |
|
3439 |
dstY "{ Class: SmallInteger }" | |
|
3440 |
||
5357 | 3441 |
"wrong when pasting multiple lines" |
3442 |
false "autoIndent" ifTrue:[ |
|
4771 | 3443 |
indent := self leftIndentForLine:lineNr. |
3444 |
||
4812 | 3445 |
text := someText |
3446 |
collect:[:ln||line| |
|
3447 |
ln notNil ifTrue:[ |
|
3448 |
line := ln withoutLeadingSeparators. |
|
3449 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3450 |
line := (String new:indent), line |
|
3451 |
]. |
|
3452 |
line |
|
3453 |
] ifFalse:[ |
|
3454 |
nil |
|
3455 |
] |
|
3456 |
]. |
|
4771 | 3457 |
] ifFalse:[ |
3458 |
text := someText |
|
3459 |
]. |
|
3460 |
||
3461 |
visLine := self listLineToVisibleLine:lineNr. |
|
3462 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3463 |
self withoutRedrawInsertLines:text |
|
3464 |
from:start to:end |
|
3465 |
before:lineNr. |
|
3466 |
] ifFalse:[ |
|
3467 |
nLines := end - start + 1. |
|
3468 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3469 |
self withoutRedrawInsertLines:text |
|
3470 |
from:start to:end |
|
3471 |
before:lineNr. |
|
3472 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3473 |
] ifFalse:[ |
|
3474 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3475 |
and:(firstLineShown + nLines + nLinesShown). |
|
3476 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3477 |
dstY := srcY + (nLines * fontHeight). |
|
3478 |
||
3479 |
"/ |
|
3480 |
"/ scroll ... |
|
3481 |
"/ |
|
3482 |
" |
|
3483 |
stupid: must catchExpose before inserting new |
|
3484 |
stuff - since catchExpose may perform redraws |
|
3485 |
" |
|
3486 |
self catchExpose. |
|
3487 |
self withoutRedrawInsertLines:text |
|
3488 |
from:start to:end |
|
3489 |
before:lineNr. |
|
3490 |
self |
|
3491 |
copyFrom:self |
|
3492 |
x:textStartLeft y:srcY |
|
3493 |
toX:textStartLeft y:dstY |
|
3494 |
width:w |
|
3495 |
height:(height - dstY) |
|
3496 |
async:true. |
|
3497 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3498 |
self waitForExpose |
|
3499 |
]. |
|
3500 |
]. |
|
3501 |
widthOfWidestLine notNil ifTrue:[ |
|
3502 |
text do:[:line | |
|
3503 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3504 |
] |
|
3505 |
]. |
|
3506 |
self textChanged. |
|
3507 |
||
3508 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3509 |
! |
|
3510 |
||
654 | 3511 |
insertLines:lines withCR:withCr |
3160 | 3512 |
"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
|
3513 |
Cursor is moved behind insertion. |
641 | 3514 |
If withCr is true, append cr after last line" |
3515 |
||
3516 |
|start end nLines wasOn| |
|
3517 |
||
3518 |
lines notNil ifTrue:[ |
|
4649 | 3519 |
nLines := lines size. |
3520 |
(nLines == 1) ifTrue:[ |
|
3521 |
self insertStringAtCursor:(lines at:1). |
|
3522 |
withCr ifTrue:[ |
|
3523 |
self insertCharAtCursor:(Character cr) |
|
3524 |
] |
|
3525 |
] ifFalse:[ |
|
3526 |
(cursorCol ~~ 1) ifTrue:[ |
|
3527 |
self insertStringAtCursor:(lines at:1). |
|
3528 |
self insertCharAtCursor:(Character cr). |
|
3529 |
start := 2 |
|
3530 |
] ifFalse:[ |
|
3531 |
start := 1 |
|
3532 |
]. |
|
3533 |
withCr ifTrue:[ |
|
3534 |
end := nLines |
|
3535 |
] ifFalse:[ |
|
3536 |
end := nLines - 1 |
|
3537 |
]. |
|
3538 |
(start <= nLines) ifTrue:[ |
|
3539 |
(end >= start) ifTrue:[ |
|
3540 |
wasOn := self hideCursor. |
|
3541 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3542 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3543 |
wasOn ifTrue:[self showCursor]. |
|
3544 |
] |
|
3545 |
]. |
|
3546 |
withCr ifFalse:[ |
|
3547 |
"last line without cr" |
|
3548 |
self insertStringAtCursor:(lines at:nLines) |
|
3549 |
] |
|
3550 |
] |
|
641 | 3551 |
] |
654 | 3552 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3553 |
"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
|
3554 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3555 |
! |
3556 |
||
3557 |
insertLines:lines withCr:withCr |
|
3558 |
"insert a bunch of lines at cursor position. Cursor |
|
3559 |
is moved behind insertion. |
|
3560 |
If withCr is true, append cr after last line" |
|
3561 |
||
2363 | 3562 |
<resource:#obsolete> |
3563 |
||
1292 | 3564 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3565 |
self insertLines:lines withCR:withCr. |
|
3566 |
||
3567 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3568 |
! |
3569 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3570 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3571 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3572 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3573 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3574 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3575 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3576 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3577 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3578 |
self selectFromLine:startLine col:startCol |
4823 | 3579 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3580 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3581 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3582 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3583 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3584 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3585 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3586 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3587 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3588 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3589 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3590 |
col == 0 ifTrue:[ |
3591 |
line > 1 ifTrue:[ |
|
3592 |
line := line - 1. |
|
5216 | 3593 |
col := (self listAt:line) size + 1. |
5060 | 3594 |
] ifFalse:[ |
3595 |
col := 1. |
|
3596 |
] |
|
3597 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3598 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3599 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3600 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3601 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3602 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3603 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3604 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3605 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3606 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3607 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3608 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3609 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3610 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3611 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3612 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3613 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3614 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3615 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3616 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3617 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3618 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3619 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3620 |
[start <= end] whileTrue:[ |
4823 | 3621 |
stop := aString indexOf:(Character cr) startingAt:start. |
3622 |
stop == 0 ifTrue:[ |
|
3623 |
stop := end + 1 |
|
3624 |
]. |
|
3625 |
subString := aString copyFrom:start to:(stop - 1). |
|
3626 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3627 |
(stop <= end) ifTrue:[ |
|
3628 |
c := c + subString size. |
|
3629 |
self insert:(Character cr) atLine:l col:c. |
|
3630 |
l := l + 1. |
|
3631 |
c := 1 |
|
3632 |
]. |
|
3633 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3634 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3635 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3636 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3637 |
! |
3638 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3639 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3640 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3641 |
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
|
3642 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3643 |
aString isNil ifTrue:[ |
4823 | 3644 |
"new:" |
3645 |
self insertCharAtCursor:(Character cr). |
|
3646 |
^ self |
|
105 | 3647 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3648 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3649 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3650 |
]. |
3651 |
||
654 | 3652 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3653 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3654 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3655 |
! |
3656 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3657 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3658 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3659 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3660 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3661 |
shown ifTrue:[ |
4889 | 3662 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3663 |
self invalidateLine:lineNr. |
3664 |
] ifFalse:[ |
|
3665 |
self redrawLine:lineNr from:colNr |
|
3666 |
] |
|
3667 |
] |
|
3668 |
||
4191 | 3669 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3670 |
! |
3671 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3672 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3673 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3674 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3675 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3676 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3677 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3678 |
aString size > 0 ifTrue:[ |
4823 | 3679 |
wasOn := self hideCursor. |
3680 |
(aString includes:Character tab) ifTrue:[ |
|
3681 |
self checkForExistingLine:cursorLine. |
|
3682 |
oldLen := (list at:cursorLine) size. |
|
3683 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
3684 |
newLen := (list at:cursorLine) size. |
|
3685 |
deltaLen := newLen - oldLen. |
|
3686 |
] ifFalse:[ |
|
3687 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
3688 |
deltaLen := aString size. |
|
3689 |
]. |
|
3690 |
self setCursorCol:(cursorCol + deltaLen). |
|
3691 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3692 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3693 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
3694 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3695 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3696 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3697 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3698 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3699 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3700 |
|wasOn nextTab| |
105 | 3701 |
|
121 | 3702 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3703 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3704 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3705 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 3706 |
! |
3707 |
||
3542 | 3708 |
joinLines |
3890 | 3709 |
"join lines (remove line-break)" |
3710 |
||
3583 | 3711 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
3712 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
3713 |
self |
3890 | 3714 |
undoableDo:[ |
3715 |
|line col lineLen| |
|
3716 |
||
3717 |
line := cursorLine. |
|
3718 |
col := cursorCol. |
|
3719 |
lineLen := (list at:line) size. |
|
3720 |
col > lineLen ifTrue:[ |
|
3721 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
3722 |
] ifFalse:[ |
|
3723 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
3724 |
]. |
|
3725 |
self mergeLine:line removeBlanks:true. |
|
3726 |
self cursorLine:line col:col. |
|
3727 |
] |
|
3728 |
info:'Join' |
|
3542 | 3729 |
! |
3730 |
||
2952 | 3731 |
mergeLine:lineNr |
3732 |
"merge line lineNr with line lineNr+1" |
|
3733 |
||
3734 |
self mergeLine:lineNr removeBlanks:true |
|
3735 |
||
3736 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
3737 |
! |
|
3738 |
||
4458 | 3739 |
mergeLine:lineNr removeBlanks:removeBlanks |
3740 |
"merge line lineNr with line lineNr+1" |
|
3741 |
||
3742 |
|len| |
|
3743 |
||
3744 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3745 |
||
3746 |
len := (self listAt:lineNr) size. |
|
3747 |
self nonUndoableDo:[ |
|
4823 | 3748 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 3749 |
]. |
3750 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
3751 |
! |
|
3752 |
||
5761 | 3753 |
parenthizeSelection |
3754 |
"place parenthesis around the selected text. |
|
3755 |
if already parenthized, de-parenthize it" |
|
3756 |
||
3757 |
self parenthizeSelectionWith:$( and:$) |
|
3758 |
||
3759 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
3760 |
! |
|
3761 |
||
2506 | 3762 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 3763 |
"if already parenthized, de-parenthize it" |
3764 |
||
5560 | 3765 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3766 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3767 |
self hasSelection ifFalse:[^ self]. |
5560 | 3768 |
startLine := selectionStartLine. |
3769 |
endLine := selectionEndLine. |
|
3770 |
startCol := selectionStartCol. |
|
3771 |
endCol := selectionEndCol. |
|
3772 |
||
3773 |
newSelectionEnd := endCol. |
|
3774 |
||
3775 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
|
3776 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
|
3777 |
self deleteCharAtLine:endLine col:endCol. |
|
4823 | 3778 |
newSelectionEnd := newSelectionEnd-1. |
3779 |
]. |
|
5560 | 3780 |
self deleteCharAtLine:startLine col:startCol. |
3781 |
startLine == endLine ifTrue:[ |
|
4823 | 3782 |
newSelectionEnd := newSelectionEnd-1. |
3783 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3784 |
] ifFalse:[ |
5560 | 3785 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4823 | 3786 |
newSelectionEnd := newSelectionEnd+1. |
5560 | 3787 |
self insert:openingCharacter atLine:startLine col:startCol. |
3788 |
startLine == endLine ifTrue:[ |
|
4823 | 3789 |
newSelectionEnd := newSelectionEnd+1. |
3790 |
] |
|
3160 | 3791 |
]. |
3792 |
self |
|
5560 | 3793 |
selectFromLine:startLine col:startCol |
3794 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 3795 |
|
3796 |
"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
|
3797 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
3798 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3799 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3800 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3801 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3802 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3803 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3804 |
|
5114 | 3805 |
NoModificationError handle:[:ex | |
3806 |
^ self |
|
3807 |
] do:[ |
|
3808 |
lastLine := list size. |
|
3809 |
finished := false. |
|
3810 |
[finished] whileFalse:[ |
|
3811 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 3812 |
finished := true |
3813 |
] ifFalse:[ |
|
5114 | 3814 |
line := list at:lastLine. |
3815 |
line notNil ifTrue:[ |
|
3816 |
line isBlank ifTrue:[ |
|
3817 |
self basicListAt:lastLine put:nil. |
|
3818 |
line := nil |
|
3819 |
] |
|
3820 |
]. |
|
3821 |
line notNil ifTrue:[ |
|
3822 |
finished := true |
|
3823 |
] ifFalse:[ |
|
3824 |
lastLine := lastLine - 1 |
|
3825 |
] |
|
4771 | 3826 |
] |
5114 | 3827 |
]. |
3828 |
(lastLine ~~ list size) ifTrue:[ |
|
3829 |
list grow:lastLine. |
|
3830 |
"/ self textChanged |
|
4771 | 3831 |
] |
118 | 3832 |
]. |
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 |
|
4458 | 3835 |
replace:aCharacter atLine:lineNr col:colNr |
3836 |
"replace a single character at lineNr/colNr" |
|
3837 |
||
3838 |
|originalChar| |
|
3839 |
||
3840 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
3841 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
3842 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
3843 |
! |
|
3844 |
||
4713 | 3845 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 3846 |
|pattern replacePattern| |
3847 |
||
3848 |
pattern := patternArg string. |
|
3849 |
replacePattern := replacePatternArg string. |
|
4630 | 3850 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
3851 |
self rememberSearchPattern:pattern. |
|
3852 |
self rememberSearchPattern:replacePattern. |
|
4713 | 3853 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 3854 |
self |
3855 |
undoableDo:[ |
|
3856 |
all ifTrue:[ |
|
3857 |
self |
|
3858 |
replaceString:pattern |
|
3859 |
to:replacePattern |
|
4713 | 3860 |
ignoreCase:ignoreCase |
4630 | 3861 |
] ifFalse:[ |
3862 |
(self selectionAsString notNil |
|
4713 | 3863 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 3864 |
ifTrue:[ |
4742 | 3865 |
self replaceSelectionBy:replacePattern. |
4630 | 3866 |
self |
3867 |
search:pattern |
|
4713 | 3868 |
ignoreCase:ignoreCase |
4630 | 3869 |
forward:(lastSearchDirection = #forward). |
3870 |
]. |
|
3871 |
] |
|
3872 |
] |
|
3873 |
info:'Replace' |
|
3430 | 3874 |
] |
3875 |
||
3876 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
3877 |
! |
|
3878 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3879 |
replaceCharAtCursor:aCharacter |
5413 | 3880 |
"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
|
3881 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3882 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3883 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3884 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3885 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 3886 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3887 |
] ifFalse:[ |
4823 | 3888 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
3889 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3890 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3891 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3892 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3893 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3894 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
3895 |
|
4458 | 3896 |
replaceContentsWith:newContents |
5413 | 3897 |
"undoably replace everything" |
4458 | 3898 |
|
3899 |
|originalContents| |
|
3900 |
||
3901 |
originalContents := self contents. |
|
3902 |
self contents:newContents keepUndoHistory:true. |
|
3903 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
3904 |
! |
|
3905 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3906 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 3907 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3908 |
|
5216 | 3909 |
"/ 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
|
3910 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3911 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3912 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
3913 |
|
4458 | 3914 |
replaceLine:lineNr with:newText |
5413 | 3915 |
"undoably replace a line at lineNr" |
4458 | 3916 |
|
3917 |
|originalLine| |
|
3918 |
||
3919 |
originalLine := self listAt:lineNr. |
|
3920 |
originalLine isNil ifTrue:[ |
|
4823 | 3921 |
self checkForExistingLine:lineNr |
4458 | 3922 |
]. |
3923 |
self list at:lineNr put:newText. |
|
3924 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
3925 |
self invalidateLine:lineNr. |
|
3926 |
||
3927 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
3928 |
! |
|
3929 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3930 |
replaceLines:lines withCR:withCr |
5413 | 3931 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3932 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3933 |
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
|
3934 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3935 |
|
1809 | 3936 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3937 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3938 |
lines notNil ifTrue:[ |
4661 | 3939 |
wasOn := self hideCursor. |
3940 |
nLines := lines size. |
|
3941 |
line := cursorLine. |
|
3942 |
col := cursorCol. |
|
3943 |
lines keysAndValuesDo:[:i :l | |
|
3944 |
self replaceString:(l ? '') atLine:line col:col. |
|
3945 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
3946 |
line := line + 1. |
|
3947 |
col := 1. |
|
3948 |
] ifFalse:[ |
|
3949 |
col := col + (l size). |
|
3950 |
] |
|
3951 |
]. |
|
3952 |
self cursorLine:line col:col. |
|
3953 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
3954 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3955 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3956 |
|
4661 | 3957 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
3958 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3959 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
3960 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3961 |
replaceSelectionBy:something |
5413 | 3962 |
"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
|
3963 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3964 |
|
4666 | 3965 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 3966 |
! |
3967 |
||
3968 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 3969 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 3970 |
leave cursor after insertion or leave it, depending on keep" |
3971 |
||
4666 | 3972 |
self replaceSelectionBy:something keepCursor:keep select:false |
3973 |
||
3974 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
3975 |
! |
|
3976 |
||
3977 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 3978 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 3979 |
leave cursor after insertion or leave it, depending on keep. |
3980 |
If selectNewText is true, select the new text; otherwise deselect" |
|
3981 |
||
3982 |
|sel l c selStartLine selStartCol| |
|
105 | 3983 |
|
3984 |
l := cursorLine. |
|
3985 |
c := cursorCol. |
|
3986 |
||
4818 | 3987 |
sel := self selectionAsString. |
4666 | 3988 |
sel isNil ifTrue:[ |
3989 |
selStartLine := l. |
|
3990 |
selStartCol := c. |
|
3991 |
] ifFalse:[ |
|
3992 |
selStartLine := selectionStartLine. |
|
3993 |
selStartCol := selectionStartCol. |
|
3994 |
||
4053 | 3995 |
self setLastStringToReplace: sel. |
3996 |
||
4010 | 3997 |
self deleteSelection. |
3998 |
replacing := true. |
|
4818 | 3999 |
lastReplacementInfo rememberReplacement. |
4048 | 4000 |
lastReplacementInfo lastReplacement: ''. |
4818 | 4001 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 4002 |
undoSupport actionInfo:'replace'. |
3161 | 4003 |
]. |
4004 |
||
4005 |
something isCharacter ifTrue:[ |
|
4051 | 4006 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 4007 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 4008 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 4009 |
]. |
4010 | 4010 |
]. |
4011 |
self isInInsertMode ifTrue:[ |
|
4012 |
self insertCharAtCursor:something |
|
4013 |
] ifFalse:[ |
|
4014 |
self replaceCharAtCursor:something |
|
4015 |
] |
|
105 | 4016 |
] ifFalse:[ |
4010 | 4017 |
something isString ifTrue:[ |
4048 | 4018 |
lastReplacementInfo lastReplacement: something. |
4010 | 4019 |
self isInInsertMode ifTrue:[ |
4020 |
self insertStringAtCursor:something |
|
4021 |
] ifFalse:[ |
|
4022 |
self replaceStringAtCursor:something |
|
4023 |
] |
|
4024 |
] ifFalse:[ |
|
4025 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4026 |
]. |
|
105 | 4027 |
]. |
4028 |
keep ifTrue:[ |
|
4010 | 4029 |
self cursorLine:l col:c |
4666 | 4030 |
]. |
4031 |
selectNewText ifTrue:[ |
|
4032 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 4033 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4034 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4035 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4036 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4037 |
|
4458 | 4038 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4039 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4040 |
This is not prepared to encounter special chars (except TAB) in the string." |
4041 |
||
4042 |
|originalString| |
|
4043 |
||
4044 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4045 |
||
4046 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4047 |
||
4048 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4049 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4050 |
! |
|
4051 |
||
4713 | 4052 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4053 |
|continue count| |
4054 |
||
4055 |
self cursorToTop. |
|
4056 |
self selectFromBeginning. |
|
4057 |
count := 0. |
|
4058 |
continue := true. |
|
4059 |
[ continue ] whileTrue:[ |
|
4713 | 4060 |
(self selectionAsString notNil |
4061 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4062 |
ifTrue:[ |
|
4742 | 4063 |
self replaceSelectionBy:aNewString. |
4713 | 4064 |
count := count + 1. |
4065 |
]. |
|
4066 |
self |
|
4067 |
searchFwd:aString |
|
4068 |
ignoreCase:ignoreCase |
|
4069 |
ifAbsent:[ |
|
4070 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4071 |
bindWith:aString with:aNewString with:count). |
|
4072 |
continue := false. |
|
4073 |
]. |
|
3549 | 4074 |
]. |
3430 | 4075 |
|
4076 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4077 |
! |
|
4078 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4079 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4080 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4081 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4082 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4083 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4084 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4085 |
(aString includes:Character tab) ifTrue:[ |
4823 | 4086 |
"/ need special care for TAB (to move cursor correctly) |
4087 |
i1 := 1. |
|
4088 |
[i1 ~~ 0] whileTrue:[ |
|
4089 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4090 |
i2 ~~ 0 ifTrue:[ |
|
4091 |
i1 ~~ i2 ifTrue:[ |
|
4092 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4093 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4094 |
]. |
|
4095 |
self replaceTABAtCursor. |
|
4096 |
i2 := i2 + 1. |
|
4097 |
] ifFalse:[ |
|
4098 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4099 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4100 |
]. |
|
4101 |
i1 := i2. |
|
4102 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4103 |
] ifFalse:[ |
4823 | 4104 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
5325 | 4105 |
self setValidatedCursorCol:(cursorCol + aString size). |
4106 |
"/ self cursorCol:(cursorCol + aString size). |
|
4107 |
]. |
|
4108 |
wasOn ifTrue:[ |
|
4109 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
|
4110 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
4111 |
]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4112 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4113 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4114 |
"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
|
4115 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4116 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4117 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4118 |
"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
|
4119 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4120 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4121 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4122 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4123 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4124 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4125 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4126 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4127 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4128 |
! |
4129 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4130 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4131 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4132 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4133 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4134 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4135 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4136 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4137 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4138 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4139 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4140 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4141 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4142 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4143 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4144 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4145 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4146 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4147 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4148 |
|
4458 | 4149 |
splitLine:lineNr before:colNr |
4150 |
"split the line linNr before colNr; the right part (from colNr) |
|
4151 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4152 |
||
4153 |
self basicSplitLine:lineNr before:colNr. |
|
4154 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4155 |
! |
|
4156 |
||
5761 | 4157 |
toggleTabSetting |
4158 |
"toggle between 4-col |
|
4159 |
and 8-col tabs" |
|
4160 |
||
4161 |
(tabPositions == self class tab4Positions) |
|
4162 |
ifTrue:[self setTab8] |
|
4163 |
ifFalse:[self setTab4] |
|
4164 |
||
4165 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4166 |
! |
|
4167 |
||
4168 |
undentSelectionBy1 |
|
4169 |
"undent selected line-range |
|
4170 |
by 1 space (i.e. to the left)" |
|
4171 |
||
4172 |
self undentBy:1 |
|
4173 |
||
4174 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4175 |
! |
|
4176 |
||
5146 | 4177 |
withAutoIndent:aBoolean do:aBlock |
4178 |
|sav| |
|
4179 |
||
4180 |
sav := autoIndent. |
|
4181 |
autoIndent := aBoolean. |
|
4182 |
aBlock ensure:[ autoIndent := sav ]. |
|
4183 |
! |
|
4184 |
||
4458 | 4185 |
withoutRedrawAt:lineNr put:aString |
4186 |
"replace a line at lineNr" |
|
4187 |
||
4188 |
|originalLine| |
|
4189 |
||
4190 |
originalLine := self listAt:lineNr. |
|
4191 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4192 |
super withoutRedrawAt:lineNr put:aString. |
|
4193 |
! |
|
4194 |
||
4195 |
withoutRedrawInsertLine:aString before:lineNr |
|
4196 |
"insert the argument, aString before line lineNr; the string |
|
4197 |
becomes line lineNr; everything else is moved down; the view |
|
4198 |
is not redrawn" |
|
4199 |
||
4771 | 4200 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4201 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4202 |
! |
|
4203 |
||
4204 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4205 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4206 |
||
4207 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4208 |
self isReadOnly ifFalse:[ |
|
4823 | 4209 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4210 |
]. |
4211 |
! |
|
4212 |
||
4213 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4214 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4215 |
||
4216 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4217 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4218 |
! |
|
4219 |
||
3890 | 4220 |
wrapLines |
4221 |
"wrap lines (insert line-break)" |
|
4222 |
||
4223 |
|lineLength answerString string| |
|
4224 |
||
4225 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4226 |
||
4227 |
self hasSelection ifFalse:[ |
|
4228 |
self selectLine:cursorLine. |
|
4229 |
]. |
|
4230 |
string := self selectionAsString. |
|
4231 |
string isEmptyOrNil ifTrue:[ |
|
4232 |
Dialog information:(resources string:'Nothing selected.'). |
|
4233 |
^ self. |
|
4234 |
]. |
|
4235 |
||
4236 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4237 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4238 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4239 |
lineLength < 1 ifTrue:[ |
4240 |
lineLength := 1. |
|
4241 |
]. |
|
4242 |
||
4243 |
self |
|
4244 |
undoableDo:[ |
|
4245 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4246 |
||
4247 |
line := selectionStartLine. |
|
4248 |
col := selectionStartCol. |
|
4249 |
||
4250 |
self cutSelection. |
|
4251 |
self cursorLine:line col:col. |
|
4252 |
||
4253 |
lastGoodCol := col. |
|
4254 |
||
4255 |
inStream := string readStream. |
|
4256 |
[ inStream atEnd ] whileFalse:[ |
|
4257 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4258 |
word := WriteStream on:(String new:10). |
|
4259 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4260 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4261 |
self insertCharAtCursor:(Character cr). |
|
4262 |
col := 1. |
|
4263 |
] ifFalse:[ |
|
4264 |
col ~~ 1 ifTrue:[ |
|
4265 |
self insertStringAtCursor:' '. |
|
4266 |
col := col + 1. |
|
4267 |
] |
|
4268 |
]. |
|
4269 |
self insertStringAtCursor:word contents. |
|
4270 |
col := col + word size. |
|
4271 |
]. |
|
4272 |
] |
|
4273 |
info:'Wrap' |
|
4388 | 4274 |
|
4275 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4276 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4277 |
|
2752 | 4278 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4279 |
|
2952 | 4280 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4281 |
"delete characters from startCol to endCol in line lineNr" |
4282 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4283 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4284 |
|
4673 | 4285 |
self unselect. |
4286 |
||
4287 |
cursorLine == lineNr ifTrue:[ |
|
4288 |
cursorCol >= startCol ifTrue:[ |
|
4289 |
cursorCol >= endCol ifTrue:[ |
|
4290 |
cursorCol := startCol. |
|
4291 |
] ifFalse:[ |
|
4292 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
5489 | 4293 |
"/ self assert:(cursorCol >= 0). |
4294 |
cursorCol := cursorCol max:1. |
|
4673 | 4295 |
] |
4296 |
]. |
|
4297 |
]. |
|
4298 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4299 |
line := self listAt:lineNr. |
827 | 4300 |
|
4673 | 4301 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4302 |
||
4303 |
lineSize := line size. |
|
4304 |
||
4305 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4306 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4307 |
||
4308 |
stop >= start ifTrue:[ |
|
4309 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
|
4310 |
ifFalse:[ newLine := '' ]. |
|
4311 |
||
4312 |
stop == lineSize ifFalse:[ |
|
4313 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4314 |
newLine := line string species fromString:newLine. |
|
4190 | 4315 |
]. |
4673 | 4316 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
4317 |
]. |
|
4318 |
||
4319 |
(trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4320 |
newLine := nil |
|
4321 |
]. |
|
4322 |
||
4323 |
prevWidth := self widthOfLine:lineNr. |
|
4324 |
||
4771 | 4325 |
self basicListAt:lineNr put:newLine. |
4673 | 4326 |
|
4327 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4328 |
"/ remember old width of this line, |
|
4329 |
"/ only clear widthOfWidestLine, if this lines |
|
4330 |
"/ length was (one of) the longest. |
|
4331 |
"/ avoids slow delete with huge texts. |
|
4332 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4333 |
||
4334 |
"/ scroll left if reqiured |
|
4335 |
viewOrigin x > 0 ifTrue:[ |
|
4336 |
newWidth := self widthOfLine:lineNr. |
|
4337 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4338 |
self scrollHorizontalTo:(newWidth |
|
4339 |
- width |
|
4340 |
+ margin + margin |
|
4889 | 4341 |
+ (gc font widthOf:' ')) |
4673 | 4342 |
] |
4190 | 4343 |
]. |
4673 | 4344 |
self textChanged. |
4345 |
] ifFalse:[ |
|
4346 |
self textChanged "/ textChangedButNoSizeChange |
|
4347 |
]. |
|
4889 | 4348 |
gc font hasOverlappingCharacters ifTrue:[ |
4673 | 4349 |
self invalidateLine:lineNr. |
4350 |
] ifFalse:[ |
|
4351 |
self redrawLine:lineNr from:start. |
|
4352 |
]. |
|
4353 |
]. |
|
827 | 4354 |
|
4191 | 4355 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4356 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4357 |
|
2952 | 4358 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4359 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4360 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4361 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4362 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4363 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4364 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4365 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4366 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4367 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4368 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4369 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4370 |
startLineNr <= list size ifTrue:[ |
4771 | 4371 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4372 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4373 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4374 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4375 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4376 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4377 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4378 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4379 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4380 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4381 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4382 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4383 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4384 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4385 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4386 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4387 |
|
4226 | 4388 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4389 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4390 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4391 |
|
2952 | 4392 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4393 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4394 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4395 |
|
2952 | 4396 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4397 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4398 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4399 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4400 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4401 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4402 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4403 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4404 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4405 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4406 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4407 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4408 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4409 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4410 |
|
2952 | 4411 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4412 |
"insert a single character at lineNr/colNr; |
827 | 4413 |
set emphasis to character at current position" |
4414 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4415 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4416 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4417 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4418 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4419 |
aCharacter == (Character cr) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4420 |
self splitLine:lineNr before:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4421 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4422 |
]. |
827 | 4423 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4424 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4425 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4426 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4427 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4428 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4429 |
self st80EditMode ifFalse:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4430 |
(trimBlankLines |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4431 |
and:[colNr > lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4432 |
and:[aCharacter == Character space]]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4433 |
^ self |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4434 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4435 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4436 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4437 |
(lineSize == 0) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4438 |
newLine := aCharacter asString species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4439 |
drawCharacterOnly := true |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4440 |
] ifFalse: [ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4441 |
(colNr > lineSize) ifTrue: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4442 |
colNr == (lineSize +1) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4443 |
attribute := line emphasisAt:lineSize |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4444 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4445 |
newLine := line species new:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4446 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4447 |
drawCharacterOnly := true |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4448 |
] ifFalse: [ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4449 |
attribute := line emphasisAt:colNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4450 |
newLine := line species new:(lineSize + 1). |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4451 |
|
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4452 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4453 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4454 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4455 |
]. |
827 | 4456 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4457 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4458 |
newLine := aCharacter asString species fromString:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4459 |
line isText ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4460 |
newLine := newLine asText |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4461 |
] |
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4462 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4463 |
newLine at:colNr put:aCharacter. |
827 | 4464 |
|
4465 |
attribute notNil ifTrue:[ |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4466 |
newLine emphasisAt:colNr put:attribute. |
827 | 4467 |
]. |
4468 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4469 |
aCharacter == (Character tab) ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4470 |
newLine := self withTabsExpanded:newLine. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4471 |
drawCharacterOnly := false |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4472 |
]. |
827 | 4473 |
|
4771 | 4474 |
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
|
4475 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4476 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4477 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4478 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4479 |
shown ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4480 |
"/ care for italic text - in this case, we must also |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4481 |
"/ redraw the character before the insertion in order |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4482 |
"/ to fix the slanted piece of the character. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4483 |
"/ (but we must clip, to avoid destoying the character before) |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4484 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4485 |
colNr > 1 ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4486 |
cursorVisibleLine notNil ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4487 |
oldClip := self clippingRectangleOrNil. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4488 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4489 |
y := self yOfVisibleLine:cursorVisibleLine. |
4190 | 4490 |
|
4889 | 4491 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4492 |
self invalidateLine:lineNr. |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4493 |
] ifFalse:[ |
4190 | 4494 |
drawCharacterOnly ifTrue:[ |
4889 | 4495 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4190 | 4496 |
self redrawLine:lineNr from:colNr-1 to:colNr |
4497 |
] ifFalse:[ |
|
4498 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4499 |
self redrawLine:lineNr from:colNr-1 |
|
4500 |
]. |
|
4501 |
self clippingRectangle:oldClip. |
|
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4502 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4503 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4504 |
^ self. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4505 |
]. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4506 |
]. |
4889 | 4507 |
gc font hasOverlappingCharacters ifTrue:[ |
4189
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4508 |
self invalidateLine:lineNr. |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4509 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4510 |
drawCharacterOnly ifTrue:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4511 |
self redrawLine:lineNr col:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4512 |
] ifFalse:[ |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4513 |
self redrawLine:lineNr from:colNr |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4514 |
] |
c9adf30e582a
changed: #basicInsert:atLine:col:
Claus Gittinger <cg@exept.de>
parents:
4165
diff
changeset
|
4515 |
] |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4516 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4517 |
|
4191 | 4518 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4519 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4520 |
|
4771 | 4521 |
basicListAt:lineNr put:newLine |
4522 |
"redefinable for special subclasses (with virtual list)" |
|
4523 |
||
4524 |
list at:lineNr put:newLine. |
|
4525 |
! |
|
4526 |
||
4527 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4528 |
"redefinable for special subclasses (with virtual list)" |
|
4529 |
||
4530 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4531 |
! |
|
4532 |
||
2952 | 4533 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4534 |
"merge line lineNr with line lineNr+1" |
4535 |
||
827 | 4536 |
|leftPart rightPart bothParts nextLineNr i| |
4537 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4538 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
4771 | 4539 |
"/ empty list or beyond end of text |
4540 |
^ self |
|
827 | 4541 |
]. |
4542 |
leftPart := self listAt:lineNr. |
|
4543 |
||
4544 |
leftPart isNil ifTrue:[ |
|
4771 | 4545 |
leftPart := ''. |
4546 |
autoIndent ifTrue:[ |
|
4547 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4548 |
leftPart := String new:i |
|
4549 |
] |
|
4550 |
] |
|
827 | 4551 |
]. |
4552 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4553 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4554 |
||
4555 |
nextLineNr > (list size) ifFalse:[ |
|
4771 | 4556 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4557 |
rightPart := '' |
|
4558 |
] ifFalse:[ |
|
4559 |
removeBlanks ifTrue:[ |
|
4560 |
rightPart := rightPart withoutLeadingSeparators. |
|
4561 |
] |
|
4562 |
]. |
|
4563 |
||
4564 |
bothParts := leftPart , rightPart. |
|
4565 |
(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4566 |
self basicListAt:lineNr put:bothParts. |
|
4567 |
self redrawLine:lineNr. |
|
4568 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4569 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4570 |
|
1319 | 4571 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4572 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4573 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4574 |
|
2952 | 4575 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4576 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4577 |
|
5045 | 4578 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4579 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4580 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4581 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4582 |
aCharacter == (Character cr) ifTrue:[ |
4190 | 4583 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4584 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4585 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4586 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4587 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4588 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4589 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4590 |
|
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4591 |
(trimBlankLines |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4592 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4593 |
and:[aCharacter == Character space]]) ifTrue:[ |
4190 | 4594 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4595 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4596 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4597 |
(lineSize == 0) ifTrue:[ |
4190 | 4598 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4599 |
] ifFalse: [ |
5045 | 4600 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
4601 |
newLineSpecies := aCharacter stringSpecies |
|
4602 |
] ifFalse:[ |
|
4603 |
newLineSpecies := line species |
|
4604 |
]. |
|
4605 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4606 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4607 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4608 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4609 |
aCharacter == (Character tab) ifTrue:[ |
4190 | 4610 |
newLine := self withTabsExpanded:newLine. |
4611 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4612 |
]. |
4771 | 4613 |
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
|
4614 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4615 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4616 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4617 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4618 |
shown ifTrue:[ |
4889 | 4619 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4620 |
self invalidateLine:lineNr. |
4621 |
] ifFalse:[ |
|
4622 |
drawCharacterOnly ifTrue:[ |
|
4623 |
self redrawLine:lineNr col:colNr |
|
4624 |
] ifFalse:[ |
|
4625 |
self redrawLine:lineNr from:colNr |
|
4626 |
] |
|
4627 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4628 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4629 |
|
4190 | 4630 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4631 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4632 |
! |
4633 |
||
3235 | 4634 |
basicReplaceString:aString atLine:lineNr col:colNr |
4635 |
"replace multiple characters starting at lineNr/colNr. |
|
4636 |
This is not prepared to encounter special chars (except TAB) |
|
4637 |
in the string." |
|
4638 |
||
5045 | 4639 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4640 |
|
4641 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4642 |
||
4643 |
self checkForExistingLine:lineNr. |
|
4644 |
line := list at:lineNr. |
|
4645 |
lineSize := line size. |
|
4646 |
||
4647 |
endCol := colNr + aString size - 1. |
|
4648 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4649 |
newLine := aString species new:endCol. |
3235 | 4650 |
] ifFalse: [ |
5571 | 4651 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5045 | 4652 |
newLineSpecies := aString stringSpecies |
4653 |
] ifFalse:[ |
|
4654 |
newLineSpecies := line species |
|
4655 |
]. |
|
4656 |
||
4657 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4658 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4659 |
]. |
4660 |
newLine replaceFrom:colNr with:aString. |
|
4661 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4662 |
newLine := self withTabsExpanded:newLine. |
3235 | 4663 |
]. |
4771 | 4664 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4665 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4666 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4667 |
]. |
4668 |
self textChanged. |
|
4669 |
shown ifTrue:[ |
|
4889 | 4670 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4671 |
self invalidateLine:lineNr. |
4672 |
] ifFalse:[ |
|
4673 |
self redrawLine:lineNr from:colNr |
|
4674 |
] |
|
3235 | 4675 |
] |
4676 |
||
4190 | 4677 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4678 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4679 |
! |
4680 |
||
2952 | 4681 |
basicSplitLine:lineNr before:colNr |
4682 |
"split the line linNr before colNr; the right part (from colNr) |
|
4683 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4684 |
||
3160 | 4685 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 4686 |
srcY "{ Class: SmallInteger }" | |
4687 |
||
3027 | 4688 |
list isNil ifTrue:[ ^ self ]. |
4689 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
4690 |
||
4691 |
(colNr == 1) ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4692 |
self nonUndoableDo:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4693 |
self insertLine:nil before:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4694 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4695 |
^ self |
3027 | 4696 |
]. |
4697 |
||
4698 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4699 |
line notNil ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4700 |
lineSize := line size. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4701 |
(colNr <= lineSize) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4702 |
rightRest := line copyFrom:colNr to:lineSize. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4703 |
(colNr > 1) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4704 |
leftRest := line copyTo:(colNr - 1) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4705 |
] |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4706 |
] ifFalse:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4707 |
leftRest := line |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4708 |
] |
3027 | 4709 |
]. |
4710 |
leftRest notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4711 |
(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 4712 |
]. |
4771 | 4713 |
self basicListAt:lineNr put:leftRest. |
3027 | 4714 |
self nonUndoableDo:[ |
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4715 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 4716 |
]. |
4717 |
visLine := self listLineToVisibleLine:(lineNr). |
|
4718 |
visLine notNil ifTrue:[ |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4719 |
w := self widthForScrollBetween:lineNr |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4720 |
and:(firstLineShown + nLinesShown). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4721 |
srcY := topMargin + (visLine * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4722 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4723 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4724 |
self catchExpose. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4725 |
self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4726 |
copyFrom:self |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4727 |
x:textStartLeft y:srcY |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4728 |
toX:textStartLeft y:(srcY + fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4729 |
width:w |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4730 |
height:((nLinesShown - visLine - 1) * fontHeight) |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4731 |
async:true. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4732 |
]. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4733 |
self redrawLine:lineNr. |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4734 |
self redrawLine:(lineNr + 1). |
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4735 |
mustWait ifTrue:[self waitForExpose] |
3027 | 4736 |
]. |
4737 |
widthOfWidestLine := nil. "/ unknown |
|
4738 |
self textChanged. |
|
2952 | 4739 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
4740 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 4741 |
! |
4742 |
||
2954 | 4743 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 4744 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
4745 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4746 |
because the text might have been pasted from an alien view." |
|
2954 | 4747 |
|
4748 |
|newLine newLines nLines| |
|
4749 |
||
4750 |
nLines := end - start + 1. |
|
4751 |
newLines := Array new:(lines size). |
|
4752 |
start to:end do:[:index | |
|
4328 | 4753 |
newLine := lines at:index. |
4754 |
newLine notNil ifTrue:[ |
|
4755 |
newLine isString ifTrue:[ |
|
4756 |
newLine isBlank ifTrue:[ |
|
4757 |
newLine := nil |
|
4758 |
] ifFalse:[ |
|
4759 |
(newLine includes:(Character tab)) ifTrue:[ |
|
4760 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
4761 |
] |
|
4762 |
] |
|
4763 |
] |
|
4764 |
]. |
|
4765 |
newLines at:index put:newLine |
|
2954 | 4766 |
]. |
4767 |
list isNil ifTrue: [ |
|
4328 | 4768 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 4769 |
] ifFalse: [ |
4328 | 4770 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 4771 |
]. |
4772 |
||
4773 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 4774 |
overlapping copy - if it didn't, we had to use:" |
4775 |
" |
|
4776 |
index := list size. |
|
4777 |
[index > lineNr] whileTrue: [ |
|
4328 | 4778 |
pIndex := index - 1. |
4779 |
list at:index put:(list at:pIndex). |
|
4780 |
index := pIndex |
|
2954 | 4781 |
]. |
4782 |
" |
|
4783 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
4784 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
4785 |
self contentsChanged |
|
4786 |
||
4328 | 4787 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 4788 |
! |
4789 |
||
4790 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 4791 |
"insert aString (which has no crs) at lineNr/colNr. |
4792 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
4793 |
because the text might have been pasted from an alien view." |
|
2954 | 4794 |
|
4360 | 4795 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 4796 |
|
4623 | 4797 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 4798 |
|
4799 |
strLen := aString size. |
|
4800 |
self checkForExistingLine:lineNr. |
|
4801 |
||
4802 |
stringType := aString string species. |
|
4803 |
isText := aString isText. |
|
4804 |
line := list at:lineNr. |
|
4805 |
||
4806 |
line notNil ifTrue:[ |
|
4328 | 4807 |
lineSize := line size. |
4808 |
line isString ifFalse:[ |
|
4809 |
stringType := line species |
|
4810 |
] ifTrue:[ |
|
4360 | 4811 |
lineCharWidth := line bitsPerCharacter. |
4812 |
stringCharWidth := aString bitsPerCharacter. |
|
4813 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 4814 |
stringType := line string species |
4360 | 4815 |
] ifFalse:[ |
4816 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
4817 |
stringType := aString string species |
|
4818 |
] |
|
4328 | 4819 |
]. |
4820 |
line isText ifTrue:[ isText := true ] |
|
4821 |
]. |
|
2954 | 4822 |
] ifFalse:[ |
4328 | 4823 |
lineSize := 0 |
2954 | 4824 |
]. |
4825 |
||
4826 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 4827 |
newLine := aString |
2954 | 4828 |
] ifFalse:[ |
4328 | 4829 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
4830 |
sz := colNr + strLen - 1 |
|
4831 |
] ifFalse:[ |
|
4832 |
sz := lineSize + strLen |
|
4833 |
]. |
|
4834 |
||
4360 | 4835 |
newLine := stringType new:sz. |
4836 |
isText ifTrue:[ |
|
4837 |
newLine := Text string:newLine |
|
4328 | 4838 |
]. |
4839 |
||
4840 |
(lineSize ~~ 0) ifTrue: [ |
|
4841 |
(colNr > lineSize) ifTrue: [ |
|
4842 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
4843 |
] ifFalse: [ |
|
4844 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4845 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
4846 |
] |
|
4847 |
]. |
|
4848 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 4849 |
]. |
4850 |
||
4851 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 4852 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 4853 |
]. |
4854 |
||
4771 | 4855 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 4856 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 4857 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 4858 |
]. |
4859 |
self textChanged. |
|
4860 |
||
4360 | 4861 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4862 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4863 |
|
2752 | 4864 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4865 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4866 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4867 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4868 |
|
5216 | 4869 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 4870 |
dragIsActive := false. |
4871 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4872 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4873 |
"/ also give that guy a chance to close its popup view |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
4874 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
4875 |
]. |
4609 | 4876 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
4877 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4878 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4879 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4880 |
|
4420 | 4881 |
"On X11, be nice and paste PRIMARY when middle click. |
4882 |
Note, that middle button on X11 is translated to button |
|
4883 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 4884 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 4885 |
self undoableDo:[ |
4886 |
self paste: (self getClipboardText:#selection). |
|
4887 |
]. |
|
4888 |
^self. |
|
4889 |
]. |
|
4890 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4891 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4892 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4893 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4894 |
"/ 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
|
4895 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4896 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4897 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4898 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4899 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4900 |
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
|
4901 |
|
4420 | 4902 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
4903 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 4904 |
! |
4905 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4906 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4907 |
"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
|
4908 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4909 |
|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
|
4910 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
4911 |
(button == 1) ifTrue:[ |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4912 |
typeOfSelection := nil. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4913 |
|
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4914 |
dragIsActive ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4915 |
self unselect |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4916 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4917 |
selectionStartLine isNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4918 |
clickCol notNil ifTrue:[ |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4919 |
self cursorMovementAllowed ifTrue:[ |
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4920 |
newCursorCol := clickCol. |
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4921 |
|
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4922 |
cursorType ~~ #block ifTrue:[ |
3790 | 4923 |
clickPos notNil ifTrue:[ |
4924 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
4925 |
"/ (i.e. if its an ibeam). |
|
4926 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
4927 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
|
4928 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
|
4929 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
4930 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
4931 |
]. |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
4932 |
]. |
5056 | 4933 |
"/ the following fixes the ugly select behavior when double clicking on |
4934 |
"/ a partially visible last line (where the first click used to |
|
4935 |
"/ scroll the text so that the second click was handled on another |
|
4936 |
"/ line. An alternative (possibly better) solution would be to |
|
4937 |
"/ remember the last click posision and adjust in the double click |
|
4938 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
4939 |
"/ Time will show, if this hack works. |
|
5057 | 4940 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
4941 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
4942 |
Processor |
|
4943 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
|
5742 | 4944 |
after:0.3 seconds. |
5057 | 4945 |
] ifFalse:[ |
4946 |
self cursorLine:clickLine col:newCursorCol. |
|
4947 |
]. |
|
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4948 |
]. |
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4949 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4950 |
list notEmptyOrNil ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4951 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4952 |
(clickLine >= list size) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4953 |
(clickLine > (self list size + 2) |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4954 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4955 |
self selectAll |
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4956 |
]. |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4957 |
]. |
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4958 |
] |
4394
c3cabdc1f4cc
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4388
diff
changeset
|
4959 |
] |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4960 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4961 |
] |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4962 |
] ifFalse:[ |
4048 | 4963 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
3788
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4964 |
]. |
b72271bf0bc2
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3786
diff
changeset
|
4965 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4966 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4967 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
4968 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
4969 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4970 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4971 |
|
2580 | 4972 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4973 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
4974 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4975 |
| n oldTypeOfSelection | |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4976 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4977 |
oldTypeOfSelection := typeOfSelection. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
4978 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
4979 |
self changeTypeOfSelectionTo:nil. |
2580 | 4980 |
|
4981 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4982 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4983 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4984 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4985 |
cursorCol := cursorCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4986 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4987 |
self validateNewSelection. |
4420 | 4988 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4989 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4990 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4991 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4992 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
4993 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4994 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4995 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4996 |
self addToSelectionAfter:[ self cursorRight ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
4997 |
] ifFalse:[ |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4998 |
"/ Compensate for Claus paste-cursordown-paste feature. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
4999 |
"/ Right after paste the cursor is at the beginning of the |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5000 |
"/ selection. But if immediately after paste user moves cursor right |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5001 |
"/ (but without shift!!!!!!), she probably wants to move past the |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5002 |
"/ pasted text, not into it. This is how every other editor behaves. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5003 |
oldTypeOfSelection == #paste ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5004 |
cursorLine := selectionEndLine. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5005 |
cursorCol := selectionEndCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5006 |
]. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5007 |
|
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5008 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5009 |
"/ to the end of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5010 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5011 |
self setCursorLine: selectionEndLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5012 |
self setCursorCol: selectionEndCol + 1. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5013 |
self unselect; makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5014 |
^ self. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5015 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5016 |
self unselect; makeCursorVisible. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5017 |
self cursorRight. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5018 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5019 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5020 |
^ self |
2580 | 5021 |
]. |
5022 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5023 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5024 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5025 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5026 |
selectionEndCol := cursorCol - 1. |
4970 | 5027 |
"/ selectionEndCol == 1 ifTrue:[ |
5028 |
"/ selectionEndCol := 0. |
|
5029 |
"/ ]. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5030 |
self setCursorLine: cursorLine + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5031 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5032 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5033 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5034 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5035 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5036 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5037 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5038 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5039 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5040 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5041 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5042 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5043 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5044 |
"/ self setCursorLine:(selectionEndLine ? selectionStartLine). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5045 |
"/ self setCursorCol:selectionStartCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5046 |
"/ (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5047 |
"/ self setCursorCol:1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5048 |
"/ self setCursorLine:(cursorLine - 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5049 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5050 |
"/ self makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5051 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5052 |
"/ shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5053 |
"/ clickLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5054 |
"/ clickCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5055 |
"/ self setCursorLine: cursorLine + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5056 |
"/ self expandSelectionDown. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5057 |
"/ ^ self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5058 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5059 |
"/ self unselect. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5060 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5061 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5062 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5063 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5064 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5065 |
self addToSelectionAfter:[ self cursorDown:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5066 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5067 |
"/ If there's selection, unselect and move cursor |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5068 |
"/ one line below last selection line but at the |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5069 |
"/ selectionStartCol column. This behavior is |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5070 |
"/ useful when pasting... |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5071 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5072 |
self setCursorLine: selectionEndLine. |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5073 |
self setCursorCol: selectionStartCol. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5074 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5075 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5076 |
self cursorDown:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5077 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5078 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5079 |
"/ flush keyboard to avoid runaway cursor |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5080 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5081 |
self sensor flushKeyboardFor:self. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5082 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5083 |
^ self |
2580 | 5084 |
]. |
5085 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5086 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5087 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5088 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5089 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5090 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5091 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5092 |
selectionStartCol := cursorCol-1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5093 |
self setCursorCol: cursorCol-1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5094 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5095 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5096 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5097 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5098 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5099 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5100 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5101 |
selectionEndLine := clickStartLine := cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5102 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5103 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5104 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5105 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5106 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5107 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5108 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5109 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5110 |
self redrawFromLine:selectionStartLine to:cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5111 |
self setCursorLine: cursorLine - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5112 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5113 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5114 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5115 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5116 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5117 |
self hasSelection ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5118 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5119 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5120 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5121 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5122 |
"/ self setCursorLine:selectionStartLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5123 |
"/ self setCursorCol:selectionStartCol. |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5124 |
"/ self makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5125 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5126 |
"/ shifted ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5127 |
"/ self unselect. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5128 |
"/ ] |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5129 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5130 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5131 |
(key == #CursorLeft) ifTrue:[ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5132 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5133 |
self addToSelectionAfter:[self cursorLeft]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5134 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5135 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5136 |
"/ to the end of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5137 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5138 |
self setCursorLine:selectionStartLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5139 |
self setCursorCol:selectionStartCol. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5140 |
self unselect; makeCursorVisible. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5141 |
^ self. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5142 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5143 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5144 |
self cursorLeft. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5145 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5146 |
^self |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5147 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5148 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5149 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5150 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5151 |
self addToSelectionAfter: [ self cursorUp:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5152 |
] ifFalse:[ |
4975
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5153 |
"/ If there's selection, unselect and move cursor |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5154 |
"/ to the beggining of selection. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5155 |
self hasSelection ifTrue:[ |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5156 |
self setCursorLine:selectionStartLine. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5157 |
self setCursorCol:selectionStartCol. |
bee454945bf7
Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4974
diff
changeset
|
5158 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5159 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5160 |
self cursorUp:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5161 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5162 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5163 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5164 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5165 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5166 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5167 |
]. |
2580 | 5168 |
]. |
4420 | 5169 |
|
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5170 |
"Modified: / 28-03-2014 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2580 | 5171 |
! |
5172 |
||
2952 | 5173 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5174 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5175 |
|
4521 | 5176 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 5177 |
#Replace #Undo #Redo #Accept |
3780 | 5178 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 5179 |
#DeleteSpaces #Join |
3780 | 5180 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 5181 |
#SelectWord #ExpandSelectionByWord |
3780 | 5182 |
#SelectToEnd #SelectFromBeginning |
4707 | 5183 |
#SelectLine #ExpandSelectionByLine |
3780 | 5184 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
5185 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5186 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5187 |
#GotoLine #BeginOfText #EndOfText |
|
5188 |
#InsertLine #DeleteLine |
|
5189 |
#SelectLineFromBeginning |
|
5190 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 5191 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 5192 |
#'F*' #'f*')> |
2017 | 5193 |
|
4730 | 5194 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5195 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5196 |
|
5197 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5198 |
|
4701 | 5199 |
"/ experimental |
4818 | 5200 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 5201 |
(immediateCompletion |
4818 | 5202 |
or:[currentUserPrefs codeCompletionOnControlKey |
5203 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5204 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5205 |
self initializeCompletionSupport. |
4609 | 5206 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5207 |
]. |
5394 | 5208 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5209 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5210 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5211 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5212 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5213 |
completionSupport notNil ifTrue:[ |
5394 | 5214 |
completionSupport stopCompletionProcess. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5215 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5216 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5217 |
|
4818 | 5218 |
key isSymbol ifTrue:[ |
5643 | 5219 |
(device modifierKeys includes:key) ifFalse:[ |
4818 | 5220 |
lastReplacementInfo stillCollectingInput:false. |
5221 |
] |
|
5222 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5223 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 5224 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5225 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5226 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5227 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5228 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 5229 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5230 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5231 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5232 |
]. |
3799 | 5233 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5234 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5235 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5236 |
self learnMode ifTrue:[ |
4482 | 5237 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5238 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5239 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5240 |
|
4238 | 5241 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
5242 |
"the macro named key exists" |
|
3780 | 5243 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5244 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5245 |
|
4482 | 5246 |
key isSymbol ifFalse:[ |
5247 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
5248 |
self handleNonCommandKey:key. |
|
5249 |
^ self |
|
5250 |
]. |
|
5251 |
||
5252 |
event isNil ifTrue:[ |
|
5253 |
event := WindowGroup lastEventQuerySignal query. |
|
5254 |
]. |
|
5255 |
shiftPressed := event hasShift. |
|
5256 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5257 |
rawKey := event rawKey. |
4482 | 5258 |
|
5133 | 5259 |
key == #InsertUUID ifTrue:[ |
5260 |
self insertUUID. |
|
5261 |
^ self. |
|
5262 |
]. |
|
5263 |
||
4253 | 5264 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
5265 |
self deleteWordBeforeCursor. |
|
5266 |
^ self. |
|
5267 |
]. |
|
5268 |
||
5119 | 5269 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 5270 |
selectionStartLine notNil ifTrue:[ |
5271 |
((key == #BasicBackspace) |
|
4818 | 5272 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 5273 |
ifTrue:[ |
5274 |
self deleteSelection. |
|
5275 |
] ifFalse: [ |
|
5276 |
self copyAndDeleteSelection. |
|
5277 |
]. |
|
4609 | 5278 |
] ifFalse:[ |
5279 |
self makeCursorVisible. |
|
5280 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
5281 |
"/ self deleteWordBeforeCursor. |
|
5282 |
"/ ] ifFalse:[ |
|
5283 |
self deleteCharBeforeCursor. |
|
5284 |
"/ ]. |
|
3780 | 5285 |
]. |
4738 | 5286 |
true "immediateCompletion" ifTrue:[ |
5394 | 5287 |
completionSupport notNil ifTrue:[ |
5288 |
completionSupport postKeyPress:key |
|
5289 |
]. |
|
4731 | 5290 |
]. |
3780 | 5291 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5292 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5293 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5294 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5295 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5296 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5297 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5298 |
|
3235 | 5299 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5300 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 5301 |
^ self. |
3160 | 5302 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5303 |
|
4162 | 5304 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
5305 |
CharacterSetView notNil ifTrue:[ |
|
5306 |
self specialCharacters. |
|
5307 |
^ self. |
|
5308 |
] |
|
5309 |
]. |
|
5310 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5311 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5312 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5313 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5314 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 5315 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5316 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5317 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5318 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5319 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5320 |
(('[fF][0-9]' match:key) |
5321 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5322 |
shiftPressed ifFalse:[ |
|
4818 | 5323 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5324 |
fKeyMacros notNil ifTrue:[ |
5325 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5326 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5327 |
^ self |
|
5328 |
] |
|
5329 |
] |
|
5330 |
] |
|
5331 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5332 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5333 |
|
2506 | 5334 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5335 |
self parenthizeSelectionWith:$( and:$). |
5336 |
^ self. |
|
2506 | 5337 |
]. |
5338 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5339 |
self parenthizeSelectionWith:$" and:$". |
5340 |
^ self. |
|
2506 | 5341 |
]. |
5342 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5343 |
self parenthizeSelectionWith:$' and:$'. |
5344 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5345 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5346 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5347 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5348 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5349 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5350 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5351 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5352 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5353 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5354 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5355 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5356 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5357 |
|
3542 | 5358 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5359 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5360 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5361 |
self makeCursorVisible. |
|
5362 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5363 |
^ self |
|
5364 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5365 |
(key == #SelectWord) ifTrue:[ |
3780 | 5366 |
self makeCursorVisible. |
5367 |
self selectWordUnderCursor. |
|
5368 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5369 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5370 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5371 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5372 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5373 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5374 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5375 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5376 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5377 |
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
|
5378 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5379 |
(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
|
5380 |
(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
|
5381 |
(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
|
5382 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5383 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5384 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5385 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5386 |
shiftPressed ifTrue: [ |
5387 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5388 |
"/ self unselect. |
|
5389 |
"/ self cursorHome. |
|
5390 |
"Jan's modification" |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5391 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
4257 | 5392 |
"/ Jan's modification modified by his own request ;-)) |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5393 |
"/ JV: Well, does not work correctly. Better to fix addToSelectionAfter: |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5394 |
"/ self selectFromBeginOfLine. |
3780 | 5395 |
] ifFalse: [ |
5396 |
self unselect. |
|
5397 |
ctrlPressed ifTrue:[ |
|
5398 |
self cursorHome. |
|
5399 |
] ifFalse:[ |
|
5400 |
self cursorToBeginOfLine. |
|
5401 |
] |
|
5402 |
]. |
|
5403 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5404 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5405 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5406 |
shiftPressed ifTrue:[ |
5407 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5408 |
"/ self unselect. |
|
5409 |
"/ self cursorToBottom |
|
4257 | 5410 |
" Jan's modification" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5411 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
4257 | 5412 |
"/ Jan's modification modified by his own request ;-)) |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5413 |
"/ JV: Well, does not work correctly. Better to fix addToSelectionAfter: |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5414 |
"/ self selectToEndOfLine. |
3780 | 5415 |
] ifFalse:[ |
5416 |
self unselect. |
|
5417 |
ctrlPressed ifTrue:[ |
|
5418 |
self cursorToBottom |
|
5419 |
] ifFalse:[ |
|
5420 |
self cursorToEndOfLine. |
|
5421 |
] |
|
5422 |
]. |
|
5423 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5424 |
]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5425 |
(key == #NextWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5426 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5427 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5428 |
self cursorToNextWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5429 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5430 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5431 |
self cursorToNextWord |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5432 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5433 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5434 |
]. |
3310 | 5435 |
(key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5436 |
(key == #PreviousWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5437 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5438 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5439 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5440 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5441 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5442 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5443 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5444 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5445 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5446 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5447 |
|
5119 | 5448 |
(rawKey == #CursorRight |
5449 |
or:[rawKey == #CursorDown |
|
5450 |
or:[rawKey == #CursorLeft |
|
5451 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5452 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5453 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5454 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5455 |
|
5119 | 5456 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5457 |
self unselect. self cursorReturn. |
5458 |
^ self |
|
3257 | 5459 |
]. |
5460 |
||
5461 |
(key == #Return) ifTrue:[ |
|
3780 | 5462 |
shiftPressed ifTrue:[ |
5463 |
self unselect. self cursorReturn. |
|
5464 |
^ self |
|
5465 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5466 |
|
3780 | 5467 |
self isReadOnly ifTrue:[ |
5468 |
self unselect; makeCursorVisible. |
|
5469 |
self cursorReturn |
|
5470 |
] ifFalse:[ |
|
5471 |
self isInInsertMode ifFalse:[ |
|
5529 | 5472 |
self cursorReturn:true. |
3780 | 5473 |
autoIndent == true ifTrue:[ |
5474 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5475 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5476 |
self cursorCol:(i+1 max:1) |
5477 |
] |
|
3780 | 5478 |
] |
5479 |
] ifTrue:[ |
|
4826 | 5480 |
|left right oldIndent| |
4812 | 5481 |
|
3780 | 5482 |
"/ old version just unselected ... |
5483 |
"/ self unselect; makeCursorVisible. |
|
5484 |
||
5485 |
"/ new version deletes ... |
|
5486 |
typeOfSelection == #paste ifTrue:[ |
|
5487 |
self unselect; makeCursorVisible. |
|
5488 |
] ifFalse:[ |
|
5489 |
self copyAndDeleteSelection. |
|
5490 |
]. |
|
4816 | 5491 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5492 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5493 |
self insertCharAtCursor:(Character cr). |
5112 | 5494 |
|
3780 | 5495 |
autoIndent == true ifTrue:[ |
4816 | 5496 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5497 |
"/ nothing to do. |
|
4812 | 5498 |
] ifFalse:[ |
5499 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5500 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5501 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5502 |
left := left withoutSeparators. |
5503 |
right := right withoutSeparators. |
|
5504 |
(left endsWith:'[') ifTrue:[ |
|
5505 |
"/ i := i + 4. |
|
4816 | 5506 |
] ifFalse:[ |
4823 | 5507 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5508 |
i := i - 4. |
5509 |
]. |
|
4812 | 5510 |
]. |
4826 | 5511 |
oldIndent := self leftIndentOfLine:cursorLine. |
5512 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5513 |
self st80EditMode ifTrue:[ |
|
5514 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5515 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5516 |
]. |
|
5517 |
]. |
|
4812 | 5518 |
self cursorCol:(i+1 max:1) |
5519 |
]. |
|
5520 |
] |
|
3780 | 5521 |
]. |
5522 |
]. |
|
5523 |
]. |
|
5524 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5525 |
]. |
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
|
5526 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5527 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5528 |
self unselect. self cursorTab. |
5529 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5530 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5531 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5532 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5533 |
||
5534 |
self hasSelection ifTrue:[ |
|
5535 |
selectStyle == #line ifTrue:[ |
|
4238 | 5536 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5537 |
macroName := #IndentBy4. |
|
5538 |
] ifFalse:[ |
|
5539 |
macroName := #UndentBy4. |
|
5540 |
]. |
|
5541 |
macroName notNil ifTrue:[ |
|
5542 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5543 |
]. |
5544 |
] |
|
5545 |
]. |
|
5546 |
||
5547 |
self unselect. |
|
5548 |
(key == #Tab) ifTrue:[ |
|
5549 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5550 |
self cursorTab. |
|
5551 |
^ self |
|
5552 |
]. |
|
5553 |
self insertTabAtCursor. |
|
5554 |
^ self |
|
5555 |
]. |
|
5556 |
self cursorBacktab. |
|
5557 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5558 |
]. |
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
|
5559 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5560 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5561 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5562 |
shiftPressed ifTrue:[ |
5563 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5564 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5565 |
self makeCursorVisible. |
|
5566 |
self deleteCharAtCursor. |
|
5567 |
]. |
|
5568 |
^ self |
|
5569 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5570 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5571 |
|
5119 | 5572 |
(rawKey == #Delete |
870 | 5573 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5574 |
selectionStartLine notNil ifTrue:[ |
4130 | 5575 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5576 |
"/ To remove text repetetively, use Cut instead. |
|
5577 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5578 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5579 |
((key == #BasicDelete) |
4818 | 5580 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5581 |
self deleteSelection. |
5582 |
] ifFalse:[ |
|
5583 |
self copyAndDeleteSelection. |
|
5584 |
]. |
|
5585 |
^ self |
|
5586 |
]. |
|
5587 |
self makeCursorVisible. |
|
5588 |
self deleteCharAtCursor. |
|
5589 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5590 |
]. |
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
|
5591 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5592 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5593 |
self unselect. |
5594 |
cursorVisibleLine == 1 ifTrue:[ |
|
5595 |
self cursorHome. |
|
5596 |
] ifFalse:[ |
|
5597 |
self cursorToFirstVisibleLine |
|
5598 |
]. |
|
5599 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5600 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5601 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5602 |
self unselect. |
5603 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5604 |
self cursorToBottom. |
|
5605 |
] ifFalse:[ |
|
5606 |
self cursorToLastVisibleLine |
|
5607 |
]. |
|
5608 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5609 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5610 |
((key == #Escape) |
3257 | 5611 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5612 |
self makeCursorVisible. |
5613 |
self unselect. self selectCursorLineFromBeginning. |
|
5614 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5615 |
]. |
3257 | 5616 |
(key == #SelectLine) ifTrue:[ |
3780 | 5617 |
self makeCursorVisible. |
5618 |
self unselect. self selectCursorLine. |
|
5619 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5620 |
]. |
3257 | 5621 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5622 |
"/ self makeCursorVisible. |
3780 | 5623 |
self selectExpandCursorLine. |
5624 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5625 |
]. |
3257 | 5626 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5627 |
self makeCursorVisible. |
5628 |
self unselect. self deleteCursorLine. |
|
5629 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5630 |
]. |
3257 | 5631 |
(key == #InsertLine) ifTrue:[ |
3780 | 5632 |
self makeCursorVisible. |
5633 |
self unselect. self insertLine:nil before:cursorLine. |
|
5634 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5635 |
]. |
3781 | 5636 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5637 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5638 |
|
3310 | 5639 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5640 |
"Modified: / 14-07-2011 / 12:08:28 / cg" |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5641 |
"Modified: / 31-03-2014 / 16:27:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5642 |
! |
5643 |
||
2952 | 5644 |
executeKeyboardMacro:cmdMacro |
5645 |
Error handle:[:ex | |
|
4823 | 5646 |
self warn:'Error in keyboard macro: ' , ex description. |
5647 |
ex return. |
|
2952 | 5648 |
] do:[ |
4823 | 5649 |
AbortOperationRequest handle:[:ex | |
5650 |
self warn:'Keyboard macro aborted'. |
|
5651 |
ex return. |
|
5652 |
] do:[ |
|
5653 |
Parser |
|
5654 |
evaluate:cmdMacro asString |
|
5655 |
receiver:self |
|
5656 |
notifying:nil |
|
5657 |
compile:false. |
|
5658 |
]. |
|
2952 | 5659 |
]. |
5660 |
! |
|
5661 |
||
5340
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5662 |
extendSelectionToX:x y:y setPrimarySelection:aBoolean |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5663 |
| movedVisibleLine movedLine movedCol movedUp | |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5664 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5665 |
movedVisibleLine := self visibleLineOfY:y. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5666 |
movedLine := self visibleLineToAbsoluteLine:movedVisibleLine. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5667 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5668 |
(x < leftMargin) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5669 |
movedCol := 0 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5670 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5671 |
movedCol := self colOfX:x inVisibleLine:movedVisibleLine |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5672 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5673 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5674 |
"find out if we are before or after initial click" |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5675 |
movedUp := false. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5676 |
(movedLine < (clickStartLine ? movedLine)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5677 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5678 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5679 |
(movedLine == (clickStartLine ? movedLine)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5680 |
(movedCol < (clickStartCol ? movedCol)) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5681 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5682 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5683 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5684 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5685 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5686 |
self hasSelection ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5687 |
movedUp ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5688 |
"/ Set cursor to selection start |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5689 |
self setCursorLine: selectionStartLine col: selectionStartCol |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5690 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5691 |
"/ Set cursor to selection end |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5692 |
self setCursorLine: selectionEndLine col: selectionEndCol + 1 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5693 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5694 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5695 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5696 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5697 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5698 |
super extendSelectionToX:x y:y setPrimarySelection:aBoolean. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5699 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5700 |
"Created: / 02-05-2015 / 07:33:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 5701 |
! |
5702 |
||
5703 |
handleNonCommandKey:keyArg |
|
4700 | 5704 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 5705 |
|
5706 |
self isReadOnly ifTrue:[ |
|
4988 | 5707 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5708 |
^ self. |
2952 | 5709 |
]. |
5710 |
||
5711 |
key := keyArg. |
|
5712 |
||
5713 |
typeOfSelection == #paste ifTrue:[ |
|
4846
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5714 |
"Pasted selection will NOT be replaced by keystroke (non-standard, St/X feature)" |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5715 |
|
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5716 |
"/ After paste, the cursor is at the beginning to support |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5717 |
"/ paste-cursordown-paste. Compensate for this here - we want |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5718 |
"/ to continue editing after the end of the selection. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5719 |
"/ This is |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5720 |
cursorLine := selectionEndLine. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5721 |
cursorCol := selectionEndCol + 1. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5722 |
|
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5723 |
"/ Cursor position set, we can unselect. |
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5724 |
self unselect. |
2952 | 5725 |
]. |
5726 |
||
4700 | 5727 |
selStartLineBefore := selectionStartLine. |
5728 |
selStartColBefore := self selectionStartCol. |
|
5729 |
selEndLineBefore := selectionEndLine. |
|
5730 |
selEndColBefore := self selectionEndCol. |
|
2952 | 5731 |
|
4940 | 5732 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 5733 |
key isCharacter ifTrue:[ |
4940 | 5734 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5735 |
] ifFalse:[ |
4940 | 5736 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 5737 |
]. |
2952 | 5738 |
]. |
5739 |
||
5740 |
"replace selection by what is typed in - |
|
3235 | 5741 |
if word was selected with a space, keep it. |
4700 | 5742 |
if there was no selection, the key's character is inserted" |
3235 | 5743 |
|
5744 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5745 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 5746 |
]. |
2952 | 5747 |
|
5748 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5749 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 5750 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5751 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5752 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5753 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5754 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5755 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5756 |
] |
3160 | 5757 |
]. |
2952 | 5758 |
selectStyle := nil. |
5759 |
||
3235 | 5760 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 5761 |
selectionStartLine := selStartLineBefore. |
5762 |
selectionStartCol := selStartColBefore. |
|
5763 |
selectionEndLine := selEndLineBefore. |
|
5764 |
selectionEndCol := selEndColBefore. |
|
3235 | 5765 |
]. |
5766 |
||
2952 | 5767 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5768 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5769 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5770 |
"claus: only do it for closing parenthesis - |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5771 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5772 |
" |
2952 | 5773 |
" |
4481 | 5774 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 5775 |
" |
4481 | 5776 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5777 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5778 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5779 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5780 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5781 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5782 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5783 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5784 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5785 |
self cursorLine:line col:col. |
4940 | 5786 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5787 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5788 |
"/ want to wait 200ms, but not if another keyPress |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5789 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5790 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5791 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5792 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5793 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5794 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5795 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5796 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5797 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5798 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5799 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5800 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5801 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5802 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5803 |
] |
2952 | 5804 |
]. |
5805 |
||
5806 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
5807 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
5808 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
5809 |
"/ |
|
5810 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5811 |
"/ self selection. |
|
5812 |
"/ typeOfSelection := #paste. |
|
3160 | 5813 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
5814 |
"/ ]. |
3235 | 5815 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5816 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5817 |
self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5818 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5819 |
self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
5820 |
]. |
3235 | 5821 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5822 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 5823 |
|
5824 |
"Modified (comment): / 25-01-2012 / 00:30:11 / cg" |
|
4846
cd2e0b754655
Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4845
diff
changeset
|
5825 |
"Modified: / 30-08-2013 / 20:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 5826 |
! |
5827 |
||
5828 |
keyPress:key x:x y:y |
|
5829 |
"handle keyboard input" |
|
5830 |
||
4771 | 5831 |
|wasOn| |
5832 |
||
5833 |
wasOn := cursorShown. |
|
5834 |
||
5689 | 5835 |
NoModificationError |
5836 |
handle:[:ex | |
|
5837 |
self flashReadOnly. |
|
5838 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
5839 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
5840 |
]. |
|
5841 |
] |
|
5842 |
do:[ |
|
5843 |
self undoableDo:[ |
|
5844 |
self doKeyPress:key x:x y:y |
|
5845 |
]. |
|
5846 |
]. |
|
5847 |
||
4242 | 5848 |
self repairDamage |
5849 |
||
5850 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 5851 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 5852 |
! |
5853 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5854 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5855 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5856 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5857 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
5858 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5859 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5860 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5861 |
requestAutoAccept |
5068 | 5862 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
5863 |
This forces my value to be accepted into my model. |
|
5864 |
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
|
5865 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5866 |
acceptEnabled == false ifTrue:[ |
4823 | 5867 |
"/ nope - |
5868 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5869 |
]. |
5404 | 5870 |
"/ cg: only do this if modified. |
5871 |
"/ otherwise, users would have to make sure that the contents is |
|
5872 |
"/ always correct (which they don't). If you change this back, |
|
5873 |
"/ please check the expecco file-save or file-reimport dialog, |
|
5874 |
"/ which has a problem with that behavior. |
|
5875 |
self modified ifTrue:[ |
|
5876 |
self accept. |
|
5877 |
]. |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5878 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5879 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
5880 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5881 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5882 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5883 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5884 |
|cv| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5885 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5886 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5887 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5888 |
cv notNil ifTrue:[ |
4823 | 5889 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5890 |
] |
4967 | 5891 |
! |
5892 |
||
5893 |
unmapped |
|
5894 |
super unmapped. |
|
5895 |
||
5896 |
completionSupport notNil ifTrue:[ |
|
5897 |
completionSupport release. |
|
5898 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5899 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5900 |
|
1807 | 5901 |
!EditTextView methodsFor:'focus handling'! |
5902 |
||
4818 | 5903 |
focusOut |
5904 |
super focusOut. |
|
5905 |
||
5906 |
completionSupport notNil ifTrue:[ |
|
5907 |
completionSupport release. |
|
5908 |
]. |
|
5909 |
! |
|
5910 |
||
1807 | 5911 |
hasKeyboardFocus:aBoolean |
5912 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
5913 |
(otherwise, I would not know about this)" |
|
5914 |
||
5915 |
hasKeyboardFocus := aBoolean. |
|
4609 | 5916 |
|
3160 | 5917 |
(cursorShown |
5918 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5919 |
and:[self isReadOnly not]]) ifTrue:[ |
4609 | 5920 |
self drawCursor |
5921 |
]. |
|
5922 |
||
5923 |
hasKeyboardFocus ifFalse:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5924 |
completionSupport notNil ifTrue:[ |
4821 | 5925 |
"/ this is a hack for Windows: |
5926 |
"/ on windows, an activate:false event is first sent to my textView, |
|
5927 |
"/ then an activate is sent to the completion popup. |
|
5928 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
5929 |
"/ therefore, allow for the activate of the completionMenu and it's button event to be processed. |
|
5930 |
"/ before forcing it to be closed... |
|
5773 | 5931 |
completionSupport startTimeoutForEditViewLostFocus. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5932 |
]. |
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5933 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
5934 |
|
4821 | 5935 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 5936 |
! |
5937 |
||
5938 |
showFocus:explicit |
|
5939 |
"in addition to however my superclass thinks how a focusView is to be |
|
5940 |
displayed, show the cursor when I got the focus" |
|
5941 |
||
5239 | 5942 |
self hasKeyboardFocus:true. |
1807 | 5943 |
self showCursor. |
5944 |
super showFocus:explicit |
|
5945 |
||
5946 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5947 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5948 |
|
4967 | 5949 |
showNoFocus:explicit |
5950 |
"the view lost the keyboard focus |
|
5951 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
5952 |
- change any display attributes as req'd." |
|
5953 |
||
5954 |
super showNoFocus:explicit. |
|
5149 | 5955 |
|
5956 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
5957 |
"/ not when the focus is lost normally (because this also happens when |
|
5958 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
5959 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
5960 |
explicit ifTrue:[ |
|
5961 |
completionSupport notNil ifTrue:[ |
|
5962 |
completionSupport release. |
|
5963 |
]. |
|
4818 | 5964 |
]. |
5965 |
! |
|
5966 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5967 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5968 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5969 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5970 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5971 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5972 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
5973 |
and:[self enabled |
4781 | 5974 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5975 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
5976 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5977 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5978 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
5979 |
^ false |
1807 | 5980 |
! ! |
5981 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5982 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5983 |
|
4237 | 5984 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5985 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5986 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5987 |
|
4482 | 5988 |
|cmdMacro| |
5989 |
||
5990 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5991 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5992 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5993 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
5994 |
^ true |
4238 | 5995 |
|
5996 |
" |
|
4483 | 5997 |
EditTextView open |
4238 | 5998 |
contents:'bla'; |
5999 |
selectAll; |
|
6000 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6001 |
EditTextView open |
4238 | 6002 |
contents:'bla'; |
6003 |
selectAll; |
|
6004 |
executekeyboardMacroNamed:#blabla. |
|
6005 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6006 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6007 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6008 |
! |
6009 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6010 |
indent |
3221 | 6011 |
"indent a line-range - this is done by searching for the |
6012 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6013 |
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
|
6014 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6015 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6016 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6017 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6018 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6019 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6020 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6021 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 6022 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6023 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6024 |
self unselect. |
3160 | 6025 |
self |
3786 | 6026 |
undoableDo:[self indentFromLine:start toLine:end] |
6027 |
info:'Indent' |
|
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 |
|
4237 | 6030 |
indentBy4 |
5050 | 6031 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6032 |
||
6033 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6034 |
! |
|
6035 |
||
6036 |
indentBy8 |
|
6037 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6038 |
|
6039 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6040 |
! |
|
6041 |
||
5050 | 6042 |
indentBy:n |
6043 |
|line1 line2| |
|
6044 |
||
6045 |
line1 := self selectionStartLine. |
|
6046 |
line2 := self selectionEndLine. |
|
6047 |
line1 isNil ifTrue:[ |
|
5833 | 6048 |
line1 := self cursorLine. |
6049 |
line1 notNil ifTrue:[ |
|
6050 |
line2 := line1 |
|
6051 |
] |
|
5769 | 6052 |
] ifFalse:[ |
5833 | 6053 |
line2 notNil ifTrue:[ |
6054 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
5769 | 6055 |
]. |
6056 |
]. |
|
5050 | 6057 |
line1 notNil ifTrue:[ |
5833 | 6058 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6059 |
] |
6060 |
! |
|
6061 |
||
6062 |
indentByTab |
|
6063 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6064 |
! |
|
6065 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6066 |
indentFromLine:start toLine:end |
3221 | 6067 |
"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
|
6068 |
last non-empty line before start, and change the indent |
4742 | 6069 |
of the selected line-range based on that line's indent." |
6070 |
||
4811 | 6071 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6072 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6073 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6074 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6075 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6076 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6077 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6078 |
self indentFromLine:start toLine:end by:delta |
6079 |
! |
|
6080 |
||
6081 |
indentFromLine:start toLine:end by:delta |
|
6082 |
"indent a line-range - this is done by searching for the |
|
6083 |
last non-empty line before start, and change the indent |
|
6084 |
of the selected line-range based on that line's indent." |
|
6085 |
||
6086 |
|d line spaces anyChange| |
|
6087 |
||
6088 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6089 |
(delta > 0) ifTrue:[ |
4742 | 6090 |
spaces := String new:delta |
6091 |
]. |
|
6092 |
||
6093 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6094 |
start to:end do:[:lineNr | |
4742 | 6095 |
line := self listAt:lineNr. |
6096 |
line notNil ifTrue:[ |
|
6097 |
line isBlank ifTrue:[ |
|
4771 | 6098 |
self basicListAt:lineNr put:nil |
4742 | 6099 |
] ifFalse:[ |
6100 |
(delta > 0) ifTrue:[ |
|
6101 |
line := spaces , line. |
|
6102 |
widthOfWidestLine notNil ifTrue:[ |
|
6103 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6104 |
] |
|
6105 |
] ifFalse:[ |
|
6106 |
"check if deletion is ok" |
|
6107 |
d := delta negated + 1. |
|
6108 |
||
6109 |
line size > d ifTrue:[ |
|
6110 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
6111 |
line := line copyFrom:d |
|
6112 |
] |
|
6113 |
]. |
|
6114 |
widthOfWidestLine := nil |
|
6115 |
]. |
|
6116 |
self replaceLine:lineNr with:line. |
|
6117 |
anyChange := true. |
|
6118 |
] |
|
6119 |
] |
|
6120 |
]. |
|
6121 |
||
6122 |
anyChange ifTrue:[ self textChanged ]. |
|
6123 |
||
3221 | 6124 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6125 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6126 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6127 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6128 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6129 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6130 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6131 |
this is done by searching for the last non-empty line before it |
4823 | 6132 |
and returning its indent. |
6133 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6134 |
|
827 | 6135 |
"SHOULD GO TO ListView" |
6136 |
||
6137 |
|line lnr indent| |
|
6138 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6139 |
lnr := lineNr. |
827 | 6140 |
|
4823 | 6141 |
"/ [lnr ~~ 1] whileTrue:[ |
6142 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 6143 |
lnr := lnr - 1. |
6144 |
line := self listAt:lnr. |
|
6145 |
||
6146 |
line notNil ifTrue:[ |
|
6147 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
6148 |
indent ~~ 0 ifTrue:[ |
|
6149 |
(line endsWith:$[) ifTrue:[ |
|
6150 |
^ indent + 4 - 1 |
|
6151 |
]. |
|
6152 |
^ indent - 1 |
|
6153 |
] |
|
6154 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6155 |
]. |
827 | 6156 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6157 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6158 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 6159 |
! |
6160 |
||
6161 |
undentBy4 |
|
5050 | 6162 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6163 |
||
6164 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6165 |
! |
|
6166 |
||
6167 |
undentBy8 |
|
6168 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6169 |
|
6170 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6171 |
! |
6172 |
||
6173 |
undentBy:n |
|
6174 |
self indentBy:(n negated) |
|
6175 |
! |
|
6176 |
||
6177 |
undentByTab |
|
6178 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6179 |
! ! |
6180 |
||
0 | 6181 |
!EditTextView methodsFor:'initialization'! |
6182 |
||
941 | 6183 |
fetchDeviceResources |
6184 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6185 |
||
6186 |
super fetchDeviceResources. |
|
6187 |
||
5643 | 6188 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6189 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6190 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6191 |
|
6192 |
"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
|
6193 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6194 |
! |
6195 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6196 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6197 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6198 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6199 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6200 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6201 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6202 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6203 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6204 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6205 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6206 |
super initStyle. |
4576 | 6207 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6208 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6209 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6210 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6211 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6212 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6213 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6214 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6215 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6216 |
cursorTypeNoFocus := cursorType. |
|
6217 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6218 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6219 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6220 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6221 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6222 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 6223 |
cursorType ~~ #block ifTrue:[ |
6224 |
cursorNoFocusFgColor := cursorBgColor |
|
6225 |
] ifFalse:[ |
|
6226 |
cursorNoFocusFgColor := cursorFgColor |
|
6227 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6228 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6229 |
|
2088 | 6230 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6231 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6232 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6233 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6234 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6235 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6236 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6237 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6238 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6239 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6240 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6241 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6242 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6243 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6244 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6245 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6246 |
cursorCol := 1. |
5251 | 6247 |
cursorLineHolder := ValueHolder with:1. |
6248 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6249 |
modifiedChannel := ValueHolder with:false. |
6250 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6251 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6252 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6253 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6254 |
tabMeansNextField := false. |
5106 | 6255 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6256 |
autoIndent := false. |
|
5251 | 6257 |
editMode := ValueHolder with:EditMode insertMode. |
6258 |
learnMode := ValueHolder with:false. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6259 |
trimBlankLines := self st80EditMode not. |
2131 | 6260 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6261 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6262 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6263 |
"/ enable drop by default |
2589 | 6264 |
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
|
6265 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6266 |
undoSupport := UndoSupport for:self. |
5251 | 6267 |
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
|
6268 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6269 |
"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
|
6270 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6271 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6272 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6273 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6274 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6275 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6276 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6277 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6278 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6279 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6280 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6281 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6282 |
! |
6283 |
||
6284 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6285 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6286 |
completionSupport release |
4771 | 6287 |
]. |
6288 |
super release |
|
0 | 6289 |
! ! |
6290 |
||
2580 | 6291 |
!EditTextView methodsFor:'macros'! |
6292 |
||
6293 |
executeLearnedKeyboardMacro |
|
4673 | 6294 |
"replay the characters as learned previously" |
6295 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6296 |
(self learnMode not and:[learnedMacro size > 0]) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6297 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6298 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6299 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6300 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6301 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6302 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6303 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6304 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6305 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6306 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6307 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6308 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6309 |
]. |
2580 | 6310 |
] ifFalse:[ |
5153 | 6311 |
self flash:'no macro'. |
2580 | 6312 |
]. |
6313 |
! |
|
6314 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6315 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6316 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6317 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6318 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6319 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6320 |
|
2580 | 6321 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6322 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6323 |
|
2580 | 6324 |
|fg bg| |
6325 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6326 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6327 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6328 |
aBoolean ifTrue:[ |
5795 | 6329 |
learnedMacro := OrderedCollection new. |
6330 |
fg := self whiteColor. |
|
6331 |
bg := self blackColor. |
|
2580 | 6332 |
] ifFalse:[ |
5795 | 6333 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6334 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6335 |
]. |
6336 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6337 |
! |
|
6338 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6339 |
learnModeHolder |
4673 | 6340 |
"a holder returning true, if in learn mode" |
6341 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6342 |
learnMode isNil ifTrue:[ |
5251 | 6343 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6344 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6345 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6346 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6347 |
|
4673 | 6348 |
rememberLearnedMacroAs: nameString |
6349 |
Macros isNil ifTrue:[ |
|
6350 |
Macros := Dictionary new. |
|
6351 |
]. |
|
6352 |
Macros at:nameString put:learnedMacro |
|
6353 |
! |
|
6354 |
||
2580 | 6355 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6356 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6357 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6358 |
self learnMode:(self learnMode not). |
2580 | 6359 |
! ! |
6360 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6361 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6362 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6363 |
babelFishTranslate:fromToModeString |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6364 |
"translate the selected text and paste it after the selection" |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6365 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6366 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6367 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6368 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6369 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6370 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6371 |
self withWaitCursorDo:[ |
4143
34d78a2ca94f
changed: #babelFishTranslate:
Claus Gittinger <cg@exept.de>
parents:
4142
diff
changeset
|
6372 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
3799 | 6373 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
6374 |
] do:[ |
|
6375 |
translated := SOAP::BabelFishClient new translate:original mode:fromToModeString. |
|
6376 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6377 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6378 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6379 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6380 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6381 |
self unselect. |
3799 | 6382 |
self |
6383 |
undoablePaste:translated |
|
6384 |
info:'Translate' |
|
3495 | 6385 |
|
6386 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6387 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6388 |
|
3517 | 6389 |
compareWithClipboard |
6390 |
"compare the selection against the clipboard contents" |
|
6391 |
||
6392 |
|t1 t2| |
|
6393 |
||
6394 |
t2 := self getClipboardText. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6395 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6396 |
Dialog information:'Clipboard is empty.'. |
6397 |
^ self. |
|
3517 | 6398 |
]. |
6399 |
||
6400 |
self hasSelection ifTrue:[ |
|
4823 | 6401 |
t1 := self selectionAsString. |
3517 | 6402 |
] ifFalse:[ |
4823 | 6403 |
t1 := self contents asString |
3517 | 6404 |
]. |
6405 |
t1 := t1 string. |
|
6406 |
||
6407 |
t1 = t2 ifTrue:[ |
|
4823 | 6408 |
Dialog information:'Strings are equal.'. |
6409 |
^ self. |
|
3517 | 6410 |
]. |
6411 |
DiffTextView |
|
4823 | 6412 |
openOn:t1 label:'Editor' |
6413 |
and:t2 label:'Clipboard' |
|
3517 | 6414 |
! |
6415 |
||
5826 | 6416 |
compareWithFile |
6417 |
"compare the selection or the whole text against the contents of a file" |
|
6418 |
||
6419 |
|fn t1 t2| |
|
6420 |
||
6421 |
fn := Dialog requestFileName:'Compare against file:' default:defaultFileNameForFileDialog. |
|
6422 |
fn isEmptyOrNil ifTrue:[^ self]. |
|
6423 |
||
6424 |
t2 := fn asFilename contentsOfEntireFile. |
|
6425 |
t2 isEmptyOrNil ifTrue:[ |
|
6426 |
Dialog information:'File is empty.'. |
|
6427 |
^ self. |
|
6428 |
]. |
|
6429 |
||
6430 |
self hasSelection ifTrue:[ |
|
6431 |
t1 := self selectionAsString. |
|
6432 |
] ifFalse:[ |
|
6433 |
t1 := self contents asString |
|
6434 |
]. |
|
6435 |
t1 := t1 string. |
|
6436 |
||
6437 |
t1 = t2 ifTrue:[ |
|
6438 |
Dialog information:'Same contents.'. |
|
6439 |
^ self. |
|
6440 |
]. |
|
6441 |
DiffTextView |
|
6442 |
openOn:t1 label:'Editor' |
|
6443 |
and:t2 label:'File' |
|
6444 |
! |
|
6445 |
||
5689 | 6446 |
copySelection |
6447 |
"copy contents into smalltalk copybuffer. |
|
6448 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6449 |
||
6450 |
self hasSelection ifTrue:[ |
|
6451 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
|
6452 |
]. |
|
6453 |
super copySelection. |
|
6454 |
||
6455 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6456 |
! |
|
6457 |
||
121 | 6458 |
cut |
6459 |
"cut selection into copybuffer" |
|
6460 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6461 |
self deleteCopyToClipboard:true |
121 | 6462 |
! |
6463 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6464 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6465 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6466 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6467 |
cursorLine notNil ifTrue:[ |
4823 | 6468 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6469 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6470 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6471 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6472 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6473 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6474 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6475 |
|
4129 | 6476 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6477 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6478 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6479 |
self flashReadOnly. |
3786 | 6480 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6481 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6482 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6483 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6484 |
sel notNil ifTrue:[ |
4129 | 6485 |
self setLastStringToReplace: sel. |
4053 | 6486 |
|
3786 | 6487 |
line := selectionStartLine. |
6488 |
col := selectionStartCol. |
|
6489 |
||
6490 |
toClipboard ifTrue:[ |
|
6491 |
" |
|
6492 |
remember in CopyBuffer |
|
6493 |
" |
|
6494 |
self setClipboardText:sel. "/ lastString. |
|
6495 |
]. |
|
6496 |
||
6497 |
" |
|
6498 |
append to DeleteHistory (if there is one) |
|
6499 |
" |
|
6500 |
history := Smalltalk at:#DeleteHistory. |
|
6501 |
history notNil ifTrue:[ |
|
6502 |
history addAll:(sel asStringCollection). |
|
6503 |
history size > 1000 ifTrue:[ |
|
6504 |
history := history copyFrom:(history size - 1000) |
|
6505 |
]. |
|
6506 |
]. |
|
6507 |
||
6508 |
" |
|
6509 |
now, delete it |
|
6510 |
" |
|
6511 |
self |
|
6512 |
undoableDo:[self deleteSelection] |
|
6513 |
info:'Delete'. |
|
4048 | 6514 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6515 |
] ifFalse:[ |
3786 | 6516 |
" |
6517 |
a cut without selection will search&cut again |
|
6518 |
" |
|
6519 |
self undoableDo:[ |
|
6520 |
self again |
|
6521 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6522 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6523 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6524 |
"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
|
6525 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6526 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6527 |
editMenu |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6528 |
"return the views middleButtonMenu" |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6529 |
|
3781 | 6530 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 6531 |
#Find #GotoLine #SaveAs #Print |
3890 | 6532 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6533 |
#ToggleAutoIndent #ToggleInsertMode |
5826 | 6534 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6535 |
<resource: #programMenu> |
1054 | 6536 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6537 |
|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
|
6538 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6539 |
|
2460 | 6540 |
items := #( |
5826 | 6541 |
('Redo' redo Redo ) |
6542 |
('Again (for All)' multipleAgain AgainForAll ) |
|
6543 |
('-' ) |
|
6544 |
('Search...' search Find ) |
|
6545 |
('Goto Line...' gotoLine GotoLine ) |
|
6546 |
('-' ) |
|
6547 |
('Tools' tools ) |
|
6548 |
('Font...' changeFont ) |
|
6549 |
('Insert Unicode...' insertUnicode ) |
|
6550 |
). |
|
4213 | 6551 |
CharacterSetView notNil ifTrue:[ |
5826 | 6552 |
items := items , |
6553 |
#( |
|
6554 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6555 |
). |
|
4213 | 6556 |
]. |
6557 |
items := items , #( |
|
5826 | 6558 |
('-' ) |
6559 |
('Save As...' save SaveAs ) |
|
6560 |
('Print' doPrint Print ) |
|
6561 |
('=' ) |
|
6562 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 6563 |
|
2866 | 6564 |
miscItems := #( |
5826 | 6565 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6566 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
6567 |
('-' ) |
|
6568 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
6569 |
('Join Lines' joinLines Join ) |
|
6570 |
('Wrap Lines...' wrapLines Wrap ) |
|
6571 |
('-' ) |
|
6572 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
6573 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
6574 |
('-' ) |
|
6575 |
('Insert File...' insertFile ) |
|
6576 |
('Insert URL Contents...' insertURL ) |
|
6577 |
('Insert new UUID' insertUUID ) |
|
6578 |
('Insert Date && Time' insertDateAndTime ) |
|
6579 |
('-' ) |
|
6580 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6581 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
6582 |
). |
|
4213 | 6583 |
"/ CharacterSetView notNil ifTrue:[ |
6584 |
"/ miscItems := miscItems , |
|
6585 |
"/ #( |
|
5529 | 6586 |
"/ ('-' ) |
4213 | 6587 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6588 |
"/ ('Font...' changeFont ) |
4213 | 6589 |
"/ ). |
5529 | 6590 |
"/ ] ifFalse:[ |
6591 |
"/ miscItems := miscItems , |
|
6592 |
"/ #( |
|
6593 |
"/ ('Font...' changeFont ) |
|
6594 |
"/"/ ('Encoding...' changeEncoding ) |
|
6595 |
"/ ). |
|
6596 |
"/ ]. |
|
2866 | 6597 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6598 |
translateItems := #( |
5826 | 6599 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6600 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6601 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6602 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6603 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6604 |
('-' ) |
|
6605 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6606 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6607 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6608 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6609 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6610 |
). |
|
3221 | 6611 |
|
6612 |
sortItems := #( |
|
5826 | 6613 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6614 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
6615 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
6616 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6617 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
6618 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
6619 |
('-' ) |
|
6620 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
6621 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6622 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6623 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
6624 |
('-' ) |
|
6625 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6626 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
6627 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6628 |
|
2762 | 6629 |
toolItems := #( |
5826 | 6630 |
('Indent' indent ) |
6631 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6632 |
('Sort' sort ) |
|
6633 |
('Split...' splitLinesAtCharacterOrString ) |
|
6634 |
('-' ) |
|
6635 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6636 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
6637 |
('Translate' babelFishTranslate ) |
|
6638 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6639 |
('Compare with File...' compareWithFile ) |
|
6640 |
). |
|
2762 | 6641 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6642 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 6643 |
toolItems := toolItems , #( |
6644 |
('-' ) |
|
6645 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6646 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6647 |
('Inspect Selected String' inspectSelectedString ) |
|
6648 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6649 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6650 |
|
2460 | 6651 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6652 |
sub receiver:self. |
2460 | 6653 |
|
2919 | 6654 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6655 |
toolSub receiver:self. |
|
6656 |
sub subMenuAt:#tools put:toolSub. |
|
6657 |
||
3495 | 6658 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6659 |
transSub receiver:self. |
|
6660 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6661 |
||
6662 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6663 |
sortSub receiver:self. |
|
6664 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6665 |
|
2866 | 6666 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6667 |
subSub receiver:self. |
|
2952 | 6668 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6669 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6670 |
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
|
6671 |
|
2866 | 6672 |
sub subMenuAt:#misc put:subSub. |
6673 |
||
3495 | 6674 |
mainItems := #( |
5826 | 6675 |
('Undo' undo Undo ) |
6676 |
('Again' again Again ) |
|
6677 |
('-' ) |
|
6678 |
('Cut' cut Cut ) |
|
6679 |
('Copy' copySelection Copy ) |
|
6680 |
('Paste' pasteOrReplace Paste ) |
|
6681 |
('-' ) |
|
6682 |
('Accept' accept Accept ) |
|
6683 |
('=' ) |
|
6684 |
('More' others Ctrl ) |
|
6685 |
). |
|
3495 | 6686 |
main := PopUpMenu itemList:mainItems resources:resources. |
6687 |
main subMenuAt:#others put:sub. |
|
6688 |
||
6689 |
sensor := self sensor. |
|
6690 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
6691 |
sensor shiftDown ifTrue:[ |
|
5826 | 6692 |
m := subSub |
6693 |
] ifFalse:[ |
|
6694 |
m := sub |
|
6695 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6696 |
] ifFalse:[ |
5826 | 6697 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6698 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6699 |
|
4742 | 6700 |
"/ the 'Smalltalk at:' code is here to |
6701 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 6702 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 6703 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
6704 |
m disable:#googleSpellingSuggestion |
|
2676 | 6705 |
]. |
4742 | 6706 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 6707 |
m disable:#internalSpellingSuggestion |
4742 | 6708 |
]. |
2676 | 6709 |
|
3811 | 6710 |
HTTPInterface isNil ifTrue:[ |
5826 | 6711 |
m disableAll:#(insertURL) |
3811 | 6712 |
]. |
6713 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
6714 |
self isReadOnly ifTrue:[ |
5826 | 6715 |
m disableAll:#(accept undo again multipleAgain redo |
6716 |
paste pasteOrReplace pasteOrReplaceFromHistory |
|
6717 |
cut indent autoIndent: insertMode: |
|
6718 |
insertFile insertFileAsStringLiteral insertURL |
|
6719 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 6720 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
5826 | 6721 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
6722 |
insertUnicode specialCharacters) |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6723 |
]. |
2817 | 6724 |
self hasSelectionForCopy ifFalse:[ |
5826 | 6725 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6726 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
6727 |
self hasSelection ifFalse:[ |
5371 | 6728 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
5826 | 6729 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString). |
2762 | 6730 |
] ifTrue:[ |
5826 | 6731 |
(Error handle:[:ex | |
6732 |
ex return:false |
|
6733 |
] do:[ |
|
6734 |
|fn| |
|
6735 |
fn := self selectionAsString. |
|
6736 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
6737 |
]) ifFalse:[ |
|
6738 |
m disableAll:#(openFileBrowserOnIt). |
|
6739 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6740 |
]. |
2569 | 6741 |
self hasUndoAction ifFalse:[ |
5826 | 6742 |
m disable:#undo. |
3115 | 6743 |
] ifTrue:[ |
5826 | 6744 |
what := undoSupport undoActionInfo. |
6745 |
what notNil ifTrue:[ |
|
6746 |
undoIdx := m indexOf:#undo. |
|
6747 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
6748 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
6749 |
]. |
2952 | 6750 |
self hasRedoAction ifFalse:[ |
5826 | 6751 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
6752 |
] ifTrue:[ |
5826 | 6753 |
what := undoSupport redoActionInfo. |
6754 |
what notNil ifTrue:[ |
|
6755 |
redoIdx := sub indexOf:#redo. |
|
6756 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
6757 |
] |
|
2952 | 6758 |
]. |
5216 | 6759 |
self canAccept ifFalse:[ |
5826 | 6760 |
m disable:#accept |
1108 | 6761 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6762 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6763 |
|
4388 | 6764 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6765 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6766 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6767 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6768 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6769 |
|
5643 | 6770 |
history := device getCopyBufferHistory copy. |
3160 | 6771 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6772 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6773 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6774 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6775 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6776 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6777 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6778 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6779 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6780 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6781 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6782 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6783 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6784 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6785 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6786 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6787 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6788 |
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
|
6789 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6790 |
box show. |
3160 | 6791 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6792 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
6793 |
"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
|
6794 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6795 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6796 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6797 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
6798 |
self sensor shiftDown ifTrue:[ |
3855 | 6799 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6800 |
]. |
2724 | 6801 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6802 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6803 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6804 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6805 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6806 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6807 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6808 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6809 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6810 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6811 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6812 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6813 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
6814 |
"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
|
6815 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
6816 |
|
2676 | 6817 |
googleSpellingSuggestion |
6818 |
"insert the google-spelling suggestion for the selected text. |
|
6819 |
Requires that the SOAP stuff is loaded and working." |
|
6820 |
||
2677 | 6821 |
|text suggestion| |
2676 | 6822 |
|
6823 |
self withWaitCursorDo:[ |
|
3799 | 6824 |
text := self selection asString string withoutSeparators. |
6825 |
text size == 0 ifTrue:[^ self]. |
|
6826 |
||
4742 | 6827 |
"/ the 'Smalltalk at:' code is here to |
6828 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
6829 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 6830 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
6831 |
^ self. |
|
6832 |
] do:[ |
|
4742 | 6833 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 6834 |
]. |
6835 |
suggestion size == 0 ifTrue:[ |
|
4742 | 6836 |
self information:('No spelling suggestion from Google for: ' , text). |
6837 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 6838 |
^ self. |
6839 |
]. |
|
6840 |
]. |
|
6841 |
self |
|
6842 |
undoablePaste:suggestion |
|
6843 |
info:'Spelling Suggestion'. |
|
3495 | 6844 |
|
6845 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 6846 |
! |
6847 |
||
3595 | 6848 |
insertDateAndTime |
6849 |
"insert the curent date and time string" |
|
6850 |
||
6851 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6852 |
self |
3786 | 6853 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 6854 |
info:'Paste Date and Time' |
3595 | 6855 |
! |
6856 |
||
2676 | 6857 |
insertFile |
3160 | 6858 |
"insert contents of a file |
2676 | 6859 |
- ask user for filename using a fileSelectionBox." |
6860 |
||
3731 | 6861 |
self insertFileAsStringLiteral:false |
6862 |
! |
|
6863 |
||
6864 |
insertFileAsStringLiteral |
|
6865 |
"insert a file's contents as a string literal. |
|
6866 |
Almost the same as the insert file, but single-quotes are doubled, |
|
6867 |
to make it a legal string literal" |
|
6868 |
||
6869 |
self insertFileAsStringLiteral:true |
|
6870 |
! |
|
6871 |
||
6872 |
insertFileAsStringLiteral:asStringLiteral |
|
6873 |
"insert contents of a file; either as-is or as a string literal. |
|
6874 |
- ask user for filename using a fileSelectionBox." |
|
6875 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6876 |
|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
|
6877 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6878 |
((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
|
6879 |
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
|
6880 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
6881 |
ifTrue:[ |
3731 | 6882 |
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
|
6883 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6884 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6885 |
[ |
3731 | 6886 |
|why| |
6887 |
||
6888 |
file := Dialog |
|
6889 |
requestFileName:(resources string:'Insert Contents Of:') |
|
6890 |
default:initial |
|
6891 |
ok:(resources string:'Insert') |
|
6892 |
abort:(resources string:'Cancel') |
|
6893 |
pattern:nil |
|
6894 |
fromDirectory:directoryForFileDialog. |
|
6895 |
file isNil ifTrue:[ |
|
6896 |
"cancel" |
|
6897 |
^ self. |
|
6898 |
]. |
|
6899 |
file := file asFilename. |
|
6900 |
directoryForFileDialog := file. |
|
6901 |
||
6902 |
ok := file isReadable and:[file isDirectory not]. |
|
6903 |
ok ifFalse:[ |
|
6904 |
file isReadable ifFalse:[ |
|
6905 |
why := '%1 is unreadable.\\Please try again.' |
|
6906 |
] ifTrue:[ |
|
6907 |
why := '%1 is a directory.\\Please try again.' |
|
6908 |
]. |
|
6909 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
6910 |
]. |
|
2909 | 6911 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
6912 |
|
5063 | 6913 |
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
|
6914 |
self |
3786 | 6915 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 6916 |
info:'Paste File' |
3495 | 6917 |
|
6918 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
6919 |
! |
|
6920 |
||
3811 | 6921 |
insertURL |
6922 |
"insert contents of a URL |
|
6923 |
- ask user for URL using a dialog." |
|
6924 |
||
6925 |
self insertURLAsStringLiteral:false |
|
6926 |
! |
|
6927 |
||
6928 |
insertURLAsStringLiteral:asStringLiteral |
|
6929 |
"insert contents of a file; either as-is or as a string literal. |
|
6930 |
- ask user for filename using a fileSelectionBox." |
|
6931 |
||
6932 |
|sel url text response initial| |
|
6933 |
||
6934 |
(sel := self selectionAsString) notEmptyOrNil |
|
6935 |
ifTrue:[ |
|
6936 |
initial := sel. |
|
6937 |
]. |
|
6938 |
||
6939 |
url := Dialog |
|
6940 |
request:(resources string:'Insert Contents of URL:') |
|
6941 |
initialAnswer:initial |
|
6942 |
okLabel:(resources string:'Insert') |
|
6943 |
title:(resources string:'URL'). |
|
6944 |
url isNil ifTrue:[ |
|
6945 |
"cancel" |
|
6946 |
^ self. |
|
6947 |
]. |
|
6948 |
response := HTTPInterface get:url. |
|
6949 |
response isErrorResponse ifTrue:[ |
|
6950 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
6951 |
^ self. |
|
6952 |
]. |
|
6953 |
text := response data asString. |
|
6954 |
||
6955 |
self |
|
6956 |
undoableDo:[ |
|
6957 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
6958 |
] |
|
6959 |
info:'Insert Contents of URL' |
|
6960 |
! |
|
6961 |
||
3495 | 6962 |
insertUUID |
6963 |
"insert a new UUID's string" |
|
6964 |
||
6965 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6966 |
self |
3786 | 6967 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 6968 |
info:'Paste New UUID' |
3495 | 6969 |
|
6970 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 6971 |
! |
6972 |
||
4940 | 6973 |
insertUnicode |
6974 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
6975 |
||
6976 |
|unicodePoint unicodeChar unicodeString| |
|
6977 |
||
6978 |
unicodeString := Dialog request:'Enter unicode (U+01FF or decimal number):'. |
|
6979 |
unicodeString size < 2 ifTrue:[ |
|
6980 |
^ self. |
|
6981 |
]. |
|
6982 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
6983 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
|
6984 |
] ifFalse:[ |
|
6985 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
|
6986 |
]. |
|
6987 |
||
6988 |
unicodeChar := Character value:unicodePoint. |
|
6989 |
self keyPress:unicodeChar x:0 y:0. |
|
6990 |
self keyRelease:unicodeChar x:0 y:0. |
|
6991 |
! |
|
6992 |
||
5331 | 6993 |
inspectSelectedString |
6994 |
"inspect the selected text" |
|
6995 |
||
6996 |
self selectionAsString inspect. |
|
6997 |
! |
|
6998 |
||
4742 | 6999 |
internalSpellingSuggestion |
7000 |
"insert the internal-spelling suggestion for the selected text. |
|
7001 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7002 |
||
7003 |
|text suggestions best| |
|
7004 |
||
7005 |
self withWaitCursorDo:[ |
|
7006 |
text := self selection asString string withoutSeparators. |
|
7007 |
text size == 0 ifTrue:[^ self]. |
|
7008 |
||
7009 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7010 |
suggestions size == 0 ifTrue:[ |
|
7011 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7012 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7013 |
^ self. |
|
7014 |
]. |
|
7015 |
Transcript showCR:suggestions. |
|
7016 |
best := suggestions first. |
|
7017 |
]. |
|
7018 |
self |
|
7019 |
undoablePaste:best |
|
7020 |
info:'Spelling Suggestion'. |
|
7021 |
! |
|
7022 |
||
4884 | 7023 |
openFileBrowserOnFileNamed:fileNameString |
7024 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 7025 |
|
4630 | 7026 |
|fn| |
2762 | 7027 |
|
4884 | 7028 |
fn := fileNameString asFilename. |
2762 | 7029 |
fn exists ifFalse:[ |
4884 | 7030 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 7031 |
fn exists ifFalse:[ |
5082 | 7032 |
^ self warn:(resources |
7033 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
7034 |
with:fn baseName allBold |
|
7035 |
with:fn directory baseName allBold). |
|
4042 | 7036 |
]. |
2762 | 7037 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7038 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7039 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7040 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 7041 |
! |
7042 |
||
4884 | 7043 |
openFileBrowserOnIt |
7044 |
"open a fileBrowser on the selected fileName" |
|
7045 |
||
7046 |
|fileNameString| |
|
7047 |
||
7048 |
fileNameString := self selectionAsString. |
|
7049 |
self openFileBrowserOnFileNamed:fileNameString |
|
7050 |
||
7051 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
7052 |
! |
|
7053 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7054 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7055 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7056 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7057 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7058 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7059 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7060 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7061 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7062 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7063 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7064 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7065 |
paste |
1289 | 7066 |
"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
|
7067 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7068 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7069 |
self checkModificationsAllowed ifTrue:[ |
4823 | 7070 |
self withSelfAndTextForPasteDo:[:me :text | |
7071 |
me unselect. |
|
7072 |
me undoablePaste:text |
|
7073 |
] |
|
2952 | 7074 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7075 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7076 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7077 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7078 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7079 |
|
3825 | 7080 |
self paste:someText withCR:false |
7081 |
! |
|
7082 |
||
7083 |
paste:someText withCR:withCR |
|
7084 |
"paste someText at cursor" |
|
7085 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7086 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7087 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7088 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7089 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7090 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7091 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7092 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7093 |
CharacterEncoderError handle:[:ex | |
3825 | 7094 |
|code msg| |
7095 |
||
7096 |
code := ex parameter. |
|
7097 |
codingErrorReported ifFalse:[ |
|
4940 | 7098 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 7099 |
code notNil ifTrue:[ |
7100 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7101 |
]. |
|
7102 |
Dialog warn:(resources stringWithCRs:msg). |
|
7103 |
codingErrorReported := true. |
|
7104 |
]. |
|
7105 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7106 |
] do:[ |
3825 | 7107 |
s isString ifTrue:[ |
4940 | 7108 |
s encoding ~~ gc characterEncoding ifTrue:[ |
7109 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 7110 |
]. |
7111 |
||
7112 |
s := s asStringCollection. |
|
7113 |
(someText endsWith:Character cr) ifTrue:[ |
|
7114 |
"/ s := s copyWith:nil. |
|
7115 |
s := s copyWith:'' "/ an empty line at the end |
|
7116 |
||
7117 |
] |
|
7118 |
] ifFalse:[ |
|
7119 |
s isStringCollection ifTrue:[ |
|
4940 | 7120 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 7121 |
] ifFalse:[ |
7122 |
(self |
|
7123 |
confirm:(resources |
|
7124 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7125 |
with:s class name)) ifFalse:[^ self]. |
|
7126 |
s := StringCollection with:s storeString . |
|
7127 |
"/ ^ self |
|
7128 |
]. |
|
7129 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7130 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7131 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7132 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7133 |
(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
|
7134 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7135 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7136 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7137 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7138 |
startCol := c1 := cursorCol. |
3180 | 7139 |
|
5194 | 7140 |
"do not autoindent here. |
7141 |
It does make things very ugly, in the inspector |
|
7142 |
(try inspecting a multiline string)..." |
|
7143 |
self withAutoIndent:false do:[ |
|
7144 |
"do not expand tabs into spaces here - |
|
7145 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7146 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7147 |
||
7148 |
self insertLines:s withCR:withCR. |
|
7149 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7150 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7151 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7152 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7153 |
typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine: |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7154 |
"/ For Claus to support paste-cursordown-paste :-) |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7155 |
"/ Move cursor the the beggining of the selection so subsequent |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7156 |
"/ cursor move will start there. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7157 |
self setCursorLine: l1. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7158 |
self setCursorCol: c1. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7159 |
|
4328 | 7160 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7161 |
"Modified: / 25-01-2012 / 00:31:30 / cg" |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7162 |
"Modified: / 30-08-2013 / 00:09:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7163 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7164 |
|
3731 | 7165 |
pasteAsStringLiteral |
7166 |
"insert clipboard string as a string literal. |
|
7167 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7168 |
to make it a legal string literal" |
|
7169 |
||
7170 |
typeOfSelection := nil. |
|
7171 |
self |
|
5107 | 7172 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 7173 |
info:'Paste as String Literal' |
3731 | 7174 |
! |
7175 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7176 |
pasteOrReplace |
1289 | 7177 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7178 |
otherwise paste at cursor position. |
7179 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7180 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7181 |
|
2724 | 7182 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7183 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7184 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7185 |
pasteOrReplace:someText |
1289 | 7186 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7187 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7188 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7189 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7190 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7191 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7192 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7193 |
self undoableDo:[ |
4823 | 7194 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7195 |
self replace:someText |
|
7196 |
] ifFalse:[ |
|
7197 |
self paste:someText. |
|
7198 |
] |
|
3542 | 7199 |
] info:'Paste/Replace'. |
1289 | 7200 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7201 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7202 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7203 |
|
5387 | 7204 |
pasteOrReplaceByKeyPress |
7205 |
"paste a previous item from the copybuffer history. |
|
7206 |
(i.e. repaste some previously deleted or copied text)" |
|
7207 |
||
7208 |
|text| |
|
7209 |
||
7210 |
self checkModificationsAllowed ifFalse:[ |
|
7211 |
self flashReadOnly. |
|
7212 |
^ self |
|
7213 |
]. |
|
7214 |
text := self getClipboardText:#clipboard. |
|
7215 |
text notNil ifTrue:[ |
|
7216 |
self pasteOrReplace:text |
|
7217 |
] |
|
7218 |
! |
|
7219 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7220 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7221 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7222 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7223 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7224 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7225 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7226 |
self checkModificationsAllowed ifFalse:[ |
4988 | 7227 |
self flashReadOnly. |
4823 | 7228 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7229 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7230 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7231 |
text notNil ifTrue:[ |
4823 | 7232 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7233 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7234 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7235 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7236 |
replace |
1289 | 7237 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7238 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7239 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7240 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7241 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7242 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 7243 |
me undoableDo:[ me replace:text ] |
7244 |
info:'Replace' |
|
2952 | 7245 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7246 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7247 |
|
121 | 7248 |
replace:someText |
1289 | 7249 |
"replace the selection by someText" |
121 | 7250 |
|
3160 | 7251 |
|selected selectedString |
7252 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7253 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7254 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7255 |
|
3130 | 7256 |
self undoableDo:[ |
4010 | 7257 |
selected := self selection. |
7258 |
selected isNil ifTrue:[ |
|
7259 |
^ self paste:someText |
|
7260 |
]. |
|
7261 |
||
7262 |
self deleteSelection. |
|
7263 |
||
7264 |
"take care, if we replace a selection without space by a word selected |
|
7265 |
with one - in this case we usually do not want the space. |
|
7266 |
But, if we replace a word-selected selection by something without a |
|
7267 |
space, we DO want the space added." |
|
7268 |
||
7269 |
selected size == 1 ifTrue:[ |
|
7270 |
selectedString := selected at:1. |
|
7271 |
]. |
|
7272 |
||
7273 |
someText size == 1 ifTrue:[ |
|
7274 |
|cutOffSpace addSpace replacement replacementString| |
|
7275 |
||
7276 |
cutOffSpace := false. |
|
7277 |
addSpace := false. |
|
7278 |
replacement := someText copyFrom:1. |
|
7279 |
||
7280 |
selectedString notNil ifTrue:[ |
|
7281 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7282 |
"selection has no space" |
|
7283 |
||
7284 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7285 |
cutOffSpace := true |
|
7286 |
] |
|
7287 |
] ifTrue:[ |
|
7288 |
addSpace := true |
|
7289 |
] |
|
7290 |
]. |
|
7291 |
replacementString := replacement at:1. |
|
7292 |
cutOffSpace ifTrue:[ |
|
7293 |
(replacementString startsWith:' ') ifTrue:[ |
|
7294 |
replacementString := replacementString withoutSpaces |
|
7295 |
]. |
|
7296 |
] ifFalse:[ |
|
7297 |
selectStyle == #wordLeft ifTrue:[ |
|
7298 |
"want a space at left" |
|
7299 |
(replacementString startsWith:' ') ifFalse:[ |
|
7300 |
replacementString := replacementString withoutSpaces. |
|
7301 |
replacementString := ' ' , replacementString |
|
7302 |
] |
|
7303 |
]. |
|
7304 |
selectStyle == #wordRight ifTrue:[ |
|
7305 |
"want a space at right" |
|
7306 |
||
7307 |
(replacementString endsWith:' ') ifFalse:[ |
|
7308 |
replacementString := replacementString withoutSpaces. |
|
7309 |
replacementString := replacementString , ' ' |
|
7310 |
] |
|
7311 |
]. |
|
7312 |
]. |
|
7313 |
replacement at:1 put: replacementString. |
|
7314 |
self paste:replacement. |
|
7315 |
] ifFalse:[ |
|
7316 |
self paste:someText |
|
7317 |
]. |
|
4053 | 7318 |
self setLastStringToReplace: selectedString. |
7319 |
||
4048 | 7320 |
lastReplacementInfo lastReplacement: someText. |
4010 | 7321 |
|
7322 |
selStartLine := selectionStartLine. |
|
7323 |
selStartCol := self selectionStartCol. |
|
7324 |
selEndLine := selectionEndLine. |
|
7325 |
selEndCol := self selectionEndCol. |
|
3130 | 7326 |
] |
3542 | 7327 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7328 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7329 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7330 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7331 |
! |
7332 |
||
3430 | 7333 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7334 |
"search for a string - show a box to enter searchpattern |
3430 | 7335 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7336 |
- 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
|
7337 |
|
3430 | 7338 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7339 |
||
7340 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7341 |
lastSearchDirection := #forward. |
|
7342 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7343 |
caseHolder := ValueHolder with:ign. |
7344 |
patternHolder := ValueHolder with:''. |
|
7345 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7346 |
lastSearchPattern notNil ifTrue:[ |
4823 | 7347 |
initialString := lastSearchPattern |
3430 | 7348 |
]. |
7349 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 7350 |
initialString := self selectionAsString |
3430 | 7351 |
]. |
7352 |
initialString isNil ifTrue:[ |
|
4823 | 7353 |
LastSearchPatterns size > 0 ifTrue:[ |
7354 |
initialString := LastSearchPatterns first |
|
7355 |
] |
|
3430 | 7356 |
]. |
7357 |
initialString notNil ifTrue:[ |
|
4823 | 7358 |
patternHolder value:initialString. |
7359 |
replacePatternHolder value:initialString. |
|
3430 | 7360 |
]. |
7361 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7362 |
search := [:fwd | |
4823 | 7363 |
self |
7364 |
search:patternHolder value |
|
7365 |
ignoreCase:caseHolder value |
|
7366 |
forward:fwd. |
|
7367 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7368 |
replace := [:all | |
4823 | 7369 |
self |
7370 |
replace:patternHolder value |
|
7371 |
by:replacePatternHolder value |
|
7372 |
all:all |
|
7373 |
ignoreCase:caseHolder value |
|
7374 |
]. |
|
3430 | 7375 |
bindings := IdentityDictionary new. |
7376 |
bindings at:#searchPattern put:patternHolder. |
|
7377 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7378 |
modal ifTrue:[ |
|
4823 | 7379 |
bindings at:#nextAction |
7380 |
put:[ |
|
7381 |
flag := true. |
|
7382 |
action := search. |
|
7383 |
searchBox doAccept. |
|
7384 |
]. |
|
7385 |
bindings at:#prevAction |
|
7386 |
put:[ |
|
7387 |
flag := false. |
|
7388 |
action := search. |
|
7389 |
searchBox doAccept. |
|
7390 |
]. |
|
7391 |
bindings at:#replaceAction |
|
7392 |
put:[ |
|
7393 |
flag := false. |
|
7394 |
action := replace. |
|
7395 |
searchBox doAccept. |
|
7396 |
]. |
|
7397 |
bindings at:#replaceAllAction |
|
7398 |
put:[ |
|
7399 |
flag := true. |
|
7400 |
action := replace. |
|
7401 |
searchBox doAccept. |
|
7402 |
]. |
|
3430 | 7403 |
] ifFalse:[ |
4823 | 7404 |
bindings at:#nextAction put:[ search value:true. ]. |
7405 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7406 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7407 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7408 |
]. |
7409 |
bindings at:#ignoreCase put:caseHolder. |
|
7410 |
bindings at:#patternList put:LastSearchPatterns. |
|
7411 |
modal ifTrue:[ |
|
4823 | 7412 |
searchBox := SimpleDialog new. |
3430 | 7413 |
] ifFalse:[ |
4823 | 7414 |
searchBox := ApplicationModel new. |
7415 |
searchBox createBuilder. |
|
3430 | 7416 |
]. |
7417 |
searchBox resources:(self resources). |
|
7418 |
bldr := searchBox builder. |
|
7419 |
bldr addBindings:bindings. |
|
7420 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7421 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7422 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7423 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7424 |
modal ifTrue:[ |
|
4823 | 7425 |
searchBox openDialog. |
7426 |
searchBox accepted ifTrue:[ |
|
7427 |
action value:flag |
|
7428 |
]. |
|
3430 | 7429 |
] ifFalse:[ |
4823 | 7430 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7431 |
(bldr componentAt:#cancelButton) |
|
7432 |
label:(resources string:'Close'); |
|
7433 |
action:[ searchBox closeRequest ]. |
|
7434 |
||
7435 |
"/ searchBox masterApplication:self application. |
|
7436 |
||
7437 |
self topView beMaster. |
|
7438 |
(searchBox window) |
|
7439 |
beSlave; |
|
7440 |
openInGroup:(self windowGroup). |
|
7441 |
||
7442 |
"/ searchBox window open. |
|
7443 |
||
5283 | 7444 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
3430 | 7445 |
] |
7446 |
||
7447 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7448 |
! |
|
7449 |
||
121 | 7450 |
showDeleted |
7451 |
"open a readonly editor on all deleted text" |
|
7452 |
||
7453 |
|v| |
|
7454 |
||
7455 |
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
|
7456 |
v readOnly:true. |
121 | 7457 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7458 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7459 |
|
3221 | 7460 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7461 |
"sort/reorder the selected lines. |
7462 |
how: |
|
7463 |
#lines |
|
7464 |
#linesByFirstWord |
|
7465 |
#linesByNthWord |
|
7466 |
#linesByNthNumber |
|
7467 |
#linesByNthHexNumber |
|
7468 |
#words |
|
7469 |
#linesByLength |
|
7470 |
#reverse |
|
7471 |
" |
|
7472 |
||
7473 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7474 |
|
7475 |
lineWise := true. |
|
7476 |
||
4763 | 7477 |
how == #reverse ifTrue:[ |
7478 |
operation := [:lines | lines reverse]. |
|
7479 |
] ifFalse:[ |
|
7480 |
operation := [:linesOrWords | |
|
7481 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7482 |
]. |
|
7483 |
||
7484 |
how == #linesByLength ifTrue:[ |
|
7485 |
fetcher := [:l | l size]. |
|
7486 |
] ifFalse:[ |
|
7487 |
how == #lines ifTrue:[ |
|
7488 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7489 |
] ifFalse:[ |
|
7490 |
how == #linesByFirstWord ifTrue:[ |
|
7491 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7492 |
] ifFalse:[ |
|
7493 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7494 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7495 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7496 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7497 |
LastColumnNumberForSort := n. |
|
7498 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7499 |
how == #linesByNthNumber ifTrue:[ |
|
7500 |
innerExtractor := extractor. |
|
7501 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7502 |
] ifFalse:[ |
|
7503 |
how == #linesByNthHexNumber ifTrue:[ |
|
7504 |
innerExtractor := extractor. |
|
7505 |
extractor := [:l | |
|
7506 |
|s| |
|
7507 |
s := innerExtractor value:l. |
|
7508 |
(s startsWith:'16r') ifTrue:[ |
|
7509 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7510 |
] ifFalse:[ |
|
7511 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7512 |
] |
|
7513 |
] |
|
4753 | 7514 |
] |
4763 | 7515 |
]. |
7516 |
] ifFalse:[ |
|
7517 |
how == #words ifTrue:[ |
|
7518 |
lineWise := false. |
|
7519 |
extractor := [:w | w]. |
|
7520 |
] ifFalse:[ |
|
7521 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7522 |
] |
4373 | 7523 |
] |
7524 |
] |
|
4763 | 7525 |
]. |
7526 |
ignoreCase ifTrue:[ |
|
7527 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7528 |
] ifFalse:[ |
|
7529 |
fetcher := extractor. |
|
7530 |
]. |
|
7531 |
]. |
|
3221 | 7532 |
]. |
7533 |
||
7534 |
lineWise ifTrue:[ |
|
4763 | 7535 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7536 |
start == end ifTrue:[^ self ]. |
7537 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7538 |
lines := operation value:lines. |
4373 | 7539 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7540 |
] ifFalse:[ |
7541 |
"process the whole selection as a string" |
|
7542 |
s := self selectionAsString. |
|
7543 |
words := s asCollectionOfWords. |
|
7544 |
words := operation value:words. |
|
7545 |
s := words asStringCollection asStringWith:Character space. |
|
7546 |
self replace:s. |
|
7547 |
]. |
|
3221 | 7548 |
self textChanged. |
4373 | 7549 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7550 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7551 |
! |
7552 |
||
7553 |
sortSelection:how ignoreCase:ignoreCase |
|
7554 |
"sort the selected lines" |
|
7555 |
||
7556 |
|start end| |
|
7557 |
||
7558 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7559 |
||
7560 |
start := selectionStartLine. |
|
7561 |
end := selectionEndLine. |
|
7562 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7563 |
end := end - 1 |
3221 | 7564 |
]. |
7565 |
||
7566 |
self |
|
4373 | 7567 |
undoableDo:[ |
7568 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7569 |
] |
|
3786 | 7570 |
info:'Sort' |
4373 | 7571 |
|
7572 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7573 |
! |
7574 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7575 |
specialCharacters |
2915 | 7576 |
CharacterSetView |
4823 | 7577 |
openAsInputFor:self |
7578 |
label:'Special Character Input' |
|
7579 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7580 |
! |
7581 |
||
5370 | 7582 |
splitLinesAtCharacterOrString |
7583 |
"ask user for the character and split after it" |
|
7584 |
||
7585 |
|sel in out separator record| |
|
7586 |
||
7587 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7588 |
||
7589 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7590 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7591 |
||
7592 |
sel := self selectionAsString. |
|
7593 |
in := sel readStream. |
|
7594 |
out := CharacterWriteStream on:(String new). |
|
7595 |
[in atEnd] whileFalse:[ |
|
7596 |
record := in throughAll:separator. |
|
7597 |
out nextPutLine:record. |
|
7598 |
]. |
|
7599 |
self |
|
7600 |
undoableDo:[ |
|
7601 |
self replaceSelectionBy:(out contents). |
|
7602 |
] |
|
7603 |
info:'Split Selection' |
|
7604 |
! |
|
7605 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7606 |
undoablePaste:someText |
3495 | 7607 |
self undoablePaste:someText info:nil. |
7608 |
||
7609 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7610 |
! |
|
7611 |
||
7612 |
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
|
7613 |
self |
4823 | 7614 |
undoableDo:[ |
7615 |
self paste:someText. |
|
7616 |
] |
|
7617 |
info:infoOrNil |
|
3495 | 7618 |
|
7619 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7620 |
! |
|
7621 |
||
7622 |
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
|
7623 |
self |
4823 | 7624 |
undoableDo:[ |
7625 |
self pasteOrReplace:someText. |
|
7626 |
] |
|
7627 |
info:infoOrNil |
|
3495 | 7628 |
|
7629 |
"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
|
7630 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7631 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7632 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7633 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7634 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7635 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7636 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7637 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7638 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7639 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7640 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7641 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7642 |
|
2724 | 7643 |
withSelfAndTextForPasteDo:aBlock |
7644 |
"common code for paste/replace of the copybuffer" |
|
7645 |
||
7646 |
|sel| |
|
7647 |
||
7648 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7649 |
self flashReadOnly. |
4823 | 7650 |
^ self |
2724 | 7651 |
]. |
7652 |
||
7653 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7654 |
sel notNil ifTrue:[ |
|
4823 | 7655 |
aBlock value:self value:sel. |
2724 | 7656 |
] |
105 | 7657 |
! ! |
7658 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7659 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7660 |
|
3880 | 7661 |
beep |
5244 | 7662 |
"output an audible beep or bell on my screen device" |
7663 |
||
3880 | 7664 |
UserPreferences current beepInEditor ifTrue:[ |
7665 |
super beep |
|
7666 |
] |
|
7667 |
! |
|
7668 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7669 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7670 |
"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
|
7671 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7672 |
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
|
7673 |
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
|
7674 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7675 |
self isReadOnly ifTrue: [ |
4823 | 7676 |
exceptionBlock isNil ifTrue:[ |
7677 |
^ false |
|
7678 |
]. |
|
7679 |
||
7680 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7681 |
^ false |
|
7682 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7683 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7684 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7685 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7686 |
"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
|
7687 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7688 |
|
2596 | 7689 |
currentSelectionBgColor |
7690 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7691 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 7692 |
]. |
5216 | 7693 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 7694 |
^ super currentSelectionBgColor |
7695 |
||
7696 |
" |
|
7697 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
7698 |
" |
|
7699 |
! |
|
7700 |
||
7701 |
currentSelectionFgColor |
|
7702 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 7703 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 7704 |
]. |
7705 |
^ super currentSelectionFgColor |
|
7706 |
! |
|
7707 |
||
3996 | 7708 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7709 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 7710 |
|
7711 |
super resetVariablesBeforeNewSearch. |
|
7712 |
||
7713 |
"/ new search invalidates remembered string |
|
4048 | 7714 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7715 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
7716 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 7717 |
! |
7718 |
||
4053 | 7719 |
setLastStringToReplace: aString |
7720 |
||
7721 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
7722 |
||
7723 |
|lastReplaceIgnoredCase| |
|
7724 |
||
4064 | 7725 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
7726 |
self clearSearchAction. |
|
7727 |
||
4053 | 7728 |
lastReplacementInfo lastStringToReplace: aString. |
7729 |
lastStringFromReplaceForNextSearch := aString. |
|
7730 |
||
7731 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 7732 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
7733 |
ifTrue: [lastSearchIgnoredCase] |
|
7734 |
ifFalse: [nil]. |
|
4053 | 7735 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
7736 |
! |
|
7737 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7738 |
st80EditMode |
5255 | 7739 |
"If on, the cursor wraps at the line end (like in vi or st80); |
7740 |
if off, we have the Rand-editor behavior (random access)" |
|
7741 |
||
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7742 |
^ st80Mode ? (UserPreferences current st80EditMode) |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7743 |
! |
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
7744 |
|
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7745 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7746 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7747 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7748 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7749 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
7750 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7751 |
textChanged |
522 | 7752 |
"my text was modified (internally). |
7753 |
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
|
7754 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 7755 |
is used to notify scrollers, other views etc.). |
7756 |
||
7757 |
As some authors of this code have been very sloppy in tha past |
|
7758 |
(not sending contentsChanged, but textChanged), |
|
7759 |
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
|
7760 |
|
641 | 7761 |
self contentsChanged. |
1015 | 7762 |
self modified:true. |
5774 | 7763 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7764 |
contentsWasSaved := false |
641 | 7765 |
|
1015 | 7766 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 7767 |
! |
7768 |
||
2617 | 7769 |
textChangedButNoSizeChange |
2207 | 7770 |
"my text was modified (internally). |
7771 |
Sent whenever text has been edited (not to confuse with |
|
7772 |
contentsChanged, which is triggered when the size has changed, and |
|
7773 |
is used to notify scrollers, other views etc.)" |
|
7774 |
||
7775 |
self modified:true. |
|
7776 |
contentsWasSaved := false |
|
7777 |
||
7778 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7779 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7780 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7781 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7782 |
|
5216 | 7783 |
canAccept |
7784 |
"true if text can be accepts. |
|
7785 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7786 |
||
7787 |
^ acceptEnabled ~~ false |
|
7788 |
! |
|
7789 |
||
7790 |
canCut |
|
7791 |
"true if there is a selection possibly to be cut. |
|
7792 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
7793 |
||
7794 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7795 |
^ self hasSelection |
|
7796 |
! |
|
7797 |
||
7798 |
canDoAgain |
|
7799 |
"true if there is a possible repeat last edit operation. |
|
7800 |
Used to disable the menu if there is nothing" |
|
7801 |
||
7802 |
|lastStringToReplace| |
|
7803 |
||
7804 |
self isReadOnly ifTrue:[ ^ false ]. |
|
7805 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
7806 |
^ lastStringToReplace notNil |
|
7807 |
! |
|
7808 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7809 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7810 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7811 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7812 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7813 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7814 |
"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
|
7815 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
7816 |
|
4064 | 7817 |
hasSearchActionSelection |
7818 |
||
7819 |
^ typeOfSelection == #searchAction |
|
7820 |
! |
|
7821 |
||
1878 | 7822 |
isKeyboardConsumer |
7823 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 7824 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 7825 |
|
3476 | 7826 |
^ self isReadOnly not |
1878 | 7827 |
! |
7828 |
||
997 | 7829 |
specClass |
1390 | 7830 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
7831 |
||
997 | 7832 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 7833 |
^ super specClass |
7834 |
||
1390 | 7835 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 7836 |
! |
7837 |
||
324 | 7838 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
7839 |
"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
|
7840 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7841 |
"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
|
7842 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7843 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 7844 |
|
7845 |
"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
|
7846 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
7847 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7848 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7849 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7850 |
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
|
7851 |
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
|
7852 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7853 |
|
697 | 7854 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7855 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7856 |
w := super widthOfContents. |
5643 | 7857 |
(dev := device ) isNil ifTrue:[ |
4889 | 7858 |
"/ really don't know ... |
4823 | 7859 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
7860 |
]. |
4889 | 7861 |
^ w + (gc font widthOn:dev) |
697 | 7862 |
|
7863 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7864 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7865 |
|
1588 | 7866 |
!EditTextView methodsFor:'realization'! |
7867 |
||
7868 |
realize |
|
7869 |
"make the view visible - scroll to make the cursor visible." |
|
7870 |
||
7871 |
super realize. |
|
7872 |
||
7873 |
self makeCursorVisible. |
|
5643 | 7874 |
cursorFgColor := cursorFgColor onDevice:device. |
7875 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 7876 |
|
7877 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
7878 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
7879 |
! ! |
|
7880 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7881 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7882 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7883 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7884 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7885 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7886 |
cursorShown ifTrue:[ |
4823 | 7887 |
cursorVisibleLine notNil ifTrue:[ |
7888 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
7889 |
self drawCursorCharacter |
|
7890 |
] |
|
7891 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7892 |
] |
105 | 7893 |
! |
7894 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7895 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7896 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7897 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7898 |
cursorShown ifTrue:[ |
4823 | 7899 |
(visLine == cursorVisibleLine) ifTrue:[ |
7900 |
self drawCursorCharacter |
|
7901 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7902 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7903 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7904 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7905 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7906 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7907 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7908 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7909 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7910 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7911 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7912 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7913 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7914 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7915 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7916 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7917 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7918 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7919 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7920 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7921 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7922 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7923 |
cursorShown ifTrue:[ |
4823 | 7924 |
(visLine == cursorVisibleLine) ifTrue:[ |
7925 |
(colNr == cursorCol) ifTrue:[ |
|
7926 |
self drawCursorCharacter. |
|
7927 |
^ self |
|
7928 |
] |
|
7929 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7930 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7931 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
7932 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7933 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7934 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7935 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7936 |
"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
|
7937 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7938 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 7939 |
cursorShown ifTrue:[ |
7940 |
self redrawCursorIfInVisibleLine:visLine |
|
7941 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7942 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7943 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7944 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7945 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7946 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7947 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7948 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7949 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7950 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7951 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7952 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7953 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7954 |
"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
|
7955 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7956 |
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
|
7957 |
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
|
7958 |
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
|
7959 |
|
4889 | 7960 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7961 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
7962 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7963 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7964 |
"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
|
7965 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7966 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7967 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7968 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7969 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7970 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7971 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7972 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7973 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7974 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7975 |
"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
|
7976 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7977 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7978 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7979 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7980 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7981 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7982 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7983 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7984 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7985 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7986 |
"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
|
7987 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7988 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7989 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7990 |
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
|
7991 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
7992 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7993 |
prevCursorState ifTrue:[ |
4823 | 7994 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7995 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7996 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
7997 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7998 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7999 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8000 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8001 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8002 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8003 |
prevCursorState := cursorShown. |
1601 | 8004 |
"/ cursorShown := false. |
1591 | 8005 |
cursorShown ifTrue:[ |
4823 | 8006 |
self hideCursor |
1591 | 8007 |
] |
8008 |
||
1601 | 8009 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8010 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8011 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8012 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8013 |
"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
|
8014 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8015 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8016 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8017 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8018 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8019 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8020 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8021 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8022 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8023 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8024 |
"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
|
8025 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8026 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8027 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8028 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8029 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8030 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8031 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8032 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8033 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8034 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8035 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8036 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8037 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8038 |
|
2822 | 8039 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8040 |
! |
8041 |
||
8042 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8043 |
"do a backward search" |
|
8044 |
||
8045 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8046 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8047 |
! |
8048 |
||
8049 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8050 |
"do a backward search" |
|
8051 |
||
8052 |
cursorLine isNil ifTrue:[^ self]. |
|
8053 |
||
3160 | 8054 |
self |
4119 | 8055 |
searchBackwardFor:pattern |
8056 |
ignoreCase:ign |
|
8057 |
startingAtLine:startLine col:startCol |
|
5717 | 8058 |
ifFound:[:line :col :endColOrNil | |
4119 | 8059 |
self cursorMovementAllowed ifTrue:[ |
8060 |
self cursorLine:line col:col. |
|
8061 |
]. |
|
5717 | 8062 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
1339 | 8063 |
"/ self makeLineVisible:cursorLine |
4119 | 8064 |
typeOfSelection := #search] |
8065 |
ifAbsent:aBlock |
|
1339 | 8066 |
|
8067 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8068 |
! |
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 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8071 |
"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
|
8072 |
|
2554 | 8073 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8074 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8075 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8076 |
searchForMatchingParenthesis |
3160 | 8077 |
"search for a matching parenthesis starting at cursor position. |
8078 |
Search for the corresponding character is done forward if its an opening, |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8079 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8080 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8081 |
|
2822 | 8082 |
self cursorMovementAllowed ifFalse:[^ self]. |
8083 |
||
3160 | 8084 |
self |
4823 | 8085 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8086 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8087 |
ifNotFound:[self showNotFound] |
|
8088 |
onError:[self beep] |
|
1339 | 8089 |
|
8090 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8091 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8092 |
|
3967 | 8093 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8094 |
"do a forward search" |
8095 |
||
8096 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 8097 |
self |
8098 |
searchForwardFor:pattern |
|
8099 |
ignoreCase:ign |
|
8100 |
match: match |
|
8101 |
startingAtLine:startLine col:startCol |
|
5717 | 8102 |
ifFound:[:line :col :endColOrNil| |
3967 | 8103 |
self cursorMovementAllowed ifTrue:[ |
8104 |
self cursorLine:line col:col. |
|
8105 |
]. |
|
5717 | 8106 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
1339 | 8107 |
"/ self makeLineVisible:cursorLine |
3967 | 8108 |
typeOfSelection := #search |
8109 |
] |
|
8110 |
ifAbsent:aBlock |
|
1339 | 8111 |
|
8112 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8113 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8114 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8115 |
|
3967 | 8116 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8117 |
"do a forward search" |
|
8118 |
||
8119 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8120 |
! |
|
8121 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8122 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8123 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8124 |
|
2822 | 8125 |
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
|
8126 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8127 |
|
3982 | 8128 |
searchPatternForSearchBar |
8129 |
||
8130 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8131 |
||
8132 |
|searchPattern| |
|
8133 |
||
4138 | 8134 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 8135 |
searchPattern isNil |
8136 |
ifTrue: [searchPattern := lastSearchPattern] |
|
8137 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
8138 |
^ searchPattern |
|
8139 |
! |
|
8140 |
||
3578 | 8141 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8142 |
"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
|
8143 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8144 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8145 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8146 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8147 |
"/ |
3967 | 8148 |
"/ 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
|
8149 |
"/ original string (for search after again) |
4121 | 8150 |
"/ 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
|
8151 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8152 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8153 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8154 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8155 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8156 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8157 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8158 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8159 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8160 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8161 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8162 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8163 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8164 |
"/ 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
|
8165 |
"/ if there was a previous search, only take the selection if |
3967 | 8166 |
"/ 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
|
8167 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8168 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8169 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8170 |
sel notNil ifTrue:[ |
3967 | 8171 |
(lastSearchPattern isNil |
4484 | 8172 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
8173 |
) ifTrue:[ |
|
3967 | 8174 |
self cursorLine:selectionStartLine col:selectionStartCol. |
8175 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8176 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8177 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8178 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8179 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8180 |
"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
|
8181 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8182 |
|
5717 | 8183 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8184 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8185 |
typeOfSelection := #search. |
8186 |
! |
|
8187 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8188 |
startPositionForSearchBackward |
2822 | 8189 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8190 |
! |
|
8191 |
||
8192 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8193 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8194 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8195 |
selectionStartLine notNil ifTrue:[ |
4823 | 8196 |
startLine := selectionStartLine. |
8197 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8198 |
] ifFalse:[ |
4823 | 8199 |
cursorLine isNil ifTrue:[ |
8200 |
startLine := list size. |
|
8201 |
startCol := self listAt:startLine size. |
|
8202 |
] ifFalse:[ |
|
8203 |
startLine := cursorLine min:list size. |
|
8204 |
startCol := cursorCol |
|
8205 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8206 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8207 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8208 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8209 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8210 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8211 |
startPositionForSearchForward |
2822 | 8212 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8213 |
! |
|
8214 |
||
8215 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8216 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8217 |
|
3160 | 8218 |
"/ 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
|
8219 |
"/ 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
|
8220 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8221 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8222 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8223 |
] ifFalse:[ |
4064 | 8224 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8225 |
startCol := 0 |
|
8226 |
]. |
|
8227 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8228 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8229 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8230 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8231 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8232 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8235 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8236 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8237 |
addToSelectionAfter:aBlock |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8238 |
"Extends the selection accroding to cursor position |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8239 |
after evaluation of `aBlock`. Used to implement |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8240 |
Shift-Up/Down/Left/Right, Shift-Home & Shift-End." |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8241 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8242 |
"/ Following comment is in czech and thus now very useful. |
4970 | 8243 |
"/ However I (JV) kept it here as this is one of the very |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8244 |
"/ first fix/hack we made to Smalltalk/X ages ago, if not |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8245 |
"/ the very first one. Actually, this method and comment was |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8246 |
"/ written by Martin Dvorak. Yeah, being bit nostalgic... |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8247 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8248 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8249 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8250 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8251 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8252 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8253 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8254 |
| startLine startCol endLine endCol curLine curCol cursorAtTheBeginning cursorAtTheEnd cursorWasShown flip extModeStandard | |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8255 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8256 |
curLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8257 |
curCol := cursorCol. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8258 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8259 |
self hasSelection ifTrue: [ |
4970 | 8260 |
startLine := selectionStartLine. |
8261 |
startCol := selectionStartCol. |
|
8262 |
endLine := selectionEndLine. |
|
8263 |
endCol := selectionEndCol. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8264 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8265 |
startLine := endLine := curLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8266 |
startCol := curCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8267 |
endCol := curCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8268 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8269 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8270 |
cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8271 |
cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8272 |
self assert: cursorAtTheBeginning | cursorAtTheEnd. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8273 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8274 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8275 |
cursorWasShown := self hideCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8276 |
aBlock value. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8277 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8278 |
cursorAtTheBeginning ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8279 |
(cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8280 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8281 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8282 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8283 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8284 |
flip := cursorLine == endLine and:[cursorCol > endCol]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8285 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8286 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8287 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8288 |
(cursorLine > endLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8289 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8290 |
startLine := endLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8291 |
startCol := endCol + 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8292 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8293 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8294 |
endCol := cursorCol - 1 |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8295 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8296 |
startLine := cursorLine. |
4823 | 8297 |
startCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8298 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8299 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8300 |
cursorAtTheEnd ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8301 |
(cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8302 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8303 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8304 |
]. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8305 |
flip := cursorLine == startLine and:[cursorCol < startCol]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8306 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8307 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8308 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8309 |
(cursorLine < startLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8310 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8311 |
endLine := startLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8312 |
endCol := startCol - 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8313 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8314 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8315 |
startCol := cursorCol |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8316 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8317 |
endLine := cursorLine. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8318 |
endCol := cursorCol - 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8319 |
] |
4823 | 8320 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8321 |
]. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8322 |
self selectFromLine:startLine col:startCol toLine: endLine col:endCol . |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8323 |
cursorWasShown ifTrue:[self showCursor]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8324 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8325 |
"Modified: / 27-03-2014 / 10:05:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4970 | 8326 |
"Modified (comment): / 25-03-2014 / 17:18:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8327 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8328 |
|
1850 | 8329 |
autoMoveCursorToEndOfSelection |
8330 |
"return true, if the cursor should be automatically moved to the |
|
8331 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8332 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8333 |
not be affected by selecting" |
8334 |
||
8335 |
^ true |
|
8336 |
! |
|
8337 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8338 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8339 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 8340 |
typeOfSelection := newType. |
8341 |
selectionStartLine notNil ifTrue:[ |
|
8342 |
self |
|
8343 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8344 |
toLine:selectionEndLine col:selectionEndCol |
|
8345 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8346 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8347 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8348 |
|
4707 | 8349 |
findNextWordAfterSelectionAndAddToSelection |
8350 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8351 |
||
8352 |
selectionStartCol isNil ifTrue:[ |
|
8353 |
self selectWordUnderCursor. |
|
8354 |
^ self |
|
8355 |
]. |
|
8356 |
||
8357 |
selStartCol := selectionStartCol. |
|
8358 |
selEndCol := selectionEndCol. |
|
8359 |
selStartLine := selectionStartLine. |
|
8360 |
selEndLine := selectionEndLine. |
|
8361 |
||
8362 |
self cursorToNextWord. |
|
8363 |
self selectWordUnderCursor. |
|
8364 |
||
8365 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8366 |
! |
|
8367 |
||
4138 | 8368 |
searchPatternFromUserSelectionOrReplace |
8369 |
||
8370 |
|sel searchPattern| |
|
8371 |
||
8372 |
"/ |
|
8373 |
"/ if the last operation was a replace, set pattern to last |
|
8374 |
"/ original string (for search after again) |
|
8375 |
"/ |
|
8376 |
(lastStringFromReplaceForNextSearch notNil |
|
8377 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
8378 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
8379 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8380 |
] ifFalse:[ |
|
8381 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8382 |
]. |
|
8383 |
^ searchPattern |
|
8384 |
]. |
|
8385 |
||
8386 |
"/ |
|
8387 |
"/ if there is a selection: |
|
8388 |
"/ if there was no previous search, take it as search pattern. |
|
8389 |
"/ if there was a previous search, only take the selection if |
|
8390 |
"/ it did not result from a paste. |
|
8391 |
"/ (to allow search-paste to be repeated) |
|
8392 |
"/ |
|
8393 |
sel := self selection. |
|
8394 |
sel notNil ifTrue:[ |
|
8395 |
typeOfSelection ~~ #search ifTrue:[ |
|
8396 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8397 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8398 |
searchPattern := sel asStringWithoutFinalCR. |
|
8399 |
] |
|
8400 |
]. |
|
8401 |
]. |
|
8402 |
||
8403 |
^ searchPattern |
|
8404 |
! |
|
8405 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8406 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8407 |
"select the whole text. |
5593 | 8408 |
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
|
8409 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8410 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8411 |
list isNil ifTrue:[ |
4823 | 8412 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8413 |
] ifFalse:[ |
4823 | 8414 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8415 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8416 |
] |
1082 | 8417 |
|
8418 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8419 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8420 |
|
4117 | 8421 |
selectAllInitially |
8422 |
"select the whole text. This is called only once during the initialization |
|
8423 |
for editFields which are shown in a table or tree. |
|
8424 |
The selectAll is called via this method to allow for easier redefinition and |
|
8425 |
to distinguish auto-select from user-initiated selects." |
|
8426 |
||
8427 |
self selectAll |
|
8428 |
! |
|
8429 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8430 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8431 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8432 |
|
3160 | 8433 |
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
|
8434 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8435 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8436 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8437 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8438 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8439 |
cursorCol > 1 ifTrue:[ |
4823 | 8440 |
self selectFromLine:cursorLine col:1 |
8441 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8442 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8443 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8444 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8445 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8446 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8447 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8448 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8449 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8450 |
selectionStartLine isNil ifTrue:[ |
4823 | 8451 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8452 |
] ifFalse:[ |
4823 | 8453 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8454 |
toLine:cursorLine+1 col:0. |
|
8455 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8456 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8457 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8458 |
|
4257 | 8459 |
selectFromBeginOfLine |
8460 |
"select the text from the beginning of the current line to the current cursor position." |
|
8461 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8462 |
| newCursorCol ln | |
4271 | 8463 |
|
4257 | 8464 |
list isNil ifTrue:[ |
8465 |
self unselect |
|
8466 |
] ifFalse:[ |
|
8467 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8468 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8469 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 8470 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
8471 |
cursorCol := newCursorCol. |
|
4257 | 8472 |
typeOfSelection := nil |
8473 |
] |
|
8474 |
] |
|
8475 |
||
8476 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8477 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8478 |
! |
8479 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8480 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8481 |
"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
|
8482 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8483 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8484 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8485 |
list isNil ifTrue:[ |
4823 | 8486 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8487 |
] ifFalse:[ |
4823 | 8488 |
cursorCol == 0 ifTrue:[ |
8489 |
col := 0 |
|
8490 |
] ifFalse:[ |
|
8491 |
col := cursorCol - 1 |
|
8492 |
]. |
|
8493 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8494 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8495 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8496 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8497 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8498 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8499 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8500 |
super selectFromLine:startLine col:startCol toLine:endLine col:endCol. |
5293
bb7a5aa59ddb
Merged 5251ecf0c9bb and 9d85f8e1e20c (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
8501 |
"JV: That's actually rubbish as then you loose the original positon |
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8502 |
and if user wants to extend/shring the selection further, you don't know |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8503 |
from which end to do it!!" |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8504 |
"/ (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[ |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8505 |
"/ self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8506 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8507 |
typeOfSelection := nil |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8508 |
|
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8509 |
"Modified: / 27-08-2013 / 13:28:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8510 |
"Modified (comment): / 27-08-2013 / 15:58:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8511 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8512 |
|
4257 | 8513 |
selectToEndOfLine |
8514 |
"select the text from the current cursor position to the end of the current line" |
|
8515 |
||
4271 | 8516 |
| newCursorCol line | |
8517 |
||
4257 | 8518 |
list isNil ifTrue:[ |
8519 |
self unselect |
|
8520 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
8521 |
cursorCol >= 1 ifTrue:[ |
4271 | 8522 |
line := list at: cursorLine. |
8523 |
newCursorCol := line size. |
|
8524 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8525 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8526 |
||
8527 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
8528 |
cursorCol := newCursorCol. |
|
4257 | 8529 |
typeOfSelection := nil |
8530 |
] |
|
8531 |
] |
|
8532 |
||
8533 |
"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
|
8534 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8535 |
! |
8536 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8537 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8538 |
"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
|
8539 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8540 |
list isNil ifTrue:[ |
4823 | 8541 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8542 |
] ifFalse:[ |
4823 | 8543 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8544 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8545 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8546 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8547 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8548 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8549 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8550 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8551 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8552 |
! |
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 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8555 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8556 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8557 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8558 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8559 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8560 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8561 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8562 |
wasOn ifTrue:[self showCursor] |
105 | 8563 |
! ! |
8564 |
||
8565 |
!EditTextView methodsFor:'undo & again'! |
|
8566 |
||
2952 | 8567 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8568 |
^ undoSupport addUndo:action. |
2952 | 8569 |
! |
8570 |
||
105 | 8571 |
again |
8572 |
"repeat the last action (which was a cut or replace). |
|
8573 |
If current selection is not last string, search forward to |
|
3160 | 8574 |
next occurrence of it before repeating the last operation." |
105 | 8575 |
|
4048 | 8576 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8577 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8578 |
|
8579 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8580 |
lastStringToReplace isNil ifTrue:[ |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8581 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8582 |
]. |
4048 | 8583 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8584 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8585 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8586 |
self undoableDo:[ |
4010 | 8587 |
s := lastStringToReplace asString. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8588 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8589 |
(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
|
8590 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8591 |
|
4053 | 8592 |
"set lastStringToReplace as the next search string |
8593 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8594 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8595 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8596 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8597 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8598 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8599 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8600 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8601 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8602 |
"if we are already there (after a find), ommit search" |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8603 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8604 |
(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8605 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8606 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8607 |
self deleteSelection. |
4051 | 8608 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8609 |
self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false. |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8610 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8611 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8612 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8613 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8614 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8615 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8616 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8617 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8618 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8619 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8620 |
startColForSearch := selectionEndCol ? (cursorCol - 1) |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8621 |
]. |
4048 | 8622 |
self |
8623 |
searchForwardFor:s |
|
8624 |
ignoreCase: lastReplaceIgnoredCase |
|
8625 |
match: lastReplaceWasMatch |
|
8626 |
startingAtLine:cursorLine col:startColForSearch |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8627 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8628 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8629 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8630 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8631 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8632 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8633 |
self selectFromLine:line col:col |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8634 |
toLine:line col:(col + s size - 1). |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8635 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8636 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8637 |
self deleteSelection. |
4051 | 8638 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8639 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8640 |
repl := lastReplacementInfo lastReplacement asString "withoutSpaces" |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8641 |
] ifTrue:[ |
4051 | 8642 |
repl := lastReplacementInfo lastReplacement "withoutSpaces". |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8643 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8644 |
self insertLines:repl asStringCollection withCR:false. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8645 |
self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1). |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8646 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8647 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8648 |
selectStyle := savedSelectStyle. |
4484 | 8649 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8650 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8651 |
] |
4048 | 8652 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8653 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8654 |
self sensor compressKeyPressEventsWithKey:#Again. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8655 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8656 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8657 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8658 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8659 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8660 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8661 |
^ true. |
501 | 8662 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8663 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8664 |
! |
8665 |
||
2952 | 8666 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8667 |
^ undoSupport hasRedoAction. |
2952 | 8668 |
! |
8669 |
||
8670 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8671 |
^ undoSupport hasUndoAction. |
2952 | 8672 |
! |
8673 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8674 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8675 |
"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
|
8676 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8677 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8678 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8679 |
|
2952 | 8680 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8681 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8682 |
! |
8683 |
||
8684 |
redo |
|
3780 | 8685 |
"undo the last undo" |
8686 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8687 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8688 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8689 |
] ifTrue:[ |
3780 | 8690 |
undoSupport redo. |
2952 | 8691 |
] |
8692 |
! |
|
8693 |
||
121 | 8694 |
undo |
3780 | 8695 |
"undo the last edit operation" |
8696 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8697 |
undoSupport hasUndoAction ifFalse:[ |
3780 | 8698 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8699 |
] ifTrue:[ |
3780 | 8700 |
undoSupport undo. |
121 | 8701 |
] |
2952 | 8702 |
! |
8703 |
||
8704 |
undoableDo:aBlock |
|
3495 | 8705 |
self undoableDo:aBlock info:nil. |
8706 |
||
8707 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 8708 |
! |
8709 |
||
8710 |
undoableDo:aBlock info:aString |
|
5689 | 8711 |
|selectionRestore| |
8712 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8713 |
self checkModificationsAllowed ifFalse:[ |
4823 | 8714 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
8715 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
8716 |
] ifTrue:[ |
5689 | 8717 |
undoSupport isInTransaction ifFalse:[ |
8718 |
selectionRestore := RestoreSelectionAndCursor new |
|
8719 |
cursorLine:cursorLine cursorCol:cursorCol |
|
8720 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
8721 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
8722 |
info:nil. |
|
8723 |
]. |
|
8724 |
undoSupport |
|
8725 |
undoableDo:[ |
|
8726 |
aBlock value. |
|
8727 |
selectionRestore notNil ifTrue:[ |
|
8728 |
undoSupport transactionNotEmpty ifTrue:[ |
|
8729 |
undoSupport addUndoFirst:selectionRestore |
|
8730 |
]. |
|
8731 |
]. |
|
8732 |
] |
|
8733 |
info:aString. |
|
8734 |
]. |
|
8735 |
||
8736 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 8737 |
! ! |
8738 |
||
8739 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
8740 |
||
8741 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8742 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
8743 |
! |
|
8744 |
||
3115 | 8745 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 8746 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 8747 |
! |
8748 |
||
2952 | 8749 |
line:arg1 col:arg2 character:arg3 |
8750 |
^ self new line:arg1 col:arg2 character:arg3 |
|
8751 |
! |
|
8752 |
||
3115 | 8753 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 8754 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 8755 |
! |
8756 |
||
3235 | 8757 |
line:arg1 col:arg2 characters:arg3 info:info |
8758 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
8759 |
! |
|
8760 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8761 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8762 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8763 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8764 |
|
2952 | 8765 |
line:arg1 col:arg2 string:arg3 |
8766 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 8767 |
! |
8768 |
||
8769 |
line:arg1 col:arg2 string:arg3 info:info |
|
8770 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 8771 |
! |
8772 |
||
8773 |
line:arg1 string:arg3 info:info |
|
8774 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 8775 |
! |
8776 |
||
8777 |
text:arg info:info |
|
8778 |
^ (self new text:arg) info:info |
|
3115 | 8779 |
! ! |
8780 |
||
8781 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
8782 |
||
8783 |
info |
|
8784 |
^ userFriendlyInfo |
|
8785 |
! |
|
8786 |
||
8787 |
info:aString |
|
8788 |
userFriendlyInfo := aString |
|
2952 | 8789 |
! ! |
8790 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8791 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8792 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8793 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8794 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8795 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8796 |
"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
|
8797 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
8798 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8799 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8800 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8801 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8802 |
^ false |
5710 | 8803 |
! |
8804 |
||
8805 |
isRestoreSelectionAndCursor |
|
8806 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8807 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8808 |
|
2952 | 8809 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
8810 |
||
3160 | 8811 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 8812 |
"set instance variables (automatically generated)" |
8813 |
||
8814 |
self assert:(line1Arg notNil). |
|
8815 |
self assert:(col1Arg notNil). |
|
8816 |
self assert:(line2Arg notNil). |
|
8817 |
self assert:(col2Arg notNil). |
|
8818 |
||
8819 |
line1 := line1Arg. |
|
8820 |
col1 := col1Arg. |
|
8821 |
line2 := line2Arg. |
|
8822 |
col2 := col2Arg. |
|
8823 |
! ! |
|
8824 |
||
8825 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
8826 |
||
3160 | 8827 |
executeIn:editor |
2952 | 8828 |
editor unselect. |
3160 | 8829 |
editor |
4823 | 8830 |
deleteFromLine:line1 |
8831 |
col:col1 |
|
8832 |
toLine:line2 |
|
8833 |
col:col2. |
|
2952 | 8834 |
editor cursorLine:line1 col:col1. |
8835 |
! ! |
|
8836 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8837 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8838 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8839 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8840 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8841 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8842 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8843 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8844 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8845 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8846 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8847 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8848 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8849 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8850 |
|
3160 | 8851 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8852 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8853 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8854 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8855 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8856 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8857 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8858 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8859 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8860 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8861 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8862 |
|
3160 | 8863 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8864 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8865 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8866 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8867 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8868 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8869 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8870 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8871 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8872 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8873 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8874 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8875 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8876 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8877 |
|
3160 | 8878 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8879 |
"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
|
8880 |
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
|
8881 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8882 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8883 |
previousDeleteAction line == line ifTrue:[ |
4823 | 8884 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
8885 |
^ true |
|
8886 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8887 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8888 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8889 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8890 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8891 |
|
3160 | 8892 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8893 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8894 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8895 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8896 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8897 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8898 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8899 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8900 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8901 |
|
3160 | 8902 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8903 |
editor unselect. |
3160 | 8904 |
editor |
4823 | 8905 |
deleteFromLine:line |
8906 |
col:col1 |
|
8907 |
toLine:line |
|
8908 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8909 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8910 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
8911 |
|
3235 | 8912 |
!EditTextView::EditMode class methodsFor:'constants'! |
8913 |
||
8914 |
insertAndSelectMode |
|
8915 |
^ InsertAndSelectMode |
|
8916 |
! |
|
8917 |
||
8918 |
insertMode |
|
8919 |
^ InsertMode |
|
8920 |
! |
|
8921 |
||
8922 |
overwriteMode |
|
8923 |
^ OverwriteMode |
|
8924 |
! ! |
|
8925 |
||
8926 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
8927 |
||
8928 |
isInsertAndSelectMode |
|
8929 |
^ false |
|
8930 |
! |
|
8931 |
||
8932 |
isInsertMode |
|
8933 |
^ false |
|
8934 |
! |
|
8935 |
||
8936 |
symbolicName |
|
8937 |
self subclassResponsibility |
|
8938 |
! ! |
|
8939 |
||
8940 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
8941 |
||
8942 |
infoPrintString |
|
8943 |
^ 'IS' |
|
8944 |
! ! |
|
8945 |
||
8946 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
8947 |
||
8948 |
isInsertAndSelectMode |
|
8949 |
^ true |
|
8950 |
! |
|
8951 |
||
8952 |
isInsertMode |
|
8953 |
^ true |
|
8954 |
! ! |
|
8955 |
||
8956 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
8957 |
||
8958 |
infoPrintString |
|
8959 |
^ 'I' |
|
8960 |
! ! |
|
8961 |
||
8962 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
8963 |
||
8964 |
isInsertMode |
|
8965 |
^ true |
|
8966 |
! ! |
|
8967 |
||
8968 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
8969 |
||
8970 |
infoPrintString |
|
8971 |
^ 'O' |
|
8972 |
! ! |
|
8973 |
||
4048 | 8974 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
8975 |
||
8976 |
lastReplaceIgnoredCase |
|
8977 |
^ lastReplaceIgnoredCase ? false |
|
8978 |
! |
|
8979 |
||
8980 |
lastReplaceIgnoredCase:something |
|
8981 |
lastReplaceIgnoredCase := something. |
|
8982 |
! |
|
8983 |
||
8984 |
lastReplaceWasMatch |
|
8985 |
^ lastReplaceWasMatch ? false |
|
8986 |
! |
|
8987 |
||
8988 |
lastReplaceWasMatch:something |
|
8989 |
lastReplaceWasMatch := something. |
|
8990 |
! |
|
8991 |
||
8992 |
lastReplacement |
|
8993 |
^ lastReplacement |
|
8994 |
! |
|
8995 |
||
8996 |
lastReplacement:something |
|
4053 | 8997 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 8998 |
lastReplacement := something. |
8999 |
! |
|
9000 |
||
9001 |
lastStringToReplace |
|
9002 |
^ lastStringToReplace |
|
9003 |
! |
|
9004 |
||
9005 |
lastStringToReplace:something |
|
9006 |
lastStringToReplace := something. |
|
4818 | 9007 |
! |
9008 |
||
9009 |
previousReplacements |
|
9010 |
^ previousReplacements ? #() |
|
9011 |
! |
|
9012 |
||
9013 |
stillCollectingInput |
|
9014 |
^ stillCollectingInput |
|
9015 |
! |
|
9016 |
||
9017 |
stillCollectingInput:aBoolean |
|
9018 |
stillCollectingInput := aBoolean. |
|
9019 |
! ! |
|
9020 |
||
9021 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9022 |
||
9023 |
rememberReplacement |
|
9024 |
"remember the previous replacement (called when a new one appears). |
|
9025 |
Mostly for the benefit of the code completion..." |
|
9026 |
||
9027 |
|oldString newString| |
|
9028 |
||
9029 |
oldString := lastStringToReplace. |
|
9030 |
newString := lastReplacement. |
|
9031 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
9032 |
previousReplacements isNil ifTrue:[ |
|
9033 |
previousReplacements := OrderedCollection new. |
|
9034 |
]. |
|
9035 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9036 |
previousReplacements addFirst:(oldString -> newString). |
|
9037 |
previousReplacements size > 20 ifTrue:[ |
|
9038 |
previousReplacements removeLast. |
|
9039 |
] |
|
9040 |
]. |
|
4048 | 9041 |
! ! |
9042 |
||
2952 | 9043 |
!EditTextView::PasteString methodsFor:'accessing'! |
9044 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9045 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9046 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9047 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9048 |
"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
|
9049 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9050 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9051 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9052 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9053 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9054 |
"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
|
9055 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9056 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9057 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9058 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9059 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9060 |
"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
|
9061 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9062 |
|
3160 | 9063 |
line:lineArg col:colArg string:stringArg |
2952 | 9064 |
self assert:(lineArg notNil). |
9065 |
self assert:(colArg notNil). |
|
9066 |
self assert:(stringArg notNil). |
|
9067 |
||
9068 |
line := lineArg. |
|
9069 |
col := colArg. |
|
9070 |
string := stringArg. |
|
9071 |
! |
|
9072 |
||
9073 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9074 |
self assert:(lineArg notNil). |
|
9075 |
self assert:(colArg notNil). |
|
9076 |
self assert:(stringArg notNil). |
|
9077 |
||
9078 |
line := lineArg. |
|
9079 |
col := colArg. |
|
9080 |
string := stringArg. |
|
9081 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9082 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9083 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9084 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9085 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9086 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9087 |
"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
|
9088 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9089 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9090 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9091 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9092 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9093 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9094 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9095 |
"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
|
9096 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9097 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9098 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9099 |
"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
|
9100 |
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
|
9101 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9102 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9103 |
previousPasteAction line == line ifTrue:[ |
4823 | 9104 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9105 |
^ true |
|
9106 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9107 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9108 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9109 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9110 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9111 |
"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
|
9112 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9113 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9114 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9115 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9116 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9117 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9118 |
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
|
9119 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9120 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9121 |
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
|
9122 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9123 |
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
|
9124 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9125 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9126 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9127 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9128 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9129 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9130 |
! ! |
9131 |
||
9132 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9133 |
||
3160 | 9134 |
executeIn:editor |
2952 | 9135 |
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
|
9136 |
editor paste:string. |
2952 | 9137 |
selected ~~ true ifTrue:[ |
4823 | 9138 |
editor unselect |
2952 | 9139 |
]. |
9140 |
! ! |
|
9141 |
||
9142 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9143 |
||
3235 | 9144 |
col |
9145 |
^ col |
|
9146 |
! |
|
9147 |
||
9148 |
col1 |
|
9149 |
^ col |
|
9150 |
! |
|
9151 |
||
9152 |
col2 |
|
9153 |
^ col |
|
9154 |
! |
|
9155 |
||
9156 |
line |
|
9157 |
^ line |
|
9158 |
! |
|
9159 |
||
3160 | 9160 |
line:lineArg col:colArg character:characterArg |
2952 | 9161 |
line := lineArg. |
9162 |
col := colArg. |
|
9163 |
character := characterArg. |
|
9164 |
! ! |
|
9165 |
||
9166 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9167 |
||
3160 | 9168 |
executeIn:editor |
9169 |
editor |
|
4823 | 9170 |
replace:character |
9171 |
atLine:line |
|
9172 |
col:col. |
|
2952 | 9173 |
editor cursorLine:line col:col. |
105 | 9174 |
! ! |
9175 |
||
3235 | 9176 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9177 |
||
9178 |
characters |
|
9179 |
^ characters |
|
9180 |
! |
|
9181 |
||
9182 |
col1 |
|
9183 |
^ col1 |
|
9184 |
! |
|
9185 |
||
9186 |
col2 |
|
9187 |
^ col2 |
|
9188 |
! |
|
9189 |
||
9190 |
line |
|
9191 |
^ line |
|
9192 |
! |
|
9193 |
||
9194 |
line:lineArg col:colArg character:characterArg |
|
9195 |
line := lineArg. |
|
9196 |
col1 := col2 := colArg. |
|
9197 |
characters := characterArg asString. |
|
9198 |
! |
|
9199 |
||
9200 |
line:lineArg col:colArg characters:charactersArg |
|
9201 |
line := lineArg. |
|
9202 |
col1 := colArg. |
|
9203 |
characters := charactersArg asString. |
|
9204 |
col2 := col1 + charactersArg size - 1 |
|
9205 |
! ! |
|
9206 |
||
9207 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9208 |
||
9209 |
canCombineWithNext:anotherAction |
|
9210 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9211 |
! |
|
9212 |
||
9213 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9214 |
"I will combine only if we both are single character deletes, |
|
9215 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9216 |
(i.e. single-character typing)" |
|
9217 |
||
9218 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 9219 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9220 |
^ true |
|
9221 |
]. |
|
3235 | 9222 |
]. |
9223 |
||
9224 |
^ false |
|
9225 |
! |
|
9226 |
||
9227 |
combineWithNext:nextReplaceAction |
|
9228 |
self assert:(line == nextReplaceAction line). |
|
9229 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9230 |
||
9231 |
col2 := nextReplaceAction col2. |
|
9232 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9233 |
characters := characters , nextReplaceAction characters. |
|
9234 |
! ! |
|
9235 |
||
9236 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9237 |
||
9238 |
executeIn:editor |
|
9239 |
editor |
|
4823 | 9240 |
replaceString:characters |
9241 |
atLine:line |
|
9242 |
col:col1. |
|
3235 | 9243 |
editor cursorLine:line col:col1. |
9244 |
! ! |
|
9245 |
||
3131 | 9246 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9247 |
||
9248 |
text:something |
|
9249 |
text := something. |
|
9250 |
! ! |
|
9251 |
||
9252 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9253 |
||
3160 | 9254 |
executeIn:editor |
3131 | 9255 |
editor contents:text |
9256 |
! ! |
|
9257 |
||
3130 | 9258 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9259 |
||
3160 | 9260 |
line:lineArg string:stringArg |
3130 | 9261 |
line := lineArg. |
9262 |
text := stringArg. |
|
9263 |
! ! |
|
9264 |
||
9265 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9266 |
||
3160 | 9267 |
executeIn:editor |
3130 | 9268 |
editor list at:line put:text. |
9269 |
editor invalidateLine:line |
|
9270 |
! ! |
|
9271 |
||
3402 | 9272 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9273 |
||
9274 |
line:lineArg lines:lineCollectionArg |
|
9275 |
line := lineArg. |
|
9276 |
text := lineCollectionArg. |
|
9277 |
||
9278 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9279 |
! ! |
|
9280 |
||
9281 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9282 |
||
9283 |
executeIn:editor |
|
9284 |
|lnr| |
|
9285 |
||
9286 |
lnr := line. |
|
9287 |
text do:[:eachLine | |
|
4823 | 9288 |
editor list at:lnr put:eachLine. |
9289 |
editor invalidateLine:lnr. |
|
9290 |
lnr := lnr + 1. |
|
3402 | 9291 |
]. |
9292 |
||
9293 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9294 |
! ! |
|
9295 |
||
5689 | 9296 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9297 |
||
9298 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9299 |
cursorLine := cursorLineArg. |
|
9300 |
cursorCol := cursorColArg. |
|
9301 |
selectionStartLine := selectionStartLineArg. |
|
9302 |
selectionStartCol := selectionStartColArg. |
|
9303 |
selectionEndLine := selectionEndLineArg. |
|
9304 |
selectionEndCol := selectionEndColArg. |
|
9305 |
! |
|
9306 |
||
9307 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
|
9308 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
|
9309 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9310 |
info:info |
|
9311 |
||
9312 |
cursorLine := cursorLineArg. |
|
9313 |
cursorCol := cursorColArg. |
|
9314 |
selectionStartLine := selectionStartLineArg. |
|
9315 |
selectionStartCol := selectionStartColArg. |
|
9316 |
selectionEndLine := selectionEndLineArg. |
|
9317 |
selectionEndCol := selectionEndColArg. |
|
9318 |
userFriendlyInfo := info. |
|
9319 |
||
9320 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9321 |
! ! |
|
9322 |
||
9323 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9324 |
||
9325 |
executeIn:editor |
|
9326 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9327 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
9328 |
editor setCursorLine:cursorLine col:cursorCol. |
|
9329 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
9330 |
] ifFalse:[ |
|
9331 |
editor cursorLine:cursorLine col:cursorCol. |
|
9332 |
]. |
|
9333 |
||
9334 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9335 |
! ! |
|
9336 |
||
5710 | 9337 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9338 |
||
9339 |
isRestoreSelectionAndCursor |
|
9340 |
^ true |
|
9341 |
! ! |
|
9342 |
||
865 | 9343 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9344 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9345 |
version |
5361 | 9346 |
^ '$Header$' |
3945 | 9347 |
! |
9348 |
||
9349 |
version_CVS |
|
5361 | 9350 |
^ '$Header$' |
4843
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9351 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9352 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9353 |
version_HG |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9354 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9355 |
^ '$Changeset: <not expanded> $' |
0 | 9356 |
! ! |
4481 | 9357 |