author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 14 Jan 2017 00:35:41 +0000 | |
branch | jv |
changeset 6063 | ef1842cb1d75 |
parent 6023 | 1df17efc16f7 |
child 6085 | 4ecbe3a93aec |
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 |
|
5988 | 179 |
cursorLine <Number> line where cursor sits (1..) |
180 |
||
181 |
cursorVisibleLine <Number> visible line where cursor sits (1..nLinesShown) |
|
182 |
||
183 |
cursorCol <Number> col where cursor sits (1..) |
|
184 |
||
185 |
cursorShown <Boolean> true, if cursor is currently shown |
|
186 |
||
187 |
readOnly <Boolean> true, if text may not be edited |
|
188 |
||
189 |
modifiedChannel <ValueHolder> holding true, if text has been modified. |
|
190 |
cleared on accept. |
|
191 |
||
192 |
acceptChannel <ValueHolder> holding true, if text has been accepted. |
|
193 |
||
194 |
fixedSize <Boolean> true, if no lines may be added/removed |
|
195 |
||
196 |
exceptionBlock <Block> block to be evaluated when readonly text is about to be modified |
|
197 |
if it returns true, the modification will be done anyway. |
|
198 |
if it returns anything else, the modification is not done. |
|
199 |
||
200 |
cursorFgColor <Color> color used for cursor drawing |
|
201 |
cursorBgColor <Color> color used for cursor drawing |
|
202 |
||
203 |
cursorType <Symbol> how the cursor is drawn; currently implemented |
|
204 |
are #none, #block (solid-block cursor), #ibeam |
|
205 |
(vertical bar at insertion point) |
|
206 |
and #caret (caret below insertion-point). |
|
207 |
see cursorType: for an up-to-date list. |
|
208 |
||
209 |
cursorTypeNoFocus <Symbol> like above, if view has no focus |
|
210 |
nil means: hide the cursor. |
|
211 |
||
212 |
undoAction <Block> block which undoes last cut, paste or replace |
|
213 |
(not yet fully implemented) |
|
214 |
||
215 |
typeOfSelection <Symbol> #paste, if selection created by paste, nil otherwise |
|
216 |
this affects the next keyPress: if #paste it does not |
|
217 |
replace; otherwise it replaces the selection. |
|
218 |
||
219 |
lastCut <String> last cut or replaced string |
|
220 |
||
221 |
lastReplacementInfo <LastReplacementInfo> holds the information about the last replace action |
|
222 |
lastStringToReplace is the string to be replaced by lastReplacement |
|
223 |
lastReplacement is the string to replace lastStringToReplace |
|
224 |
||
4053 | 225 |
lastStringFromReplaceForNextSearch <String> string to be taken be the next search action |
5988 | 226 |
(cleared after a new selection) |
227 |
||
228 |
replacing <Boolean> true if entered characters replace last selection |
|
229 |
||
230 |
showMatchingParenthesis <Boolean> if true, shows matching parenthesis |
|
231 |
when entering one; this is the default. |
|
232 |
||
233 |
hasKeyboardFocus <Boolean> true if this view has the focus |
|
234 |
||
235 |
acceptAction <Block> accept action - evaluated passing the contents as |
|
236 |
argument |
|
237 |
||
238 |
tabMeansNextField <Boolean> if true, Tab is ignored as input and shifts keyboard |
|
239 |
focus to the next field. For editTextViews, this is false |
|
240 |
by default (i.e. tabs can be entered into the text). |
|
241 |
For some subclasses (inputFields), this may be true. |
|
242 |
||
243 |
trimBlankLines <Boolean> if true, trailing blanks are |
|
244 |
removed when editing. |
|
245 |
Also, empty lines are represented as nil in the lines collection. |
|
246 |
Default is true. |
|
247 |
||
248 |
wordWrap <Boolean> Currently not used. |
|
249 |
||
250 |
lockUpdates <Boolean> internal, private |
|
251 |
||
252 |
prevCursorState <Boolean> temporary, private |
|
253 |
||
254 |
cursorMovementWhenUpdating |
|
255 |
<Symbol> defines where the cursor is to be positioned if the |
|
256 |
model changes its value by some outside activity |
|
257 |
(i.e. not by user input into the field). |
|
258 |
Can be one of: |
|
259 |
#keep / nil -> stay where it was |
|
260 |
#endOfText -> cursor to the end |
|
261 |
#endOfLine -> stay in the line, but move to end |
|
262 |
#beginOfText -> cursor to the beginning |
|
263 |
#beginOfLine -> stay in the line, but move to begin |
|
264 |
The default is #beginOfText |
|
265 |
||
266 |
||
267 |
||
268 |
dropTarget <DropTarget|nil> drop operation descriptor or nil (drop disabled) |
|
2589 | 269 |
|
270 |
||
2712
e83d71c9bdec
ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents:
2707
diff
changeset
|
271 |
userPreference values: |
5988 | 272 |
userPreferences.st80EditMode |
273 |
<Boolean> if true, cursor positioning is |
|
274 |
done as in vi or ST80; i.e. |
|
275 |
wysiwyg mode is somewhat relaxed, |
|
276 |
in that the cursor cannot be |
|
277 |
positioned behind a lines end. |
|
278 |
This is not yet completely implemented. |
|
33 | 279 |
used globals: |
280 |
||
5988 | 281 |
DeleteHistory <Text> last 1000 lines of deleted text |
282 |
(but only if this variable exists already) |
|
586 | 283 |
|
284 |
[styleSheet parameters:] |
|
121 | 285 |
|
5988 | 286 |
textCursorForegroundColor <Color> cursor fg color; default: text background |
287 |
textCursorBackgroundColor <Color> cursor bg color; default: text foreground |
|
288 |
textCursorNoFocusForegroundColor |
|
289 |
<Color> cursor fg color if no focus; default: cursor fg color |
|
290 |
textCursorType <Symbol> cursor type; default: #block |
|
586 | 291 |
|
292 |
[author:] |
|
5988 | 293 |
Claus Gittinger |
586 | 294 |
|
295 |
[see also:] |
|
5988 | 296 |
CodeView Workspace TextView ListView |
297 |
EditField |
|
0 | 298 |
" |
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
299 |
! |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
300 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
301 |
examples |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
302 |
" |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
303 |
non MVC operation: |
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
304 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
305 |
basic setup: |
4823 | 306 |
[exBegin] |
307 |
|top textView| |
|
308 |
||
309 |
top := StandardSystemView new. |
|
310 |
top extent:300@200. |
|
311 |
||
312 |
textView := EditTextView new. |
|
313 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
314 |
top addSubView:textView. |
|
315 |
||
316 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
317 |
||
318 |
top open. |
|
319 |
[exEnd] |
|
594 | 320 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
321 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
322 |
with vertical scrollbar: |
4823 | 323 |
[exBegin] |
324 |
|top scrollView textView| |
|
325 |
||
326 |
top := StandardSystemView new. |
|
327 |
top extent:300@200. |
|
328 |
||
329 |
scrollView := ScrollableView for:EditTextView. |
|
330 |
textView := scrollView scrolledView. |
|
331 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
332 |
top addSubView:scrollView. |
|
333 |
||
334 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
335 |
||
336 |
top open. |
|
337 |
[exEnd] |
|
594 | 338 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
339 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
340 |
with horizontal & vertical scrollbars: |
4823 | 341 |
[exBegin] |
342 |
|top scrollView textView| |
|
343 |
||
344 |
top := StandardSystemView new. |
|
345 |
top extent:300@200. |
|
346 |
||
347 |
scrollView := HVScrollableView for:EditTextView. |
|
348 |
textView := scrollView scrolledView. |
|
349 |
scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
350 |
top addSubView:scrollView. |
|
351 |
||
352 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
353 |
||
354 |
top open. |
|
355 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
356 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
357 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
358 |
set the action for accept: |
4823 | 359 |
[exBegin] |
360 |
|top textView| |
|
361 |
||
362 |
top := StandardSystemView new. |
|
363 |
top extent:300@200. |
|
364 |
||
365 |
textView := EditTextView new. |
|
366 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
367 |
top addSubView:textView. |
|
368 |
||
369 |
textView contents:('/etc/hosts' asFilename contentsOfEntireFile). |
|
370 |
textView acceptAction:[:contents | |
|
371 |
Transcript showCR:'will not overwrite the file with:'. |
|
372 |
Transcript showCR:contents asString |
|
373 |
]. |
|
374 |
top open. |
|
375 |
[exEnd] |
|
594 | 376 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
377 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
378 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
379 |
non-string (text) items: |
4823 | 380 |
[exBegin] |
381 |
|top textView list| |
|
382 |
||
383 |
list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection. |
|
384 |
1 to:list size by:2 do:[:nr | |
|
385 |
list at:nr put:(Text string:(list at:nr) |
|
386 |
emphasis:(Array with:#bold with:(#color->Color red))) |
|
387 |
]. |
|
388 |
||
389 |
top := StandardSystemView new. |
|
390 |
top extent:300@200. |
|
391 |
||
392 |
textView := EditTextView new. |
|
393 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
394 |
top addSubView:textView. |
|
395 |
||
396 |
textView contents:list. |
|
397 |
top open. |
|
398 |
[exEnd] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
399 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
400 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
401 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
402 |
MVC operation: |
594 | 403 |
(the examples model here is a plug simulating a real model; |
404 |
real world applications would not use a plug ..) |
|
4823 | 405 |
[exBegin] |
406 |
|top textView model| |
|
407 |
||
408 |
model := Plug new. |
|
409 |
model respondTo:#accepted: |
|
410 |
with:[:newContents | |
|
411 |
Transcript showCR:'will not overwrite the file with:'. |
|
412 |
Transcript showCR:newContents asString |
|
413 |
]. |
|
414 |
model respondTo:#getList |
|
415 |
with:['/etc/hosts' asFilename contentsOfEntireFile]. |
|
416 |
||
417 |
||
418 |
top := StandardSystemView new. |
|
419 |
top extent:300@200. |
|
420 |
||
421 |
textView := EditTextView new. |
|
422 |
textView origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
423 |
top addSubView:textView. |
|
424 |
||
425 |
textView listMessage:#getList; |
|
426 |
model:model; |
|
427 |
changeMessage:#accepted:; |
|
428 |
aspect:#list. |
|
429 |
top open. |
|
430 |
[exEnd] |
|
594 | 431 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
432 |
|
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
433 |
two textViews on the same model: |
4823 | 434 |
[exBegin] |
435 |
|top1 textView1 top2 textView2 model currentContents| |
|
436 |
||
437 |
model := Plug new. |
|
438 |
model respondTo:#accepted: |
|
439 |
with:[:newContents | |
|
440 |
Transcript showCR:'accepted:'. |
|
441 |
Transcript showCR:newContents asString. |
|
442 |
currentContents := newContents. |
|
443 |
model changed:#contents |
|
444 |
]. |
|
445 |
model respondTo:#getList |
|
446 |
with:[Transcript showCR:'query'. |
|
447 |
currentContents]. |
|
448 |
||
449 |
||
450 |
top1 := StandardSystemView new. |
|
451 |
top1 extent:300@200. |
|
452 |
||
453 |
textView1 := EditTextView new. |
|
454 |
textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
455 |
top1 addSubView:textView1. |
|
456 |
||
457 |
textView1 listMessage:#getList; |
|
458 |
model:model; |
|
459 |
aspect:#contents; |
|
460 |
changeMessage:#accepted:. |
|
461 |
top1 open. |
|
462 |
||
463 |
top2 := StandardSystemView new. |
|
464 |
top2 extent:300@200. |
|
465 |
||
466 |
textView2 := EditTextView new. |
|
467 |
textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
468 |
top2 addSubView:textView2. |
|
469 |
||
470 |
textView2 listMessage:#getList; |
|
471 |
model:model; |
|
472 |
aspect:#contents; |
|
473 |
changeMessage:#accepted:. |
|
474 |
top2 open. |
|
475 |
[exEnd] |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
476 |
" |
4978
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 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
479 |
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
|
480 |
" |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
481 |
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
|
482 |
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
|
483 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
484 |
* 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
|
485 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
486 |
* 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
|
487 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
488 |
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
|
489 |
2. Stop dragging |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
490 |
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
|
491 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
492 |
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
|
493 |
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
|
494 |
(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
|
495 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
496 |
* 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
|
497 |
Scenario: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
498 |
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
|
499 |
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
|
500 |
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
|
501 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
502 |
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
|
503 |
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
|
504 |
(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
|
505 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
506 |
* 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
|
507 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
512 |
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
|
513 |
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
|
514 |
(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
|
515 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
516 |
Scenario B: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
517 |
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
|
518 |
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
|
519 |
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
|
520 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
521 |
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
|
522 |
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
|
523 |
(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
|
524 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
525 |
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
|
526 |
UserPreferences current selectionExtensionMode |
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 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
529 |
* 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
|
530 |
Scenario A: |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
531 |
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
|
532 |
2. Select word |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
533 |
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
|
534 |
|
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
535 |
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
|
536 |
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
|
537 |
(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
|
538 |
|
297
08eec8838a4c
beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
539 |
" |
0 | 540 |
! ! |
541 |
||
865 | 542 |
!EditTextView class methodsFor:'defaults'! |
59 | 543 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
544 |
defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
545 |
^ nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
546 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
547 |
"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
|
548 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
549 |
|
1419 | 550 |
st80Mode |
551 |
"return true, if the st80 editing mode is turned on. |
|
552 |
This setting affects the behavior of the cursor, when positioned |
|
5909 | 553 |
beyond the end of a line or the end of the text. |
554 |
This method is here for backward compatibility, when this flag was stored |
|
555 |
in a class var. It is now in the user's settings. |
|
556 |
Please do not call it, but go to the prefs directly, to make it easier to find those getters." |
|
1419 | 557 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
558 |
^ UserPreferences current st80EditMode |
1419 | 559 |
|
560 |
" |
|
561 |
EditTextView st80Mode:true |
|
562 |
EditTextView st80Mode:false |
|
563 |
" |
|
564 |
||
565 |
"Modified: / 16.1.1998 / 22:54:57 / cg" |
|
566 |
! |
|
567 |
||
568 |
st80Mode:aBoolean |
|
569 |
"turns on/off st80 behavior, where the cursor cannot be positioned |
|
5909 | 570 |
beyond the end of a line or the last line. |
571 |
This method is here for backward compatibility, when this flag was stored |
|
572 |
in a class var. It is now in the user's settings. |
|
573 |
Please do not call it, but go to the prefs directly, to make it easier to find those setters." |
|
1419 | 574 |
|
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
575 |
UserPreferences current st80EditMode:aBoolean. |
1419 | 576 |
|
577 |
" |
|
578 |
EditTextView st80Mode:true |
|
579 |
EditTextView st80Mode:false |
|
580 |
" |
|
581 |
||
582 |
"Modified: / 16.1.1998 / 22:55:19 / cg" |
|
583 |
! |
|
584 |
||
59 | 585 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
586 |
"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
|
587 |
|
1390 | 588 |
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor' |
4823 | 589 |
#'textCursor.noFocusForegroundColor' |
590 |
#'textCursor.type' |
|
591 |
#'textCursor.typeNoFocus' |
|
592 |
#'editText.st80Mode')> |
|
1355 | 593 |
|
594 |
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'. |
|
595 |
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'. |
|
596 |
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'. |
|
597 |
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block. |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
598 |
DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'. |
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
599 |
|
1419 | 600 |
" |
601 |
self updateStyleCache |
|
602 |
" |
|
603 |
||
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
604 |
"Modified: / 20.5.1998 / 04:27:41 / cg" |
59 | 605 |
! ! |
606 |
||
3431 | 607 |
!EditTextView class methodsFor:'specs'! |
608 |
||
609 |
searchReplaceDialogSpec |
|
610 |
"This resource specification was automatically generated |
|
611 |
by the UIPainter of ST/X." |
|
612 |
||
613 |
"Do not manually edit this!! If it is corrupted, |
|
614 |
the UIPainter may not be able to read the specification." |
|
615 |
||
616 |
" |
|
617 |
UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec |
|
618 |
" |
|
619 |
||
620 |
<resource: #canvas> |
|
621 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
622 |
^ |
3431 | 623 |
#(FullSpec |
4823 | 624 |
name: searchReplaceDialogSpec |
625 |
window: |
|
3431 | 626 |
(WindowSpec |
4823 | 627 |
label: 'String Search and Replace' |
628 |
name: 'String Search and Replace' |
|
629 |
min: (Point 283 196) |
|
630 |
max: (Point 283 196) |
|
631 |
bounds: (Rectangle 0 0 279 192) |
|
632 |
) |
|
633 |
component: |
|
3431 | 634 |
(SpecCollection |
4823 | 635 |
collection: ( |
636 |
(LabelSpec |
|
637 |
label: 'Search Pattern:' |
|
638 |
name: 'label' |
|
639 |
layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0) |
|
640 |
level: 0 |
|
641 |
translateLabel: true |
|
642 |
adjust: left |
|
643 |
) |
|
644 |
(ComboBoxSpec |
|
645 |
name: 'patternComboBox' |
|
646 |
layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0) |
|
647 |
tabable: true |
|
648 |
model: searchPattern |
|
649 |
immediateAccept: false |
|
650 |
acceptOnLeave: true |
|
651 |
acceptOnReturn: true |
|
652 |
acceptOnTab: true |
|
653 |
acceptOnLostFocus: true |
|
654 |
acceptOnPointerLeave: false |
|
655 |
autoSelectInitialText: true |
|
656 |
comboList: patternList |
|
657 |
) |
|
658 |
(ComboBoxSpec |
|
659 |
name: 'replaceComboBox' |
|
660 |
layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0) |
|
661 |
tabable: true |
|
662 |
model: replacePattern |
|
663 |
immediateAccept: false |
|
664 |
acceptOnLeave: true |
|
665 |
acceptOnReturn: true |
|
666 |
acceptOnTab: true |
|
667 |
acceptOnLostFocus: true |
|
668 |
acceptOnPointerLeave: false |
|
669 |
autoSelectInitialText: true |
|
670 |
comboList: patternList |
|
671 |
) |
|
672 |
(CheckBoxSpec |
|
673 |
label: 'Ignore Case' |
|
674 |
name: 'ignoreCaseCheckBox' |
|
675 |
layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0) |
|
676 |
level: 0 |
|
677 |
tabable: true |
|
678 |
model: ignoreCase |
|
679 |
translateLabel: true |
|
680 |
) |
|
681 |
(VariableVerticalPanelSpec |
|
682 |
name: 'VariableVerticalPanel1' |
|
683 |
layout: (LayoutFrame 0 0 -64 1 0 1 -4 1) |
|
684 |
component: |
|
685 |
(SpecCollection |
|
686 |
collection: ( |
|
687 |
(HorizontalPanelViewSpec |
|
688 |
name: 'HorizontalPanel1' |
|
689 |
level: 0 |
|
690 |
horizontalLayout: fitSpace |
|
691 |
verticalLayout: center |
|
692 |
horizontalSpace: 3 |
|
693 |
verticalSpace: 3 |
|
694 |
ignoreInvisibleComponents: true |
|
695 |
reverseOrderIfOKAtLeft: true |
|
696 |
component: |
|
697 |
(SpecCollection |
|
698 |
collection: ( |
|
699 |
(ActionButtonSpec |
|
700 |
label: 'Replace' |
|
701 |
name: 'replaceButton' |
|
702 |
level: 2 |
|
703 |
translateLabel: true |
|
704 |
tabable: true |
|
705 |
model: replaceAction |
|
706 |
extent: (Point 134 21) |
|
707 |
) |
|
708 |
(ActionButtonSpec |
|
709 |
label: 'Replace All' |
|
710 |
name: 'replaceAllButton' |
|
711 |
level: 2 |
|
712 |
borderWidth: 1 |
|
713 |
translateLabel: true |
|
714 |
tabable: true |
|
715 |
model: replaceAllAction |
|
716 |
extent: (Point 134 21) |
|
717 |
) |
|
718 |
) |
|
719 |
||
720 |
) |
|
721 |
) |
|
722 |
(HorizontalPanelViewSpec |
|
723 |
name: 'horizontalPanelView' |
|
724 |
level: 0 |
|
725 |
horizontalLayout: fitSpace |
|
726 |
verticalLayout: center |
|
727 |
horizontalSpace: 3 |
|
728 |
verticalSpace: 3 |
|
729 |
ignoreInvisibleComponents: true |
|
730 |
reverseOrderIfOKAtLeft: true |
|
731 |
component: |
|
732 |
(SpecCollection |
|
733 |
collection: ( |
|
734 |
(ActionButtonSpec |
|
735 |
label: 'Cancel' |
|
736 |
name: 'cancelButton' |
|
737 |
level: 2 |
|
738 |
translateLabel: true |
|
739 |
tabable: true |
|
740 |
model: cancel |
|
741 |
extent: (Point 88 21) |
|
742 |
) |
|
743 |
(ActionButtonSpec |
|
744 |
label: 'Prev' |
|
745 |
name: 'prevButton' |
|
746 |
level: 2 |
|
747 |
translateLabel: true |
|
748 |
tabable: true |
|
749 |
model: prevAction |
|
750 |
extent: (Point 89 21) |
|
751 |
) |
|
752 |
(ActionButtonSpec |
|
753 |
label: 'Next' |
|
754 |
name: 'nextButton' |
|
755 |
level: 2 |
|
756 |
borderWidth: 1 |
|
757 |
translateLabel: true |
|
758 |
tabable: true |
|
759 |
model: nextAction |
|
760 |
isDefault: true |
|
761 |
extent: (Point 88 21) |
|
762 |
) |
|
763 |
) |
|
764 |
||
765 |
) |
|
766 |
) |
|
767 |
) |
|
768 |
||
769 |
) |
|
770 |
handles: (Any 0.5 1.0) |
|
771 |
) |
|
772 |
(LabelSpec |
|
773 |
label: 'Replace By:' |
|
774 |
name: 'ReplaceLabel' |
|
775 |
layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0) |
|
776 |
level: 0 |
|
777 |
translateLabel: true |
|
778 |
adjust: left |
|
779 |
) |
|
780 |
) |
|
781 |
||
782 |
) |
|
3431 | 783 |
) |
784 |
||
785 |
"Modified: / 11-10-2006 / 21:05:09 / cg" |
|
786 |
! ! |
|
787 |
||
2744 | 788 |
!EditTextView methodsFor:'Compatibility-ST80'! |
1552
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
789 |
|
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
790 |
autoAccept:aBoolean |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
791 |
"ignored for now" |
d3d4afaf4c68
dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
792 |
|
2019 | 793 |
"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
|
794 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
795 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
796 |
continuousAccept:aBoolean |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
797 |
"ignored for now" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
798 |
|
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
799 |
"Created: / 19.6.1998 / 00:03:49 / cg" |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
800 |
! |
9bf6cf249376
two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
801 |
|
1390 | 802 |
cutSelection |
803 |
self cut |
|
804 |
||
805 |
"Created: / 31.10.1997 / 03:29:50 / cg" |
|
806 |
! |
|
807 |
||
1590 | 808 |
deselect |
809 |
"remove the selection" |
|
810 |
||
811 |
^ self unselect |
|
812 |
||
813 |
"Created: / 19.6.1998 / 02:41:54 / cg" |
|
814 |
! |
|
815 |
||
2101 | 816 |
enabled:aBoolean |
817 |
||
818 |
self readOnly:aBoolean not |
|
819 |
||
820 |
"Created: / 30.3.1999 / 15:10:23 / stefan" |
|
821 |
"Modified: / 30.3.1999 / 15:10:53 / stefan" |
|
822 |
! |
|
823 |
||
1732
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
824 |
find:pattern |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
825 |
self searchFwd:pattern ifAbsent:nil |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
826 |
|
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
827 |
"Created: / 29.1.1999 / 19:09:42 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
828 |
"Modified: / 29.1.1999 / 19:10:12 / cg" |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
829 |
! |
2d433e114bbc
added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1717
diff
changeset
|
830 |
|
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
831 |
insert:aString at:aCharacterPosition |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
832 |
"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
|
833 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
834 |
|line 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 |
line := self lineOfCharacterPosition:aCharacterPosition. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
837 |
col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1. |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
838 |
col < 1 ifTrue:[ |
4823 | 839 |
col := 1 |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
840 |
]. |
1294
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
841 |
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
|
842 |
|
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
843 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
844 |
|top v| |
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 |
top := StandardSystemView new. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
847 |
top extent:300@300. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
848 |
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
|
849 |
top openAndWait. |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
850 |
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
|
851 |
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
|
852 |
" |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
853 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
854 |
"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
|
855 |
! |
dac755d4acd3
added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents:
1292
diff
changeset
|
856 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
857 |
insertAndSelect:aString at:aCharacterPosition |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
858 |
"insert a selected string at aCharacterPosition." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
859 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
860 |
|line col| |
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 |
line := self lineOfCharacterPosition:aCharacterPosition. |
2310 | 863 |
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
|
864 |
self insertString:aString atLine:line col:col. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
865 |
self selectFromLine:line col:col toLine:line col:col + aString size - 1 |
125 | 866 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
867 |
|v| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
868 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
869 |
v := EditTextView new openAndWait. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
870 |
v contents:'1234567890\1234567890\1234567890\' withCRs. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
871 |
v insertAndSelect:'<- hello there' at:5. |
125 | 872 |
" |
1390 | 873 |
! |
874 |
||
875 |
pasteSelection |
|
876 |
self paste |
|
877 |
||
878 |
"Created: / 31.10.1997 / 03:28:53 / cg" |
|
1590 | 879 |
! |
880 |
||
881 |
replaceSelectionWith:aString |
|
882 |
^ self replaceSelectionBy:aString |
|
883 |
||
884 |
"Created: / 19.6.1998 / 02:42:32 / cg" |
|
885 |
! |
|
886 |
||
887 |
selectAt:pos |
|
888 |
"move the cursor before cursorPosition." |
|
889 |
||
890 |
self cursorToCharacterPosition:pos |
|
891 |
||
892 |
"Modified: / 19.6.1998 / 02:41:28 / cg" |
|
893 |
"Created: / 19.6.1998 / 02:43:39 / cg" |
|
894 |
! |
|
895 |
||
2101 | 896 |
textHasChanged |
897 |
^ self modified |
|
898 |
||
899 |
"Created: / 19.6.1998 / 00:09:43 / cg" |
|
2117
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
900 |
! |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
901 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
902 |
textHasChanged:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
903 |
"ST-80 compatibility: set/clear the modified flag." |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
904 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
905 |
self modified:aBoolean |
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
906 |
|
b50c6d182e28
added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2107
diff
changeset
|
907 |
"Created: / 5.2.2000 / 17:07:59 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
908 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
909 |
|
4585 | 910 |
!EditTextView methodsFor:'accessing'! |
911 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
912 |
codeAspect |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
913 |
| codeAspect app | |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
914 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
915 |
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
|
916 |
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
|
917 |
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
|
918 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
919 |
"/ 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
|
920 |
"/ 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
|
921 |
^((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
|
922 |
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
|
923 |
ifFalse:[nil] |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
924 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
925 |
"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
|
926 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
927 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
928 |
codeAspect: aSymbol |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
929 |
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
|
930 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
931 |
"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
|
932 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
933 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
934 |
completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
935 |
^ completionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
936 |
! |
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 |
completionSupport:anEditTextViewCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
939 |
completionSupport := anEditTextViewCompletionSupport. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
940 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
941 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
942 |
completionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
943 |
^ self class defaultCompletionSupportClass |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
944 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
945 |
"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
|
946 |
! |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
947 |
|
4609 | 948 |
editedClass |
949 |
|cm| |
|
950 |
||
951 |
cm := self editedMethodOrClass. |
|
952 |
cm isBehavior ifTrue:[^ cm]. |
|
953 |
cm isMethod ifTrue:[^ cm mclass]. |
|
954 |
^ nil |
|
955 |
! |
|
956 |
||
4775
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
957 |
editedLanguage |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
958 |
^ nil |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
959 |
|
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
960 |
"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
|
961 |
! |
e34752e6214e
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4771
diff
changeset
|
962 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
963 |
editedLanguage: aProgrammingLanguage |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
964 |
"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
|
965 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
966 |
"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
|
967 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
968 |
|
4609 | 969 |
editedMethod |
970 |
|cm| |
|
971 |
||
972 |
cm := self editedMethodOrClass. |
|
973 |
cm isMethod ifTrue:[^ cm]. |
|
974 |
cm isBehavior ifTrue:[^ nil]. |
|
975 |
^ nil |
|
976 |
! |
|
977 |
||
978 |
editedMethodOrClass |
|
979 |
^ nil |
|
980 |
! |
|
981 |
||
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
982 |
editedMethodOrClass: methodOrClass |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
983 |
"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
|
984 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
985 |
"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
|
986 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
987 |
|
4585 | 988 |
hasSelectionOrTextInCursorLine |
989 |
^ (self selectionOrTextOfCursorLine:false) notNil |
|
990 |
! |
|
991 |
||
4589 | 992 |
selectionOrTextOfCursorLine |
993 |
^ self selectionOrTextOfCursorLine:true |
|
994 |
! |
|
995 |
||
4585 | 996 |
selectionOrTextOfCursorLine:doSelect |
997 |
|sel lNr line| |
|
998 |
||
999 |
sel := self selectionAsString. |
|
1000 |
sel notNil ifTrue:[^ sel]. |
|
1001 |
||
1002 |
lNr := self cursorLine. |
|
1003 |
line := self listAt:lNr. |
|
1004 |
line notEmptyOrNil ifTrue:[ |
|
1005 |
doSelect ifTrue:[ |
|
1006 |
self selectLine:lNr. |
|
1007 |
]. |
|
1008 |
^ line |
|
1009 |
]. |
|
1010 |
||
1011 |
^ nil |
|
1012 |
! ! |
|
1013 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1014 |
!EditTextView methodsFor:'accessing-behavior'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1015 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1016 |
acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1017 |
"return the action to be performed on accept (or nil)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1018 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1019 |
^ acceptAction |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1020 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1021 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1022 |
acceptAction:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1023 |
"set the action to be performed on accept" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1024 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1025 |
acceptAction := aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1026 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1027 |
|
2792 | 1028 |
acceptChannel |
1029 |
"return the valueHolder holding true if text was accepted. |
|
1030 |
By placing a true into this channel, an accept can also be forced." |
|
1031 |
||
1032 |
^ acceptChannel |
|
1033 |
||
1034 |
"Modified: / 30.1.1998 / 14:17:11 / cg" |
|
1035 |
! |
|
1036 |
||
1037 |
acceptChannel:aValueHolder |
|
1038 |
"set the valueHolder holding true if text was accepted. |
|
1039 |
By placing a true into this channel, an accept can also be forced." |
|
1040 |
||
1041 |
|prev| |
|
1042 |
||
1043 |
prev := acceptChannel. |
|
1044 |
acceptChannel := aValueHolder. |
|
1045 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1046 |
||
1047 |
"Created: / 30.1.1998 / 14:51:09 / cg" |
|
1048 |
! |
|
1049 |
||
1108 | 1050 |
acceptEnabled:aBoolean |
1051 |
"enable/disable accept. This greys the corresponding item in the menu" |
|
1052 |
||
1053 |
acceptEnabled := aBoolean |
|
1054 |
||
1055 |
"Created: 7.3.1997 / 11:04:34 / cg" |
|
1056 |
! |
|
1057 |
||
2792 | 1058 |
accepted |
1059 |
"return true if text was accepted" |
|
1060 |
||
1061 |
^ acceptChannel value |
|
1062 |
||
1063 |
"Created: 14.2.1997 / 16:43:46 / cg" |
|
1064 |
! |
|
1065 |
||
1066 |
accepted:aBoolean |
|
1067 |
"set/clear the accepted flag. |
|
1068 |
This may force my current contents to be placed into my model." |
|
1069 |
||
1070 |
acceptChannel value:aBoolean. |
|
1071 |
||
1072 |
"Created: / 14.2.1997 / 16:44:01 / cg" |
|
1073 |
"Modified: / 30.1.1998 / 14:20:15 / cg" |
|
1074 |
! |
|
1075 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1076 |
autoIndent:aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1077 |
autoIndent := aBoolean |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1078 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1079 |
"Created: 5.3.1996 / 14:37:50 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1080 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1081 |
|
4803
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1082 |
codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1083 |
^ codeAspectHolder |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1084 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1085 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1086 |
codeAspectHolder:something |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1087 |
codeAspectHolder := something. |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1088 |
! |
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
1089 |
|
2774 | 1090 |
cursorMovementWhenUpdating |
3160 | 1091 |
"return what is be done with the cursor, |
2774 | 1092 |
when I get a new text (via the model or the #contents/#list) |
1093 |
Allowed arguments are: |
|
4823 | 1094 |
#keep / nil -> stay where it was |
1095 |
#endOfText -> position cursor to the end |
|
1096 |
#beginOfText -> position cursor to the beginning |
|
1097 |
#endOfLine -> position cursor to the current lines end |
|
1098 |
#beginOfLine -> position cursor to the current lines start |
|
2774 | 1099 |
The default is #beginOfText. |
1100 |
This may be useful for fields which get new values assigned from |
|
1101 |
the program (i.e. not from the user)" |
|
1102 |
||
1103 |
^ cursorMovementWhenUpdating |
|
1104 |
||
1105 |
"Modified: 16.12.1995 / 16:27:55 / cg" |
|
1106 |
! |
|
1107 |
||
2133 | 1108 |
cursorMovementWhenUpdating:aSymbolOrNil |
3160 | 1109 |
"define what should be done with the cursor, |
2133 | 1110 |
when I get a new text (via the model or the #contents/#list) |
1111 |
Allowed arguments are: |
|
4823 | 1112 |
#keep / nil -> stay where it was |
1113 |
#endOfText -> position cursor to the end |
|
1114 |
#beginOfText -> position cursor to the beginning |
|
1115 |
#endOfLine -> position cursor to the current lines end |
|
1116 |
#beginOfLine -> position cursor to the current lines start |
|
2133 | 1117 |
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
|
1118 |
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
|
1119 |
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
|
1120 |
|
2133 | 1121 |
cursorMovementWhenUpdating := aSymbolOrNil |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1122 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1123 |
"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
|
1124 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1125 |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1126 |
disableIfInvisible:aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1127 |
disableIfInvisible := aBoolean |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1128 |
! |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1129 |
|
2438 | 1130 |
dontReplaceSelectionOnInput |
4742 | 1131 |
"remember that the current selection was created by a paste operation |
1132 |
(as opposed to an explicit selection by the user). |
|
1133 |
This selection will not be replaced by followup user input, |
|
1134 |
so multiple pastes will be possible." |
|
1135 |
||
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
|
1136 |
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
|
1137 |
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
|
1138 |
]. |
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1139 |
|
be32b0744ff3
Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5340
diff
changeset
|
1140 |
"Modified: / 02-05-2015 / 21:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2438 | 1141 |
! |
1142 |
||
3235 | 1143 |
editModeHolder |
1144 |
^ editMode. |
|
1145 |
! |
|
1146 |
||
1147 |
editModeInsert |
|
1148 |
editMode value:EditMode insertMode |
|
1149 |
! |
|
1150 |
||
1151 |
editModeInsertAndSelect |
|
1152 |
editMode value:EditMode insertAndSelectMode |
|
1153 |
! |
|
1154 |
||
1155 |
editModeOverwrite |
|
1156 |
editMode value:EditMode overwriteMode |
|
1157 |
! |
|
1158 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1159 |
exceptionBlock:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1160 |
"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
|
1161 |
readonly text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1162 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1163 |
exceptionBlock := aBlock |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1164 |
! |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1165 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1166 |
fixedSize |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1167 |
"make the texts size fixed (no lines may be added). |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1168 |
OBSOLETE: use readOnly" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1169 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1170 |
<resource:#obsolete> |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1171 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1172 |
|menu| |
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1173 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1174 |
self obsoleteMethodWarning:'use #readOnly:'. |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1175 |
readOnly == true ifFalse:[ |
4823 | 1176 |
readOnly := true. |
1177 |
(menu := self middleButtonMenu) notNil ifTrue:[ |
|
1178 |
menu disableAll:#(cut paste replace indent) |
|
1179 |
] |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1180 |
] |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1181 |
|
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1182 |
"Modified: 14.2.1997 / 17:35:24 / cg" |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1183 |
! |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
1184 |
|
5858 | 1185 |
generateTextAfterEndHook:aBlock |
1186 |
"some applications may want to dynamically generate lines below the bottom line, |
|
1187 |
when the cursor is moved there. |
|
1188 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1189 |
which want to automatically generate additional lines lazily, |
|
1190 |
but which cannot afford to generate the whole text in advance |
|
1191 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1192 |
If set, this hook is called whenever the cursor is about to be moved below the |
5859 | 1193 |
last line, getting the new lineNr (i.e > contents size) as argument. |
5858 | 1194 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1195 |
number, into which the cursor should be moved |
1196 |
(eg. if 10 additional lines are generated, it may want to return oldSize+1, |
|
5858 | 1197 |
to make the cursor end in the last line which was inserted)" |
5890 | 1198 |
|
5858 | 1199 |
self setAttribute:#generateTextAfterEndHook to:aBlock |
1200 |
! |
|
1201 |
||
1202 |
generateTextBeforeStartHook:aBlock |
|
1203 |
"some applications may want to dynamically generate lines above the top |
|
1204 |
line, when the cursor is moved there. |
|
1205 |
For example, disassembly views or memory dumps (hex-dumps), |
|
1206 |
which want to automatically generate additional lines lazily, |
|
1207 |
but which cannot afford to generate the whole text in advance |
|
1208 |
(eg: who wants to disassemble gigabytes?). |
|
5890 | 1209 |
If set, this hook is called whenever the cursor is about to be moved above the |
5859 | 1210 |
top, getting the new lineNr (i.e < 1) as argument. |
5858 | 1211 |
It may generate more text (by setting my contents) and return a new cursor line |
5890 | 1212 |
number, into which the cursor should be moved |
1213 |
(eg. if 10 additional lines are generated, it may want to return 10, to make the |
|
5858 | 1214 |
cursor end in the last line which was inserted)" |
5890 | 1215 |
|
5858 | 1216 |
self setAttribute:#generateTextBeforeStartHook to:aBlock |
1217 |
! |
|
1218 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1219 |
insertMode:aBoolean |
3235 | 1220 |
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
|
1221 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1222 |
"Created: 6.3.1996 / 12:24:05 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1223 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
1224 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1225 |
insertModeHolder |
3235 | 1226 |
^ BlockValue |
4823 | 1227 |
with:[:m | m isInsertMode] |
1228 |
argument:(editMode). |
|
3465 | 1229 |
|
1230 |
"Modified: / 08-03-2007 / 22:58:37 / cg" |
|
3235 | 1231 |
! |
1232 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
1233 |
isInInsertMode |
3235 | 1234 |
^ editMode value isInsertMode |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1235 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
1236 |
|
5216 | 1237 |
isNotReadOnly |
1238 |
"return true, if the text is not readonly." |
|
1239 |
||
1240 |
^ self isReadOnly not |
|
1241 |
! |
|
1242 |
||
2792 | 1243 |
isReadOnly |
1244 |
"return true, if the text is readonly." |
|
1245 |
||
1246 |
^ readOnly value |
|
1247 |
||
1248 |
"Modified: 14.2.1997 / 17:35:56 / cg" |
|
1249 |
! |
|
1250 |
||
2796 | 1251 |
modeLabelHolder |
1252 |
"a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty" |
|
1253 |
||
3160 | 1254 |
^ BlockValue |
4041 | 1255 |
with:[:e :l | |
1256 |
self isReadOnly ifTrue:[ |
|
1257 |
'' |
|
1258 |
] ifFalse:[ |
|
5724 | 1259 |
l ifTrue:[ 'L' allBold withColor:#red] |
4041 | 1260 |
ifFalse:[ e infoPrintString]]] |
1261 |
argument:(self editModeHolder) |
|
1262 |
argument:(self learnModeHolder). |
|
3465 | 1263 |
|
1264 |
"Modified: / 08-03-2007 / 22:58:59 / cg" |
|
2796 | 1265 |
! |
1266 |
||
2792 | 1267 |
modified |
1268 |
"return true if text was modified" |
|
1269 |
||
1270 |
^ modifiedChannel value |
|
1271 |
! |
|
1272 |
||
1273 |
modified:aBoolean |
|
1274 |
"set/clear the modified flag" |
|
1275 |
||
1276 |
modifiedChannel value:aBoolean |
|
1277 |
||
1278 |
"Modified: 14.2.1997 / 16:44:05 / cg" |
|
1279 |
! |
|
1280 |
||
1281 |
modifiedChannel |
|
1282 |
"return the valueHolder holding true if text was modified" |
|
1283 |
||
1284 |
^ modifiedChannel |
|
1285 |
! |
|
1286 |
||
1287 |
modifiedChannel:aValueHolder |
|
1288 |
"set the valueHolder holding true if text was modified" |
|
1289 |
||
1290 |
|prev| |
|
1291 |
||
1292 |
prev := modifiedChannel. |
|
1293 |
modifiedChannel := aValueHolder. |
|
1294 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
1295 |
||
1296 |
"Created: / 30.1.1998 / 14:51:32 / cg" |
|
1297 |
! |
|
1298 |
||
1299 |
readOnly |
|
1300 |
"make the text readonly. |
|
4664 | 1301 |
Obsolete because it is obfuscating (looks like a getter) |
1302 |
- use #readOnly:" |
|
2792 | 1303 |
|
1304 |
<resource:#obsolete> |
|
1305 |
||
1306 |
self obsoleteMethodWarning:'use #readOnly:'. |
|
3705 | 1307 |
self readOnly:true. |
2792 | 1308 |
|
4664 | 1309 |
"Modified: / 14-02-1997 / 17:35:56 / cg" |
1310 |
"Modified (comment): / 02-08-2013 / 16:46:57 / cg" |
|
2792 | 1311 |
! |
1312 |
||
1313 |
readOnly:aBoolean |
|
1314 |
"make the text readonly (aBoolean == true) or writable (aBoolean == false). |
|
1315 |
The argument may also be a valueHolder." |
|
1316 |
||
1317 |
readOnly := aBoolean |
|
1318 |
||
1319 |
"Created: 14.2.1997 / 17:35:39 / cg" |
|
1320 |
! |
|
1321 |
||
4782 | 1322 |
reallyModifiedChannel |
1323 |
"return the valueHolder holding true if text was really modified. |
|
1324 |
For compatibility with views which use the modified flag for syntax highlighting." |
|
1325 |
||
1326 |
^ self modifiedChannel |
|
1327 |
! |
|
1328 |
||
5909 | 1329 |
st80EditMode |
1330 |
"If on, the cursor wraps at the line end (like in vi or st80); |
|
1331 |
if off, we have the Rand-editor behavior (random access)" |
|
1332 |
||
1333 |
^ st80Mode ? (UserPreferences current st80EditMode) |
|
1334 |
! |
|
1335 |
||
1336 |
st80EditMode:aBooleanOrNil |
|
4192 | 1337 |
"set/clear the st80Mode flag. |
1338 |
If on, the cursor wraps at the line end (like in vi or st80); |
|
5255 | 1339 |
if off, we have the Rand-editor behavior (random access) |
1340 |
if nil, the setting follows the current userPref setting." |
|
1341 |
||
1342 |
st80Mode := aBooleanOrNil |
|
4192 | 1343 |
|
1344 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1345 |
! |
|
1346 |
||
5909 | 1347 |
st80Mode:aBooleanOrNil |
1348 |
self obsoleteMethodWarning. |
|
1349 |
self st80EditMode:aBooleanOrNil |
|
1350 |
||
1351 |
"Created: / 09-11-2010 / 13:55:50 / cg" |
|
1352 |
! |
|
1353 |
||
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1354 |
tabMeansNextField:aBoolean |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1355 |
"set/clear tabbing to the next field. |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1356 |
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
|
1357 |
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
|
1358 |
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
|
1359 |
input fields." |
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1360 |
|
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1361 |
tabMeansNextField := aBoolean |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1362 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1363 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1364 |
tabRequiresControl |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1365 |
"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
|
1366 |
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
|
1367 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1368 |
|
3160 | 1369 |
^ tabRequiresControl |
2779
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1370 |
! |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1371 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1372 |
tabRequiresControl:aBoolean |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1373 |
"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
|
1374 |
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
|
1375 |
to allow for easier text entry" |
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1376 |
|
5ca530482fdd
unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
1377 |
tabRequiresControl := aBoolean |
5909 | 1378 |
! |
1379 |
||
1380 |
trimBlankLines |
|
1381 |
"If on, the blank lines are trimmed to zero size; |
|
1382 |
if nil, the setting follows the current userPref setting." |
|
1383 |
||
1384 |
^ trimBlankLines ? (UserPreferences current trimBlankLines) |
|
1385 |
! |
|
1386 |
||
1387 |
trimBlankLines:aBooleanOrNil |
|
1388 |
"If on, the blank lines are trimmed to zero size; |
|
1389 |
if nil, the setting follows the current userPref setting." |
|
1390 |
||
1391 |
trimBlankLines := aBooleanOrNil. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1392 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1393 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1394 |
!EditTextView methodsFor:'accessing-contents'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1395 |
|
1902
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1396 |
at:lineNr basicPut:aLine |
5413 | 1397 |
"change a line without change notification. |
1398 |
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
|
1399 |
|
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1400 |
(self at:lineNr) = aLine ifFalse:[ |
4823 | 1401 |
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
|
1402 |
]. |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1403 |
! |
302a68c2255e
added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents:
1899
diff
changeset
|
1404 |
|
522 | 1405 |
at:lineNr put:aLine |
5413 | 1406 |
"replace a line by something new. |
1407 |
this is not undoably, unless you care for yourself" |
|
1408 |
||
5393 | 1409 |
|oldLine| |
1410 |
||
1411 |
oldLine := (self at:lineNr) ? ''. |
|
1412 |
(oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[ |
|
4823 | 1413 |
super at:lineNr put:aLine. |
1414 |
self textChanged |
|
522 | 1415 |
]. |
1416 |
! |
|
1417 |
||
4700 | 1418 |
characterAfterCursor |
1419 |
"return the character one after the cursor - space if beyond line." |
|
1420 |
||
1421 |
^ self characterAtLine:cursorLine col:cursorCol+1 |
|
1422 |
! |
|
1423 |
||
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1424 |
characterBeforeCursor |
4700 | 1425 |
"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
|
1426 |
|
5142 | 1427 |
cursorCol <= 1 ifTrue:[^ nil]. |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1428 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1429 |
^ self characterAtLine:cursorLine col:cursorCol-1 |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1430 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1431 |
"Created: / 17.6.1998 / 15:16:41 / cg" |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1432 |
! |
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
1433 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1434 |
characterUnderCursor |
2707 | 1435 |
"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
|
1436 |
For non-block cursors, this is the character immediately to the right |
5413 | 1437 |
of the insertion-bar or caret. |
1438 |
For block cursors, this is the highlighted cursor-character" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1439 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1440 |
^ self characterAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1441 |
! |
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 |
contents |
2213 | 1444 |
"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
|
1445 |
|
5988 | 1446 |
|numLines| |
1447 |
||
1448 |
list isNil ifTrue:[^ '']. |
|
1449 |
self trimBlankLines ifTrue:[ |
|
1450 |
self removeTrailingBlankLines. |
|
1451 |
] ifFalse:[ |
|
1452 |
"/ the last line does not count, if the cursor is at |
|
1453 |
"/ the begining |
|
1454 |
cursorCol == 1 ifTrue:[ |
|
1455 |
numLines := list size. |
|
1456 |
cursorLine == numLines ifTrue:[ |
|
1457 |
numLines > 1 ifTrue:[ |
|
1458 |
(self listAt:numLines) isEmptyOrNil ifTrue:[ |
|
1459 |
list grow:numLines-1. |
|
1460 |
]. |
|
1461 |
]. |
|
1462 |
]. |
|
1463 |
]. |
|
1464 |
]. |
|
3707
8f6bc68b9319
changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents:
3705
diff
changeset
|
1465 |
^ super contents. |
3313 | 1466 |
|
1467 |
"Modified: / 04-07-2006 / 19:22:32 / fm" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1468 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1469 |
|
5413 | 1470 |
contents:aStringOrStringCollectionOrNil |
1471 |
"replace the whole contents by something new. |
|
5414 | 1472 |
this is not undoably, unless you care for yourself. |
1473 |
See replaceContentsWith:newContents for an undoable version of this" |
|
5413 | 1474 |
|
1475 |
self contents:aStringOrStringCollectionOrNil keepUndoHistory:false. |
|
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1476 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1477 |
|
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1478 |
contents:something keepUndoHistory:keepUndoHistory |
5414 | 1479 |
"set the contents and optionally clear the undo history. |
1480 |
The contents-change is not undoable." |
|
1481 |
||
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1482 |
super contents:something. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1483 |
keepUndoHistory ifFalse:[ |
4823 | 1484 |
undoSupport resetHistories. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1485 |
]. |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1486 |
! |
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1487 |
|
2213 | 1488 |
contentsAsString |
1489 |
"return the contents as a String (i.e. without emphasis)" |
|
1490 |
||
1491 |
list isNil ifTrue:[^ '']. |
|
1492 |
self removeTrailingBlankLines. |
|
1493 |
^ (list collect:[:each | each isNil ifTrue:[''] |
|
4823 | 1494 |
ifFalse:[each string] |
1495 |
]) asStringWithCRs |
|
2213 | 1496 |
! |
1497 |
||
5067 | 1498 |
contentsAsStringWithTabs |
1499 |
"return the contents as a String (i.e. without emphasis) |
|
1500 |
and with leading spaces replaced by tab characters |
|
1501 |
(i.e. as would be written to a file)" |
|
1502 |
||
1503 |
list isNil ifTrue:[^ '']. |
|
1504 |
self removeTrailingBlankLines. |
|
1505 |
^ (list collect:[:each | |
|
1506 |
each isNil |
|
1507 |
ifTrue:[''] |
|
1508 |
ifFalse:[each string withTabs] |
|
1509 |
]) asStringWithCRs |
|
1510 |
! |
|
1511 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1512 |
cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1513 |
"return the cursors col (1..). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1514 |
This is the absolute col; NOT the visible col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1515 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1516 |
^ cursorCol |
125 | 1517 |
! |
1518 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1519 |
cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1520 |
"return a valueHolder for the cursors column (1..)." |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1521 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1522 |
^ cursorColHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1523 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1524 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1525 |
cursorLine |
3160 | 1526 |
"return the cursors line (1..). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1527 |
This is the absolute line; NOT the visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1528 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1529 |
^ cursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1530 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1531 |
|
5400 | 1532 |
cursorLineAndColumnLabelHolder |
5399 | 1533 |
"return a valueHolder for the cursors line and column as an info string |
1534 |
of the form 'line : col'. |
|
1535 |
This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)" |
|
1536 |
||
1537 |
^ BlockValue |
|
1538 |
with:[:l :c | '%1 : %2' bindWith:l with:c] |
|
1539 |
argument:self cursorLineHolder |
|
1540 |
argument:self cursorColHolder |
|
1541 |
! |
|
1542 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1543 |
cursorLineHolder |
3160 | 1544 |
"return a valueHolder for the cursors line (1..). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1545 |
This is the absolute line; NOT the visible line" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1546 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1547 |
^ cursorLineHolder |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1548 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
1549 |
|
4713 | 1550 |
lineStringBeforeCursor |
1551 |
"return the line's string before the cursor. |
|
1552 |
Pad with spaces up to the cursor position if beyond the end of line" |
|
1553 |
||
1554 |
|line| |
|
1555 |
||
1556 |
line := ((self at:cursorLine) ? '') string. |
|
1557 |
line size < (cursorCol-1) ifTrue:[ |
|
1558 |
^ line paddedTo:(cursorCol-1) |
|
1559 |
]. |
|
1560 |
^ line copyTo:(cursorCol-1) |
|
1561 |
! |
|
1562 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1563 |
list:something |
5413 | 1564 |
"replace the whole contents by something new. |
1565 |
this is not undoably, unless you care for yourself. |
|
1566 |
position cursor home when setting contents" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1567 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1568 |
|prevCursorLine prevCursorCol| |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1569 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1570 |
prevCursorLine := cursorLine. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1571 |
prevCursorCol := cursorCol. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1572 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1573 |
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
|
1574 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1575 |
(cursorMovementWhenUpdating == #endOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1576 |
or:[cursorMovementWhenUpdating == #end]) ifTrue:[ |
4823 | 1577 |
^ self cursorToEndOfText |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1578 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1579 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1580 |
(cursorMovementWhenUpdating == #endOfLine) ifTrue:[ |
4823 | 1581 |
^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1. |
3160 | 1582 |
]. |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1583 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1584 |
(cursorMovementWhenUpdating == #beginOfText |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1585 |
or:[cursorMovementWhenUpdating == #begin]) ifTrue:[ |
4823 | 1586 |
^ self cursorHome |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1587 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1588 |
(cursorMovementWhenUpdating == #beginOfLine) ifTrue:[ |
4823 | 1589 |
^ 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
|
1590 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1591 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
1592 |
"/ 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
|
1593 |
"/ self cursorLine:prevCursorLine col:prevCursorCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1594 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1595 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1596 |
setContents:something |
5413 | 1597 |
"replace the whole contents by something new |
1598 |
AND clear the remembered undo actions" |
|
1599 |
||
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1600 |
|selType| |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1601 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
1602 |
undoSupport resetHistories. |
2955 | 1603 |
|
1476
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1604 |
selType := typeOfSelection. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1605 |
super setContents:something. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1606 |
typeOfSelection := selType. |
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1607 |
|
ac38c8af8585
setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents:
1449
diff
changeset
|
1608 |
"Created: / 31.3.1998 / 23:35:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1609 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1610 |
|
4609 | 1611 |
!EditTextView methodsFor:'accessing-dimensions'! |
1612 |
||
1613 |
xOfCursor |
|
4728 | 1614 |
|point| |
1615 |
||
1616 |
cursorVisibleLine isNil ifTrue:[ |
|
1617 |
"/ take the end of the selection, if any |
|
1618 |
(selectionStartLine notNil |
|
1619 |
and:[ self listLineIsVisible:selectionEndLine ]) |
|
1620 |
ifTrue:[ |
|
1621 |
^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine. |
|
1622 |
]. |
|
1623 |
||
1624 |
"/ point := device |
|
1625 |
"/ translatePoint:(device pointerPosition) |
|
1626 |
"/ fromView:nil |
|
1627 |
"/ toView:self. |
|
1628 |
"/ ((self bounds) containsPoint:point) ifTrue:[ |
|
1629 |
"/ ^ point x |
|
1630 |
"/ ]. |
|
1631 |
"/ ^ 0 |
|
1632 |
^ nil |
|
1633 |
]. |
|
4609 | 1634 |
^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine. |
1635 |
||
1636 |
"Created: / 27-05-2005 / 07:43:41 / janfrog" |
|
1637 |
! ! |
|
4590 | 1638 |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1639 |
!EditTextView methodsFor:'accessing-look'! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1640 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1641 |
cursorForegroundColor:color1 backgroundColor:color2 |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1642 |
"set both cursor foreground and cursor background colors" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1643 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1644 |
|wasOn| |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1645 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1646 |
wasOn := self hideCursor. |
5643 | 1647 |
cursorFgColor := color1 onDevice:device. |
1648 |
cursorBgColor := color2 onDevice:device. |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1649 |
wasOn ifTrue:[self showCursor] |
1333 | 1650 |
! |
1651 |
||
1899 | 1652 |
cursorType |
1653 |
"return the style of the text cursor. |
|
4721 | 1654 |
Currently, supported are: #none |
1655 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1656 |
#bigCaret and #bigSolidCaret" |
|
1899 | 1657 |
|
1658 |
^ cursorType |
|
1659 |
||
1660 |
"Modified: / 5.5.1999 / 14:52:33 / cg" |
|
1661 |
! |
|
1662 |
||
1333 | 1663 |
cursorType:aCursorTypeSymbol |
1664 |
"set the style of the text cursor. |
|
4721 | 1665 |
Currently, supported are: #none |
1666 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
1667 |
#bigCaret and #bigSolidCaret" |
|
1333 | 1668 |
|
1334 | 1669 |
cursorType := aCursorTypeSymbol. |
1333 | 1670 |
|
1671 |
"Created: 21.9.1997 / 13:42:23 / cg" |
|
1672 |
"Modified: 21.9.1997 / 13:43:35 / cg" |
|
1334 | 1673 |
! |
1674 |
||
1899 | 1675 |
cursorTypeNoFocus |
1676 |
"return the style of the text cursor when the view has no focus. |
|
1677 |
If left unspecified, this is the same as the regular cursorType." |
|
1678 |
||
1679 |
^ cursorTypeNoFocus |
|
1680 |
||
1681 |
"Created: / 5.5.1999 / 14:52:46 / cg" |
|
1682 |
! |
|
1683 |
||
1334 | 1684 |
cursorTypeNoFocus:aCursorTypeSymbol |
1685 |
"set the style of the text cursor when the view has no focus. |
|
1686 |
If left unspecified, this is the same as the regular cursorType." |
|
1687 |
||
1688 |
cursorTypeNoFocus := aCursorTypeSymbol |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1689 |
! ! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1690 |
|
4048 | 1691 |
!EditTextView methodsFor:'accessing-replace'! |
1692 |
||
4746 | 1693 |
lastReplacementInfo |
1694 |
^ lastReplacementInfo |
|
1695 |
! |
|
1696 |
||
4048 | 1697 |
lastStringToReplace: aString |
4818 | 1698 |
! |
1699 |
||
1700 |
previousReplacements |
|
1701 |
"accessor for the code completion" |
|
1702 |
||
1703 |
^ lastReplacementInfo previousReplacements |
|
4048 | 1704 |
! ! |
1705 |
||
2119 | 1706 |
!EditTextView methodsFor:'change & update'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1707 |
|
125 | 1708 |
accept |
1709 |
"accept the current contents by executing the accept-action and/or |
|
5937 | 1710 |
changeMessage. |
1711 |
Historically, ST/X used a callBack (acceptAction); |
|
1712 |
and ST80/VW used the model, into which the text is stored. |
|
1713 |
We support both; if there is a mode, it gets a value: message, |
|
1714 |
If there is an acceptAction, it is called." |
|
125 | 1715 |
|
1108 | 1716 |
acceptEnabled == false ifTrue:[ |
5937 | 1717 |
self beep. |
1718 |
^ self |
|
2035
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1719 |
]. |
6924861adf08
added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents:
2029
diff
changeset
|
1720 |
(disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[ |
5937 | 1721 |
^ self |
1108 | 1722 |
]. |
1723 |
||
125 | 1724 |
lockUpdates := true. |
1013 | 1725 |
|
1726 |
"/ |
|
1727 |
"/ ST-80 way of doing it |
|
1728 |
"/ |
|
1729 |
model notNil ifTrue:[ |
|
5937 | 1730 |
self sendChangeMessage:changeMsg with:self argForChangeMessage. |
1731 |
acceptChannel notNil ifTrue:[ |
|
1732 |
acceptChannel value:true withoutNotifying:self. |
|
5525 | 1733 |
]. |
2999 | 1734 |
]. |
1735 |
||
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1736 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1737 |
"/ ST/X way of doing things |
5937 | 1738 |
"/ as a historic leftover, |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1739 |
"/ 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
|
1740 |
"/ - not with the actual string |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1741 |
"/ |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1742 |
acceptAction notNil ifTrue:[ |
5937 | 1743 |
acceptAction value:self list |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1744 |
]. |
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1745 |
|
125 | 1746 |
lockUpdates := false. |
757
2cc7e423f0ef
only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents:
730
diff
changeset
|
1747 |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1748 |
"Modified: / 30.1.1998 / 14:19:00 / cg" |
131 | 1749 |
! |
1750 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1751 |
argForChangeMessage |
597 | 1752 |
"return the argument to be passed with the change notification. |
1753 |
Defined as separate method for easier subclassability." |
|
1754 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1755 |
^ self contents |
597 | 1756 |
|
1757 |
"Modified: 29.4.1996 / 12:42:14 / cg" |
|
121 | 1758 |
! |
1759 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1760 |
getListFromModel |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1761 |
"get my contents from the model. |
597 | 1762 |
Redefined to ignore updates resulting from my own changes |
1763 |
(i.e. if lockUpdates is true)." |
|
121 | 1764 |
|
1765 |
" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1766 |
ignore updates from my own change |
121 | 1767 |
" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
1768 |
lockUpdates ifTrue:[ |
4823 | 1769 |
lockUpdates := false. |
1770 |
^ self |
|
121 | 1771 |
]. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1772 |
super getListFromModel. |
3249
a4beb76b3f59
code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents:
3241
diff
changeset
|
1773 |
undoSupport resetHistories. |
2196
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1774 |
|
f8c955dd6eb9
validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents:
2186
diff
changeset
|
1775 |
"/ validate the cursorLine |
3160 | 1776 |
(cursorLine notNil |
2310 | 1777 |
and:[ cursorLine > list size ]) ifTrue:[ |
4823 | 1778 |
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
|
1779 |
]. |
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1780 |
! |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1781 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1782 |
update:something with:aParameter from:changedObject |
1438
bed1564b0640
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1437
diff
changeset
|
1783 |
changedObject == acceptChannel ifTrue:[ |
4823 | 1784 |
acceptChannel value == true ifTrue:[ |
1785 |
self accept. |
|
1786 |
]. |
|
1787 |
^ self. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1788 |
]. |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1789 |
super update:something with:aParameter from:changedObject |
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1790 |
|
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
1791 |
"Created: / 30.1.1998 / 14:15:56 / cg" |
1439
d1b3ca91ed8a
fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents:
1438
diff
changeset
|
1792 |
"Modified: / 1.2.1998 / 13:15:55 / cg" |
121 | 1793 |
! ! |
1794 |
||
6015 | 1795 |
!EditTextView methodsFor:'commenting'! |
1796 |
||
1797 |
commentFrom:line1 to:line2 commentStrings:commentStrings |
|
1798 |
"helper function to comment out a block. |
|
1799 |
All lines from line1 to line2 get an end-of-line comment |
|
1800 |
in the first col |
|
1801 |
(if no eol comment is available, a bracketing comment is used)." |
|
1802 |
||
1803 |
|eolComment opening closing| |
|
1804 |
||
1805 |
eolComment := commentStrings at:1. |
|
1806 |
eolComment isNil ifTrue:[ |
|
1807 |
opening := (commentStrings at:2) at:1. |
|
1808 |
closing := (commentStrings at:2) at:2. |
|
1809 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1810 |
]. |
|
1811 |
||
1812 |
line1 to:line2 do:[:lineNr | |
|
1813 |
|l| |
|
1814 |
||
1815 |
l := self listAt:lineNr. |
|
1816 |
l isNil ifTrue:[l := '']. |
|
1817 |
eolComment notNil ifTrue:[ |
|
1818 |
l := eolComment , l |
|
1819 |
] ifFalse:[ |
|
1820 |
l := opening , l , closing |
|
1821 |
]. |
|
1822 |
self replaceLine:lineNr with:l. |
|
1823 |
widthOfWidestLine notNil ifTrue:[ |
|
1824 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1825 |
]. |
|
1826 |
]. |
|
1827 |
self textChanged. |
|
1828 |
||
1829 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
|
1830 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1831 |
! |
|
1832 |
||
1833 |
commentSelection:commentStrings |
|
1834 |
"convenient function to comment out a block. |
|
1835 |
All lines from line1 to line2 get an end-of-line comment |
|
1836 |
in the first col." |
|
1837 |
||
1838 |
|e commentPair opening closing| |
|
1839 |
||
1840 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
1841 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
|
1842 |
||
1843 |
self |
|
1844 |
undoableDo:[ |
|
1845 |
selectionStartLine isNil ifTrue:[ |
|
1846 |
self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1847 |
] ifFalse:[ |
|
1848 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1849 |
self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1850 |
] ifFalse:[ |
|
1851 |
commentPair := commentStrings at:2 ifAbsent:nil. |
|
1852 |
commentPair isNil ifTrue:[ |
|
1853 |
self beep. |
|
1854 |
] ifFalse:[ |
|
1855 |
opening := commentPair at:1. |
|
1856 |
closing := commentPair at:2. |
|
1857 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1858 |
||
1859 |
e := selectionEndCol. |
|
1860 |
||
1861 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1862 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
1863 |
||
1864 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
|
1865 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1866 |
toLine:selectionEndLine col:e+closing size. |
|
1867 |
] |
|
1868 |
] |
|
1869 |
]. |
|
1870 |
] |
|
1871 |
info:'Comment'. |
|
1872 |
||
1873 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
|
1874 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
|
1875 |
! |
|
1876 |
||
1877 |
uncommentFrom:line1 to:line2 commentStrings:commentStrings |
|
1878 |
"helper function to comment out a block. |
|
1879 |
All lines from line1 to line2 get an end-of-line comment |
|
1880 |
in the first col. |
|
1881 |
(if no eol comment is available, a bracketing comment is removed)." |
|
1882 |
||
1883 |
|eolComment opening closing rest| |
|
1884 |
||
1885 |
eolComment := commentStrings at:1. |
|
1886 |
eolComment isNil ifTrue:[ |
|
1887 |
opening := (commentStrings at:2) at:1. |
|
1888 |
closing := (commentStrings at:2) at:2. |
|
1889 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1890 |
] ifFalse:[ |
|
1891 |
rest := eolComment size + 1. |
|
1892 |
]. |
|
1893 |
||
1894 |
line1 to:line2 do:[:lineNr | |
|
1895 |
|l| |
|
1896 |
||
1897 |
l := self listAt:lineNr. |
|
1898 |
l notNil ifTrue:[ |
|
1899 |
eolComment notNil ifTrue:[ |
|
1900 |
(l startsWith:eolComment) ifTrue:[ |
|
1901 |
l := l copyFrom:rest |
|
1902 |
] ifFalse:[ |
|
1903 |
(l withoutLeadingSeparators startsWith:eolComment) ifTrue:[ |
|
1904 |
"/ only for single lines? |
|
1905 |
true "line1 = line2" ifTrue:[ |
|
1906 |
|numSpaces| |
|
1907 |
||
1908 |
numSpaces := l indexOfNonSeparator - 1. |
|
1909 |
l := l copyFrom:numSpaces+1+rest. |
|
1910 |
l := (String new:numSpaces),l |
|
1911 |
]. |
|
1912 |
]. |
|
1913 |
] |
|
1914 |
] ifFalse:[ |
|
1915 |
((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[ |
|
1916 |
l := l copyFrom:opening size + 1. |
|
1917 |
l := l copyButLast:closing size. |
|
1918 |
]. |
|
1919 |
]. |
|
1920 |
self replaceLine:lineNr with:l. |
|
1921 |
] |
|
1922 |
]. |
|
1923 |
||
1924 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
1925 |
self textChanged. |
|
1926 |
! |
|
1927 |
||
1928 |
uncommentSelection:commentStrings |
|
1929 |
"convenient function to comment out a block. |
|
1930 |
All lines from line1 to line2 get an end-of-line comment |
|
1931 |
in the first col." |
|
1932 |
||
1933 |
|e commentPair opening closing sz1 sz2 l1 l2 c1 c2| |
|
1934 |
||
1935 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
|
1936 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
|
1937 |
||
1938 |
self |
|
1939 |
undoableDo:[ |
|
1940 |
selectionStartLine isNil ifTrue:[ |
|
1941 |
self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings |
|
1942 |
] ifFalse:[ |
|
1943 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1944 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings |
|
1945 |
] ifFalse:[ |
|
1946 |
commentPair := commentStrings at:2. |
|
1947 |
opening := commentPair at:1. |
|
1948 |
closing := commentPair at:2. |
|
1949 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1950 |
||
1951 |
sz1 := opening size. |
|
1952 |
sz2 := closing size. |
|
1953 |
||
1954 |
((self |
|
1955 |
stringAtLine:selectionStartLine |
|
1956 |
from:selectionStartCol |
|
1957 |
to:selectionStartCol+sz1 - 1) = opening |
|
1958 |
and:[(self |
|
1959 |
stringAtLine:selectionEndLine |
|
1960 |
from:selectionEndCol - sz2 + 1 |
|
1961 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1962 |
||
1963 |
l2 := selectionEndLine. c2 := selectionEndCol. |
|
1964 |
l1 := selectionStartLine. c1 := selectionStartCol. |
|
1965 |
self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2. |
|
1966 |
self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1. |
|
1967 |
||
1968 |
e := c2 - sz2. |
|
1969 |
l1 == l2 ifTrue:[e := e - sz1]. |
|
1970 |
self selectFromLine:l1 col:c1 toLine:l2 col:e. |
|
1971 |
] |
|
1972 |
] |
|
1973 |
]. |
|
1974 |
] |
|
1975 |
info:'Uncomment'. |
|
1976 |
||
1977 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
|
1978 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
|
1979 |
! ! |
|
1980 |
||
121 | 1981 |
!EditTextView methodsFor:'cursor handling'! |
1982 |
||
4820 | 1983 |
basicCursorReturn |
1984 |
"move cursor to start of next line; scroll if at end of visible text" |
|
1985 |
||
1986 |
|wasOn| |
|
1987 |
||
1988 |
self checkForExistingLine:(cursorLine + 1). |
|
1989 |
cursorVisibleLine notNil ifTrue:[ |
|
1990 |
nFullLinesShown notNil ifTrue:[ |
|
1991 |
(cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown] |
|
1992 |
] |
|
1993 |
]. |
|
1994 |
||
1995 |
wasOn := self hideCursor. |
|
1996 |
self setValidatedCursorLine:(cursorLine + 1) col:1. |
|
1997 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1998 |
||
1999 |
"Modified: 22.5.1996 / 18:27:34 / cg" |
|
2000 |
! |
|
2001 |
||
2406 | 2002 |
characterPositionOfCursor |
2003 |
^ self characterPositionOfLine:cursorLine col:cursorCol |
|
2004 |
! |
|
2005 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2006 |
cursorBacktab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2007 |
"move cursor to prev tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2008 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2009 |
self cursorCol:(self prevTabBefore:cursorCol). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2010 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2011 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2012 |
cursorCol:newCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2013 |
"move cursor to some column in the current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2014 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2015 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2016 |
|
2822 | 2017 |
(cursorCol == newCol) ifTrue:[^ self]. |
2018 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2019 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2020 |
self setValidatedCursorCol:newCol. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2021 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2022 |
|
2023 |
"Modified: 22.5.1996 / 14:25:53 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2024 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2025 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2026 |
cursorDown |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2027 |
"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
|
2028 |
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
|
2029 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2030 |
|wasOn| |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2031 |
|
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2032 |
self cursorDown:1. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2033 |
|
2707 | 2034 |
"/ cursor beyond text ? |
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2035 |
cursorLine > list size ifTrue:[ |
4595 | 2036 |
wasOn := self hideCursor. |
2037 |
self setValidatedCursorLine:(list size + 1) col:cursorCol. |
|
2038 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2039 |
self beep. |
|
632
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2040 |
]. |
5af2c22002e4
dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
2041 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2042 |
"Modified: / 10.6.1998 / 17:00:23 / cg" |
259
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2045 |
cursorDown:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2046 |
"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
|
2047 |
|
5857 | 2048 |
|inLastLine wasOn nv nL cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2049 |
|
4595 | 2050 |
(nL := cursorLine) isNil ifTrue:[ |
5857 | 2051 |
nL := firstLineShown |
2052 |
]. |
|
2053 |
||
2054 |
inLastLine := (nL == list size). |
|
5890 | 2055 |
|
5857 | 2056 |
inLastLine ifTrue:[ |
5858 | 2057 |
|generateTextAfterEndHook| |
5857 | 2058 |
|
2059 |
cursorColBefore := cursorCol. |
|
5858 | 2060 |
(generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[ |
5860 | 2061 |
wasOn := self hideCursor. |
2062 |
nL := generateTextAfterEndHook value:(nL + n). |
|
2063 |
self setValidatedCursorLine:nL col:cursorColBefore. |
|
2064 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2065 |
^ self. |
|
5890 | 2066 |
]. |
4595 | 2067 |
]. |
2068 |
||
2069 |
self st80EditMode ifTrue:[ |
|
5857 | 2070 |
nL == list size ifTrue:[ |
2071 |
wasOn := self hideCursor. |
|
2072 |
self setValidatedCursorLine:nL col:(self listAt:nL) size + 1. |
|
2073 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2074 |
self beep. |
|
2075 |
^ self. |
|
2076 |
] |
|
4595 | 2077 |
]. |
2078 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2079 |
cursorVisibleLine notNil ifTrue:[ |
5857 | 2080 |
wasOn := self hideCursor. |
2081 |
nv := cursorVisibleLine + n - 1. |
|
2082 |
(nv >= nFullLinesShown) ifTrue:[ |
|
2083 |
self scrollDown:(nv - nFullLinesShown + 1) |
|
2084 |
]. |
|
2085 |
self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol). |
|
2086 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2087 |
] ifFalse:[ |
5857 | 2088 |
self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol). |
2089 |
self makeCursorVisible. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2090 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
2091 |
|
1561
db5f27354172
make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
2092 |
"Modified: / 10.6.1998 / 16:59:17 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2093 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2094 |
|
121 | 2095 |
cursorHome |
597 | 2096 |
"scroll to top AND move cursor to first line of text." |
121 | 2097 |
|
674 | 2098 |
self cursorLine:1 col:1 |
2099 |
||
2100 |
"/ |wasOn| |
|
2101 |
"/ |
|
2102 |
"/ wasOn := self hideCursor. |
|
2103 |
"/ self scrollToTop. |
|
2104 |
"/ cursorLine := cursorVisibleLine := 1. |
|
2105 |
"/ cursorCol := self validateCursorCol:1 inLine:cursorLine. |
|
2106 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
2107 |
||
2108 |
"Modified: 22.5.1996 / 18:26:42 / cg" |
|
121 | 2109 |
! |
2110 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2111 |
cursorLeft |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2112 |
"move cursor to left" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2113 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2114 |
(cursorCol ~~ 1) ifTrue:[ |
4823 | 2115 |
self cursorCol:(cursorCol - 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2116 |
] ifFalse:[ |
4823 | 2117 |
cursorLine ~~ 1 ifTrue:[ |
2118 |
self st80EditMode ifTrue:[ |
|
2119 |
self cursorUp. |
|
2120 |
self cursorToEndOfLine. |
|
2121 |
] |
|
2122 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2123 |
] |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2124 |
|
1426
de76570ba19e
crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
2125 |
"Modified: / 23.1.1998 / 12:37:13 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2126 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2127 |
|
4126 | 2128 |
cursorLeft:n |
2129 |
"move cursor to left" |
|
2130 |
||
2131 |
n timesRepeat:[ |
|
2132 |
self cursorLeft |
|
2133 |
]. |
|
2134 |
! |
|
2135 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2136 |
cursorLine:line col:col |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2137 |
"this positions onto physical - not visible - line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2138 |
|
5056 | 2139 |
self cursorLine:line col:col makeVisible:true |
2140 |
! |
|
2141 |
||
2142 |
cursorLine:line col:col makeVisible:makeVisibleBoolean |
|
2143 |
"this positions onto physical - not visible - line" |
|
2144 |
||
676 | 2145 |
|wasOn newCol| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2146 |
|
2822 | 2147 |
((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self]. |
2148 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2149 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2150 |
self setValidatedCursorLine:line. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2151 |
|
672 | 2152 |
(col < 1) ifTrue:[ |
4823 | 2153 |
newCol := 1 |
672 | 2154 |
] ifFalse:[ |
4823 | 2155 |
newCol := col. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2156 |
]. |
2647
23dca8f032c3
changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents:
2627
diff
changeset
|
2157 |
self st80EditMode ifTrue:[ |
4823 | 2158 |
(cursorLine == list size |
2159 |
and:[cursorLine ~~ line]) ifTrue:[ |
|
2160 |
newCol := (self listAt:(list size)) size + 1. |
|
2161 |
] |
|
1419 | 2162 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2163 |
self setValidatedCursorCol:newCol. |
5056 | 2164 |
makeVisibleBoolean ifTrue:[ |
2165 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
2166 |
] ifFalse:[ |
|
2167 |
wasOn ifTrue:[self showCursor] |
|
2168 |
]. |
|
672 | 2169 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2170 |
"Modified: / 20.6.1998 / 18:19:06 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2171 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2172 |
|
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2173 |
cursorMovementAllowed |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2174 |
"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
|
2175 |
(via button-click, or cursor-key with selection). |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2176 |
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
|
2177 |
in special subclasses (such as a terminal view), where |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2178 |
this is not wanted" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2179 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2180 |
^ true |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2181 |
|
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2182 |
"Created: / 18.6.1998 / 14:11:16 / cg" |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2183 |
! |
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
2184 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2185 |
cursorReturn |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2186 |
"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
|
2187 |
|
4820 | 2188 |
self basicCursorReturn |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2189 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2190 |
|
5529 | 2191 |
cursorReturn:withPossibleAutoIndent |
2192 |
"move cursor to start of next line; scroll if at end of visible text" |
|
2193 |
||
2194 |
self basicCursorReturn |
|
2195 |
! |
|
2196 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2197 |
cursorRight |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2198 |
"move cursor to right" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2199 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2200 |
|l| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2201 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2202 |
self st80EditMode ifTrue:[ |
4823 | 2203 |
l := (self listAt:cursorLine). |
2204 |
cursorCol >= (l size + 1) ifTrue:[ |
|
5529 | 2205 |
cursorLine <= list size ifTrue:[ |
2206 |
self cursorReturn:false. "/ no autoindent |
|
4823 | 2207 |
]. |
2208 |
^ self |
|
2209 |
] |
|
3160 | 2210 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2211 |
self cursorCol:(cursorCol + 1) |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2212 |
|
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
2213 |
"Modified: / 20.6.1998 / 18:19:07 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2214 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2215 |
|
4126 | 2216 |
cursorRight:n |
2217 |
"move cursor to right" |
|
2218 |
||
2219 |
n timesRepeat:[ |
|
2220 |
self cursorRight |
|
2221 |
]. |
|
2222 |
! |
|
2223 |
||
1833 | 2224 |
cursorShown:aBoolean |
2225 |
"change cursor visibility |
|
2226 |
return true if cursor was visible before." |
|
2227 |
||
2228 |
|oldState| |
|
2229 |
||
4494 | 2230 |
aBoolean == cursorShown ifTrue:[ |
2231 |
^ cursorShown |
|
2232 |
]. |
|
1833 | 2233 |
oldState := cursorShown. |
2234 |
||
2235 |
aBoolean ifTrue:[ |
|
4494 | 2236 |
self drawCursor. |
1833 | 2237 |
] ifFalse:[ |
4494 | 2238 |
(cursorShown and:[shown]) ifTrue: [ |
2239 |
self undrawCursor. |
|
2240 |
]. |
|
1833 | 2241 |
]. |
2242 |
cursorShown := aBoolean. |
|
2243 |
||
2244 |
^ oldState |
|
2245 |
||
2246 |
"Modified: / 30.3.1999 / 15:32:43 / stefan" |
|
2247 |
"Created: / 30.3.1999 / 15:59:30 / stefan" |
|
2248 |
! |
|
2249 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2250 |
cursorTab |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2251 |
"move cursor to next tabstop" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2252 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2253 |
self cursorCol:(self nextTabAfter:cursorCol). |
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 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2256 |
cursorToBeginOfLine |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2257 |
"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
|
2258 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2259 |
|textStart l| |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2260 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2261 |
l := self listAt:cursorLine. |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2262 |
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
|
2263 |
cursorCol > textStart ifTrue:[ |
4823 | 2264 |
self cursorCol:textStart |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2265 |
] ifFalse:[ |
4823 | 2266 |
self cursorCol:1 |
3020
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2267 |
] |
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2268 |
|
68a2dfad4e5e
CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
2269 |
"Created: / 8.8.2004 / 18:51:21 / janfrog" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2270 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2271 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2272 |
cursorToBottom |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2273 |
"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
|
2274 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2275 |
|wasOn newTop| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2276 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2277 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2278 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2279 |
newTop := list size - nFullLinesShown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2280 |
(newTop < 1) ifTrue:[ |
4823 | 2281 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2282 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2283 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2284 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2285 |
self setValidatedCursorLine:(list size) col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2286 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2287 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2288 |
|
674 | 2289 |
"Modified: 22.5.1996 / 18:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2290 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2291 |
|
1415
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2292 |
cursorToCharacterPosition:pos |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2293 |
"compute line/col from character position (1..) |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2294 |
and move the cursor onto that char" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2295 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2296 |
|line col| |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2297 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2298 |
line := self lineOfCharacterPosition:pos. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2299 |
col := pos - (self characterPositionOfLine:line col:1) + 1. |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2300 |
self cursorLine:line col:col |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2301 |
|
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2302 |
"Created: / 15.1.1998 / 21:55:33 / cg" |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2303 |
! |
f75eeebc0d1d
added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1390
diff
changeset
|
2304 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2305 |
cursorToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2306 |
"move cursor down below last line of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2307 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2308 |
|wasOn newTop lineNr line| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2309 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2310 |
lineNr := list size. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2311 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2312 |
cursorLine >= lineNr ifTrue:[ |
4823 | 2313 |
line := self listAt:cursorLine. |
2314 |
(line isEmptyOrNil) ifTrue:[ |
|
2315 |
^ self |
|
2316 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2317 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2318 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2319 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2320 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2321 |
lineNr := lineNr + 1. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2322 |
newTop := lineNr - nFullLinesShown. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2323 |
(newTop < 1) ifTrue:[ |
4823 | 2324 |
newTop := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2325 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2326 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2327 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2328 |
self setValidatedCursorLine:lineNr col:1. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2329 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2330 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2331 |
|
674 | 2332 |
"Modified: 22.5.1996 / 18:27:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2333 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2334 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2335 |
cursorToEndOfLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2336 |
"move cursor to end of current line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2337 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2338 |
|line| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2339 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2340 |
line := (self listAt:cursorLine). |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2341 |
self cursorCol:(line size + 1) |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2342 |
|
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2343 |
"Modified: 13.8.1997 / 15:34:02 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2344 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2345 |
|
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2346 |
cursorToEndOfText |
4288 | 2347 |
"move cursor to the end of the text (behind the last character in last line)" |
2348 |
||
2349 |
|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
|
2350 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2351 |
wasOn := self hideCursor. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2352 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2353 |
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
|
2354 |
(newTop < 1) ifTrue:[ |
4288 | 2355 |
newTop := 1 |
2129
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2356 |
]. |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2357 |
self scrollToLine:newTop. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2358 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2359 |
self setValidatedCursorLine:list size. |
4288 | 2360 |
lastLineLength := (self listAt:cursorLine) size. |
2361 |
pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1]. |
|
2362 |
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
|
2363 |
|
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2364 |
self makeCursorVisibleAndShowCursor:wasOn. |
4288 | 2365 |
|
4289
d74f746d4c0d
comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents:
4288
diff
changeset
|
2366 |
"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
|
2367 |
! |
989228af033d
added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents:
2121
diff
changeset
|
2368 |
|
3310 | 2369 |
cursorToEndOfWord |
2370 |
"move the cursor to the end of the word" |
|
2371 |
||
2372 |
(cursorLine > list size) ifTrue:[^ self]. |
|
2373 |
||
2374 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2375 |
:beginLine :beginCol :endLine :endCol :style | |
2376 |
||
2377 |
self cursorLine:endLine col:endCol+1 |
|
3310 | 2378 |
] |
2379 |
||
2380 |
"Created: / 28-06-2006 / 19:16:30 / cg" |
|
2381 |
! |
|
2382 |
||
131 | 2383 |
cursorToFirstVisibleLine |
2384 |
"place cursor into the first visible line; do not scroll." |
|
2385 |
||
2386 |
self cursorLine:(self visibleLineToAbsoluteLine:1) col:1 |
|
2387 |
! |
|
2388 |
||
2389 |
cursorToLastVisibleLine |
|
2390 |
"place cursor into the first visible line; do not scroll." |
|
2391 |
||
2392 |
self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1 |
|
2393 |
! |
|
2394 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2395 |
cursorToNextWord |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2396 |
"move the cursor to the beginning of the next word" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2397 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2398 |
|col line searching| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2399 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2400 |
(cursorLine > list size) ifTrue:[^ self]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2401 |
|
3890 | 2402 |
self |
4707 | 2403 |
wordAtLine:cursorLine col:cursorCol |
2404 |
do:[ |
|
3890 | 2405 |
:beginLine :beginCol :endLine :endCol :style | |
2406 |
||
2407 |
line := endLine. |
|
2408 |
col := endCol + 1. |
|
2409 |
searching := true. |
|
4707 | 2410 |
[searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[ |
3890 | 2411 |
self wordAtLine:line col:col do:[ |
2412 |
:beginLine :beginCol :endLine :endCol :style | |
|
2413 |
||
2414 |
(line > list size) ifTrue:[ |
|
2415 |
"break out" |
|
2416 |
searching := false |
|
2417 |
] ifFalse:[ |
|
2418 |
line := endLine. |
|
2419 |
col := endCol + 1. |
|
2420 |
] |
|
2421 |
] |
|
2422 |
]. |
|
2423 |
self cursorLine:line col:col |
|
4707 | 2424 |
] |
121 | 2425 |
! |
2426 |
||
499 | 2427 |
cursorToPreviousWord |
2428 |
"move the cursor to the beginning of this or the previous word" |
|
2429 |
||
2430 |
|col line searching l| |
|
2431 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2432 |
(cursorLine > list size) ifTrue:[^ self]. "/ this is rubbish |
499 | 2433 |
|
2434 |
self wordAtLine:cursorLine col:cursorCol do:[ |
|
4823 | 2435 |
:beginLine :beginCol :endLine :endCol :style | |
2436 |
||
2437 |
line := beginLine. |
|
2438 |
col := beginCol. |
|
2439 |
style == #wordLeft ifTrue:[ |
|
2440 |
col := col + 1 |
|
2441 |
]. |
|
2442 |
||
2443 |
(cursorLine == line |
|
2444 |
and:[cursorCol == col]) ifTrue:[ |
|
2445 |
searching := true. |
|
2446 |
||
2447 |
col > 1 ifTrue:[ |
|
2448 |
col := col - 1. |
|
2449 |
]. |
|
2450 |
||
2451 |
[searching] whileTrue:[ |
|
2452 |
(col == 1) ifTrue:[ |
|
2453 |
line == 1 ifTrue:[ |
|
2454 |
searching := false |
|
2455 |
] ifFalse:[ |
|
2456 |
line := line - 1. |
|
2457 |
l := list at:line. |
|
2458 |
col := l size + 1. |
|
2459 |
] |
|
2460 |
] ifFalse:[ |
|
2461 |
(self characterAtLine:line col:col) isSeparator ifFalse:[ |
|
2462 |
self wordAtLine:line col:col do:[ |
|
2463 |
:beginLine :beginCol :endLine :endCol :style | |
|
2464 |
||
2465 |
line := beginLine. |
|
2466 |
col := beginCol. |
|
2467 |
style == #wordLeft ifTrue:[ |
|
2468 |
col := col + 1 |
|
2469 |
]. |
|
2470 |
searching := false. |
|
2471 |
] |
|
2472 |
] ifTrue:[ |
|
2473 |
col := col - 1 |
|
2474 |
] |
|
2475 |
] |
|
2476 |
] |
|
2477 |
]. |
|
2478 |
self cursorLine:line col:col |
|
499 | 2479 |
] |
2480 |
||
2481 |
"Created: 8.3.1996 / 21:52:48 / cg" |
|
2482 |
"Modified: 8.3.1996 / 22:12:45 / cg" |
|
2483 |
! |
|
2484 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2485 |
cursorToTop |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2486 |
"move cursor to absolute home" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2487 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2488 |
self cursorLine:1 col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2489 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2490 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2491 |
cursorUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2492 |
"move cursor up; scroll if at start of visible text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2493 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2494 |
self cursorUp:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2495 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2496 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2497 |
cursorUp:n |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2498 |
"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
|
2499 |
|
5856 | 2500 |
|wasOn nv nl cursorColBefore| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2501 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2502 |
cursorLine isNil ifTrue:[ |
5850 | 2503 |
self setCursorLine:(firstLineShown + nFullLinesShown - 1). |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2504 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2505 |
nl := cursorLine - n. |
5850 | 2506 |
nl < 1 ifTrue:[ |
5858 | 2507 |
|generateTextBeforeStartHook| |
5890 | 2508 |
|
5856 | 2509 |
cursorColBefore := cursorCol. |
5858 | 2510 |
(generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[ |
2511 |
nl := generateTextBeforeStartHook value:nl |
|
5890 | 2512 |
]. |
5850 | 2513 |
nl := nl max:1 |
2514 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2515 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2516 |
(nl ~~ cursorLine) ifTrue: [ |
5850 | 2517 |
wasOn := self hideCursor. |
2518 |
cursorVisibleLine notNil ifTrue:[ |
|
2519 |
nv := cursorVisibleLine - n. |
|
2520 |
nv < 1 ifTrue:[ |
|
2521 |
self scrollUp:(nv negated + 1) |
|
2522 |
]. |
|
2523 |
]. |
|
5856 | 2524 |
self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol). |
3725
410e861ca010
also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents:
3707
diff
changeset
|
2525 |
"/ wasOn ifTrue:[self showCursor]. |
5850 | 2526 |
self makeCursorVisibleAndShowCursor:wasOn. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2527 |
] |
672 | 2528 |
|
674 | 2529 |
"Modified: 22.5.1996 / 18:28:11 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2530 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2531 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2532 |
cursorVisibleLine:visibleLineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2533 |
"put cursor to visibleline/col" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2534 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2535 |
|wasOn newCol listLine| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2536 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2537 |
wasOn := self hideCursor. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2538 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2539 |
listLine := self visibleLineToAbsoluteLine:visibleLineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2540 |
self setValidatedCursorLine:listLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2541 |
cursorVisibleLine := visibleLineNr. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2542 |
|
676 | 2543 |
newCol := colNr. |
2544 |
(newCol < 1) ifTrue:[ |
|
4823 | 2545 |
newCol := 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2546 |
]. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2547 |
self setValidatedCursorCol:newCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2548 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2549 |
self makeCursorVisibleAndShowCursor:wasOn. |
672 | 2550 |
|
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
2551 |
"Modified: / 20.6.1998 / 18:40:28 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2552 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2553 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2554 |
cursorX:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2555 |
"put cursor to position next to x/y coordinate in view" |
121 | 2556 |
|
2557 |
|line col| |
|
2558 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2559 |
line := self visibleLineOfY:y. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2560 |
col := self colOfX:x inVisibleLine:line. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2561 |
self cursorVisibleLine:line col:col. |
121 | 2562 |
! |
2563 |
||
2564 |
drawCursor |
|
2565 |
"draw the cursor if shown and cursor is visible. |
|
2566 |
(but not, if there is a selection - to avoid confusion)" |
|
2567 |
||
2568 |
shown ifTrue:[ |
|
4823 | 2569 |
cursorVisibleLine notNil ifTrue:[ |
2570 |
self hasSelection ifFalse:[ |
|
2571 |
self drawCursorCharacter |
|
2572 |
] |
|
2573 |
] |
|
121 | 2574 |
] |
2575 |
! |
|
2576 |
||
2577 |
drawCursor:cursorType with:fgColor and:bgColor |
|
2578 |
"draw a cursor; the argument cursorType specifies what type |
|
125 | 2579 |
of cursor should be drawn. |
4721 | 2580 |
Currently, supported are: #none, |
2581 |
#block, #frame, #ibeam, #caret, #solidCaret |
|
4580 | 2582 |
#bigCaret and #bigSolidCaret" |
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2583 |
|
2570 | 2584 |
|x y w char y2 x1 x2 oldPaint oldClip| |
121 | 2585 |
|
2586 |
self hasSelection ifTrue:[ |
|
4580 | 2587 |
" |
2588 |
hide cursor, if there is a selection |
|
2589 |
" |
|
2590 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
|
121 | 2591 |
]. |
2592 |
||
1334 | 2593 |
cursorType == #none ifTrue:[ |
4580 | 2594 |
^ self |
1334 | 2595 |
]. |
2596 |
||
121 | 2597 |
cursorType == #block ifTrue:[ |
4829 | 2598 |
super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor. |
4580 | 2599 |
^ self |
121 | 2600 |
]. |
2429
eed79a96e43b
eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents:
2427
diff
changeset
|
2601 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
121 | 2602 |
y := self yOfVisibleLine:cursorVisibleLine. |
2603 |
||
1449
2a54bdfff203
eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
2604 |
oldPaint := self paint. "/ do not clobber GC |
121 | 2605 |
cursorType == #frame ifTrue:[ |
4580 | 2606 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
2607 |
||
2608 |
char := self characterUnderCursor asString. |
|
4829 | 2609 |
self paint:bgColor. |
4889 | 2610 |
self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2. |
133 | 2611 |
] ifFalse:[ |
4580 | 2612 |
self paint:bgColor. |
2613 |
cursorType == #ibeam ifTrue:[ |
|
2614 |
x1 := x - 1. |
|
5581 | 2615 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2616 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2617 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2618 |
^ self |
|
2619 |
]. |
|
2620 |
||
2621 |
cursorType == #Ibeam ifTrue:[ |
|
2622 |
x1 := x - 1. |
|
2623 |
y := y + 1. |
|
5581 | 2624 |
y2 := y + fontHeight - lineSpacing - 1. |
4580 | 2625 |
self displayLineFromX:x1 y:y toX:x1 y:y2. |
2626 |
self displayLineFromX:x y:y toX:x y:y2. |
|
2627 |
self displayLineFromX:x1-2 y:y toX:x+2 y:y. |
|
2628 |
self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. |
|
2629 |
^ self |
|
2630 |
]. |
|
2631 |
||
2632 |
y := y + fontHeight - 3. |
|
2633 |
((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[ |
|
2634 |
w := (fontWidth * 2 // 3) max:4. |
|
2635 |
y2 := y + w + (w//2). |
|
2636 |
] ifFalse:[ |
|
2637 |
w := (fontWidth // 2) max:4. |
|
2638 |
y2 := y + w. |
|
2639 |
]. |
|
2640 |
x1 := x - w. |
|
2641 |
x2 := x + w. |
|
2642 |
||
2643 |
oldClip := self clippingRectangleOrNil. |
|
2644 |
self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)). |
|
2645 |
||
2646 |
cursorType == #caret ifTrue:[ |
|
2647 |
self lineWidth:2. |
|
2648 |
self displayLineFromX:x1 y:y2 toX:x y:y. |
|
2649 |
self displayLineFromX:x y:y toX:x2 y:y2. |
|
2650 |
] ifFalse:[ |
|
2651 |
"anything else: solidCaret" |
|
2652 |
||
2653 |
self fillPolygon:(Array with:(x1 @ y2) |
|
2654 |
with:(x @ y) |
|
2655 |
with:(x2 @ y2)) |
|
2656 |
]. |
|
2657 |
||
2658 |
self clippingRectangle:oldClip |
|
121 | 2659 |
]. |
133 | 2660 |
self paint:oldPaint. |
662
4bcdf0cce3a7
dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
2661 |
|
2088 | 2662 |
"Modified: / 15.12.1999 / 22:24:17 / cg" |
121 | 2663 |
! |
2664 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2665 |
drawCursorCharacter |
3160 | 2666 |
"draw the cursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2667 |
(i.e. the cursor if no selection) |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2668 |
- helper for many cursor methods" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2669 |
|
3160 | 2670 |
(hasKeyboardFocus |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2671 |
and:[self enabled |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
2672 |
and:[self isReadOnly not]]) ifTrue:[ |
4823 | 2673 |
self drawFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2674 |
] ifFalse:[ |
4823 | 2675 |
self drawNoFocusCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2676 |
] |
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2677 |
|
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
2678 |
"Modified: / 23.3.1999 / 13:52:48 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2679 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2680 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2681 |
drawFocusCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2682 |
"draw the cursor when the focus is in the view." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2683 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2684 |
self hasSelection ifTrue:[ |
5260 | 2685 |
^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1). |
1334 | 2686 |
]. |
2687 |
cursorType == #none ifTrue:[ |
|
4823 | 2688 |
^ self undrawCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2689 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2690 |
self drawCursor:cursorType with:cursorFgColor and:cursorBgColor. |
1334 | 2691 |
|
2692 |
"Modified: 22.9.1997 / 00:16:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2693 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2694 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2695 |
drawNoFocusCursor |
3160 | 2696 |
"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
|
2697 |
|
1334 | 2698 |
|cType| |
2699 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2700 |
self hasSelection ifTrue:[ |
4823 | 2701 |
^ super redrawVisibleLine:cursorVisibleLine col:cursorCol. |
121 | 2702 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2703 |
|
1334 | 2704 |
cType := cursorTypeNoFocus ? cursorType. |
2705 |
cType == #none ifTrue:[ |
|
4823 | 2706 |
^ self undrawCursor |
1334 | 2707 |
]. |
2708 |
||
2709 |
cType == #block ifTrue:[ |
|
4823 | 2710 |
^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2711 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
2712 |
|
1334 | 2713 |
^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor. |
2714 |
||
2715 |
"Modified: 22.9.1997 / 00:16:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2716 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2717 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2718 |
gotoLine:aLineNumber |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2719 |
"position cursor onto line, aLineNumber. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2720 |
Make certain that this line is visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2721 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2722 |
self makeLineVisible:aLineNumber. |
2951 | 2723 |
self unselect. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2724 |
self cursorLine:aLineNumber col:1 |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2725 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2726 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2727 |
hideCursor |
1833 | 2728 |
"make cursor invisible if currently invisible" |
2729 |
||
2730 |
^ self cursorShown:false |
|
2731 |
||
2732 |
"Modified: / 30.3.1999 / 16:02:28 / stefan" |
|
121 | 2733 |
! |
2734 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2735 |
makeCursorVisible |
3160 | 2736 |
"scroll text to make cursorline visible |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2737 |
(i.e. to have cursorLine in visible area)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2738 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2739 |
|line col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2740 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2741 |
cursorLine notNil ifTrue:[ |
4823 | 2742 |
line := cursorLine. |
2743 |
col := cursorCol. |
|
2744 |
" |
|
2745 |
if there is a selection, its better to |
|
2746 |
have its start being visible, instead of the end |
|
2747 |
" |
|
2748 |
(selectionStartLine notNil |
|
2749 |
and:[selectionEndLine notNil]) ifTrue:[ |
|
2750 |
expandingTop ~~ false ifTrue:[ |
|
2751 |
line := selectionStartLine. |
|
2752 |
col := selectionStartCol. |
|
2753 |
] ifFalse:[ |
|
2754 |
line := selectionEndLine. |
|
2755 |
col := selectionEndCol |
|
2756 |
] |
|
2757 |
]. |
|
2758 |
self makeLineVisible:line. |
|
2759 |
self makeColVisible:col inLine:line |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2760 |
] |
479
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2761 |
|
fae6d1251888
fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents:
477
diff
changeset
|
2762 |
"Modified: 6.3.1996 / 13:46:46 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2763 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2764 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2765 |
makeCursorVisibleAndShowCursor:flag |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2766 |
"scroll to make cursorLine visible; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2767 |
if flag is true, draw the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2768 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2769 |
self makeCursorVisible. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2770 |
flag ifTrue:[self showCursor] |
121 | 2771 |
! |
2772 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2773 |
setCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2774 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2775 |
|
2815 | 2776 |
cursorCol := (colNr max:1). |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2777 |
cursorColHolder value:cursorCol. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2778 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2779 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2780 |
setCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2781 |
"strictly private: set the cursorLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2782 |
|
3303 | 2783 |
"/ self assert:(lineNr notNil). |
2784 |
||
2785 |
cursorLine := (lineNr ? 1). |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2786 |
cursorLineHolder value:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2787 |
self updateCursorVisibleLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2788 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2789 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2790 |
setCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2791 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2792 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2793 |
self setCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2794 |
self setCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2795 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2796 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2797 |
setValidatedCursorCol:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2798 |
"strictly private: set the cursorCol" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2799 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2800 |
self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2801 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2802 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2803 |
setValidatedCursorLine:lineNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2804 |
"strictly private: set the cursorLine and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2805 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2806 |
self setCursorLine:(self validateCursorLine:lineNr). |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2807 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2808 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2809 |
setValidatedCursorLine:lineNr col:colNr |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2810 |
"strictly private: set the cursorLine, col and update the visibleLine" |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2811 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2812 |
self setValidatedCursorLine:lineNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2813 |
self setValidatedCursorCol:colNr. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2814 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2815 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2816 |
showCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2817 |
"make cursor visible if currently invisible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2818 |
|
1833 | 2819 |
^ self cursorShown:true |
2820 |
||
2821 |
"Modified: / 30.3.1999 / 16:02:34 / stefan" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2822 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2823 |
|
5761 | 2824 |
singleQuoteSelection |
2825 |
"place single quotes around the selected text" |
|
2826 |
||
2827 |
|line1 col1 line2 col2| |
|
2828 |
||
2829 |
line1 := self selectionStartLine. |
|
2830 |
col1 := self selectionStartCol. |
|
2831 |
line2 := self selectionEndLine. |
|
2832 |
col2 := self selectionEndCol. |
|
2833 |
(line1 notNil |
|
2834 |
and:[ col1 notNil |
|
2835 |
and:[ line2 notNil |
|
2836 |
and:[ col2 notNil ]]]) |
|
2837 |
ifTrue:[ |
|
2838 |
self insertString:Character quote asString atLine:line2 col:col2+1. |
|
2839 |
self insertString:Character quote asString atLine:line1 col:col1. |
|
2840 |
self selectFromLine:line1 col:col1 toLine:line2 col:col2+2. |
|
2841 |
] ifFalse:[ |
|
2842 |
self beep. |
|
2843 |
] |
|
2844 |
||
2845 |
"Created: / 06-06-2016 / 11:03:36 / cg" |
|
2846 |
! |
|
2847 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2848 |
undrawCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2849 |
"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
|
2850 |
|
2085
4498b1a50d72
fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents:
2072
diff
changeset
|
2851 |
|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
|
2852 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2853 |
cursorVisibleLine notNil ifTrue:[ |
4494 | 2854 |
prevCol := cursorCol - 1. |
2855 |
||
2856 |
"/ if there is any italic stuff in the cursor line, |
|
2857 |
"/ redraw it completely (because characters overlap). |
|
2858 |
cursorCol > 1 ifTrue:[ |
|
2859 |
(line := self listAt:cursorLine) notNil ifTrue:[ |
|
2860 |
line hasChangeOfEmphasis ifTrue:[ |
|
2861 |
line size >= (cursorCol-1) ifTrue:[ |
|
2862 |
e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1). |
|
2863 |
line size >= (cursorCol) ifTrue:[ |
|
2864 |
e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol). |
|
2865 |
line size >= (cursorCol+1) ifTrue:[ |
|
2866 |
e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1) |
|
2867 |
]. |
|
2868 |
]. |
|
2869 |
]. |
|
2870 |
(e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[ |
|
2871 |
^ super redrawVisibleLine:cursorVisibleLine |
|
2872 |
] |
|
2873 |
] |
|
2874 |
] |
|
2875 |
]. |
|
2876 |
||
2877 |
((cursorType == #caret) |
|
2878 |
or:[cursorType == #solidCaret |
|
2879 |
or:[cursorType == #bigSolidCaret |
|
2880 |
or:[cursorType == #bigCaret |
|
2881 |
or:[cursorType == #Ibeam]]]]) ifTrue:[ |
|
2882 |
"caret-cursor touches 4 characters" |
|
2883 |
((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[ |
|
2884 |
super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol. |
|
2885 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2886 |
super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol. |
|
2887 |
] ifFalse:[ |
|
2888 |
"care for left margin" |
|
2889 |
super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1. |
|
2890 |
]. |
|
2891 |
^ self |
|
2892 |
]. |
|
2893 |
||
2894 |
cursorType == #ibeam ifTrue:[ |
|
2895 |
"ibeam-cursor touches 2 characters" |
|
2896 |
cursorCol > 1 ifTrue:[ |
|
2897 |
super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol. |
|
2898 |
] ifFalse:[ |
|
2899 |
"care for left margin" |
|
2900 |
super redrawVisibleLine:cursorVisibleLine. |
|
2901 |
]. |
|
2902 |
^ self |
|
2903 |
]. |
|
2904 |
||
2905 |
"block cursor is simple - just one character under cursor" |
|
2906 |
||
2907 |
"/ however, if italic characters are involved, we must care |
|
2908 |
"/ for the chars before/after the cursor. |
|
2909 |
"/ We redraw the part of the previous character which got |
|
2910 |
"/ detroyed by the block cursor. |
|
2911 |
"/ (must change the clip, to avoid destroying the prev-prev character) |
|
2912 |
||
2913 |
line := self visibleAt:cursorVisibleLine. |
|
2914 |
(line notNil and:[line isText]) ifTrue:[ |
|
2915 |
cursorCol > 1 ifTrue:[ |
|
2916 |
oldClip := self clippingRectangleOrNil. |
|
2917 |
x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
2918 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4889 | 2919 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
4494 | 2920 |
super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol. |
2921 |
self clippingRectangle:oldClip. |
|
2922 |
^ self. |
|
2923 |
]. |
|
2924 |
]. |
|
2925 |
super redrawVisibleLine:cursorVisibleLine col:cursorCol |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2926 |
] |
728
3ef81000ee8c
new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents:
698
diff
changeset
|
2927 |
|
2088 | 2928 |
"Modified: / 15.12.1999 / 22:25:59 / cg" |
121 | 2929 |
! |
2930 |
||
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2931 |
updateCursorVisibleLine |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2932 |
"strictly private: set the visibleLine from the cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2933 |
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
|
2934 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2935 |
cursorVisibleLine := self listLineToVisibleLine:cursorLine. |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2936 |
! |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
2937 |
|
672 | 2938 |
validateCursorCol:col inLine:line |
674 | 2939 |
"check of col is a valid cursor position; return a new col-nr if not. |
3160 | 2940 |
Here, no limits are enforced (and col is returned), |
5593 | 2941 |
but it may be redefined in EditFields or views which don't like the |
674 | 2942 |
cursor to be positioned behind the end of a textLine (vi/st-80 behavior)" |
672 | 2943 |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2944 |
|l max| |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2945 |
|
1419 | 2946 |
"/ in ST80 mode, |
2707 | 2947 |
"/ the cursor may not be positioned beyond the |
2948 |
"/ end of a line or beyond the last line of the text |
|
3160 | 2949 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2950 |
self st80EditMode ifTrue:[ |
4823 | 2951 |
l := (self listAt:line). |
2952 |
max := l size + 1. |
|
2953 |
col > max ifTrue:[ |
|
2954 |
^ max |
|
2955 |
] |
|
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
2956 |
]. |
672 | 2957 |
^ col |
2958 |
||
1419 | 2959 |
"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
|
2960 |
"Modified: / 20.6.1998 / 18:19:24 / cg" |
674 | 2961 |
! |
2962 |
||
2963 |
validateCursorLine:line |
|
2964 |
"check of line is a valid cursor line; return a fixed line-nr if not. |
|
3160 | 2965 |
Here, no limits are enforced (and line is returned), but it may be |
5593 | 2966 |
redefined in views which don't like the cursor to be positioned |
674 | 2967 |
behind the end of the text (vi/st-80 behavior), or want to |
2968 |
skip reserved regions" |
|
2969 |
||
1419 | 2970 |
"/ |
2971 |
"/ in st80Mode, the cursor may not be positioned |
|
5367 | 2972 |
"/ beyond the last line |
2973 |
"/ (but it must be posible to place it on one line below the last one |
|
2974 |
"/ - otherwise deleteSelection and some others fail to delete from previousToLastLine) |
|
1419 | 2975 |
"/ |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
2976 |
self st80EditMode ifTrue:[ |
5367 | 2977 |
^ (line min:(list size + 1)) max:1 |
1419 | 2978 |
]. |
674 | 2979 |
^ line |
2980 |
||
1419 | 2981 |
"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
|
2982 |
"Modified: / 20.6.1998 / 18:19:26 / cg" |
672 | 2983 |
! |
2984 |
||
121 | 2985 |
withCursorOffDo:aBlock |
2986 |
"evaluate aBlock with cursor off; turn it on afterwards." |
|
2987 |
||
2988 |
(shown not or:[cursorShown not]) ifTrue:[ |
|
4823 | 2989 |
^ aBlock value |
121 | 2990 |
]. |
2991 |
self hideCursor. |
|
2522
d80496af7eaf
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2506
diff
changeset
|
2992 |
aBlock ensure:[ |
4823 | 2993 |
self showCursor |
121 | 2994 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2995 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
2996 |
|
2589 | 2997 |
!EditTextView methodsFor:'drag & drop'! |
2998 |
||
2999 |
allowDrop:aBoolean |
|
3236 | 3000 |
"enable/disable drop support" |
3001 |
||
2589 | 3002 |
aBoolean ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3003 |
dropTarget := nil. |
2589 | 3004 |
] ifTrue:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3005 |
dropTarget isNil ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3006 |
dropTarget := DropTarget |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3007 |
receiver:self |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3008 |
argument:nil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3009 |
dropSelector:#'drop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3010 |
canDropSelector:#'canDrop:' |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3011 |
] |
3236 | 3012 |
]. |
3013 |
! |
|
3014 |
||
3412 | 3015 |
canDrop:aDropContext |
3016 |
"public from d&d. |
|
3017 |
I accept textObjects and fileObjects only." |
|
3018 |
||
4089
c6567fb50316
comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents:
4064
diff
changeset
|
3019 |
"/ cg: disabled to avoid unintended drop (is same as copy-past, anyway) |
3412 | 3020 |
aDropContext sourceWidget == self ifTrue:[^ false]. |
3021 |
^ self canDropObjects:aDropContext dropObjects |
|
3022 |
||
3023 |
"Modified: / 13-10-2006 / 17:41:09 / cg" |
|
3024 |
! |
|
3025 |
||
3026 |
canDropObjects:aCollectionOfDropObjects |
|
3027 |
"public from d&d. |
|
3028 |
I accept textObjects and fileObjects only." |
|
2589 | 3029 |
|
3030 |
self checkModificationsAllowed ifFalse:[^ false]. |
|
3031 |
||
3412 | 3032 |
aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ]. |
3033 |
^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])] |
|
3034 |
||
3035 |
"Created: / 13-10-2006 / 15:56:57 / cg" |
|
3036 |
"Modified: / 13-10-2006 / 17:41:14 / cg" |
|
3037 |
! |
|
3038 |
||
3039 |
drop:aDropContext |
|
3040 |
"public from d&d. |
|
3041 |
drop objects (new API)" |
|
3042 |
||
3043 |
self dropObjects:(aDropContext dropObjects) |
|
3044 |
||
3045 |
"Modified: / 13-10-2006 / 17:41:19 / cg" |
|
3046 |
! |
|
3047 |
||
3048 |
dropFileObject:aDropObject |
|
2589 | 3049 |
"drop objects |
3236 | 3050 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
3051 |
||
4136 | 3052 |
|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
|
3053 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3054 |
pasteWhat := #name. |
3412 | 3055 |
|
3056 |
fn := aDropObject asFilename. |
|
3057 |
(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
|
3058 |
enforcedDropMode := UserPreferences current enforcedDropModeForFiles. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3059 |
(enforcedDropMode notNil |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3060 |
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
|
3061 |
pasteWhat := enforcedDropMode. |
3886 | 3062 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3063 |
sensor := self sensor. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3064 |
(sensor shiftDown or:[sensor ctrlDown]) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3065 |
pasteWhat := #name. |
3886 | 3066 |
] ifFalse:[ |
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3067 |
(sensor metaDown) ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3068 |
pasteWhat := #contents. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3069 |
] ifFalse:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3070 |
dontAskAgainHolder := false asValue. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3071 |
answer := Dialog |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3072 |
confirmWithCancel:(resources |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3073 |
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
|
3074 |
with:fn name allBold) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3075 |
labels:#( 'Cancel' 'Name' 'Contents' ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3076 |
values:#( nil #name #contents ) |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3077 |
default:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3078 |
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
|
3079 |
title:(resources string:'Drop What'). |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3080 |
answer isNil ifTrue:[ ^ self ]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3081 |
|
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3082 |
dontAskAgainHolder value ifTrue:[ |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3083 |
UserPreferences current enforcedDropModeForFiles:#contents |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3084 |
]. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3085 |
pasteWhat := answer. |
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3086 |
] |
3886 | 3087 |
] |
3088 |
]. |
|
3089 |
]. |
|
3090 |
||
3907
e4be6bf71a98
Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents:
3890
diff
changeset
|
3091 |
pasteWhat == #name ifTrue:[ |
3886 | 3092 |
text := fn pathName |
3093 |
] ifFalse:[ |
|
3094 |
self withWaitCursorDo:[ |
|
5063 | 3095 |
text := fn contentsAsString |
4136 | 3096 |
]. |
3097 |
(app := self application) notNil ifTrue:[ |
|
3098 |
app droppedFile:fn in:self |
|
3099 |
]. |
|
3886 | 3100 |
]. |
3101 |
||
3799 | 3102 |
self |
3103 |
undoablePaste:text |
|
3104 |
info:'Drop File'. |
|
3412 | 3105 |
|
3106 |
"Created: / 13-10-2006 / 17:38:31 / cg" |
|
3495 | 3107 |
"Modified: / 28-07-2007 / 13:27:09 / cg" |
3412 | 3108 |
! |
3109 |
||
3110 |
dropObject:aDropObject |
|
3111 |
"drop objects |
|
3112 |
For bw. compatibility, also collections of drop objects are handled (may vanish)" |
|
3113 |
||
3415 | 3114 |
|text| |
3115 |
||
3412 | 3116 |
(aDropObject isFileObject) ifTrue:[ |
3799 | 3117 |
self dropFileObject:aDropObject |
3412 | 3118 |
] ifFalse:[ |
3799 | 3119 |
aDropObject isTextObject ifTrue:[ |
3120 |
text := aDropObject theObject. |
|
3121 |
text isStringCollection ifTrue:[ |
|
3122 |
text := text asStringWithoutFinalCR |
|
3123 |
]. |
|
3124 |
] ifFalse:[ |
|
3125 |
text := aDropObject theObject asString |
|
3126 |
]. |
|
3127 |
self |
|
3128 |
undoablePaste:text |
|
3129 |
info:'Drop'. |
|
3412 | 3130 |
]. |
3131 |
||
3132 |
"Created: / 13-10-2006 / 17:37:05 / cg" |
|
3495 | 3133 |
"Modified: / 28-07-2007 / 13:26:53 / cg" |
3412 | 3134 |
! |
3135 |
||
3136 |
dropObjects:aCollectionOfDropObjects |
|
3137 |
"public from d&d. |
|
3138 |
drop objects (old API)" |
|
3139 |
||
3868 | 3140 |
aCollectionOfDropObjects do:[:el | |
3141 |
self dropObject:el |
|
3412 | 3142 |
]. |
3143 |
||
3144 |
"Created: / 13-10-2006 / 15:59:40 / cg" |
|
3145 |
"Modified: / 13-10-2006 / 17:41:23 / cg" |
|
2589 | 3146 |
! ! |
3147 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3148 |
!EditTextView methodsFor:'editing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3149 |
|
5761 | 3150 |
applyConverterToSelection:converter |
3151 |
"apply a converter to the selected text" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3152 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3153 |
|line1 line2| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3154 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3155 |
line1 := self selectionStartLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3156 |
line2 := self selectionEndLine. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3157 |
line1 isNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3158 |
line1 := self perform:#cursorLine ifNotUnderstood:nil. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3159 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3160 |
line2 := line1 |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3161 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3162 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3163 |
line1 notNil ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3164 |
line1 to:line2 do:[:lineNr | |
5761 | 3165 |
|line col1 col2 newLine| |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3166 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3167 |
line := (self listAt:lineNr) copy. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3168 |
line size > 0 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3169 |
lineNr == line1 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3170 |
col1 := selectionStartCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3171 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3172 |
col1 := 1. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3173 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3174 |
lineNr == line2 ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3175 |
col2 := selectionEndCol. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3176 |
] ifFalse:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3177 |
col2 := (self listAt:lineNr) size. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3178 |
]. |
5761 | 3179 |
newLine := converter value:line value:lineNr value:col1 value:col2. |
3180 |
self withoutRedrawAt:lineNr put:newLine. |
|
3181 |
self invalidateLine:lineNr. |
|
3182 |
]. |
|
3183 |
]. |
|
3184 |
] |
|
3185 |
||
3186 |
"Created: / 06-06-2016 / 10:53:17 / cg" |
|
3187 |
! |
|
3188 |
||
3189 |
convertSelectionToLowercase |
|
3190 |
"to-lower selected text" |
|
3191 |
||
3192 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3193 |
col1 to:col2 do:[:col | |
|
3194 |
|ch| |
|
3195 |
||
3196 |
ch := line at:col. |
|
3197 |
line at:col put:ch asLowercase. |
|
3198 |
]. |
|
3199 |
line. |
|
3200 |
]. |
|
3201 |
||
3202 |
"Created: / 06-06-2016 / 10:50:28 / cg" |
|
3203 |
! |
|
3204 |
||
3205 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
|
3206 |
"toLower/toUppercaseFirst/toUpper selected text" |
|
3207 |
||
3208 |
self applyConverterToSelection:[:line :lineNr :col1 :col2 | |
|
3209 |
|isAllLower isLowerFirst isAllUpper isUpperFirst |
|
3210 |
makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst| |
|
3211 |
||
3212 |
isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true. |
|
3213 |
col1 to:col2 do:[:col | |
|
3214 |
|ch| |
|
3215 |
||
3216 |
ch := line at:col. |
|
3217 |
ch isUppercase ifTrue:[ |
|
3218 |
isAllLower := false. |
|
3219 |
col == col1 ifTrue:[ |
|
3220 |
isLowerFirst := false. |
|
3221 |
]. |
|
3222 |
] ifFalse:[ |
|
3223 |
ch isLowercase ifTrue:[ |
|
3224 |
isAllUpper := false. |
|
3225 |
col == col1 ifTrue:[ |
|
3226 |
isUpperFirst := false. |
|
3227 |
]. |
|
3228 |
] |
|
3229 |
]. |
|
3230 |
]. |
|
3231 |
||
3232 |
makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false. |
|
3233 |
isLowerFirst ifTrue:[ |
|
3234 |
makeUppercaseFirst := true. |
|
3235 |
] ifFalse:[ |
|
3236 |
"/ must remember where we come from - otherwise, we end up |
|
3237 |
"/ in upperFirst - lowerFirst cycle. |
|
3238 |
"/ think about a good place to store this state |
|
3239 |
false "(isUpperFirst and:[isAllUpper not])" ifTrue:[ |
|
3240 |
makeLowercaseFirst := true. |
|
3241 |
] ifFalse:[ |
|
3242 |
isAllUpper ifTrue:[ |
|
3243 |
makeLowercase := true. |
|
3244 |
] ifFalse:[ |
|
3245 |
makeUppercase := true. |
|
3246 |
] |
|
3247 |
] |
|
3248 |
]. |
|
3249 |
makeUppercaseFirst ifTrue:[ |
|
3250 |
line at:col1 put:(line at:col1) asUppercase. |
|
3251 |
] ifFalse:[ |
|
3252 |
makeLowercaseFirst ifTrue:[ |
|
3253 |
line at:col1 put:(line at:col1) asLowercase. |
|
3254 |
] ifFalse:[ |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3255 |
col1 to:col2 do:[:col | |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3256 |
|ch| |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3257 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3258 |
ch := line at:col. |
5761 | 3259 |
ch := makeLowercase |
3260 |
ifTrue:[ ch asLowercase ] |
|
3261 |
ifFalse:[ |
|
3262 |
makeUppercase |
|
3263 |
ifTrue:[ ch asUppercase ] |
|
3264 |
ifFalse:[ |
|
3265 |
col == col1 |
|
3266 |
ifTrue:[ ch asUppercase ] |
|
3267 |
ifFalse:[ ch asLowercase ] |
|
3268 |
] |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3269 |
]. |
5761 | 3270 |
line at:col put:ch. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3271 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3272 |
]. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3273 |
]. |
5761 | 3274 |
line |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3275 |
] |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3276 |
|
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3277 |
"Created: / 14-07-2011 / 11:40:26 / cg" |
5761 | 3278 |
"Modified: / 06-06-2016 / 10:57:15 / cg" |
3279 |
! |
|
3280 |
||
3281 |
convertSelectionToUppercase |
|
3282 |
"to-upper selected text" |
|
3283 |
||
3284 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3285 |
col1 to:col2 do:[:col | |
|
3286 |
|ch| |
|
3287 |
||
3288 |
ch := line at:col. |
|
3289 |
line at:col put:ch asUppercase. |
|
3290 |
]. |
|
3291 |
line. |
|
3292 |
]. |
|
3293 |
||
3294 |
"Created: / 06-06-2016 / 11:09:04 / cg" |
|
3295 |
! |
|
3296 |
||
3297 |
convertSelectionToUppercaseFirst |
|
3298 |
"to-upperFirst selected text" |
|
3299 |
||
3300 |
self applyConverterToSelection:[:line :lnr :col1 :col2 | |
|
3301 |
|state| |
|
3302 |
||
3303 |
state := #first. |
|
3304 |
col1 to:col2 do:[:col | |
|
3305 |
|ch| |
|
3306 |
||
3307 |
ch := line at:col. |
|
3308 |
ch isSeparator ifFalse:[ |
|
3309 |
state == #first ifTrue:[ |
|
3310 |
line at:col put:ch asUppercase. |
|
3311 |
state := #skipRest |
|
3312 |
] |
|
3313 |
] ifTrue:[ |
|
3314 |
state := #first |
|
3315 |
] |
|
3316 |
]. |
|
3317 |
line. |
|
3318 |
]. |
|
3319 |
||
3320 |
"Created: / 06-06-2016 / 10:50:52 / cg" |
|
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3321 |
! |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
3322 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3323 |
copyAndDeleteSelection |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3324 |
"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
|
3325 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3326 |
selectionStartLine notNil ifTrue:[ |
4823 | 3327 |
self setClipboardText:(self selection). |
3328 |
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
|
3329 |
]. |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3330 |
|
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3331 |
"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
|
3332 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
3333 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3334 |
deleteCharAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3335 |
"delete single character under cursor; does not merge lines" |
121 | 3336 |
|
3337 |
|wasOn| |
|
3338 |
||
3339 |
wasOn := self hideCursor. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3340 |
self deleteCharAtLine:cursorLine col:cursorCol. |
121 | 3341 |
wasOn ifTrue:[self showCursor] |
3342 |
! |
|
3343 |
||
827 | 3344 |
deleteCharAtLine:lineNr col:colNr |
3345 |
"delete a single character at colNr in line lineNr" |
|
3346 |
||
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3347 |
self st80EditMode ifTrue:[ |
4823 | 3348 |
(self listAt:cursorLine) size + 1 = colNr ifTrue:[ |
3349 |
| wasOn | |
|
3350 |
wasOn := self hideCursor. |
|
3351 |
self |
|
3352 |
cursorReturn; |
|
3353 |
cursorCol:1; |
|
3354 |
deleteCharBeforeCursor. |
|
3355 |
wasOn ifTrue:[ self showCursor]. |
|
3356 |
^ self. |
|
3357 |
]. |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3358 |
]. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
3359 |
|
827 | 3360 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr |
3361 |
! |
|
3362 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3363 |
deleteCharBeforeCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3364 |
"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
|
3365 |
|
4592 | 3366 |
|soCol wasOn lineNrAboveCursor ln originalLine prevTab| |
121 | 3367 |
|
3368 |
wasOn := self hideCursor. |
|
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3369 |
|
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3370 |
"JV@2012-01-06: Do not play with autoindent iff cursor is at the very beginning of the line" |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3371 |
(autoIndent |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3372 |
and:[cursorCol ~~ 1 |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3373 |
and:[ (tabPositions includes:cursorCol) |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3374 |
]]) ifTrue:[ |
4592 | 3375 |
prevTab := (self prevTabBefore:cursorCol) max:1. |
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3376 |
"JV@2011-12-10: The list can be shorter than cursorLine, |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3377 |
trailing because empty lines are not physically in the list." |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3378 |
(list size >= cursorLine) ifTrue:[ |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3379 |
ln := originalLine := (list at:cursorLine) ? ''. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3380 |
] ifFalse:[ |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3381 |
ln := originalLine := ''. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3382 |
]. |
4592 | 3383 |
ln size < prevTab ifTrue:[ |
3384 |
ln := ln , (String new:prevTab withAll:Character space). |
|
3385 |
]. |
|
3386 |
(ln copyTo:prevTab) isBlank ifTrue:[ |
|
3387 |
(ln copyFrom:prevTab+1) isBlank ifTrue:[ |
|
3388 |
cursorCol > prevTab ifTrue:[ |
|
3389 |
self st80EditMode ifTrue:[ |
|
3390 |
"/ ensure that there is no conflict here: st80EditMode will |
|
3391 |
"/ not allow a cursor position beyond the end of line, |
|
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3392 |
"/ so avoid that cursorLine:col: will force us to the beginning of the line |
4592 | 3393 |
originalLine size < prevTab ifTrue:[ |
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3394 |
self at:cursorLine put:ln |
4592 | 3395 |
] |
3396 |
]. |
|
3397 |
self cursorLine:cursorLine col:prevTab. |
|
3398 |
wasOn ifTrue:[ self showCursor ]. |
|
3399 |
^ self |
|
3400 |
]. |
|
3401 |
] ifFalse:[ |
|
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3402 |
"/ cg: this is ugly behavior; deleting multiple chars at the beginning |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3403 |
"/ is annoying. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3404 |
"/ therefore, only do it, if there are only blanks after the cursor |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3405 |
"/ (ln copyFrom:prevTab+1 to:((cursorCol-1) min:ln size)) isBlank ifTrue:[ |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3406 |
"/ self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3407 |
"/ self cursorLine:cursorLine col:prevTab. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3408 |
"/ wasOn ifTrue:[ self showCursor ]. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3409 |
"/ ^ self. |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3410 |
"/ ] |
4592 | 3411 |
] |
3412 |
]. |
|
827 | 3413 |
]. |
3414 |
||
2491 | 3415 |
"/ (autoIndent |
3416 |
"/ and:[cursorCol ~~ 1 |
|
3160 | 3417 |
"/ and:[cursorLine <= (list size)]]) |
2491 | 3418 |
"/ ifTrue:[ |
3419 |
"/ soCol := (self leftIndentForLine:cursorLine) + 1. |
|
3420 |
"/ |
|
3421 |
"/ (cursorCol == soCol and:[soCol > 1]) ifTrue:[ |
|
3422 |
"/ ln := list at:cursorLine. |
|
3423 |
"/ (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[ |
|
3424 |
"/ soCol := 1 |
|
3425 |
"/ ] |
|
3426 |
"/ ] |
|
3427 |
"/ ] ifFalse:[ |
|
4592 | 3428 |
soCol := 1. |
2491 | 3429 |
"/ ]. |
3430 |
||
1419 | 3431 |
(cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[ |
4592 | 3432 |
" |
3433 |
somewhere in the middle of a line |
|
3434 |
" |
|
3435 |
self cursorLeft. |
|
3436 |
self deleteCharAtLine:cursorLine col:cursorCol. |
|
1419 | 3437 |
] ifFalse:[ |
4592 | 3438 |
" |
3439 |
at begin of line - merge with previous line; |
|
3440 |
except for the very first line. |
|
3441 |
" |
|
3442 |
(cursorLine == 1) ifFalse:[ |
|
3443 |
lineNrAboveCursor := self validateCursorLine:(cursorLine - 1). |
|
3444 |
lineNrAboveCursor < cursorLine ifTrue:[ |
|
3445 |
(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[ |
|
3446 |
"/ we are beyond the end of the text. |
|
3447 |
"/ move the cursor to the previous line. |
|
3448 |
self cursorLine:lineNrAboveCursor col:1. |
|
3449 |
] ifFalse:[ |
|
3450 |
self mergeLine:lineNrAboveCursor removeBlanks:false. |
|
3451 |
] |
|
3452 |
] |
|
3453 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3454 |
]. |
827 | 3455 |
wasOn ifTrue:[ self showCursor ] |
3456 |
||
6063
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3457 |
"Modified: / 16-01-1998 / 22:33:04 / cg" |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3458 |
"Modified: / 12-01-2017 / 22:38:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
ef1842cb1d75
Issue #116: Moved `Tools::CodeView2 >> #deleteCharBeforeCursor` up to `EditTextView`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6023
diff
changeset
|
3459 |
"Modified (comment): / 13-01-2017 / 22:10:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
827 | 3460 |
! |
3461 |
||
3462 |
deleteCharsAtLine:lineNr fromCol:colNr |
|
3463 |
"delete characters from colNr up to the end in line lineNr" |
|
3464 |
||
3465 |
|line| |
|
3466 |
||
3467 |
(line := self listAt:lineNr) notNil ifTrue:[ |
|
4823 | 3468 |
self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size) |
827 | 3469 |
] |
3470 |
||
3471 |
! |
|
3472 |
||
4458 | 3473 |
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3474 |
"delete characters from startCol to endCol in line lineNr" |
|
3475 |
||
3476 |
|deleted| |
|
3477 |
||
3478 |
deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol. |
|
3479 |
self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
|
3480 |
self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete'). |
|
3481 |
! |
|
3482 |
||
827 | 3483 |
deleteCharsAtLine:lineNr toCol:colNr |
3484 |
"delete characters from start up to colNr in line lineNr" |
|
3485 |
||
3486 |
self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr |
|
3487 |
||
3488 |
||
121 | 3489 |
! |
3490 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3491 |
deleteCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3492 |
"delete the line where the cursor sits" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3493 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3494 |
self deleteLine:cursorLine |
121 | 3495 |
! |
3496 |
||
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3497 |
deleteFromCharacterPosition:charPos1 to:charPos2 |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3498 |
"delete a substring at a character position" |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3499 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3500 |
|line1 col1 line2 col2| |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3501 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3502 |
line1 := self lineOfCharacterPosition:charPos1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3503 |
col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1. |
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3504 |
col1 == 0 ifTrue:[ |
4823 | 3505 |
line1 := line1 - 1. |
3506 |
col1 := (self listAt:line1) size + 1. |
|
2725
eccf283b2efb
deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents:
2724
diff
changeset
|
3507 |
]. |
2385
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3508 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3509 |
line2 := self lineOfCharacterPosition:charPos2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3510 |
col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3511 |
|
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3512 |
self deleteFromLine:line1 col:col1 toLine:line2 col:col2. |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3513 |
! |
357e8a1cb2b2
added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents:
2373
diff
changeset
|
3514 |
|
2954 | 3515 |
deleteFromLine:startLine col:startCol toLine:endLine col:endCol |
3516 |
"delete all text from startLine/startCol to endLine/endCol - |
|
3517 |
joining lines if nescessary" |
|
3518 |
||
3519 |
|line newLine lineSize nMore| |
|
3520 |
||
3521 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
3522 |
list isNil ifTrue:[^ self]. |
|
3523 |
startLine > list size ifTrue:[ ^ self]. "/ deleted space below text |
|
3524 |
||
3525 |
(startLine == endLine) ifTrue:[ |
|
4225 | 3526 |
"/ delete chars within a line |
3527 |
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol. |
|
3528 |
^ self |
|
2954 | 3529 |
]. |
3530 |
||
3531 |
((startCol == 1) and:[endCol == 0]) ifTrue:[ |
|
4225 | 3532 |
"/ delete full lines only |
3533 |
endLine > startLine ifTrue:[ |
|
3534 |
self deleteFromLine:startLine toLine:(endLine - 1) |
|
3535 |
]. |
|
3536 |
^ self |
|
2954 | 3537 |
]. |
3538 |
||
3539 |
"/ delete right rest of 1st line |
|
4786 | 3540 |
self deleteCharsAtLine:startLine fromCol:(startCol max:1). |
2954 | 3541 |
|
3542 |
"/ delete the inner lines ... |
|
3543 |
endLine > (startLine + 1) ifTrue:[ |
|
4225 | 3544 |
self deleteFromLine:(startLine + 1) toLine:(endLine - 1) |
2954 | 3545 |
]. |
3546 |
||
3547 |
(endCol ~~ 0) ifTrue:[ |
|
4225 | 3548 |
"/ delete the left rest of the last line |
3549 |
||
3550 |
self deleteCharsAtLine:(startLine + 1) toCol:endCol. |
|
3551 |
||
3552 |
"/ must add blanks, if startCol lies beyond end of startLine |
|
3553 |
startLine <= list size ifTrue:[ |
|
3554 |
line := list at:startLine. |
|
3555 |
lineSize := line size. |
|
3556 |
(startCol > lineSize) ifTrue:[ |
|
3557 |
newLine := line. |
|
3558 |
line isNil ifTrue:[ |
|
3559 |
newLine := String new:(startCol - 1) |
|
3560 |
] ifFalse:[ |
|
3561 |
nMore := startCol - 1 - lineSize. |
|
3562 |
nMore > 0 ifTrue:[ |
|
3563 |
newLine := line , (line species new:nMore) |
|
3564 |
] |
|
3565 |
]. |
|
3566 |
newLine ~~ line ifTrue:[ |
|
4771 | 3567 |
self basicListAt:startLine put:newLine. |
4225 | 3568 |
]. |
3569 |
"/ TODO: remember old maxwidth of linerange, |
|
3570 |
"/ only clear widthOfWidestLine, if this max |
|
3571 |
"/ length was (one of) the longest. |
|
3572 |
"/ avoids slow delete with huge texts. |
|
3573 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
3574 |
self textChanged. |
|
3575 |
] |
|
3576 |
] |
|
2954 | 3577 |
]. |
3578 |
||
3579 |
"/ merge the left rest of 1st line with right rest of last line into one |
|
3580 |
self mergeLine:startLine removeBlanks:false |
|
3581 |
||
4225 | 3582 |
"Modified: / 10-11-1998 / 23:52:59 / cg" |
3583 |
"Modified: / 18-03-2011 / 18:25:01 / az" |
|
2954 | 3584 |
! |
3585 |
||
4458 | 3586 |
deleteFromLine:startLineNr toLine:endLineNr |
3587 |
"delete some lines" |
|
3588 |
||
3589 |
|deleted| |
|
3590 |
||
3591 |
deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0. |
|
3592 |
self basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
3593 |
self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete'). |
|
3594 |
! |
|
3595 |
||
827 | 3596 |
deleteLine:lineNr |
3597 |
"delete line" |
|
3598 |
||
3599 |
self deleteFromLine:lineNr toLine:lineNr |
|
3600 |
||
3601 |
||
3602 |
! |
|
3603 |
||
4458 | 3604 |
deleteLineWithoutRedraw:lineNr |
3605 |
"delete line - no redraw; |
|
3606 |
return true, if something was really deleted" |
|
3607 |
||
3608 |
|deleted ret| |
|
3609 |
||
3610 |
deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0. |
|
3611 |
ret := self basicDeleteLineWithoutRedraw:lineNr. |
|
3612 |
self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete'). |
|
3613 |
^ ret. |
|
3614 |
! |
|
3615 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3616 |
deleteLinesWithoutRedrawFrom:startLine to:endLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3617 |
"delete lines - no redraw; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3618 |
return true, if something was really deleted" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3619 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3620 |
|lastLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3621 |
|
4771 | 3622 |
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
|
3623 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3624 |
(list isNil or:[startLine > list size]) ifTrue:[^ false]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3625 |
(endLine > list size) ifTrue:[ |
4771 | 3626 |
lastLine := list size |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3627 |
] ifFalse:[ |
4771 | 3628 |
lastLine := endLine |
3629 |
]. |
|
3630 |
self basicListRemoveFromIndex:startLine toIndex:lastLine. |
|
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3631 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3632 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3633 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3634 |
"/ avoids slow delete with huge texts. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3635 |
widthOfWidestLine := nil. "/ i.e. unknown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3636 |
self textChanged. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3637 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3638 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
3639 |
"Modified: / 10.11.1998 / 23:55:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3640 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3641 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3642 |
deleteSelection |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3643 |
"delete the selection" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3644 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3645 |
|wasOn startLine startCol endLine endCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3646 |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
3647 |
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
|
3648 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3649 |
selectionStartLine notNil ifTrue:[ |
4823 | 3650 |
wasOn := self hideCursor. |
3651 |
||
3652 |
startLine := selectionStartLine. |
|
3653 |
startCol := selectionStartCol. |
|
3654 |
endLine := selectionEndLine. |
|
3655 |
endCol := selectionEndCol. |
|
3656 |
self unselectWithoutRedraw. |
|
3657 |
self deleteFromLine:startLine col:startCol toLine:endLine col:endCol. |
|
3658 |
self setCursorLine:startLine col:startCol. |
|
3659 |
||
3660 |
self makeCursorVisibleAndShowCursor:wasOn |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3661 |
] |
121 | 3662 |
! |
3663 |
||
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3664 |
deleteWordBeforeCursor |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3665 |
"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
|
3666 |
|
2952 | 3667 |
|wasOn beginCol beginLine endCol endLine| |
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3668 |
|
3799 | 3669 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
5361 | 3670 |
cursorCol <= 1 ifTrue:[ |
3671 |
self deleteCharBeforeCursor. |
|
3672 |
^ self |
|
3673 |
]. |
|
3799 | 3674 |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3675 |
wasOn := self hideCursor. |
3799 | 3676 |
self |
3677 |
undoableDo:[ |
|
3678 |
endCol := cursorCol-1. |
|
3679 |
endLine := cursorLine. |
|
3680 |
self cursorToPreviousWord. |
|
3681 |
beginCol := cursorCol. |
|
3682 |
beginLine := cursorLine. |
|
3683 |
self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
5361 | 3684 |
self cursorLine:cursorLine col:beginCol. |
3799 | 3685 |
] |
3686 |
info:'Delete Word'. |
|
2157
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3687 |
wasOn ifTrue:[ self showCursor ]. |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3688 |
|
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3689 |
"Modified: / 22.2.2000 / 23:59:04 / cg" |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3690 |
! |
ba22c3cc278b
added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3691 |
|
5761 | 3692 |
indentSelectionBy1 |
3693 |
"indent selected line-range |
|
3694 |
by 1 space (i.e. to the right)" |
|
3695 |
||
3696 |
self indentBy:1 |
|
3697 |
||
3698 |
"Created: / 06-06-2016 / 10:58:19 / cg" |
|
3699 |
! |
|
3700 |
||
4458 | 3701 |
insert:aCharacter atLine:lineNr col:colNr |
3702 |
"insert a single character at lineNr/colNr; |
|
3703 |
set emphasis to character at current position" |
|
3704 |
||
3705 |
self basicInsert:aCharacter atLine:lineNr col:colNr. |
|
3706 |
aCharacter ~~ Character cr ifTrue:[ |
|
4823 | 3707 |
self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert'). |
4458 | 3708 |
] |
3709 |
! |
|
3710 |
||
121 | 3711 |
insertCharAtCursor:aCharacter |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3712 |
"insert a single character at cursor-position - advance cursor." |
121 | 3713 |
|
3714 |
|wasOn| |
|
3715 |
||
3716 |
wasOn := self hideCursor. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3717 |
aCharacter == Character tab ifTrue:[ |
4820 | 3718 |
"/ needs special care to advance cursor correctly |
3719 |
self insertTabAtCursor |
|
121 | 3720 |
] ifFalse:[ |
4820 | 3721 |
self insert:aCharacter atLine:cursorLine col:cursorCol. |
3722 |
aCharacter == (Character cr) ifTrue:[ |
|
3723 |
self basicCursorReturn |
|
3724 |
] ifFalse:[ |
|
3725 |
self cursorRight. |
|
3726 |
]. |
|
121 | 3727 |
]. |
3728 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3729 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3730 |
"Modified: / 12.6.1998 / 21:50:20 / cg" |
121 | 3731 |
! |
3732 |
||
641 | 3733 |
insertLine:aString before:lineNr |
3734 |
"insert the line aString before line lineNr" |
|
3735 |
||
3736 |
^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr. |
|
3737 |
||
3738 |
"Modified: 14.5.1996 / 13:42:54 / cg" |
|
3739 |
! |
|
3740 |
||
155 | 3741 |
insertLines:aStringCollection before:lineNr |
3742 |
"insert a bunch before line lineNr" |
|
3743 |
||
3744 |
self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr |
|
3745 |
||
3746 |
"Modified: 6.9.1995 / 20:51:03 / claus" |
|
3747 |
! |
|
3748 |
||
4771 | 3749 |
insertLines:someText from:start to:end before:lineNr |
3750 |
"insert a bunch of lines before line lineNr. |
|
3751 |
The cursor position is left unchanged." |
|
3752 |
||
3753 |
|text indent visLine w nLines "{ Class: SmallInteger }" |
|
3754 |
srcY "{ Class: SmallInteger }" |
|
3755 |
dstY "{ Class: SmallInteger }" | |
|
3756 |
||
5357 | 3757 |
"wrong when pasting multiple lines" |
3758 |
false "autoIndent" ifTrue:[ |
|
4771 | 3759 |
indent := self leftIndentForLine:lineNr. |
3760 |
||
4812 | 3761 |
text := someText |
3762 |
collect:[:ln||line| |
|
3763 |
ln notNil ifTrue:[ |
|
3764 |
line := ln withoutLeadingSeparators. |
|
3765 |
(line isEmpty or:[indent == 0]) ifFalse:[ |
|
3766 |
line := (String new:indent), line |
|
3767 |
]. |
|
3768 |
line |
|
3769 |
] ifFalse:[ |
|
3770 |
nil |
|
3771 |
] |
|
3772 |
]. |
|
4771 | 3773 |
] ifFalse:[ |
3774 |
text := someText |
|
3775 |
]. |
|
3776 |
||
3777 |
visLine := self listLineToVisibleLine:lineNr. |
|
3778 |
(shown not or:[visLine isNil]) ifTrue:[ |
|
3779 |
self withoutRedrawInsertLines:text |
|
3780 |
from:start to:end |
|
3781 |
before:lineNr. |
|
3782 |
] ifFalse:[ |
|
3783 |
nLines := end - start + 1. |
|
3784 |
((visLine + nLines) >= nLinesShown) ifTrue:[ |
|
3785 |
self withoutRedrawInsertLines:text |
|
3786 |
from:start to:end |
|
3787 |
before:lineNr. |
|
3788 |
self redrawFromVisibleLine:visLine to:nLinesShown |
|
3789 |
] ifFalse:[ |
|
3790 |
w := self widthForScrollBetween:(lineNr + nLines) |
|
3791 |
and:(firstLineShown + nLines + nLinesShown). |
|
3792 |
srcY := topMargin + ((visLine - 1) * fontHeight). |
|
3793 |
dstY := srcY + (nLines * fontHeight). |
|
3794 |
||
3795 |
"/ |
|
3796 |
"/ scroll ... |
|
3797 |
"/ |
|
3798 |
" |
|
3799 |
stupid: must catchExpose before inserting new |
|
3800 |
stuff - since catchExpose may perform redraws |
|
3801 |
" |
|
3802 |
self catchExpose. |
|
3803 |
self withoutRedrawInsertLines:text |
|
3804 |
from:start to:end |
|
3805 |
before:lineNr. |
|
3806 |
self |
|
3807 |
copyFrom:self |
|
3808 |
x:textStartLeft y:srcY |
|
3809 |
toX:textStartLeft y:dstY |
|
3810 |
width:w |
|
3811 |
height:(height - dstY) |
|
3812 |
async:true. |
|
3813 |
self redrawFromVisibleLine:visLine to:(visLine + nLines - 1). |
|
3814 |
self waitForExpose |
|
3815 |
]. |
|
3816 |
]. |
|
3817 |
widthOfWidestLine notNil ifTrue:[ |
|
3818 |
text do:[:line | |
|
3819 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
3820 |
] |
|
3821 |
]. |
|
3822 |
self textChanged. |
|
3823 |
||
3824 |
"Modified: 29.1.1997 / 13:02:39 / cg" |
|
3825 |
! |
|
3826 |
||
654 | 3827 |
insertLines:lines withCR:withCr |
3160 | 3828 |
"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
|
3829 |
Cursor is moved behind insertion. |
641 | 3830 |
If withCr is true, append cr after last line" |
3831 |
||
3832 |
|start end nLines wasOn| |
|
3833 |
||
3834 |
lines notNil ifTrue:[ |
|
4649 | 3835 |
nLines := lines size. |
3836 |
(nLines == 1) ifTrue:[ |
|
3837 |
self insertStringAtCursor:(lines at:1). |
|
3838 |
withCr ifTrue:[ |
|
3839 |
self insertCharAtCursor:(Character cr) |
|
3840 |
] |
|
3841 |
] ifFalse:[ |
|
3842 |
(cursorCol ~~ 1) ifTrue:[ |
|
3843 |
self insertStringAtCursor:(lines at:1). |
|
3844 |
self insertCharAtCursor:(Character cr). |
|
3845 |
start := 2 |
|
3846 |
] ifFalse:[ |
|
3847 |
start := 1 |
|
3848 |
]. |
|
3849 |
withCr ifTrue:[ |
|
3850 |
end := nLines |
|
3851 |
] ifFalse:[ |
|
3852 |
end := nLines - 1 |
|
3853 |
]. |
|
3854 |
(start <= nLines) ifTrue:[ |
|
3855 |
(end >= start) ifTrue:[ |
|
3856 |
wasOn := self hideCursor. |
|
3857 |
self insertLines:lines from:start to:end before:cursorLine. |
|
3858 |
self setCursorLine:(cursorLine + (end - start + 1)). |
|
3859 |
wasOn ifTrue:[self showCursor]. |
|
3860 |
] |
|
3861 |
]. |
|
3862 |
withCr ifFalse:[ |
|
3863 |
"last line without cr" |
|
3864 |
self insertStringAtCursor:(lines at:nLines) |
|
3865 |
] |
|
3866 |
] |
|
641 | 3867 |
] |
654 | 3868 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3869 |
"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
|
3870 |
"Modified: / 12.6.1998 / 21:51:16 / cg" |
654 | 3871 |
! |
3872 |
||
3873 |
insertLines:lines withCr:withCr |
|
3874 |
"insert a bunch of lines at cursor position. Cursor |
|
3875 |
is moved behind insertion. |
|
3876 |
If withCr is true, append cr after last line" |
|
3877 |
||
2363 | 3878 |
<resource:#obsolete> |
3879 |
||
1292 | 3880 |
self obsoleteMethodWarning:'use #insertLines:withCR:'. |
3881 |
self insertLines:lines withCR:withCr. |
|
3882 |
||
3883 |
"Modified: 31.7.1997 / 23:07:22 / cg" |
|
641 | 3884 |
! |
3885 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3886 |
insertSelectedStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3887 |
"insert the argument, aString at cursor position and select it" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3888 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3889 |
|startLine startCol| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3890 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3891 |
startLine := cursorLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3892 |
startCol := cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3893 |
self insertStringAtCursor:aString. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3894 |
self selectFromLine:startLine col:startCol |
4823 | 3895 |
toLine:cursorLine col:(cursorCol - 1). |
3514
98e103cad51d
insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents:
3510
diff
changeset
|
3896 |
self makeSelectionVisible. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3897 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3898 |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3899 |
insertString:aString atCharacterPosition:charPos |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3900 |
"insert the argument, aString at a character position" |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3901 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3902 |
|line col| |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3903 |
|
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3904 |
line := self lineOfCharacterPosition:charPos. |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3905 |
col := charPos - (self characterPositionOfLine:line col:1) + 1. |
5060 | 3906 |
col == 0 ifTrue:[ |
3907 |
line > 1 ifTrue:[ |
|
3908 |
line := line - 1. |
|
5216 | 3909 |
col := (self listAt:line) size + 1. |
5060 | 3910 |
] ifFalse:[ |
3911 |
col := 1. |
|
3912 |
] |
|
3913 |
]. |
|
1935
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3914 |
self insertString:aString atLine:line col:col |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3915 |
! |
b59ff4681762
added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents:
1929
diff
changeset
|
3916 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3917 |
insertString:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3918 |
"insert the string, aString at line/col; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3919 |
handle cr's correctly" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3920 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3921 |
|start "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3922 |
stop "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3923 |
end "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3924 |
subString c |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3925 |
l "{ Class: SmallInteger }" | |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3926 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3927 |
aString isNil ifTrue:[^ self]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3928 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3929 |
^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr |
121 | 3930 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3931 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3932 |
l := lineNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3933 |
c := colNr. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3934 |
start := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3935 |
end := aString size. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3936 |
[start <= end] whileTrue:[ |
4823 | 3937 |
stop := aString indexOf:(Character cr) startingAt:start. |
3938 |
stop == 0 ifTrue:[ |
|
3939 |
stop := end + 1 |
|
3940 |
]. |
|
3941 |
subString := aString copyFrom:start to:(stop - 1). |
|
3942 |
self insertStringWithoutCRs:subString atLine:l col:c. |
|
3943 |
(stop <= end) ifTrue:[ |
|
3944 |
c := c + subString size. |
|
3945 |
self insert:(Character cr) atLine:l col:c. |
|
3946 |
l := l + 1. |
|
3947 |
c := 1 |
|
3948 |
]. |
|
3949 |
start := stop + 1 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3950 |
] |
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
3951 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3952 |
"Modified: / 10.6.1998 / 19:03:59 / cg" |
121 | 3953 |
! |
3954 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3955 |
insertStringAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3956 |
"insert the argument, aString at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3957 |
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
|
3958 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3959 |
aString isNil ifTrue:[ |
4823 | 3960 |
"new:" |
3961 |
self insertCharAtCursor:(Character cr). |
|
3962 |
^ self |
|
105 | 3963 |
]. |
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3964 |
(aString includes:(Character cr)) ifFalse:[ |
4823 | 3965 |
^ self insertStringWithoutCRsAtCursor:aString |
105 | 3966 |
]. |
3967 |
||
654 | 3968 |
self insertLines:aString asStringCollection withCR:false. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3969 |
|
1560
43d0f7c2143f
use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents:
1559
diff
changeset
|
3970 |
"Modified: / 10.6.1998 / 19:03:21 / cg" |
105 | 3971 |
! |
3972 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3973 |
insertStringWithoutCRs:aString atLine:lineNr col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3974 |
"insert aString (which has no crs) at lineNr/colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3975 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3976 |
self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
4190 | 3977 |
shown ifTrue:[ |
4889 | 3978 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 3979 |
self invalidateLine:lineNr. |
3980 |
] ifFalse:[ |
|
3981 |
self redrawLine:lineNr from:colNr |
|
3982 |
] |
|
3983 |
] |
|
3984 |
||
4191 | 3985 |
"Modified: / 09-11-2010 / 13:43:03 / cg" |
105 | 3986 |
! |
3987 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3988 |
insertStringWithoutCRsAtCursor:aString |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3989 |
"insert a string (which has no crs) at cursor position |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3990 |
- advance cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
3991 |
|
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3992 |
|wasOn oldLen newLen deltaLen| |
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3993 |
|
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
3994 |
aString size > 0 ifTrue:[ |
4823 | 3995 |
wasOn := self hideCursor. |
3996 |
(aString includes:Character tab) ifTrue:[ |
|
3997 |
self checkForExistingLine:cursorLine. |
|
3998 |
oldLen := (list at:cursorLine) size. |
|
3999 |
self insertString:aString atLine:cursorLine col:cursorCol. |
|
4000 |
newLen := (list at:cursorLine) size. |
|
4001 |
deltaLen := newLen - oldLen. |
|
4002 |
] ifFalse:[ |
|
4003 |
self insertString:aString atLine:(cursorLine ? 1) col:cursorCol. |
|
4004 |
deltaLen := aString size. |
|
4005 |
]. |
|
4006 |
self setCursorCol:(cursorCol + deltaLen). |
|
4007 |
wasOn ifTrue:[self showCursor] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4008 |
] |
1563
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
4009 |
|
b4eb49efdfcd
fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents:
1561
diff
changeset
|
4010 |
"Modified: / 10.6.1998 / 20:43:52 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4011 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4012 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4013 |
insertTabAtCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4014 |
"insert spaces to next tab" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4015 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4016 |
|wasOn nextTab| |
105 | 4017 |
|
121 | 4018 |
wasOn := self hideCursor. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4019 |
nextTab := self nextTabAfter:cursorCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4020 |
self insertStringAtCursor:(String new:(nextTab - cursorCol)). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4021 |
self makeCursorVisibleAndShowCursor:wasOn. |
105 | 4022 |
! |
4023 |
||
3542 | 4024 |
joinLines |
3890 | 4025 |
"join lines (remove line-break)" |
4026 |
||
3583 | 4027 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
4028 |
||
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
4029 |
self |
3890 | 4030 |
undoableDo:[ |
4031 |
|line col lineLen| |
|
4032 |
||
4033 |
line := cursorLine. |
|
4034 |
col := cursorCol. |
|
4035 |
lineLen := (list at:line) size. |
|
4036 |
col > lineLen ifTrue:[ |
|
4037 |
self insertString:(String new:col-lineLen) atLine:line col:col+1. |
|
4038 |
] ifFalse:[ |
|
4039 |
self deleteCharsAtLine:line fromCol:col toCol:lineLen. |
|
4040 |
]. |
|
4041 |
self mergeLine:line removeBlanks:true. |
|
4042 |
self cursorLine:line col:col. |
|
4043 |
] |
|
4044 |
info:'Join' |
|
3542 | 4045 |
! |
4046 |
||
2952 | 4047 |
mergeLine:lineNr |
4048 |
"merge line lineNr with line lineNr+1" |
|
4049 |
||
4050 |
self mergeLine:lineNr removeBlanks:true |
|
4051 |
||
4052 |
"Modified: 9.9.1997 / 09:28:03 / cg" |
|
4053 |
! |
|
4054 |
||
4458 | 4055 |
mergeLine:lineNr removeBlanks:removeBlanks |
4056 |
"merge line lineNr with line lineNr+1" |
|
4057 |
||
4058 |
|len| |
|
4059 |
||
4060 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4061 |
||
4062 |
len := (self listAt:lineNr) size. |
|
4063 |
self nonUndoableDo:[ |
|
4823 | 4064 |
self basicMergeLine:lineNr removeBlanks:removeBlanks. |
4458 | 4065 |
]. |
4066 |
self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false). |
|
4067 |
! |
|
4068 |
||
5761 | 4069 |
parenthizeSelection |
4070 |
"place parenthesis around the selected text. |
|
4071 |
if already parenthized, de-parenthize it" |
|
4072 |
||
4073 |
self parenthizeSelectionWith:$( and:$) |
|
4074 |
||
4075 |
"Created: / 06-06-2016 / 10:59:05 / cg" |
|
4076 |
! |
|
4077 |
||
2506 | 4078 |
parenthizeSelectionWith:openingCharacter and:closingCharacter |
5761 | 4079 |
"if already parenthized, de-parenthize it" |
4080 |
||
5560 | 4081 |
|newSelectionEnd startLine endLine startCol endCol| |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4082 |
|
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4083 |
self hasSelection ifFalse:[^ self]. |
5560 | 4084 |
startLine := selectionStartLine. |
4085 |
endLine := selectionEndLine. |
|
4086 |
startCol := selectionStartCol. |
|
4087 |
endCol := selectionEndCol. |
|
4088 |
||
4089 |
newSelectionEnd := endCol. |
|
4090 |
||
4091 |
(self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[ |
|
4092 |
(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[ |
|
4093 |
self deleteCharAtLine:endLine col:endCol. |
|
4823 | 4094 |
newSelectionEnd := newSelectionEnd-1. |
4095 |
]. |
|
5560 | 4096 |
self deleteCharAtLine:startLine col:startCol. |
4097 |
startLine == endLine ifTrue:[ |
|
4823 | 4098 |
newSelectionEnd := newSelectionEnd-1. |
4099 |
] |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4100 |
] ifFalse:[ |
5560 | 4101 |
self insert:closingCharacter atLine:endLine col:endCol+1. |
4823 | 4102 |
newSelectionEnd := newSelectionEnd+1. |
5560 | 4103 |
self insert:openingCharacter atLine:startLine col:startCol. |
4104 |
startLine == endLine ifTrue:[ |
|
4823 | 4105 |
newSelectionEnd := newSelectionEnd+1. |
4106 |
] |
|
3160 | 4107 |
]. |
4108 |
self |
|
5560 | 4109 |
selectFromLine:startLine col:startCol |
4110 |
toLine:endLine col:newSelectionEnd. |
|
5761 | 4111 |
|
4112 |
"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
|
4113 |
! |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
4114 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4115 |
removeTrailingBlankLines |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4116 |
"remove all blank lines at end of text" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4117 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4118 |
|lastLine "{ Class: SmallInteger }" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4119 |
line finished| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4120 |
|
5114 | 4121 |
NoModificationError handle:[:ex | |
4122 |
^ self |
|
4123 |
] do:[ |
|
4124 |
lastLine := list size. |
|
4125 |
finished := false. |
|
4126 |
[finished] whileFalse:[ |
|
4127 |
(lastLine <= 1) ifTrue:[ |
|
4771 | 4128 |
finished := true |
4129 |
] ifFalse:[ |
|
5114 | 4130 |
line := list at:lastLine. |
4131 |
line notNil ifTrue:[ |
|
4132 |
line isBlank ifTrue:[ |
|
4133 |
self basicListAt:lastLine put:nil. |
|
4134 |
line := nil |
|
4135 |
] |
|
4136 |
]. |
|
4137 |
line notNil ifTrue:[ |
|
4138 |
finished := true |
|
4139 |
] ifFalse:[ |
|
4140 |
lastLine := lastLine - 1 |
|
4141 |
] |
|
4771 | 4142 |
] |
5114 | 4143 |
]. |
4144 |
(lastLine ~~ list size) ifTrue:[ |
|
4145 |
list grow:lastLine. |
|
4146 |
"/ self textChanged |
|
4771 | 4147 |
] |
118 | 4148 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4149 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4150 |
|
4458 | 4151 |
replace:aCharacter atLine:lineNr col:colNr |
4152 |
"replace a single character at lineNr/colNr" |
|
4153 |
||
4154 |
|originalChar| |
|
4155 |
||
4156 |
originalChar := self characterAtLine:lineNr col:colNr. |
|
4157 |
self basicReplace:aCharacter atLine:lineNr col:colNr. |
|
4158 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace'). |
|
4159 |
! |
|
4160 |
||
4713 | 4161 |
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase |
3430 | 4162 |
|pattern replacePattern| |
4163 |
||
4164 |
pattern := patternArg string. |
|
4165 |
replacePattern := replacePatternArg string. |
|
4630 | 4166 |
(pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[ |
4167 |
self rememberSearchPattern:pattern. |
|
4168 |
self rememberSearchPattern:replacePattern. |
|
4713 | 4169 |
LastSearchIgnoredCase := ignoreCase. |
4630 | 4170 |
self |
4171 |
undoableDo:[ |
|
4172 |
all ifTrue:[ |
|
4173 |
self |
|
4174 |
replaceString:pattern |
|
4175 |
to:replacePattern |
|
4713 | 4176 |
ignoreCase:ignoreCase |
4630 | 4177 |
] ifFalse:[ |
4178 |
(self selectionAsString notNil |
|
4713 | 4179 |
and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ]) |
4630 | 4180 |
ifTrue:[ |
4742 | 4181 |
self replaceSelectionBy:replacePattern. |
4630 | 4182 |
self |
4183 |
search:pattern |
|
4713 | 4184 |
ignoreCase:ignoreCase |
4630 | 4185 |
forward:(lastSearchDirection = #forward). |
4186 |
]. |
|
4187 |
] |
|
4188 |
] |
|
4189 |
info:'Replace' |
|
3430 | 4190 |
] |
4191 |
||
4192 |
"Created: / 11-07-2006 / 11:19:57 / fm" |
|
4193 |
! |
|
4194 |
||
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4195 |
replaceCharAtCursor:aCharacter |
5413 | 4196 |
"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
|
4197 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4198 |
|wasOn| |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4199 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4200 |
wasOn := self hideCursor. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4201 |
aCharacter == (Character cr) ifTrue:[ |
4823 | 4202 |
self cursorReturn |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4203 |
] ifFalse:[ |
4823 | 4204 |
self replace:aCharacter atLine:cursorLine col:cursorCol. |
4205 |
self cursorRight. |
|
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4206 |
]. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4207 |
self makeCursorVisibleAndShowCursor:wasOn. |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4208 |
|
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4209 |
"Created: 6.3.1996 / 12:27:42 / cg" |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4210 |
! |
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4211 |
|
4458 | 4212 |
replaceContentsWith:newContents |
5413 | 4213 |
"undoably replace everything" |
4458 | 4214 |
|
4215 |
|originalContents| |
|
4216 |
||
4217 |
originalContents := self contents. |
|
4218 |
self contents:newContents keepUndoHistory:true. |
|
4219 |
self addUndo:(ReplaceContents text:originalContents info:'replace'). |
|
4220 |
! |
|
4221 |
||
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4222 |
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString |
5413 | 4223 |
"undoably replace a substring at a character position" |
2427
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4224 |
|
5216 | 4225 |
"/ 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
|
4226 |
self insertString:newString atCharacterPosition:charPos1. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4227 |
self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size. |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4228 |
! |
43cc7ea39bac
more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents:
2422
diff
changeset
|
4229 |
|
4458 | 4230 |
replaceLine:lineNr with:newText |
5413 | 4231 |
"undoably replace a line at lineNr" |
4458 | 4232 |
|
4233 |
|originalLine| |
|
4234 |
||
4235 |
originalLine := self listAt:lineNr. |
|
4236 |
originalLine isNil ifTrue:[ |
|
4823 | 4237 |
self checkForExistingLine:lineNr |
4458 | 4238 |
]. |
4239 |
self list at:lineNr put:newText. |
|
4240 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4241 |
self invalidateLine:lineNr. |
|
4242 |
||
4243 |
"Modified: / 12-04-2007 / 09:31:33 / cg" |
|
4244 |
! |
|
4245 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4246 |
replaceLines:lines withCR:withCr |
5413 | 4247 |
"undoably a bunch of lines at cursor position. Cursor |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4248 |
is moved behind replacement. |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4249 |
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
|
4250 |
after the last line" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4251 |
|
1809 | 4252 |
|line col nLines wasOn| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4253 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4254 |
lines notNil ifTrue:[ |
4661 | 4255 |
wasOn := self hideCursor. |
4256 |
nLines := lines size. |
|
4257 |
line := cursorLine. |
|
4258 |
col := cursorCol. |
|
4259 |
lines keysAndValuesDo:[:i :l | |
|
4260 |
self replaceString:(l ? '') atLine:line col:col. |
|
4261 |
(i ~~ nLines or:[withCr]) ifTrue:[ |
|
4262 |
line := line + 1. |
|
4263 |
col := 1. |
|
4264 |
] ifFalse:[ |
|
4265 |
col := col + (l size). |
|
4266 |
] |
|
4267 |
]. |
|
4268 |
self cursorLine:line col:col. |
|
4269 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
4270 |
"/ wasOn ifTrue:[self showCursor]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4271 |
] |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4272 |
|
4661 | 4273 |
"Created: / 18-05-1996 / 15:32:06 / cg" |
4274 |
"Modified: / 25-07-2013 / 17:00:53 / cg" |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4275 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4276 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4277 |
replaceSelectionBy:something |
5413 | 4278 |
"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
|
4279 |
leave cursor after insertion" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
4280 |
|
4666 | 4281 |
self replaceSelectionBy:something keepCursor:false select:false |
105 | 4282 |
! |
4283 |
||
4284 |
replaceSelectionBy:something keepCursor:keep |
|
5413 | 4285 |
"undoably delete the selection (if any) and insert something, a character or string; |
105 | 4286 |
leave cursor after insertion or leave it, depending on keep" |
4287 |
||
4666 | 4288 |
self replaceSelectionBy:something keepCursor:keep select:false |
4289 |
||
4290 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
|
4291 |
! |
|
4292 |
||
4293 |
replaceSelectionBy:something keepCursor:keep select:selectNewText |
|
5413 | 4294 |
"undoably delete the selection (if any) and insert something, a character or string; |
4666 | 4295 |
leave cursor after insertion or leave it, depending on keep. |
4296 |
If selectNewText is true, select the new text; otherwise deselect" |
|
4297 |
||
4298 |
|sel l c selStartLine selStartCol| |
|
105 | 4299 |
|
4300 |
l := cursorLine. |
|
4301 |
c := cursorCol. |
|
4302 |
||
4818 | 4303 |
sel := self selectionAsString. |
4666 | 4304 |
sel isNil ifTrue:[ |
4305 |
selStartLine := l. |
|
4306 |
selStartCol := c. |
|
4307 |
] ifFalse:[ |
|
4308 |
selStartLine := selectionStartLine. |
|
4309 |
selStartCol := selectionStartCol. |
|
4310 |
||
4053 | 4311 |
self setLastStringToReplace: sel. |
4312 |
||
4010 | 4313 |
self deleteSelection. |
4314 |
replacing := true. |
|
4818 | 4315 |
lastReplacementInfo rememberReplacement. |
4048 | 4316 |
lastReplacementInfo lastReplacement: ''. |
4818 | 4317 |
lastReplacementInfo stillCollectingInput:true. |
4010 | 4318 |
undoSupport actionInfo:'replace'. |
3161 | 4319 |
]. |
4320 |
||
4321 |
something isCharacter ifTrue:[ |
|
4051 | 4322 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
4818 | 4323 |
lastReplacementInfo stillCollectingInput ifTrue:[ |
4051 | 4324 |
lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something). |
4818 | 4325 |
]. |
4010 | 4326 |
]. |
4327 |
self isInInsertMode ifTrue:[ |
|
4328 |
self insertCharAtCursor:something |
|
4329 |
] ifFalse:[ |
|
4330 |
self replaceCharAtCursor:something |
|
4331 |
] |
|
105 | 4332 |
] ifFalse:[ |
4010 | 4333 |
something isString ifTrue:[ |
4048 | 4334 |
lastReplacementInfo lastReplacement: something. |
4010 | 4335 |
self isInInsertMode ifTrue:[ |
4336 |
self insertStringAtCursor:something |
|
4337 |
] ifFalse:[ |
|
4338 |
self replaceStringAtCursor:something |
|
4339 |
] |
|
4340 |
] ifFalse:[ |
|
4341 |
Transcript showCR:'EditTextView: non String-or-Character in replace'. |
|
4342 |
]. |
|
105 | 4343 |
]. |
4344 |
keep ifTrue:[ |
|
4010 | 4345 |
self cursorLine:l col:c |
4666 | 4346 |
]. |
4347 |
selectNewText ifTrue:[ |
|
4348 |
self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1 |
|
105 | 4349 |
] |
477
e7c29649e8ae
fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
4350 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
4351 |
"Modified: 9.10.1996 / 16:14:35 / cg" |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4352 |
! |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4353 |
|
4458 | 4354 |
replaceString:aString atLine:lineNr col:colNr |
5413 | 4355 |
"undoably replace multiple characters starting at lineNr/colNr. |
4458 | 4356 |
This is not prepared to encounter special chars (except TAB) in the string." |
4357 |
||
4358 |
|originalString| |
|
4359 |
||
4360 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4361 |
||
4362 |
originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1. |
|
4363 |
||
4364 |
self basicReplaceString:aString atLine:lineNr col:colNr. |
|
4365 |
self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace'). |
|
4366 |
! |
|
4367 |
||
4713 | 4368 |
replaceString:aString to:aNewString ignoreCase:ignoreCase |
3549 | 4369 |
|continue count| |
4370 |
||
4371 |
self cursorToTop. |
|
4372 |
self selectFromBeginning. |
|
4373 |
count := 0. |
|
4374 |
continue := true. |
|
4375 |
[ continue ] whileTrue:[ |
|
4713 | 4376 |
(self selectionAsString notNil |
4377 |
and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ]) |
|
4378 |
ifTrue:[ |
|
4742 | 4379 |
self replaceSelectionBy:aNewString. |
4713 | 4380 |
count := count + 1. |
4381 |
]. |
|
4382 |
self |
|
4383 |
searchFwd:aString |
|
4384 |
ignoreCase:ignoreCase |
|
4385 |
ifAbsent:[ |
|
4386 |
Dialog information:('%1 has been replaced by %2 %3 times' |
|
4387 |
bindWith:aString with:aNewString with:count). |
|
4388 |
continue := false. |
|
4389 |
]. |
|
3549 | 4390 |
]. |
3430 | 4391 |
|
4392 |
"Created: / 10-07-2006 / 16:42:48 / fm" |
|
4393 |
! |
|
4394 |
||
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4395 |
replaceStringAtCursor:aString |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4396 |
"replace multiple characters at cursor-position - advance cursor" |
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4397 |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4398 |
|wasOn i1 i2| |
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4399 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4400 |
wasOn := self hideCursor. |
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4401 |
(aString includes:Character tab) ifTrue:[ |
4823 | 4402 |
"/ need special care for TAB (to move cursor correctly) |
4403 |
i1 := 1. |
|
4404 |
[i1 ~~ 0] whileTrue:[ |
|
4405 |
i2 := aString indexOf:Character tab startingAt:i1. |
|
4406 |
i2 ~~ 0 ifTrue:[ |
|
4407 |
i1 ~~ i2 ifTrue:[ |
|
4408 |
self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol. |
|
4409 |
self cursorCol:(cursorCol + (i2 - i1)). |
|
4410 |
]. |
|
4411 |
self replaceTABAtCursor. |
|
4412 |
i2 := i2 + 1. |
|
4413 |
] ifFalse:[ |
|
4414 |
self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol. |
|
4415 |
self cursorCol:(cursorCol + (aString size - i1 + 1)). |
|
4416 |
]. |
|
4417 |
i1 := i2. |
|
4418 |
] |
|
1566
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4419 |
] ifFalse:[ |
4823 | 4420 |
self replaceString:aString atLine:cursorLine col:cursorCol. |
5325 | 4421 |
self setValidatedCursorCol:(cursorCol + aString size). |
4422 |
"/ self cursorCol:(cursorCol + aString size). |
|
4423 |
]. |
|
4424 |
wasOn ifTrue:[ |
|
4425 |
self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } |
|
4426 |
"/ self makeCursorVisibleAndShowCursor:wasOn. |
|
4427 |
]. |
|
1564
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4428 |
|
04c13358013e
renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
4429 |
"Created: / 9.6.1998 / 20:33:20 / cg" |
1597
5fdcfcedb91c
fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents:
1596
diff
changeset
|
4430 |
"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
|
4431 |
! |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4432 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4433 |
replaceTABAtCursor |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4434 |
"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
|
4435 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4436 |
|wasOn nextTab| |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4437 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4438 |
wasOn := self hideCursor. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4439 |
nextTab := self nextTabAfter:cursorCol. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4440 |
self replaceStringAtCursor:(String new:(nextTab - cursorCol)). |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4441 |
self makeCursorVisibleAndShowCursor:wasOn. |
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4442 |
|
4e37a55bd140
care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
4443 |
"Created: / 12.6.1998 / 21:53:23 / cg" |
3890 | 4444 |
! |
4445 |
||
4256
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4446 |
selectWordBeforeCursor |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4447 |
"select the word to the left of cursor" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4448 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4449 |
|savCursorLine savCursorCol beginCol beginLine endCol endLine| |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4450 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4451 |
savCursorLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4452 |
savCursorCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4453 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4454 |
endCol := cursorCol-1. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4455 |
endLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4456 |
self cursorToPreviousWord. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4457 |
beginCol := cursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4458 |
beginLine := cursorLine. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4459 |
self cursorLine:savCursorLine col:savCursorCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4460 |
self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4461 |
|
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4462 |
"Created: / 14-06-2011 / 14:46:35 / cg" |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4463 |
! |
1e4bdc48136c
added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents:
4253
diff
changeset
|
4464 |
|
4458 | 4465 |
splitLine:lineNr before:colNr |
4466 |
"split the line linNr before colNr; the right part (from colNr) |
|
4467 |
is cut off and inserted after lineNr; the view is redrawn" |
|
4468 |
||
4469 |
self basicSplitLine:lineNr before:colNr. |
|
4470 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split'). |
|
4471 |
! |
|
4472 |
||
5761 | 4473 |
toggleTabSetting |
4474 |
"toggle between 4-col |
|
4475 |
and 8-col tabs" |
|
4476 |
||
4477 |
(tabPositions == self class tab4Positions) |
|
4478 |
ifTrue:[self setTab8] |
|
4479 |
ifFalse:[self setTab4] |
|
4480 |
||
4481 |
"Created: / 06-06-2016 / 11:02:07 / cg" |
|
4482 |
! |
|
4483 |
||
4484 |
undentSelectionBy1 |
|
4485 |
"undent selected line-range |
|
4486 |
by 1 space (i.e. to the left)" |
|
4487 |
||
4488 |
self undentBy:1 |
|
4489 |
||
4490 |
"Created: / 06-06-2016 / 10:49:51 / cg" |
|
4491 |
! |
|
4492 |
||
5146 | 4493 |
withAutoIndent:aBoolean do:aBlock |
4494 |
|sav| |
|
4495 |
||
4496 |
sav := autoIndent. |
|
4497 |
autoIndent := aBoolean. |
|
4498 |
aBlock ensure:[ autoIndent := sav ]. |
|
4499 |
! |
|
4500 |
||
4458 | 4501 |
withoutRedrawAt:lineNr put:aString |
4502 |
"replace a line at lineNr" |
|
4503 |
||
4504 |
|originalLine| |
|
4505 |
||
4506 |
originalLine := self listAt:lineNr. |
|
4507 |
self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace'). |
|
4508 |
super withoutRedrawAt:lineNr put:aString. |
|
4509 |
! |
|
4510 |
||
4511 |
withoutRedrawInsertLine:aString before:lineNr |
|
4512 |
"insert the argument, aString before line lineNr; the string |
|
4513 |
becomes line lineNr; everything else is moved down; the view |
|
4514 |
is not redrawn" |
|
4515 |
||
4771 | 4516 |
self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr. |
4458 | 4517 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert'). |
4518 |
! |
|
4519 |
||
4520 |
withoutRedrawInsertLines:lines from:start to:end before:lineNr |
|
4521 |
"insert a bunch of lines before line lineNr; the view is not redrawn" |
|
4522 |
||
4523 |
self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr. |
|
4524 |
self isReadOnly ifFalse:[ |
|
4823 | 4525 |
self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert'). |
4458 | 4526 |
]. |
4527 |
! |
|
4528 |
||
4529 |
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4530 |
"insert aString (which has no crs) at lineNr/colNr" |
|
4531 |
||
4532 |
self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
4533 |
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert'). |
|
4534 |
! |
|
4535 |
||
3890 | 4536 |
wrapLines |
4537 |
"wrap lines (insert line-break)" |
|
4538 |
||
4539 |
|lineLength answerString string| |
|
4540 |
||
4541 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4542 |
||
4543 |
self hasSelection ifFalse:[ |
|
4544 |
self selectLine:cursorLine. |
|
4545 |
]. |
|
4546 |
string := self selectionAsString. |
|
4547 |
string isEmptyOrNil ifTrue:[ |
|
4548 |
Dialog information:(resources string:'Nothing selected.'). |
|
4549 |
^ self. |
|
4550 |
]. |
|
4551 |
||
4552 |
answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80. |
|
4553 |
lineLength := Number readFrom:answerString onError:nil. |
|
4388 | 4554 |
lineLength isNil ifTrue:[^ self]. |
3890 | 4555 |
lineLength < 1 ifTrue:[ |
4556 |
lineLength := 1. |
|
4557 |
]. |
|
4558 |
||
4559 |
self |
|
4560 |
undoableDo:[ |
|
4561 |
|inStream line col lineLen lastGoodCol lastStartCol word| |
|
4562 |
||
4563 |
line := selectionStartLine. |
|
4564 |
col := selectionStartCol. |
|
4565 |
||
4566 |
self cutSelection. |
|
4567 |
self cursorLine:line col:col. |
|
4568 |
||
4569 |
lastGoodCol := col. |
|
4570 |
||
4571 |
inStream := string readStream. |
|
4572 |
[ inStream atEnd ] whileFalse:[ |
|
4573 |
[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ]. |
|
4574 |
word := WriteStream on:(String new:10). |
|
4575 |
[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ]. |
|
4576 |
(col + 1 + word size > lineLength) ifTrue:[ |
|
4577 |
self insertCharAtCursor:(Character cr). |
|
4578 |
col := 1. |
|
4579 |
] ifFalse:[ |
|
4580 |
col ~~ 1 ifTrue:[ |
|
4581 |
self insertStringAtCursor:' '. |
|
4582 |
col := col + 1. |
|
4583 |
] |
|
4584 |
]. |
|
4585 |
self insertStringAtCursor:word contents. |
|
4586 |
col := col + word size. |
|
4587 |
]. |
|
4588 |
] |
|
4589 |
info:'Wrap' |
|
4388 | 4590 |
|
4591 |
"Modified: / 01-03-2012 / 19:56:22 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4592 |
! ! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4593 |
|
2752 | 4594 |
!EditTextView methodsFor:'editing-basic'! |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4595 |
|
2952 | 4596 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
3549 | 4597 |
"delete characters from startCol to endCol in line lineNr" |
4598 |
||
1803
ac7cc1b99407
scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4599 |
|line lineSize newLine start stop prevWidth newWidth| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4600 |
|
4673 | 4601 |
self unselect. |
4602 |
||
4603 |
cursorLine == lineNr ifTrue:[ |
|
5909 | 4604 |
cursorCol >= startCol ifTrue:[ |
4605 |
cursorCol >= endCol ifTrue:[ |
|
4606 |
cursorCol := startCol. |
|
4607 |
] ifFalse:[ |
|
4608 |
cursorCol := cursorCol - (endCol - startCol + 1). |
|
4609 |
"/ self assert:(cursorCol >= 0). |
|
4610 |
cursorCol := cursorCol max:1. |
|
4611 |
] |
|
4612 |
]. |
|
4673 | 4613 |
]. |
4614 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4615 |
line := self listAt:lineNr. |
827 | 4616 |
|
4673 | 4617 |
(self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self]. |
4618 |
||
4619 |
lineSize := line size. |
|
4620 |
||
4621 |
startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ]. |
|
4622 |
endCol > lineSize ifFalse:[ stop := endCol ] ifTrue:[ stop := lineSize ]. |
|
4623 |
||
4624 |
stop >= start ifTrue:[ |
|
5909 | 4625 |
start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ] |
4626 |
ifFalse:[ newLine := '' ]. |
|
4627 |
||
4628 |
stop == lineSize ifFalse:[ |
|
4629 |
line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
|
4630 |
newLine := line string species fromString:newLine. |
|
4631 |
]. |
|
4632 |
newLine := newLine, (line copyFrom:(stop + 1) to:lineSize) |
|
4633 |
]. |
|
4634 |
||
4635 |
(self trimBlankLines and:[newLine isBlank]) ifTrue:[ |
|
4636 |
newLine := nil |
|
4637 |
]. |
|
4638 |
||
4639 |
prevWidth := self widthOfLine:lineNr. |
|
4640 |
||
4641 |
self basicListAt:lineNr put:newLine. |
|
4642 |
||
4643 |
(prevWidth = widthOfWidestLine) ifTrue:[ |
|
4644 |
"/ remember old width of this line, |
|
4645 |
"/ only clear widthOfWidestLine, if this lines |
|
4646 |
"/ length was (one of) the longest. |
|
4647 |
"/ avoids slow delete with huge texts. |
|
4648 |
widthOfWidestLine := nil. "i.e. unknown" |
|
4649 |
||
4650 |
"/ scroll left if reqiured |
|
4651 |
viewOrigin x > 0 ifTrue:[ |
|
4652 |
newWidth := self widthOfLine:lineNr. |
|
4653 |
newWidth < (viewOrigin x + width) ifTrue:[ |
|
4654 |
self scrollHorizontalTo:(newWidth |
|
4655 |
- width |
|
4656 |
+ margin + margin |
|
4657 |
+ (gc font widthOf:' ')) |
|
4658 |
] |
|
4659 |
]. |
|
4660 |
self textChanged. |
|
4661 |
] ifFalse:[ |
|
4662 |
self textChanged "/ textChangedButNoSizeChange |
|
4663 |
]. |
|
4664 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4665 |
self invalidateLine:lineNr. |
|
4666 |
] ifFalse:[ |
|
4667 |
self redrawLine:lineNr from:start. |
|
4668 |
]. |
|
4673 | 4669 |
]. |
827 | 4670 |
|
4191 | 4671 |
"Modified: / 09-11-2010 / 13:42:45 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4672 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4673 |
|
2952 | 4674 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4675 |
"delete some lines" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4676 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4677 |
|wasOn nLines| |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4678 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4679 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4680 |
list isNil ifTrue:[^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4681 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4682 |
wasOn := self hideCursor. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4683 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4684 |
"/ isnt this the same as: |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4685 |
"/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr. |
4226 | 4686 |
startLineNr <= list size ifTrue:[ |
4771 | 4687 |
self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size). |
4226 | 4688 |
]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4689 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4690 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4691 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4692 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4693 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4694 |
self textChanged. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4695 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4696 |
self redrawFromLine:startLineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4697 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4698 |
nLines := list size. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4699 |
(firstLineShown >= nLines) ifTrue:[ |
4226 | 4700 |
self makeLineVisible:nLines |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4701 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4702 |
wasOn ifTrue:[self showCursor]. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4703 |
|
4226 | 4704 |
"Modified: / 10-11-1998 / 23:55:05 / cg" |
4705 |
"Modified: / 18-03-2011 / 18:26:23 / az" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4706 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4707 |
|
2952 | 4708 |
basicDeleteLineWithoutRedraw:lineNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4709 |
"delete line - no redraw; |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4710 |
return true, if something was really deleted" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4711 |
|
2952 | 4712 |
self checkModificationsAllowed ifFalse:[ ^ false]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4713 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4714 |
(list isNil or:[lineNr > list size]) ifTrue:[^ false]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4715 |
list removeIndex:lineNr. |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4716 |
"/ TODO: remember old maxwidth of linerange, |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4717 |
"/ only clear widthOfWidestLine, if this max |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4718 |
"/ length was (one of) the longest. |
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4719 |
"/ avoids slow delete with huge texts. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4720 |
widthOfWidestLine := nil. "/ i.e. unknown |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4721 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4722 |
^ true |
1717
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4723 |
|
83203096a851
dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents:
1688
diff
changeset
|
4724 |
"Modified: / 10.11.1998 / 23:53:24 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4725 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4726 |
|
2952 | 4727 |
basicInsert:aCharacter atLine:lineNr col:colNr |
3160 | 4728 |
"insert a single character at lineNr/colNr; |
827 | 4729 |
set emphasis to character at current position" |
4730 |
||
1929
8e70fb7c9701
fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents:
1928
diff
changeset
|
4731 |
|line lineSize newLine drawCharacterOnly attribute oldClip x y| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4732 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4733 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4734 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4735 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4736 |
self splitLine:lineNr before:colNr. |
4737 |
^ self |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4738 |
]. |
827 | 4739 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4740 |
drawCharacterOnly := false. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4741 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4742 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4743 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4744 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
4745 |
self st80EditMode ifFalse:[ |
5909 | 4746 |
(self trimBlankLines |
4747 |
and:[colNr > lineSize |
|
4748 |
and:[aCharacter == Character space]]) ifTrue:[ |
|
4749 |
^ self |
|
4750 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4751 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4752 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4753 |
(lineSize == 0) ifTrue:[ |
5909 | 4754 |
newLine := aCharacter asString species new:colNr. |
4755 |
drawCharacterOnly := true |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4756 |
] ifFalse: [ |
5909 | 4757 |
(colNr > lineSize) ifTrue: [ |
4758 |
colNr == (lineSize +1) ifTrue:[ |
|
4759 |
attribute := line emphasisAt:lineSize |
|
4760 |
]. |
|
4761 |
newLine := line species new:colNr. |
|
4762 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
4763 |
drawCharacterOnly := true |
|
4764 |
] ifFalse: [ |
|
4765 |
attribute := line emphasisAt:colNr. |
|
4766 |
newLine := line species new:(lineSize + 1). |
|
4767 |
||
4768 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
4769 |
newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr |
|
4770 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4771 |
]. |
827 | 4772 |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4773 |
aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[ |
5909 | 4774 |
newLine := aCharacter asString species fromString:newLine. |
4775 |
line isText ifTrue:[ |
|
4776 |
newLine := newLine asText |
|
4777 |
] |
|
2869
48d830f0aea5
insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents:
2866
diff
changeset
|
4778 |
]. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4779 |
newLine at:colNr put:aCharacter. |
827 | 4780 |
|
4781 |
attribute notNil ifTrue:[ |
|
5909 | 4782 |
newLine emphasisAt:colNr put:attribute. |
827 | 4783 |
]. |
4784 |
||
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4785 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4786 |
newLine := self withTabsExpanded:newLine. |
4787 |
drawCharacterOnly := false |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4788 |
]. |
827 | 4789 |
|
4771 | 4790 |
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
|
4791 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4792 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4793 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4794 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4795 |
shown ifTrue:[ |
5909 | 4796 |
"/ care for italic text - in this case, we must also |
4797 |
"/ redraw the character before the insertion in order |
|
4798 |
"/ to fix the slanted piece of the character. |
|
4799 |
"/ (but we must clip, to avoid destoying the character before) |
|
4800 |
(newLine notNil and:[newLine isText]) ifTrue:[ |
|
4801 |
colNr > 1 ifTrue:[ |
|
4802 |
cursorVisibleLine notNil ifTrue:[ |
|
4803 |
oldClip := self clippingRectangleOrNil. |
|
4804 |
x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x. |
|
4805 |
y := self yOfVisibleLine:cursorVisibleLine. |
|
4806 |
||
4807 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4808 |
self invalidateLine:lineNr. |
|
4809 |
] ifFalse:[ |
|
4810 |
drawCharacterOnly ifTrue:[ |
|
4811 |
self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)). |
|
4812 |
self redrawLine:lineNr from:colNr-1 to:colNr |
|
4813 |
] ifFalse:[ |
|
4814 |
self clippingRectangle:(x@y extent:((width - x) @ fontHeight)). |
|
4815 |
self redrawLine:lineNr from:colNr-1 |
|
4816 |
]. |
|
4817 |
self clippingRectangle:oldClip. |
|
4818 |
]. |
|
4819 |
]. |
|
4820 |
^ self. |
|
4821 |
]. |
|
4822 |
]. |
|
4823 |
gc font hasOverlappingCharacters ifTrue:[ |
|
4824 |
self invalidateLine:lineNr. |
|
4825 |
] ifFalse:[ |
|
4826 |
drawCharacterOnly ifTrue:[ |
|
4827 |
self redrawLine:lineNr col:colNr |
|
4828 |
] ifFalse:[ |
|
4829 |
self redrawLine:lineNr from:colNr |
|
4830 |
] |
|
4831 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4832 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4833 |
|
4191 | 4834 |
"Modified: / 09-11-2010 / 13:43:18 / cg" |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4835 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4836 |
|
4771 | 4837 |
basicListAt:lineNr put:newLine |
4838 |
"redefinable for special subclasses (with virtual list)" |
|
4839 |
||
4840 |
list at:lineNr put:newLine. |
|
4841 |
! |
|
4842 |
||
4843 |
basicListRemoveFromIndex:startLineNr toIndex:endLineNr |
|
4844 |
"redefinable for special subclasses (with virtual list)" |
|
4845 |
||
4846 |
list removeFromIndex:startLineNr toIndex:(endLineNr min:list size). |
|
4847 |
! |
|
4848 |
||
2952 | 4849 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
1319 | 4850 |
"merge line lineNr with line lineNr+1" |
4851 |
||
827 | 4852 |
|leftPart rightPart bothParts nextLineNr i| |
4853 |
||
2356
6416beb0f23a
backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents:
2350
diff
changeset
|
4854 |
(list notNil and:[(list size) >= lineNr]) ifFalse:[ |
5909 | 4855 |
"/ empty list or beyond end of text |
4856 |
^ self |
|
827 | 4857 |
]. |
4858 |
leftPart := self listAt:lineNr. |
|
4859 |
||
4860 |
leftPart isNil ifTrue:[ |
|
5909 | 4861 |
leftPart := ''. |
4862 |
autoIndent ifTrue:[ |
|
4863 |
(i := self leftIndentForLine:cursorLine) == 0 ifFalse:[ |
|
4864 |
leftPart := String new:i |
|
4865 |
] |
|
4866 |
] |
|
827 | 4867 |
]. |
4868 |
self cursorLine:lineNr col:((leftPart size) + 1). |
|
4869 |
nextLineNr := self validateCursorLine:(lineNr + 1). |
|
4870 |
||
4871 |
nextLineNr > (list size) ifFalse:[ |
|
5909 | 4872 |
(rightPart := self listAt:nextLineNr) isNil ifTrue:[ |
4873 |
rightPart := '' |
|
4874 |
] ifFalse:[ |
|
4875 |
removeBlanks ifTrue:[ |
|
4876 |
rightPart := rightPart withoutLeadingSeparators. |
|
4877 |
] |
|
4878 |
]. |
|
4879 |
||
4880 |
bothParts := leftPart , rightPart. |
|
4881 |
(self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil]. |
|
4882 |
self basicListAt:lineNr put:bothParts. |
|
4883 |
self redrawLine:lineNr. |
|
4884 |
self deleteLine:nextLineNr |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4885 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4886 |
|
1319 | 4887 |
"Created: 9.9.1997 / 09:27:38 / cg" |
4888 |
"Modified: 9.9.1997 / 09:28:27 / cg" |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4889 |
! |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4890 |
|
2952 | 4891 |
basicReplace:aCharacter atLine:lineNr col:colNr |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4892 |
"replace a single character at lineNr/colNr" |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4893 |
|
5045 | 4894 |
|line lineSize newLineSpecies newLine drawCharacterOnly| |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4895 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4896 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4897 |
|
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4898 |
aCharacter == (Character cr) ifTrue:[ |
5909 | 4899 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4900 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4901 |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4902 |
drawCharacterOnly := true. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4903 |
self checkForExistingLine:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4904 |
line := list at:lineNr. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4905 |
lineSize := line size. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4906 |
|
5909 | 4907 |
(self trimBlankLines |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4908 |
and:[colNr > lineSize |
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4909 |
and:[aCharacter == Character space]]) ifTrue:[ |
5909 | 4910 |
^ self |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4911 |
]. |
671
f3fe0d8c604d
added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents:
666
diff
changeset
|
4912 |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4913 |
(lineSize == 0) ifTrue:[ |
5909 | 4914 |
newLine := aCharacter asString species new:colNr. |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4915 |
] ifFalse: [ |
5045 | 4916 |
(aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5909 | 4917 |
newLineSpecies := aCharacter stringSpecies |
4918 |
] ifFalse:[ |
|
4919 |
newLineSpecies := line species |
|
4920 |
]. |
|
4921 |
newLine := newLineSpecies new:(colNr max:lineSize). |
|
4922 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4923 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4924 |
newLine at:colNr put:aCharacter. |
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4925 |
aCharacter == (Character tab) ifTrue:[ |
5909 | 4926 |
newLine := self withTabsExpanded:newLine. |
4927 |
drawCharacterOnly := false |
|
1558
abf35cc39757
minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
4928 |
]. |
4771 | 4929 |
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
|
4930 |
widthOfWidestLine notNil ifTrue:[ |
5909 | 4931 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4932 |
]. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4933 |
self textChanged. |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4934 |
shown ifTrue:[ |
5909 | 4935 |
gc font hasOverlappingCharacters ifTrue:[ |
4936 |
self invalidateLine:lineNr. |
|
4937 |
] ifFalse:[ |
|
4938 |
drawCharacterOnly ifTrue:[ |
|
4939 |
self redrawLine:lineNr col:colNr |
|
4940 |
] ifFalse:[ |
|
4941 |
self redrawLine:lineNr from:colNr |
|
4942 |
] |
|
4943 |
] |
|
629
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4944 |
] |
cf0a3ab9b9f1
Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents:
606
diff
changeset
|
4945 |
|
4190 | 4946 |
"Created: / 06-03-1996 / 12:29:20 / cg" |
4191 | 4947 |
"Modified: / 09-11-2010 / 13:42:54 / cg" |
105 | 4948 |
! |
4949 |
||
3235 | 4950 |
basicReplaceString:aString atLine:lineNr col:colNr |
4951 |
"replace multiple characters starting at lineNr/colNr. |
|
4952 |
This is not prepared to encounter special chars (except TAB) |
|
4953 |
in the string." |
|
4954 |
||
5045 | 4955 |
|line lineSize newLine newLineSpecies endCol| |
3235 | 4956 |
|
4957 |
self checkModificationsAllowed ifFalse:[ ^ self]. |
|
4958 |
||
4959 |
self checkForExistingLine:lineNr. |
|
4960 |
line := list at:lineNr. |
|
4961 |
lineSize := line size. |
|
4962 |
||
4963 |
endCol := colNr + aString size - 1. |
|
4964 |
(lineSize == 0) ifTrue:[ |
|
4190 | 4965 |
newLine := aString species new:endCol. |
3235 | 4966 |
] ifFalse: [ |
5571 | 4967 |
(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ |
5045 | 4968 |
newLineSpecies := aString stringSpecies |
4969 |
] ifFalse:[ |
|
4970 |
newLineSpecies := line species |
|
4971 |
]. |
|
4972 |
||
4973 |
newLine := newLineSpecies new:(endCol max:lineSize). |
|
4974 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1. |
|
3235 | 4975 |
]. |
4976 |
newLine replaceFrom:colNr with:aString. |
|
4977 |
(aString includes:(Character tab)) ifTrue:[ |
|
4190 | 4978 |
newLine := self withTabsExpanded:newLine. |
3235 | 4979 |
]. |
4771 | 4980 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
3235 | 4981 |
widthOfWidestLine notNil ifTrue:[ |
4458 | 4982 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
3235 | 4983 |
]. |
4984 |
self textChanged. |
|
4985 |
shown ifTrue:[ |
|
4889 | 4986 |
gc font hasOverlappingCharacters ifTrue:[ |
4190 | 4987 |
self invalidateLine:lineNr. |
4988 |
] ifFalse:[ |
|
4989 |
self redrawLine:lineNr from:colNr |
|
4990 |
] |
|
3235 | 4991 |
] |
4992 |
||
4190 | 4993 |
"Created: / 11-06-1998 / 10:38:32 / cg" |
4191 | 4994 |
"Modified: / 09-11-2010 / 13:42:56 / cg" |
3235 | 4995 |
! |
4996 |
||
2952 | 4997 |
basicSplitLine:lineNr before:colNr |
4998 |
"split the line linNr before colNr; the right part (from colNr) |
|
4999 |
is cut off and inserted after lineNr; the view is redrawn" |
|
5000 |
||
3160 | 5001 |
|line lineSize leftRest rightRest visLine w h mustWait |
2952 | 5002 |
srcY "{ Class: SmallInteger }" | |
5003 |
||
3027 | 5004 |
list isNil ifTrue:[ ^ self ]. |
5005 |
lineNr > (list size) ifTrue:[ ^ self ]. |
|
5006 |
||
5007 |
(colNr == 1) ifTrue:[ |
|
5909 | 5008 |
self nonUndoableDo:[ |
5009 |
self insertLine:nil before:lineNr. |
|
5010 |
]. |
|
5011 |
^ self |
|
3027 | 5012 |
]. |
5013 |
||
5014 |
line := list at:lineNr. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5015 |
line notNil ifTrue:[ |
5909 | 5016 |
lineSize := line size. |
5017 |
(colNr <= lineSize) ifTrue:[ |
|
5018 |
rightRest := line copyFrom:colNr to:lineSize. |
|
5019 |
(colNr > 1) ifTrue:[ |
|
5020 |
leftRest := line copyTo:(colNr - 1) |
|
5021 |
] |
|
5022 |
] ifFalse:[ |
|
5023 |
leftRest := line |
|
5024 |
] |
|
3027 | 5025 |
]. |
5026 |
leftRest notNil ifTrue:[ |
|
5909 | 5027 |
(self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil] |
3027 | 5028 |
]. |
4771 | 5029 |
self basicListAt:lineNr put:leftRest. |
3027 | 5030 |
self nonUndoableDo:[ |
5909 | 5031 |
self withoutRedrawInsertLine:rightRest before:(lineNr + 1). |
3027 | 5032 |
]. |
5033 |
visLine := self listLineToVisibleLine:(lineNr). |
|
5034 |
visLine notNil ifTrue:[ |
|
5909 | 5035 |
w := self widthForScrollBetween:lineNr |
5036 |
and:(firstLineShown + nLinesShown). |
|
5037 |
srcY := topMargin + (visLine * fontHeight). |
|
5038 |
h := ((nLinesShown - visLine - 1) * fontHeight). |
|
5039 |
(mustWait := (w > 0 and:[h > 0])) ifTrue:[ |
|
5040 |
self catchExpose. |
|
5041 |
self |
|
5042 |
copyFrom:self |
|
5043 |
x:textStartLeft y:srcY |
|
5044 |
toX:textStartLeft y:(srcY + fontHeight) |
|
5045 |
width:w |
|
5046 |
height:((nLinesShown - visLine - 1) * fontHeight) |
|
5047 |
async:true. |
|
5048 |
]. |
|
5049 |
self redrawLine:lineNr. |
|
5050 |
self redrawLine:(lineNr + 1). |
|
5051 |
mustWait ifTrue:[self waitForExpose] |
|
3027 | 5052 |
]. |
5053 |
widthOfWidestLine := nil. "/ unknown |
|
5054 |
self textChanged. |
|
2952 | 5055 |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5056 |
"Modified: / 06-12-2010 / 13:12:55 / cg" |
2952 | 5057 |
! |
5058 |
||
2954 | 5059 |
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr |
4328 | 5060 |
"insert a bunch of lines before line lineNr; the view is not redrawn. |
5061 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5062 |
because the text might have been pasted from an alien view." |
|
2954 | 5063 |
|
5064 |
|newLine newLines nLines| |
|
5065 |
||
5066 |
nLines := end - start + 1. |
|
5067 |
newLines := Array new:(lines size). |
|
5068 |
start to:end do:[:index | |
|
4328 | 5069 |
newLine := lines at:index. |
5070 |
newLine notNil ifTrue:[ |
|
5071 |
newLine isString ifTrue:[ |
|
5072 |
newLine isBlank ifTrue:[ |
|
5073 |
newLine := nil |
|
5074 |
] ifFalse:[ |
|
5075 |
(newLine includes:(Character tab)) ifTrue:[ |
|
5076 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
|
5077 |
] |
|
5078 |
] |
|
5079 |
] |
|
5080 |
]. |
|
5081 |
newLines at:index put:newLine |
|
2954 | 5082 |
]. |
5083 |
list isNil ifTrue: [ |
|
4328 | 5084 |
list := StringCollection new:(lineNr + nLines + 1) |
2954 | 5085 |
] ifFalse: [ |
4328 | 5086 |
list grow:((list size + nLines) max:(lineNr + nLines - 1)) |
3160 | 5087 |
]. |
5088 |
||
5089 |
"I have changed 'replaceFrom:to:with:startingAt:' to correctly handle |
|
2954 | 5090 |
overlapping copy - if it didn't, we had to use:" |
5091 |
" |
|
5092 |
index := list size. |
|
5093 |
[index > lineNr] whileTrue: [ |
|
4328 | 5094 |
pIndex := index - 1. |
5095 |
list at:index put:(list at:pIndex). |
|
5096 |
index := pIndex |
|
2954 | 5097 |
]. |
5098 |
" |
|
5099 |
list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr. |
|
5100 |
list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start. |
|
5101 |
self contentsChanged |
|
5102 |
||
4328 | 5103 |
"Modified: / 07-10-2011 / 15:55:18 / cg" |
2954 | 5104 |
! |
5105 |
||
5106 |
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr |
|
4328 | 5107 |
"insert aString (which has no crs) at lineNr/colNr. |
5108 |
Tabs are expanded here with a tab=8 setting (independent of any editor-setting, |
|
5109 |
because the text might have been pasted from an alien view." |
|
2954 | 5110 |
|
4360 | 5111 |
|isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth| |
2954 | 5112 |
|
4623 | 5113 |
(aString isNil) ifTrue:[ ^ self]. |
2954 | 5114 |
|
5115 |
strLen := aString size. |
|
5116 |
self checkForExistingLine:lineNr. |
|
5117 |
||
5118 |
stringType := aString string species. |
|
5119 |
isText := aString isText. |
|
5120 |
line := list at:lineNr. |
|
5121 |
||
5122 |
line notNil ifTrue:[ |
|
4328 | 5123 |
lineSize := line size. |
5124 |
line isString ifFalse:[ |
|
5125 |
stringType := line species |
|
5126 |
] ifTrue:[ |
|
4360 | 5127 |
lineCharWidth := line bitsPerCharacter. |
5128 |
stringCharWidth := aString bitsPerCharacter. |
|
5129 |
lineCharWidth > stringCharWidth ifTrue:[ |
|
4328 | 5130 |
stringType := line string species |
4360 | 5131 |
] ifFalse:[ |
5132 |
stringCharWidth > lineCharWidth ifTrue:[ |
|
5133 |
stringType := aString string species |
|
5134 |
] |
|
4328 | 5135 |
]. |
5136 |
line isText ifTrue:[ isText := true ] |
|
5137 |
]. |
|
2954 | 5138 |
] ifFalse:[ |
4328 | 5139 |
lineSize := 0 |
2954 | 5140 |
]. |
5141 |
||
5142 |
((colNr == 1) and:[lineSize == 0]) ifTrue: [ |
|
4328 | 5143 |
newLine := aString |
2954 | 5144 |
] ifFalse:[ |
4328 | 5145 |
(lineSize == 0 or:[colNr > lineSize]) ifTrue: [ |
5146 |
sz := colNr + strLen - 1 |
|
5147 |
] ifFalse:[ |
|
5148 |
sz := lineSize + strLen |
|
5149 |
]. |
|
5150 |
||
4360 | 5151 |
newLine := stringType new:sz. |
5152 |
isText ifTrue:[ |
|
5153 |
newLine := Text string:newLine |
|
4328 | 5154 |
]. |
5155 |
||
5156 |
(lineSize ~~ 0) ifTrue: [ |
|
5157 |
(colNr > lineSize) ifTrue: [ |
|
5158 |
newLine replaceFrom:1 to:lineSize with:line startingAt:1 |
|
5159 |
] ifFalse: [ |
|
5160 |
newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1. |
|
5161 |
newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr |
|
5162 |
] |
|
5163 |
]. |
|
5164 |
newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1 |
|
2954 | 5165 |
]. |
5166 |
||
5167 |
(aString includes:(Character tab)) ifTrue:[ |
|
4328 | 5168 |
newLine := self withTabs:(ListView tab8Positions) expand:newLine |
2954 | 5169 |
]. |
5170 |
||
4771 | 5171 |
self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]). |
2954 | 5172 |
widthOfWidestLine notNil ifTrue:[ |
4328 | 5173 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine). |
2954 | 5174 |
]. |
5175 |
self textChanged. |
|
5176 |
||
4360 | 5177 |
"Modified: / 25-01-2012 / 00:37:29 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5178 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5179 |
|
2752 | 5180 |
!EditTextView methodsFor:'event handling'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5181 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5182 |
buttonPress:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5183 |
"hide the cursor when button is activated" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5184 |
|
5216 | 5185 |
hasKeyboardFocus := true. "/ cg: why is this needed? |
2589 | 5186 |
dragIsActive := false. |
5187 |
||
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5188 |
completionSupport notNil ifTrue:[ |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5189 |
"/ 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
|
5190 |
completionSupport buttonPress:button x:x y:y |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5191 |
]. |
4609 | 5192 |
|
1817
1a9e22f755c8
show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents:
1816
diff
changeset
|
5193 |
cursorShown ifTrue: [ |
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5194 |
self drawCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5195 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5196 |
|
4420 | 5197 |
"On X11, be nice and paste PRIMARY when middle click. |
5198 |
Note, that middle button on X11 is translated to button |
|
5199 |
128 in Smalltalk/X - see XWorkstation class>>initializeConstants" |
|
5643 | 5200 |
(button == #paste and:[device platformName == #X11]) ifTrue:[ |
4420 | 5201 |
self undoableDo:[ |
5202 |
self paste: (self getClipboardText:#selection). |
|
5203 |
]. |
|
5204 |
^self. |
|
5205 |
]. |
|
5206 |
||
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5207 |
(button == 1) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5208 |
self hideCursor |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5209 |
]. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5210 |
"/ 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
|
5211 |
"/ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5212 |
"/ (button == #paste) ifTrue:[ |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5213 |
"/ self pasteOrReplace. |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5214 |
"/ ^ self |
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5215 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5216 |
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
|
5217 |
|
4420 | 5218 |
"Modified: / 23-03-1999 / 13:51:40 / cg" |
5219 |
"Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
121 | 5220 |
! |
5221 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5222 |
buttonRelease:button x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5223 |
"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
|
5224 |
|
3789
a9b4805e0754
when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents:
3788
diff
changeset
|
5225 |
|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
|
5226 |
|
3915
737e276852c8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3907
diff
changeset
|
5227 |
(button == 1) ifTrue:[ |
5882 | 5228 |
typeOfSelection := nil. |
5229 |
||
5230 |
dragIsActive ifTrue:[ |
|
5231 |
self unselect |
|
5232 |
]. |
|
5233 |
selectionStartLine isNil ifTrue:[ |
|
5234 |
clickCol notNil ifTrue:[ |
|
5235 |
self cursorMovementAllowed ifTrue:[ |
|
5236 |
newCursorCol := clickCol. |
|
5237 |
||
5238 |
cursorType ~~ #block ifTrue:[ |
|
5239 |
clickPos notNil ifTrue:[ |
|
5240 |
"/ we do something special, if the text-cursor's type is not a block-cursor |
|
5241 |
"/ (i.e. if its an ibeam). |
|
5242 |
"/ adjust clickCol if the user clicked in the right third of a character. |
|
3790 | 5243 |
x1 := self xOfCol:clickCol inVisibleLine:clickLine. |
5882 | 5244 |
x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine. |
5245 |
x2_3 := x1 + ((x2-x1) * (2/3)). |
|
5246 |
(clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ]. |
|
5247 |
]. |
|
5248 |
]. |
|
5249 |
"/ the following fixes the ugly select behavior when double clicking on |
|
5250 |
"/ a partially visible last line (where the first click used to |
|
5251 |
"/ scroll the text so that the second click was handled on another |
|
5252 |
"/ line. An alternative (possibly better) solution would be to |
|
5253 |
"/ remember the last click position and adjust in the double click |
|
5254 |
"/ event handling (i.e. subtract the number of scrolled lines in between) |
|
5255 |
"/ Time will show, if this hack works. |
|
5256 |
clickLine >= (self lastLineShown -1 ) ifTrue:[ |
|
5257 |
self cursorLine:clickLine col:newCursorCol makeVisible:false. |
|
5057 | 5258 |
Processor |
5882 | 5259 |
addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self] |
5260 |
after:0.3 seconds. |
|
5261 |
] ifFalse:[ |
|
5262 |
self cursorLine:clickLine col:newCursorCol. |
|
5263 |
]. |
|
5264 |
]. |
|
5265 |
true "self hadSelectionBeforeClick not" ifTrue:[ |
|
5266 |
list notEmptyOrNil ifTrue:[ |
|
5267 |
UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[ |
|
5268 |
(clickLine >= list size) ifTrue:[ |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5269 |
(clickLine > (self list size + 2) |
5882 | 5270 |
or:[ clickCol > (list last size + 5) ]) ifTrue:[ |
5271 |
self selectAll |
|
5272 |
]. |
|
5273 |
]. |
|
5274 |
] |
|
5275 |
] |
|
5276 |
] |
|
5277 |
] |
|
5278 |
] ifFalse:[ |
|
5279 |
lastStringFromReplaceForNextSearch := nil. "new selection invalidates remembered string" |
|
5280 |
]. |
|
5281 |
self showCursor |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5282 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5283 |
super buttonRelease:button x:x y:y |
1580
d30e562bea15
allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents:
1577
diff
changeset
|
5284 |
|
4396
7820ce5cac3d
changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents:
4394
diff
changeset
|
5285 |
"Modified: / 07-03-2012 / 18:48:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5286 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5287 |
|
2580 | 5288 |
cursorKeyPress:key shifted:shifted |
4492
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5289 |
<resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)> |
088b5fba29d0
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
4484
diff
changeset
|
5290 |
|
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5291 |
| n oldTypeOfSelection | |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5292 |
|
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5293 |
oldTypeOfSelection := typeOfSelection. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
5294 |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
5295 |
self changeTypeOfSelectionTo:nil. |
2580 | 5296 |
|
5297 |
(key == #CursorRight) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5298 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5299 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5300 |
selectionStartCol := selectionEndCol := clickStartCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5301 |
cursorCol := cursorCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5302 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5303 |
self validateNewSelection. |
4420 | 5304 |
self setPrimarySelection. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5305 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5306 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5307 |
^ self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5308 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5309 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5310 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5311 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5312 |
self addToSelectionAfter:[ self cursorRight ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5313 |
] ifFalse:[ |
4844
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5314 |
"/ 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
|
5315 |
"/ 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
|
5316 |
"/ 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
|
5317 |
"/ (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
|
5318 |
"/ 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
|
5319 |
oldTypeOfSelection == #paste ifTrue:[ |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5320 |
cursorLine := selectionEndLine. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
5321 |
cursorCol := selectionEndCol + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5322 |
]. |
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
|
5323 |
|
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
|
5324 |
"/ 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
|
5325 |
"/ 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
|
5326 |
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
|
5327 |
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
|
5328 |
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
|
5329 |
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
|
5330 |
^ self. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5331 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5332 |
self unselect; makeCursorVisible. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5333 |
self cursorRight. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5334 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5335 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5336 |
^ self |
2580 | 5337 |
]. |
5338 |
(key == #CursorDown) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5339 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5340 |
selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5341 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5342 |
selectionEndCol := cursorCol - 1. |
4970 | 5343 |
"/ selectionEndCol == 1 ifTrue:[ |
5344 |
"/ selectionEndCol := 0. |
|
5345 |
"/ ]. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5346 |
self setCursorLine: cursorLine + 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5347 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5348 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5349 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5350 |
expandingTop := false. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5351 |
self redrawLine:selectionEndLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5352 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5353 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5354 |
|
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5355 |
selectionStartLine notNil ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5356 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5357 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5358 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5359 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5360 |
"/ self setCursorLine:(selectionEndLine ? selectionStartLine). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5361 |
"/ self setCursorCol:selectionStartCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5362 |
"/ (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5363 |
"/ self setCursorCol:1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5364 |
"/ self setCursorLine:(cursorLine - 1). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5365 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5366 |
"/ self makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5367 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5368 |
"/ shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5369 |
"/ clickLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5370 |
"/ clickCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5371 |
"/ self setCursorLine: cursorLine + 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5372 |
"/ self expandSelectionDown. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5373 |
"/ ^ self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5374 |
"/ ]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5375 |
"/ self unselect. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5376 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5377 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5378 |
self cursorMovementAllowed ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5379 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown). |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5380 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5381 |
self addToSelectionAfter:[ self cursorDown:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5382 |
] 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
|
5383 |
"/ 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
|
5384 |
"/ 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
|
5385 |
"/ selectionStartCol column. This behavior is |
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5386 |
"/ 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
|
5387 |
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
|
5388 |
self setCursorLine: selectionEndLine. |
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5389 |
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
|
5390 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5391 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5392 |
self cursorDown:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5393 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5394 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5395 |
"/ flush keyboard to avoid runaway cursor |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5396 |
"/ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5397 |
self sensor flushKeyboardFor:self. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5398 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5399 |
^ self |
2580 | 5400 |
]. |
5401 |
(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
|
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5402 |
(shifted and:[selectionStartLine isNil]) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5403 |
expandingTop := true. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5404 |
key == #CursorLeft ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5405 |
cursorCol > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5406 |
selectionStartLine := selectionEndLine := clickStartLine := cursorLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5407 |
selectionEndCol := clickStartCol := cursorCol-1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5408 |
selectionStartCol := cursorCol-1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5409 |
self setCursorCol: cursorCol-1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5410 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5411 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5412 |
self redrawLine:selectionStartLine. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5413 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5414 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5415 |
] ifFalse:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5416 |
cursorLine > 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5417 |
selectionEndLine := clickStartLine := cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5418 |
selectionStartCol := clickStartCol := cursorCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5419 |
selectionEndCol := cursorCol - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5420 |
selectionStartLine := cursorLine - 1. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5421 |
selectionEndCol == 1 ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5422 |
selectionEndCol := 0. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5423 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5424 |
self validateNewSelection. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5425 |
self selectionChanged. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5426 |
self redrawFromLine:selectionStartLine to:cursorLine. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5427 |
self setCursorLine: cursorLine - 1. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5428 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5429 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5430 |
] |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5431 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5432 |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5433 |
self hasSelection ifTrue:[ |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5434 |
self cursorMovementAllowed ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5435 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5436 |
"/ treat the whole selection as cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5437 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5438 |
"/ self setCursorLine:selectionStartLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5439 |
"/ 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
|
5440 |
"/ 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
|
5441 |
"/ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5442 |
"/ shifted ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5443 |
"/ self unselect. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5444 |
"/ ] |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5445 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5446 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5447 |
(key == #CursorLeft) ifTrue:[ |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5448 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5449 |
self addToSelectionAfter:[self cursorLeft]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5450 |
] 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
|
5451 |
"/ 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
|
5452 |
"/ 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
|
5453 |
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
|
5454 |
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
|
5455 |
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
|
5456 |
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
|
5457 |
^ 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
|
5458 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5459 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5460 |
self cursorLeft. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5461 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5462 |
^self |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5463 |
]. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5464 |
(key == #CursorUp) ifTrue:[ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5465 |
n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp). |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5466 |
shifted ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5467 |
self addToSelectionAfter: [ self cursorUp:n ] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5468 |
] 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
|
5469 |
"/ 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
|
5470 |
"/ 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
|
5471 |
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
|
5472 |
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
|
5473 |
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
|
5474 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5475 |
self unselect; makeCursorVisible. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5476 |
self cursorUp:n. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5477 |
]. |
4100
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5478 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5479 |
"/ flush keyboard to avoid runaway cursor |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5480 |
"/ |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5481 |
self sensor flushKeyboardFor:self. |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5482 |
^ self |
3fbb7392a6e1
changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents:
4097
diff
changeset
|
5483 |
]. |
2580 | 5484 |
]. |
4420 | 5485 |
|
4977
d0e0234d922c
Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4976
diff
changeset
|
5486 |
"Modified: / 28-03-2014 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2580 | 5487 |
! |
5488 |
||
2952 | 5489 |
doKeyPress:key x:x y:y |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5490 |
"handle keyboard input" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5491 |
|
4521 | 5492 |
<resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll |
3781 | 5493 |
#Replace #Undo #Redo #Accept |
3780 | 5494 |
#Delete #BasicDelete #BackSpace #BasicBackspace |
4707 | 5495 |
#DeleteSpaces #Join |
3780 | 5496 |
#SearchMatchingParent #SelectMatchingParents |
4707 | 5497 |
#SelectWord #ExpandSelectionByWord |
3780 | 5498 |
#SelectToEnd #SelectFromBeginning |
4707 | 5499 |
#SelectLine #ExpandSelectionByLine |
3780 | 5500 |
#BeginOfLine #EndOfLine #NextWord #PreviousWord |
5501 |
#CursorRight #CursorDown #CursorLeft #CursorUp |
|
5502 |
#Return #Tab #BackTab #NonInsertingTab #Escape |
|
5503 |
#GotoLine #BeginOfText #EndOfText |
|
5504 |
#InsertLine #DeleteLine |
|
5505 |
#SelectLineFromBeginning |
|
5506 |
#LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode |
|
5134 | 5507 |
#OpenSpecialCharacterWindow #InsertUUID |
3780 | 5508 |
#'F*' #'f*')> |
2017 | 5509 |
|
4730 | 5510 |
|fKeyMacros shiftPressed ctrlPressed i event macroName |
5119 | 5511 |
immediateCompletion currentUserPrefs rawKey| |
4818 | 5512 |
|
5513 |
currentUserPrefs := UserPreferences current. |
|
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5514 |
|
4701 | 5515 |
"/ experimental |
4818 | 5516 |
immediateCompletion := currentUserPrefs immediateCodeCompletion. |
4738 | 5517 |
(immediateCompletion |
4818 | 5518 |
or:[currentUserPrefs codeCompletionOnControlKey |
5519 |
or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[ |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5520 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5521 |
self initializeCompletionSupport. |
4609 | 5522 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5523 |
]. |
5394 | 5524 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5525 |
"/ JV: why setting it to nil here? |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5526 |
"/ ifFalse:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5527 |
"/ completionService := nil |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5528 |
"/ ]. |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5529 |
completionSupport notNil ifTrue:[ |
5394 | 5530 |
completionSupport stopCompletionProcess. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
5531 |
(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self]. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5532 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
5533 |
|
4818 | 5534 |
key isSymbol ifTrue:[ |
5643 | 5535 |
(device modifierKeys includes:key) ifFalse:[ |
4818 | 5536 |
lastReplacementInfo stillCollectingInput:false. |
5537 |
] |
|
5538 |
]. |
|
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5539 |
(key == #LearnKeyboardMacro) ifTrue:[ |
4818 | 5540 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5541 |
self toggleLearnMode. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5542 |
^ self |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5543 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5544 |
(key == #ExecuteKeyboardMacro) ifTrue:[ |
4818 | 5545 |
lastReplacementInfo stillCollectingInput:false. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5546 |
self executeLearnedKeyboardMacro. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5547 |
^ self. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5548 |
]. |
3799 | 5549 |
(key == #Undo) ifTrue:[self undo. ^self]. |
5550 |
(key == #Redo) ifTrue:[self redo. ^self]. |
|
5551 |
||
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5552 |
self learnMode ifTrue:[ |
4482 | 5553 |
event := WindowGroup lastEventQuerySignal query. |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5554 |
learnedMacro add:event. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5555 |
]. |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
5556 |
|
4238 | 5557 |
(self executekeyboardMacroNamed:key) ifTrue:[ |
5558 |
"the macro named key exists" |
|
3780 | 5559 |
^ self |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5560 |
]. |
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
5561 |
|
4482 | 5562 |
key isSymbol ifFalse:[ |
5563 |
"the usual case: key is a character, but maybe a string also (in X11)" |
|
5564 |
self handleNonCommandKey:key. |
|
5565 |
^ self |
|
5566 |
]. |
|
5567 |
||
5568 |
event isNil ifTrue:[ |
|
5569 |
event := WindowGroup lastEventQuerySignal query. |
|
5570 |
]. |
|
5571 |
shiftPressed := event hasShift. |
|
5572 |
ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not]. |
|
5119 | 5573 |
rawKey := event rawKey. |
4482 | 5574 |
|
5133 | 5575 |
key == #InsertUUID ifTrue:[ |
5576 |
self insertUUID. |
|
5577 |
^ self. |
|
5578 |
]. |
|
5579 |
||
4253 | 5580 |
(key == #DeleteWordBeforeCursor) ifTrue:[ |
5581 |
self deleteWordBeforeCursor. |
|
5582 |
^ self. |
|
5583 |
]. |
|
5584 |
||
5119 | 5585 |
(rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
3780 | 5586 |
selectionStartLine notNil ifTrue:[ |
5587 |
((key == #BasicBackspace) |
|
4818 | 5588 |
or:[ currentUserPrefs deleteSetsClipboardText not ]) |
3780 | 5589 |
ifTrue:[ |
5590 |
self deleteSelection. |
|
5591 |
] ifFalse: [ |
|
5592 |
self copyAndDeleteSelection. |
|
5593 |
]. |
|
4609 | 5594 |
] ifFalse:[ |
5595 |
self makeCursorVisible. |
|
5596 |
"/ (shiftPressed and:[ ctrlPressed ]) ifTrue:[ |
|
5597 |
"/ self deleteWordBeforeCursor. |
|
5598 |
"/ ] ifFalse:[ |
|
5599 |
self deleteCharBeforeCursor. |
|
5600 |
"/ ]. |
|
3780 | 5601 |
]. |
4738 | 5602 |
true "immediateCompletion" ifTrue:[ |
5394 | 5603 |
completionSupport notNil ifTrue:[ |
5604 |
completionSupport postKeyPress:key |
|
5605 |
]. |
|
4731 | 5606 |
]. |
3780 | 5607 |
^ self |
2205
230cf9cef6c3
searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents:
2196
diff
changeset
|
5608 |
]. |
2184
fb634dc3e606
learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
5609 |
|
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5610 |
(key == #ToggleAutoIndent) ifTrue:[ |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5611 |
self autoIndent:(autoIndent not). |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5612 |
^ self. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5613 |
]. |
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5614 |
|
3235 | 5615 |
key == #ToggleInsertMode ifTrue:[ |
3782
79ae5dad28d4
Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
5616 |
self insertMode:(editMode value == EditMode insertMode) not. |
3780 | 5617 |
^ self. |
3160 | 5618 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5619 |
|
4162 | 5620 |
key == #OpenSpecialCharacterWindow ifTrue:[ |
5621 |
CharacterSetView notNil ifTrue:[ |
|
5622 |
self specialCharacters. |
|
5623 |
^ self. |
|
5624 |
] |
|
5625 |
]. |
|
5626 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5627 |
replacing := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5628 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5629 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5630 |
Fn pastes a key-sequence (but only if not overlayed with |
3780 | 5631 |
another function in the keyboard map) |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5632 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5633 |
see TextView>>:x:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5634 |
" |
1177
9d23e1241404
avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
5635 |
(key at:1) asLowercase == $f ifTrue:[ |
3780 | 5636 |
(('[fF][0-9]' match:key) |
5637 |
or:['[fF][0-9][0-9]' match:key]) ifTrue:[ |
|
5638 |
shiftPressed ifFalse:[ |
|
4818 | 5639 |
fKeyMacros := currentUserPrefs functionKeySequences. |
3780 | 5640 |
fKeyMacros notNil ifTrue:[ |
5641 |
(fKeyMacros includesKey:key) ifTrue:[ |
|
5642 |
self pasteOrReplace:(fKeyMacros at:key) asStringCollection. |
|
5643 |
^ self |
|
5644 |
] |
|
5645 |
] |
|
5646 |
] |
|
5647 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5648 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5649 |
|
2506 | 5650 |
(key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[ |
3780 | 5651 |
self parenthizeSelectionWith:$( and:$). |
5652 |
^ self. |
|
2506 | 5653 |
]. |
5654 |
(key == #'Ctrl2') ifTrue:[ |
|
3780 | 5655 |
self parenthizeSelectionWith:$" and:$". |
5656 |
^ self. |
|
2506 | 5657 |
]. |
5658 |
(key == #'Ctrl#') ifTrue:[ |
|
3780 | 5659 |
self parenthizeSelectionWith:$' and:$'. |
5660 |
^ self. |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5661 |
]. |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5662 |
(key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[ |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5663 |
self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5664 |
^ self. |
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5665 |
]. |
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5666 |
|
274
6df4bb990f04
handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents:
259
diff
changeset
|
5667 |
(key == #Accept) ifTrue:[^ self accept]. |
5387 | 5668 |
(key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self]. |
5669 |
(key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5670 |
(key == #Cut) ifTrue:[self cut. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5671 |
(key == #Again) ifTrue:[self again. ^self]. |
3781 | 5672 |
(key == #AgainForAll) ifTrue:[self multipleAgain. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5673 |
|
3542 | 5674 |
(key == #Join) ifTrue:[self joinLines. ^self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5675 |
(key == #Replace) ifTrue:[self replace. ^self]. |
4707 | 5676 |
(key == #ExpandSelectionByWord) ifTrue:[ |
5677 |
self makeCursorVisible. |
|
5678 |
self findNextWordAfterSelectionAndAddToSelection. |
|
5679 |
^ self |
|
5680 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5681 |
(key == #SelectWord) ifTrue:[ |
3780 | 5682 |
self makeCursorVisible. |
5683 |
self selectWordUnderCursor. |
|
5684 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5685 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5686 |
|
2505
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5687 |
(key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5688 |
(key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5689 |
(key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self]. |
9204d5313979
Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents:
2491
diff
changeset
|
5690 |
(key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5691 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5692 |
" disabled - nobody liked it ... |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5693 |
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
|
5694 |
|
1304
173d00c195f9
flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents:
1300
diff
changeset
|
5695 |
(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
|
5696 |
(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
|
5697 |
(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
|
5698 |
(key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5699 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5700 |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5701 |
(key == #BeginOfLine) ifTrue:[ |
3780 | 5702 |
shiftPressed ifTrue: [ |
5703 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5704 |
"/ self unselect. |
|
5705 |
"/ self cursorHome. |
|
5706 |
"Jan's modification" |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5707 |
self addToSelectionAfter:[ self cursorToBeginOfLine ]. |
4257 | 5708 |
"/ 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
|
5709 |
"/ 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
|
5710 |
"/ self selectFromBeginOfLine. |
3780 | 5711 |
] ifFalse: [ |
5712 |
self unselect. |
|
5713 |
ctrlPressed ifTrue:[ |
|
5714 |
self cursorHome. |
|
5715 |
] ifFalse:[ |
|
5716 |
self cursorToBeginOfLine. |
|
5717 |
] |
|
5718 |
]. |
|
5719 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5720 |
]. |
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5721 |
(key == #EndOfLine) ifTrue:[ |
3780 | 5722 |
shiftPressed ifTrue:[ |
5723 |
"/ "Original St/X code - now use Ctrl modifier" |
|
5724 |
"/ self unselect. |
|
5725 |
"/ self cursorToBottom |
|
4257 | 5726 |
" Jan's modification" |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
5727 |
self addToSelectionAfter:[ self cursorToEndOfLine ] . |
4257 | 5728 |
"/ 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
|
5729 |
"/ 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
|
5730 |
"/ self selectToEndOfLine. |
3780 | 5731 |
] ifFalse:[ |
5732 |
self unselect. |
|
5733 |
ctrlPressed ifTrue:[ |
|
5734 |
self cursorToBottom |
|
5735 |
] ifFalse:[ |
|
5736 |
self cursorToEndOfLine. |
|
5737 |
] |
|
5738 |
]. |
|
5739 |
^ self |
|
1675
b1cba2341f95
EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
5740 |
]. |
4978
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5741 |
(key == #NextWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5742 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5743 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5744 |
self cursorToNextWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5745 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5746 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5747 |
self cursorToNextWord |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5748 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5749 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5750 |
]. |
3310 | 5751 |
(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
|
5752 |
(key == #PreviousWord) ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5753 |
shiftPressed ifTrue:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5754 |
self addToSelectionAfter:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5755 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5756 |
] |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5757 |
] ifFalse:[ |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5758 |
self cursorToPreviousWord. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5759 |
]. |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5760 |
^self |
0eb26aed1456
Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4977
diff
changeset
|
5761 |
]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5762 |
(key == #GotoLine) ifTrue:[self gotoLine. ^self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5763 |
|
5119 | 5764 |
(rawKey == #CursorRight |
5765 |
or:[rawKey == #CursorDown |
|
5766 |
or:[rawKey == #CursorLeft |
|
5767 |
or:[rawKey == #CursorUp]]]) ifTrue:[ |
|
5768 |
self cursorKeyPress:rawKey shifted:shiftPressed. |
|
3780 | 5769 |
^ self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5770 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5771 |
|
5119 | 5772 |
(key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[ |
3780 | 5773 |
self unselect. self cursorReturn. |
5774 |
^ self |
|
3257 | 5775 |
]. |
5776 |
||
5777 |
(key == #Return) ifTrue:[ |
|
3780 | 5778 |
shiftPressed ifTrue:[ |
5779 |
self unselect. self cursorReturn. |
|
5780 |
^ self |
|
5781 |
]. |
|
4199
cd7069b3bc33
comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents:
4192
diff
changeset
|
5782 |
|
3780 | 5783 |
self isReadOnly ifTrue:[ |
5784 |
self unselect; makeCursorVisible. |
|
5785 |
self cursorReturn |
|
5786 |
] ifFalse:[ |
|
5787 |
self isInInsertMode ifFalse:[ |
|
5529 | 5788 |
self cursorReturn:true. |
3780 | 5789 |
autoIndent == true ifTrue:[ |
5790 |
i := self leftIndentForLine:(cursorLine + 1). |
|
4820 | 5791 |
(self listAt:cursorLine) isEmptyOrNil ifTrue:[ |
4811 | 5792 |
self cursorCol:(i+1 max:1) |
5793 |
] |
|
3780 | 5794 |
] |
5795 |
] ifTrue:[ |
|
4826 | 5796 |
|left right oldIndent| |
4812 | 5797 |
|
3780 | 5798 |
"/ old version just unselected ... |
5799 |
"/ self unselect; makeCursorVisible. |
|
5800 |
||
5801 |
"/ new version deletes ... |
|
5802 |
typeOfSelection == #paste ifTrue:[ |
|
5803 |
self unselect; makeCursorVisible. |
|
5804 |
] ifFalse:[ |
|
5805 |
self copyAndDeleteSelection. |
|
5806 |
]. |
|
4816 | 5807 |
left := (self listAt:cursorLine to:cursorCol-1) ? ''. |
5808 |
right := (self listAt:cursorLine from:cursorCol) ? ''. |
|
3780 | 5809 |
self insertCharAtCursor:(Character cr). |
5112 | 5810 |
|
3780 | 5811 |
autoIndent == true ifTrue:[ |
4816 | 5812 |
(right isEmpty and:[cursorCol ~~ 1]) ifTrue:[ |
5813 |
"/ nothing to do. |
|
4812 | 5814 |
] ifFalse:[ |
5815 |
((self listAt:cursorLine) isEmptyOrNil |
|
5112 | 5816 |
or:[ false "cursorCol == 1" ]) ifTrue:[ |
4812 | 5817 |
i := (self leftIndentForLine:cursorLine). |
4823 | 5818 |
left := left withoutSeparators. |
5819 |
right := right withoutSeparators. |
|
5820 |
(left endsWith:'[') ifTrue:[ |
|
5821 |
"/ i := i + 4. |
|
4816 | 5822 |
] ifFalse:[ |
4823 | 5823 |
(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[ |
4816 | 5824 |
i := i - 4. |
5825 |
]. |
|
4812 | 5826 |
]. |
4826 | 5827 |
oldIndent := self leftIndentOfLine:cursorLine. |
5828 |
self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent). |
|
5829 |
self st80EditMode ifTrue:[ |
|
5830 |
(self listAt:cursorLine) size < i ifTrue:[ |
|
5831 |
self insertStringAtCursor:(String new:((i-oldIndent) max:0)). |
|
5832 |
]. |
|
5833 |
]. |
|
4812 | 5834 |
self cursorCol:(i+1 max:1) |
5835 |
]. |
|
5836 |
] |
|
3780 | 5837 |
]. |
5838 |
]. |
|
5839 |
]. |
|
5840 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5841 |
]. |
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
|
5842 |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5843 |
(key == #NonInsertingTab) ifTrue:[ |
3780 | 5844 |
self unselect. self cursorTab. |
5845 |
^ self |
|
2819
a7a41dfb9df7
BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents:
2817
diff
changeset
|
5846 |
]. |
3422
a0c68e8bd56e
tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents:
3416
diff
changeset
|
5847 |
((key == #BackTab) or:[(key == #Tab)]) ifTrue:[ |
3780 | 5848 |
self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y]. |
5849 |
||
5850 |
self hasSelection ifTrue:[ |
|
5851 |
selectStyle == #line ifTrue:[ |
|
4238 | 5852 |
((key == #Tab) and:[shiftPressed not]) ifTrue:[ |
5853 |
macroName := #IndentBy4. |
|
5854 |
] ifFalse:[ |
|
5855 |
macroName := #UndentBy4. |
|
5856 |
]. |
|
5857 |
macroName notNil ifTrue:[ |
|
5858 |
self executekeyboardMacroNamed:macroName. |
|
3780 | 5859 |
]. |
5860 |
] |
|
5861 |
]. |
|
5862 |
||
5863 |
self unselect. |
|
5864 |
(key == #Tab) ifTrue:[ |
|
5865 |
(shiftPressed or:[self isInInsertMode not]) ifTrue:[ |
|
5866 |
self cursorTab. |
|
5867 |
^ self |
|
5868 |
]. |
|
5869 |
self insertTabAtCursor. |
|
5870 |
^ self |
|
5871 |
]. |
|
5872 |
self cursorBacktab. |
|
5873 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5874 |
]. |
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
|
5875 |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5876 |
"/ key == #DeleteSpaces ifTrue:[ |
5119 | 5877 |
(rawKey == #Delete) ifTrue:[ |
3780 | 5878 |
shiftPressed ifTrue:[ |
5879 |
[(cursorCol <= (self listAt:cursorLine) size) |
|
5880 |
and:[self characterUnderCursor isSeparator]] whileTrue:[ |
|
5881 |
self makeCursorVisible. |
|
5882 |
self deleteCharAtCursor. |
|
5883 |
]. |
|
5884 |
^ self |
|
5885 |
] |
|
2883
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5886 |
]. |
6cdb4a5a7b5e
shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents:
2880
diff
changeset
|
5887 |
|
5119 | 5888 |
(rawKey == #Delete |
870 | 5889 |
or:[key == #BasicDelete]) ifTrue:[ |
4129 | 5890 |
selectionStartLine notNil ifTrue:[ |
4130 | 5891 |
"/ Again function is not supporting Delete action (on purpose, to avoid replacing the next search string) |
5892 |
"/ To remove text repetetively, use Cut instead. |
|
5893 |
"/ self setLastStringToReplace: self selection asStringWithoutFinalCR. |
|
5894 |
"/ lastReplacementInfo lastReplacement: nil. |
|
3780 | 5895 |
((key == #BasicDelete) |
4818 | 5896 |
or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[ |
3780 | 5897 |
self deleteSelection. |
5898 |
] ifFalse:[ |
|
5899 |
self copyAndDeleteSelection. |
|
5900 |
]. |
|
5901 |
^ self |
|
5902 |
]. |
|
5903 |
self makeCursorVisible. |
|
5904 |
self deleteCharAtCursor. |
|
5905 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5906 |
]. |
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
|
5907 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5908 |
(key == #BeginOfText) ifTrue:[ "i.e. HOME" |
3780 | 5909 |
self unselect. |
5910 |
cursorVisibleLine == 1 ifTrue:[ |
|
5911 |
self cursorHome. |
|
5912 |
] ifFalse:[ |
|
5913 |
self cursorToFirstVisibleLine |
|
5914 |
]. |
|
5915 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5916 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5917 |
(key == #EndOfText) ifTrue:[ "i.e. END" |
3780 | 5918 |
self unselect. |
5919 |
cursorVisibleLine == nFullLinesShown ifTrue:[ |
|
5920 |
self cursorToBottom. |
|
5921 |
] ifFalse:[ |
|
5922 |
self cursorToLastVisibleLine |
|
5923 |
]. |
|
5924 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5925 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5926 |
((key == #Escape) |
3257 | 5927 |
or:[key == #SelectLineFromBeginning]) ifTrue:[ |
3780 | 5928 |
self makeCursorVisible. |
5929 |
self unselect. self selectCursorLineFromBeginning. |
|
5930 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5931 |
]. |
3257 | 5932 |
(key == #SelectLine) ifTrue:[ |
3780 | 5933 |
self makeCursorVisible. |
5934 |
self unselect. self selectCursorLine. |
|
5935 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5936 |
]. |
3257 | 5937 |
(key == #ExpandSelectionByLine) ifTrue:[ |
4707 | 5938 |
"/ self makeCursorVisible. |
3780 | 5939 |
self selectExpandCursorLine. |
5940 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5941 |
]. |
3257 | 5942 |
(key == #DeleteLine) ifTrue:[ |
3780 | 5943 |
self makeCursorVisible. |
5944 |
self unselect. self deleteCursorLine. |
|
5945 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5946 |
]. |
3257 | 5947 |
(key == #InsertLine) ifTrue:[ |
3780 | 5948 |
self makeCursorVisible. |
5949 |
self unselect. self insertLine:nil before:cursorLine. |
|
5950 |
^ self |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5951 |
]. |
3781 | 5952 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5953 |
super keyPress:key x:x y:y |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
5954 |
|
3310 | 5955 |
"Modified: / 06-02-1998 / 11:59:59 / stefan" |
4286
83ef1d9faf6d
added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents:
4285
diff
changeset
|
5956 |
"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
|
5957 |
"Modified: / 31-03-2014 / 16:27:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
121 | 5958 |
! |
5959 |
||
2952 | 5960 |
executeKeyboardMacro:cmdMacro |
5961 |
Error handle:[:ex | |
|
4823 | 5962 |
self warn:'Error in keyboard macro: ' , ex description. |
5963 |
ex return. |
|
2952 | 5964 |
] do:[ |
4823 | 5965 |
AbortOperationRequest handle:[:ex | |
5966 |
self warn:'Keyboard macro aborted'. |
|
5967 |
ex return. |
|
5968 |
] do:[ |
|
5969 |
Parser |
|
5970 |
evaluate:cmdMacro asString |
|
5971 |
receiver:self |
|
5972 |
notifying:nil |
|
5973 |
compile:false. |
|
5974 |
]. |
|
2952 | 5975 |
]. |
5976 |
! |
|
5977 |
||
5340
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5978 |
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
|
5979 |
| 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
|
5980 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5981 |
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
|
5982 |
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
|
5983 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5984 |
(x < leftMargin) ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5985 |
movedCol := 0 |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5986 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5987 |
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
|
5988 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5989 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5990 |
"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
|
5991 |
movedUp := false. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5992 |
(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
|
5993 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5994 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5995 |
(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
|
5996 |
(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
|
5997 |
movedUp := true |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5998 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
5999 |
] |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6000 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6001 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6002 |
self hasSelection ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6003 |
movedUp ifTrue:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6004 |
"/ 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
|
6005 |
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
|
6006 |
] ifFalse:[ |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6007 |
"/ 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
|
6008 |
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
|
6009 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6010 |
]. |
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6011 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6012 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6013 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6014 |
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
|
6015 |
|
fcba05443013
Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5333
diff
changeset
|
6016 |
"Created: / 02-05-2015 / 07:33:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 6017 |
! |
6018 |
||
6019 |
handleNonCommandKey:keyArg |
|
4700 | 6020 |
|selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key| |
2952 | 6021 |
|
6022 |
self isReadOnly ifTrue:[ |
|
4988 | 6023 |
self flashReadOnly. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6024 |
^ self. |
2952 | 6025 |
]. |
6026 |
||
6027 |
key := keyArg. |
|
6028 |
||
6029 |
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
|
6030 |
"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
|
6031 |
|
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
|
6032 |
"/ 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
|
6033 |
"/ 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
|
6034 |
"/ 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
|
6035 |
"/ 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
|
6036 |
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
|
6037 |
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
|
6038 |
|
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
|
6039 |
"/ 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
|
6040 |
self unselect. |
2952 | 6041 |
]. |
6042 |
||
4700 | 6043 |
selStartLineBefore := selectionStartLine. |
6044 |
selStartColBefore := self selectionStartCol. |
|
6045 |
selEndLineBefore := selectionEndLine. |
|
6046 |
selEndColBefore := self selectionEndCol. |
|
2952 | 6047 |
|
4940 | 6048 |
(gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[ |
4481 | 6049 |
key isCharacter ifTrue:[ |
4940 | 6050 |
key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 6051 |
] ifFalse:[ |
4940 | 6052 |
key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding. |
4481 | 6053 |
]. |
2952 | 6054 |
]. |
6055 |
||
6056 |
"replace selection by what is typed in - |
|
3235 | 6057 |
if word was selected with a space, keep it. |
4700 | 6058 |
if there was no selection, the key's character is inserted" |
3235 | 6059 |
|
6060 |
editMode value isInsertAndSelectMode ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6061 |
selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil. |
3235 | 6062 |
]. |
2952 | 6063 |
|
6064 |
(selectStyle == #wordLeft) ifTrue:[ |
|
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6065 |
self replaceSelectionBy:(' ' , key asString) |
2952 | 6066 |
] ifFalse:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6067 |
(selectStyle == #wordRight) ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6068 |
self replaceSelectionBy:(key asString , ' '). |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6069 |
self cursorLeft |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6070 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6071 |
self replaceSelectionBy:key |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6072 |
] |
3160 | 6073 |
]. |
2952 | 6074 |
selectStyle := nil. |
6075 |
||
3235 | 6076 |
editMode value isInsertAndSelectMode ifTrue:[ |
4700 | 6077 |
selectionStartLine := selStartLineBefore. |
6078 |
selectionStartCol := selStartColBefore. |
|
6079 |
selectionEndLine := selEndLineBefore. |
|
6080 |
selectionEndCol := selEndColBefore. |
|
3235 | 6081 |
]. |
6082 |
||
2952 | 6083 |
showMatchingParenthesis ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6084 |
"emacs style parenthesis shower" |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6085 |
(ExecutingMacroQuery query ? false) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6086 |
"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
|
6087 |
otherwise its too anoying. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6088 |
" |
2952 | 6089 |
" |
4481 | 6090 |
('()[]{}' includes:key) ifTrue:[ |
2952 | 6091 |
" |
4481 | 6092 |
(')]}' includes:key) ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6093 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6094 |
searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1) |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6095 |
ifFound:[:line :col | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6096 |
|savLine savCol sensor| |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6097 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6098 |
self withCursor:Cursor eye do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6099 |
savLine := cursorLine. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6100 |
savCol := cursorCol. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6101 |
self cursorLine:line col:col. |
4940 | 6102 |
self flush. |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6103 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6104 |
"/ 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
|
6105 |
"/ arrives in the meantime ... |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6106 |
|
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6107 |
sensor := self sensor. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6108 |
5 timesRepeat:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6109 |
(sensor hasKeyPressEventFor:self) ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6110 |
Processor activeProcess millisecondDelay:40. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6111 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6112 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6113 |
self cursorLine:savLine col:savCol |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6114 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6115 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6116 |
ifNotFound:[self showNotFound] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6117 |
onError:[self beep] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6118 |
]. |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6119 |
] |
2952 | 6120 |
]. |
6121 |
||
6122 |
"/ true "autoExpandWhileTyping" ifTrue:[ |
|
6123 |
"/ self wordAtLine:cursorLine col:cursorCol-1 do:[ |
|
6124 |
"/ :beginLine :beginCol :endLine :endCol :style | |
|
6125 |
"/ |
|
6126 |
"/ self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol. |
|
6127 |
"/ self selection. |
|
6128 |
"/ typeOfSelection := #paste. |
|
3160 | 6129 |
"/ ]. |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6130 |
"/ ]. |
3235 | 6131 |
editMode value isInsertAndSelectMode ifTrue:[ |
3813
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6132 |
selectionStartLine isNil ifTrue:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6133 |
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
|
6134 |
] ifFalse:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6135 |
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
|
6136 |
]. |
3235 | 6137 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6138 |
completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ]. |
4360 | 6139 |
|
6140 |
"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
|
6141 |
"Modified: / 30-08-2013 / 20:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2952 | 6142 |
! |
6143 |
||
6144 |
keyPress:key x:x y:y |
|
6145 |
"handle keyboard input" |
|
6146 |
||
4771 | 6147 |
|wasOn| |
6148 |
||
6149 |
wasOn := cursorShown. |
|
6150 |
||
5689 | 6151 |
NoModificationError |
6152 |
handle:[:ex | |
|
6153 |
self flashReadOnly. |
|
6154 |
(cursorShown not and:[wasOn]) ifTrue:[ |
|
6155 |
self makeCursorVisibleAndShowCursor:wasOn. |
|
6156 |
]. |
|
6157 |
] |
|
6158 |
do:[ |
|
6159 |
self undoableDo:[ |
|
6160 |
self doKeyPress:key x:x y:y |
|
6161 |
]. |
|
6162 |
]. |
|
6163 |
||
4242 | 6164 |
self repairDamage |
6165 |
||
6166 |
"Modified: / 18-04-2011 / 21:35:27 / cg" |
|
5689 | 6167 |
"Modified (format): / 30-04-2016 / 20:45:52 / cg" |
2952 | 6168 |
! |
6169 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6170 |
mapped |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6171 |
"view was made visible" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6172 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6173 |
super mapped. |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
6174 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6175 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6176 |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6177 |
requestAutoAccept |
5068 | 6178 |
"request to accept: this is invoked when a dialog closes via accept or cancel. |
6179 |
This forces my value to be accepted into my model. |
|
6180 |
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
|
6181 |
|
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6182 |
acceptEnabled == false ifTrue:[ |
4823 | 6183 |
"/ nope - |
6184 |
^ false |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6185 |
]. |
5404 | 6186 |
"/ cg: only do this if modified. |
6187 |
"/ otherwise, users would have to make sure that the contents is |
|
6188 |
"/ always correct (which they don't). If you change this back, |
|
6189 |
"/ please check the expecco file-save or file-reimport dialog, |
|
6190 |
"/ which has a problem with that behavior. |
|
6191 |
self modified ifTrue:[ |
|
6192 |
self accept. |
|
6193 |
]. |
|
3268
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6194 |
^ true. |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6195 |
! |
d30df22739ca
move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents:
3257
diff
changeset
|
6196 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6197 |
sizeChanged:how |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6198 |
"make certain, cursor is visible after the sizechange" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6199 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6200 |
|cv| |
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 |
cv := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6203 |
super sizeChanged:how. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6204 |
cv notNil ifTrue:[ |
4823 | 6205 |
self makeLineVisible:cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6206 |
] |
4967 | 6207 |
! |
6208 |
||
6209 |
unmapped |
|
6210 |
super unmapped. |
|
6211 |
||
6212 |
completionSupport notNil ifTrue:[ |
|
6213 |
completionSupport release. |
|
6214 |
]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6215 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6216 |
|
1807 | 6217 |
!EditTextView methodsFor:'focus handling'! |
6218 |
||
4818 | 6219 |
focusOut |
6220 |
super focusOut. |
|
6221 |
||
6222 |
completionSupport notNil ifTrue:[ |
|
6223 |
completionSupport release. |
|
6224 |
]. |
|
6225 |
! |
|
6226 |
||
1807 | 6227 |
hasKeyboardFocus:aBoolean |
6228 |
"sent by the windowGroup, a delegate or myself to make me show a block cursor |
|
6229 |
(otherwise, I would not know about this)" |
|
6230 |
||
6231 |
hasKeyboardFocus := aBoolean. |
|
4609 | 6232 |
|
3160 | 6233 |
(cursorShown |
6234 |
and:[self enabled |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6235 |
and:[self isReadOnly not]]) ifTrue:[ |
5890 | 6236 |
self drawCursor |
4609 | 6237 |
]. |
6238 |
||
6239 |
hasKeyboardFocus ifFalse:[ |
|
5890 | 6240 |
completionSupport notNil ifTrue:[ |
6241 |
"/ this is a hack for Windows: |
|
6242 |
"/ on windows, an activate:false event is first sent to my textView, |
|
6243 |
"/ then an activate is sent to the completion popup. |
|
6244 |
"/ this is done BEFORE the buttonPress event is delivered. |
|
6245 |
"/ therefore, allow for the activate of the completionMenu and its button event to be processed. |
|
6246 |
"/ before forcing it to be closed... |
|
6247 |
completionSupport startTimeoutForEditViewLostFocus. |
|
6248 |
]. |
|
1816
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6249 |
]. |
0b9380a0cc7e
only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents:
1811
diff
changeset
|
6250 |
|
4821 | 6251 |
"Modified (format): / 06-11-2013 / 15:37:31 / cg" |
1807 | 6252 |
! |
6253 |
||
6254 |
showFocus:explicit |
|
6255 |
"in addition to however my superclass thinks how a focusView is to be |
|
6256 |
displayed, show the cursor when I got the focus" |
|
6257 |
||
5239 | 6258 |
self hasKeyboardFocus:true. |
1807 | 6259 |
self showCursor. |
6260 |
super showFocus:explicit |
|
6261 |
||
6262 |
"Modified: 11.12.1996 / 16:56:54 / cg" |
|
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6263 |
! |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6264 |
|
4967 | 6265 |
showNoFocus:explicit |
6266 |
"the view lost the keyboard focus |
|
6267 |
(either explicit, via tabbing; or implicit, by pointer movement) |
|
6268 |
- change any display attributes as req'd." |
|
6269 |
||
6270 |
super showNoFocus:explicit. |
|
5149 | 6271 |
|
6272 |
"/ cg: only do this for an explicit change (i.e. by tabbing), |
|
6273 |
"/ not when the focus is lost normally (because this also happens when |
|
6274 |
"/ the completion-menu is clicked on), and we don't want to kill the |
|
6275 |
"/ completer. Otherwise, completion does not work when clocking into the list. |
|
6276 |
explicit ifTrue:[ |
|
6277 |
completionSupport notNil ifTrue:[ |
|
6278 |
completionSupport release. |
|
6279 |
]. |
|
4818 | 6280 |
]. |
6281 |
! |
|
6282 |
||
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6283 |
wantsFocusWithPointerEnter |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6284 |
"return true, if I want the focus when |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6285 |
the mouse pointer enters" |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6286 |
|
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6287 |
(UserPreferences current focusFollowsMouse ~~ false |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6288 |
and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true) |
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6289 |
and:[self enabled |
4781 | 6290 |
and:[true "self isReadOnly not"]]] |
4097
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6291 |
) ifTrue:[ |
233d27a2b0a0
comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents:
4089
diff
changeset
|
6292 |
^ true |
1918
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6293 |
]. |
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6294 |
|
3ac07b97b4f7
use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents:
1902
diff
changeset
|
6295 |
^ false |
1807 | 6296 |
! ! |
6297 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6298 |
!EditTextView methodsFor:'formatting'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6299 |
|
4237 | 6300 |
executekeyboardMacroNamed:macroName |
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6301 |
"try to execute the keyboard macro; |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6302 |
return true if that worked, false otherwise" |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6303 |
|
4482 | 6304 |
|cmdMacro| |
6305 |
||
6306 |
cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false]. |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6307 |
self |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6308 |
undoableDo:[ self executeKeyboardMacro:cmdMacro ] |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6309 |
info: macroName. |
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6310 |
^ true |
4238 | 6311 |
|
6312 |
" |
|
4483 | 6313 |
EditTextView open |
4238 | 6314 |
contents:'bla'; |
6315 |
selectAll; |
|
6316 |
executekeyboardMacroNamed:#IndentBy4. |
|
4483 | 6317 |
EditTextView open |
4238 | 6318 |
contents:'bla'; |
6319 |
selectAll; |
|
6320 |
executekeyboardMacroNamed:#blabla. |
|
6321 |
" |
|
4371
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6322 |
|
a631db2025af
changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents:
4360
diff
changeset
|
6323 |
"Modified: / 14-02-2012 / 11:17:27 / cg" |
4237 | 6324 |
! |
6325 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6326 |
indent |
3221 | 6327 |
"indent a line-range - this is done by searching for the |
6328 |
last non-empty line before the selection, and changing the indent |
|
4742 | 6329 |
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
|
6330 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6331 |
|start end| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6332 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6333 |
selectionStartLine isNil ifTrue:[^ self]. |
3221 | 6334 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6335 |
start := selectionStartLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6336 |
end := selectionEndLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6337 |
(selectionEndCol == 0) ifTrue:[ |
3786 | 6338 |
end := end - 1 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6339 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6340 |
self unselect. |
3160 | 6341 |
self |
3786 | 6342 |
undoableDo:[self indentFromLine:start toLine:end] |
6343 |
info:'Indent' |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6344 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6345 |
|
4237 | 6346 |
indentBy4 |
5050 | 6347 |
self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4. |
6348 |
||
6349 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6350 |
! |
|
6351 |
||
6352 |
indentBy8 |
|
6353 |
self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4. |
|
4237 | 6354 |
|
6355 |
"Modified: / 06-04-2011 / 18:52:40 / cg" |
|
6356 |
! |
|
6357 |
||
5050 | 6358 |
indentBy:n |
6359 |
|line1 line2| |
|
6360 |
||
6361 |
line1 := self selectionStartLine. |
|
6362 |
line2 := self selectionEndLine. |
|
6363 |
line1 isNil ifTrue:[ |
|
5833 | 6364 |
line1 := self cursorLine. |
6365 |
line1 notNil ifTrue:[ |
|
6366 |
line2 := line1 |
|
6367 |
] |
|
5769 | 6368 |
] ifFalse:[ |
5833 | 6369 |
line2 notNil ifTrue:[ |
6370 |
self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ]. |
|
5769 | 6371 |
]. |
6372 |
]. |
|
5050 | 6373 |
line1 notNil ifTrue:[ |
5833 | 6374 |
self indentFromLine:line1 toLine:line2 by:n. |
5050 | 6375 |
] |
6376 |
! |
|
6377 |
||
6378 |
indentByTab |
|
6379 |
self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8) |
|
6380 |
! |
|
6381 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6382 |
indentFromLine:start toLine:end |
3221 | 6383 |
"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
|
6384 |
last non-empty line before start, and change the indent |
4742 | 6385 |
of the selected line-range based on that line's indent." |
6386 |
||
4811 | 6387 |
|leftStart delta| |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6388 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6389 |
leftStart := self leftIndentForLine:start. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6390 |
(leftStart == 0) ifTrue:[^ self]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6391 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6392 |
delta := leftStart - (self leftIndentOfLine:start). |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6393 |
(delta == 0) ifTrue:[^ self]. |
4811 | 6394 |
self indentFromLine:start toLine:end by:delta |
6395 |
! |
|
6396 |
||
6397 |
indentFromLine:start toLine:end by:delta |
|
6398 |
"indent a line-range - this is done by searching for the |
|
6399 |
last non-empty line before start, and change the indent |
|
6400 |
of the selected line-range based on that line's indent." |
|
6401 |
||
6402 |
|d line spaces anyChange| |
|
6403 |
||
6404 |
(delta == 0) ifTrue:[^ self]. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6405 |
(delta > 0) ifTrue:[ |
4742 | 6406 |
spaces := String new:delta |
6407 |
]. |
|
6408 |
||
6409 |
anyChange := false. |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6410 |
start to:end do:[:lineNr | |
4742 | 6411 |
line := self listAt:lineNr. |
6412 |
line notNil ifTrue:[ |
|
6413 |
line isBlank ifTrue:[ |
|
4771 | 6414 |
self basicListAt:lineNr put:nil |
4742 | 6415 |
] ifFalse:[ |
6416 |
(delta > 0) ifTrue:[ |
|
6417 |
line := spaces , line. |
|
6418 |
widthOfWidestLine notNil ifTrue:[ |
|
6419 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line). |
|
6420 |
] |
|
6421 |
] ifFalse:[ |
|
6422 |
"check if deletion is ok" |
|
6423 |
d := delta negated + 1. |
|
6424 |
||
6425 |
line size > d ifTrue:[ |
|
6426 |
(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[ |
|
6427 |
line := line copyFrom:d |
|
6428 |
] |
|
6429 |
]. |
|
6430 |
widthOfWidestLine := nil |
|
6431 |
]. |
|
6432 |
self replaceLine:lineNr with:line. |
|
6433 |
anyChange := true. |
|
6434 |
] |
|
6435 |
] |
|
6436 |
]. |
|
6437 |
||
6438 |
anyChange ifTrue:[ self textChanged ]. |
|
6439 |
||
3221 | 6440 |
"/ self redrawFromLine:start to:end |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6441 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6442 |
"Modified: 5.3.1996 / 14:59:18 / cg" |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6443 |
! |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6444 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6445 |
leftIndentForLine:lineNr |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6446 |
"find an appropriate indent for a line. |
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6447 |
this is done by searching for the last non-empty line before it |
4823 | 6448 |
and returning its indent. |
6449 |
cg: changed: only look for the single previous line." |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6450 |
|
827 | 6451 |
"SHOULD GO TO ListView" |
6452 |
||
6453 |
|line lnr indent| |
|
6454 |
||
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6455 |
lnr := lineNr. |
827 | 6456 |
|
4823 | 6457 |
"/ [lnr ~~ 1] whileTrue:[ |
6458 |
(lnr ~~ 1) ifTrue:[ |
|
4814 | 6459 |
lnr := lnr - 1. |
6460 |
line := self listAt:lnr. |
|
6461 |
||
6462 |
line notNil ifTrue:[ |
|
6463 |
indent := line indexOfNonSeparatorStartingAt:1. |
|
6464 |
indent ~~ 0 ifTrue:[ |
|
6465 |
(line endsWith:$[) ifTrue:[ |
|
6466 |
^ indent + 4 - 1 |
|
6467 |
]. |
|
6468 |
^ indent - 1 |
|
6469 |
] |
|
6470 |
] |
|
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6471 |
]. |
827 | 6472 |
^ 0 |
474
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6473 |
|
f73ed1f5cb75
added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
6474 |
"Created: 5.3.1996 / 14:58:53 / cg" |
4237 | 6475 |
! |
6476 |
||
6477 |
undentBy4 |
|
5050 | 6478 |
self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4. |
6479 |
||
6480 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
6481 |
! |
|
6482 |
||
6483 |
undentBy8 |
|
6484 |
self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4. |
|
4237 | 6485 |
|
6486 |
"Modified: / 06-04-2011 / 18:52:49 / cg" |
|
5050 | 6487 |
! |
6488 |
||
6489 |
undentBy:n |
|
6490 |
self indentBy:(n negated) |
|
6491 |
! |
|
6492 |
||
6493 |
undentByTab |
|
6494 |
self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8). |
|
105 | 6495 |
! ! |
6496 |
||
0 | 6497 |
!EditTextView methodsFor:'initialization'! |
6498 |
||
941 | 6499 |
fetchDeviceResources |
6500 |
"fetch device colors, to avoid reallocation at redraw time" |
|
6501 |
||
6502 |
super fetchDeviceResources. |
|
6503 |
||
5643 | 6504 |
cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device]. |
6505 |
cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device]. |
|
6506 |
cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device]. |
|
941 | 6507 |
|
6508 |
"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
|
6509 |
"Modified: 18.2.1997 / 15:02:46 / cg" |
941 | 6510 |
! |
6511 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6512 |
initEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6513 |
"enable enter/leave events in addition" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6514 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6515 |
super initEvents. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6516 |
self enableEnterLeaveEvents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6517 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6518 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6519 |
initStyle |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6520 |
"initialize style specific stuff" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6521 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6522 |
super initStyle. |
4576 | 6523 |
"/ lineSpacing := 2. "/ for underwave - also looks better |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6524 |
lockUpdates := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6525 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6526 |
cursorFgColor := DefaultCursorForegroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6527 |
cursorFgColor isNil ifTrue:[cursorFgColor := bgColor]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6528 |
cursorBgColor := DefaultCursorBackgroundColor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6529 |
cursorBgColor isNil ifTrue:[cursorBgColor := fgColor]. |
4721 | 6530 |
cursorType isNil ifTrue:[cursorType := DefaultCursorType]. |
6531 |
cursorTypeNoFocus isNil ifTrue:[ |
|
6532 |
cursorTypeNoFocus := cursorType. |
|
6533 |
DefaultCursorTypeNoFocus notNil ifTrue:[ |
|
6534 |
cursorTypeNoFocus := DefaultCursorTypeNoFocus. |
|
6535 |
] |
|
1534
bcb211e1b41a
read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents:
1533
diff
changeset
|
6536 |
]. |
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6537 |
cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6538 |
cursorNoFocusFgColor isNil ifTrue:[ |
4576 | 6539 |
cursorType ~~ #block ifTrue:[ |
6540 |
cursorNoFocusFgColor := cursorBgColor |
|
6541 |
] ifFalse:[ |
|
6542 |
cursorNoFocusFgColor := cursorFgColor |
|
6543 |
] |
|
1022
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6544 |
]. |
4362861fe15e
allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents:
1018
diff
changeset
|
6545 |
|
2088 | 6546 |
"Modified: / 15.12.1999 / 22:27:45 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6547 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6548 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6549 |
initialize |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6550 |
"initialize a new EditTextView; |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6551 |
setup some instance variables" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6552 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6553 |
super initialize. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6554 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6555 |
self level:-1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6556 |
readOnly := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6557 |
fixedSize := false. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6558 |
exceptionBlock := [:errorText | ]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6559 |
cursorShown := prevCursorState := true. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6560 |
cursorLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6561 |
cursorVisibleLine := 1. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6562 |
cursorCol := 1. |
5251 | 6563 |
cursorLineHolder := ValueHolder with:1. |
6564 |
cursorColHolder := ValueHolder with:1. |
|
2119 | 6565 |
modifiedChannel := ValueHolder with:false. |
6566 |
acceptChannel := ValueHolder with:false. |
|
1437
ab84b08a9f9c
allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
6567 |
acceptChannel addDependent:self. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6568 |
showMatchingParenthesis := false. |
3296
7322b2e5222c
Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents:
3269
diff
changeset
|
6569 |
hasKeyboardFocus := false. |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
6570 |
tabMeansNextField := false. |
5106 | 6571 |
"/ autoIndent := UserPreferences current autoIndentInCodeView. |
6572 |
autoIndent := false. |
|
5251 | 6573 |
editMode := ValueHolder with:EditMode insertMode. |
6574 |
learnMode := ValueHolder with:false. |
|
2131 | 6575 |
cursorMovementWhenUpdating := #beginOfText. |
4048 | 6576 |
lastReplacementInfo := LastReplacementInfo new. |
1596
0bbdb4e9fc43
made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents:
1591
diff
changeset
|
6577 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6578 |
"/ enable drop by default |
2589 | 6579 |
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
|
6580 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
6581 |
undoSupport := UndoSupport for:self. |
5251 | 6582 |
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
|
6583 |
|
87d60a4b098b
Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4801
diff
changeset
|
6584 |
"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
|
6585 |
! |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6586 |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6587 |
initializeCompletionSupport |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6588 |
|supportClass| |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6589 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6590 |
completionSupport isNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6591 |
(supportClass := self completionSupportClass) notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6592 |
completionSupport := supportClass for:self. |
4696
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6593 |
]. |
428c8bc44cfb
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4694
diff
changeset
|
6594 |
]. |
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6595 |
|
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6596 |
"Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4771 | 6597 |
! |
6598 |
||
6599 |
release |
|
4801
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6600 |
completionSupport notNil ifTrue:[ |
69a5bff7b5cd
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4786
diff
changeset
|
6601 |
completionSupport release |
4771 | 6602 |
]. |
6603 |
super release |
|
0 | 6604 |
! ! |
6605 |
||
2580 | 6606 |
!EditTextView methodsFor:'macros'! |
6607 |
||
6608 |
executeLearnedKeyboardMacro |
|
4673 | 6609 |
"replay the characters as learned previously" |
6610 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6611 |
(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
|
6612 |
ExecutingMacroQuery |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6613 |
answer:true |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6614 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6615 |
learnedMacro do:[:event | |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6616 |
WindowGroup lastEventQuerySignal answer:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6617 |
do:[ |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6618 |
self |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6619 |
dispatchEvent:event |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6620 |
withFocusOn:nil |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6621 |
delegate:false |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6622 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6623 |
] |
8d719ca5812d
dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents:
3811
diff
changeset
|
6624 |
]. |
2580 | 6625 |
] ifFalse:[ |
5153 | 6626 |
self flash:'no macro'. |
2580 | 6627 |
]. |
6628 |
! |
|
6629 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6630 |
learnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6631 |
"true if currently learning" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6632 |
|
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6633 |
^ (learnMode value ? false). |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6634 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6635 |
|
2580 | 6636 |
learnMode:aBoolean |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6637 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6638 |
|
2580 | 6639 |
|fg bg| |
6640 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6641 |
self learnModeHolder value:aBoolean. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6642 |
|
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6643 |
aBoolean ifTrue:[ |
5795 | 6644 |
learnedMacro := OrderedCollection new. |
6645 |
fg := self whiteColor. |
|
6646 |
bg := self blackColor. |
|
2580 | 6647 |
] ifFalse:[ |
5795 | 6648 |
cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor). |
6649 |
cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor). |
|
2580 | 6650 |
]. |
6651 |
self cursorForegroundColor:fg backgroundColor:bg. |
|
6652 |
! |
|
6653 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6654 |
learnModeHolder |
4673 | 6655 |
"a holder returning true, if in learn mode" |
6656 |
||
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6657 |
learnMode isNil ifTrue:[ |
5251 | 6658 |
learnMode := ValueHolder with:false |
2795
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6659 |
]. |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6660 |
^ learnMode |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6661 |
! |
1f7b5f242eee
learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents:
2792
diff
changeset
|
6662 |
|
4673 | 6663 |
rememberLearnedMacroAs: nameString |
6664 |
Macros isNil ifTrue:[ |
|
6665 |
Macros := Dictionary new. |
|
6666 |
]. |
|
6667 |
Macros at:nameString put:learnedMacro |
|
6668 |
! |
|
6669 |
||
2580 | 6670 |
toggleLearnMode |
3793
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6671 |
"toggle the learn-mode" |
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6672 |
|
5a6074a257c1
learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents:
3790
diff
changeset
|
6673 |
self learnMode:(self learnMode not). |
2580 | 6674 |
! ! |
6675 |
||
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
6676 |
!EditTextView methodsFor:'menu & menu actions'! |
121 | 6677 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6678 |
babelFishTranslate:fromToModeString |
5962 | 6679 |
"translate the selected text and paste it after the selection. |
6680 |
This is now obsolete, as that web service no longer exists (sigh)" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6681 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6682 |
|original translated| |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6683 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6684 |
original := self selectionAsString. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6685 |
original size == 0 ifTrue:[^ self]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6686 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6687 |
self withWaitCursorDo:[ |
5962 | 6688 |
(HostNameLookupError , SOAP::SoapImplError) handle:[:ex | |
6689 |
Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs |
|
6690 |
] do:[ |
|
6691 |
translated := SOAP::BabelFishClient new |
|
6692 |
translate:original mode:fromToModeString. |
|
6693 |
] |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6694 |
]. |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6695 |
|
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6696 |
"/ v pasteOrReplace:translated |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6697 |
self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1). |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6698 |
self unselect. |
3799 | 6699 |
self |
6700 |
undoablePaste:translated |
|
5962 | 6701 |
info:'Translate' |
3495 | 6702 |
|
6703 |
"Modified: / 28-07-2007 / 13:27:21 / cg" |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6704 |
! |
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6705 |
|
3517 | 6706 |
compareWithClipboard |
6707 |
"compare the selection against the clipboard contents" |
|
6708 |
||
6709 |
|t1 t2| |
|
6710 |
||
6711 |
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
|
6712 |
t2 isEmptyOrNil ifTrue:[ |
4823 | 6713 |
Dialog information:'Clipboard is empty.'. |
6714 |
^ self. |
|
3517 | 6715 |
]. |
6716 |
||
6717 |
self hasSelection ifTrue:[ |
|
4823 | 6718 |
t1 := self selectionAsString. |
3517 | 6719 |
] ifFalse:[ |
4823 | 6720 |
t1 := self contents asString |
3517 | 6721 |
]. |
6722 |
t1 := t1 string. |
|
6723 |
||
6724 |
t1 = t2 ifTrue:[ |
|
4823 | 6725 |
Dialog information:'Strings are equal.'. |
6726 |
^ self. |
|
3517 | 6727 |
]. |
6728 |
DiffTextView |
|
4823 | 6729 |
openOn:t1 label:'Editor' |
6730 |
and:t2 label:'Clipboard' |
|
3517 | 6731 |
! |
6732 |
||
5826 | 6733 |
compareWithFile |
6734 |
"compare the selection or the whole text against the contents of a file" |
|
6735 |
||
6736 |
|fn t1 t2| |
|
6737 |
||
6738 |
fn := Dialog requestFileName:'Compare against file:' default:defaultFileNameForFileDialog. |
|
6739 |
fn isEmptyOrNil ifTrue:[^ self]. |
|
6740 |
||
6741 |
t2 := fn asFilename contentsOfEntireFile. |
|
6742 |
t2 isEmptyOrNil ifTrue:[ |
|
6743 |
Dialog information:'File is empty.'. |
|
6744 |
^ self. |
|
6745 |
]. |
|
6746 |
||
6747 |
self hasSelection ifTrue:[ |
|
6748 |
t1 := self selectionAsString. |
|
6749 |
] ifFalse:[ |
|
6750 |
t1 := self contents asString |
|
6751 |
]. |
|
6752 |
t1 := t1 string. |
|
6753 |
||
6754 |
t1 = t2 ifTrue:[ |
|
6755 |
Dialog information:'Same contents.'. |
|
6756 |
^ self. |
|
6757 |
]. |
|
6758 |
DiffTextView |
|
6759 |
openOn:t1 label:'Editor' |
|
6760 |
and:t2 label:'File' |
|
6761 |
! |
|
6762 |
||
5689 | 6763 |
copySelection |
6764 |
"copy contents into smalltalk copybuffer. |
|
6765 |
Redefined to move the (currently hidden cursor) to the selection's end" |
|
6766 |
||
6767 |
self hasSelection ifTrue:[ |
|
6768 |
self setCursorLine:selectionEndLine col:selectionEndCol+1 |
|
6769 |
]. |
|
6770 |
super copySelection. |
|
6771 |
||
6772 |
"Created: / 30-04-2016 / 21:07:10 / cg" |
|
6773 |
! |
|
6774 |
||
121 | 6775 |
cut |
6776 |
"cut selection into copybuffer" |
|
6777 |
||
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6778 |
self deleteCopyToClipboard:true |
121 | 6779 |
! |
6780 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6781 |
defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6782 |
"return a default value to show in the gotoLine box" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6783 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6784 |
cursorLine notNil ifTrue:[ |
4823 | 6785 |
^ cursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6786 |
]. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6787 |
^ super defaultForGotoLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6788 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
6789 |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6790 |
deleteCopyToClipboard:toClipboard |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6791 |
"cut selection into copybuffer" |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6792 |
|
4129 | 6793 |
|line col history sel | |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6794 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6795 |
(self checkModificationsAllowed) ifFalse:[ |
4988 | 6796 |
self flashReadOnly. |
3786 | 6797 |
^ self |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6798 |
]. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6799 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6800 |
sel := self selection. |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6801 |
sel notNil ifTrue:[ |
4129 | 6802 |
self setLastStringToReplace: sel. |
4053 | 6803 |
|
3786 | 6804 |
line := selectionStartLine. |
6805 |
col := selectionStartCol. |
|
6806 |
||
6807 |
toClipboard ifTrue:[ |
|
6808 |
" |
|
6809 |
remember in CopyBuffer |
|
6810 |
" |
|
6811 |
self setClipboardText:sel. "/ lastString. |
|
6812 |
]. |
|
6813 |
||
6814 |
" |
|
6815 |
append to DeleteHistory (if there is one) |
|
6816 |
" |
|
6817 |
history := Smalltalk at:#DeleteHistory. |
|
6818 |
history notNil ifTrue:[ |
|
6819 |
history addAll:(sel asStringCollection). |
|
6820 |
history size > 1000 ifTrue:[ |
|
6821 |
history := history copyFrom:(history size - 1000) |
|
6822 |
]. |
|
6823 |
]. |
|
6824 |
||
6825 |
" |
|
6826 |
now, delete it |
|
6827 |
" |
|
6828 |
self |
|
6829 |
undoableDo:[self deleteSelection] |
|
6830 |
info:'Delete'. |
|
4048 | 6831 |
lastReplacementInfo lastReplacement: nil |
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6832 |
] ifFalse:[ |
3786 | 6833 |
" |
6834 |
a cut without selection will search&cut again |
|
6835 |
" |
|
6836 |
self undoableDo:[ |
|
6837 |
self again |
|
6838 |
] |
|
3324
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6839 |
] |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6840 |
|
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6841 |
"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
|
6842 |
! |
1297aecf6699
delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents:
3313
diff
changeset
|
6843 |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6844 |
editMenu |
5977 | 6845 |
"return the view's middleButtonMenu" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
6846 |
|
3781 | 6847 |
<resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept |
5826 | 6848 |
#Find #GotoLine #SaveAs #Print |
3890 | 6849 |
#PasteFromHistory #Join #Wrap #Undo #Redo |
3781 | 6850 |
#ToggleAutoIndent #ToggleInsertMode |
5826 | 6851 |
#LearnKeyboardMacro #ExecuteKeyboardMacro )> |
1261
bdb18f73205c
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1198
diff
changeset
|
6852 |
<resource: #programMenu> |
1054 | 6853 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
6854 |
|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
|
6855 |
transSub sortSub what undoIdx redoIdx sensor main mainItems| |
1515 | 6856 |
|
2460 | 6857 |
items := #( |
5826 | 6858 |
('Redo' redo Redo ) |
6859 |
('Again (for All)' multipleAgain AgainForAll ) |
|
6860 |
('-' ) |
|
6861 |
('Search...' search Find ) |
|
6862 |
('Goto Line...' gotoLine GotoLine ) |
|
6863 |
('-' ) |
|
6864 |
('Tools' tools ) |
|
6865 |
('Font...' changeFont ) |
|
6866 |
('Insert Unicode...' insertUnicode ) |
|
6867 |
). |
|
4213 | 6868 |
CharacterSetView notNil ifTrue:[ |
5826 | 6869 |
items := items , |
6870 |
#( |
|
6871 |
('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
|
6872 |
). |
|
4213 | 6873 |
]. |
6874 |
items := items , #( |
|
5826 | 6875 |
('-' ) |
6876 |
('Save As...' save SaveAs ) |
|
6877 |
('Print' doPrint Print ) |
|
6878 |
('=' ) |
|
6879 |
('Misc' misc ShiftCtrl) ). |
|
2460 | 6880 |
|
2866 | 6881 |
miscItems := #( |
5826 | 6882 |
('AutoIndent \c' autoIndent: ToggleAutoIndent ) |
6883 |
('InsertMode \c' insertMode: ToggleInsertMode ) |
|
6884 |
('-' ) |
|
6885 |
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory ) |
|
6886 |
('Join Lines' joinLines Join ) |
|
6887 |
('Wrap Lines...' wrapLines Wrap ) |
|
6888 |
('-' ) |
|
6889 |
('Learn Macro' learnMode: LearnKeyboardMacro) |
|
6890 |
('Execute Macro' executeLearnedKeyboardMacro ExecuteKeyboardMacro ) |
|
6891 |
('-' ) |
|
6892 |
('Insert File...' insertFile ) |
|
6893 |
('Insert URL Contents...' insertURL ) |
|
6894 |
('Insert new UUID' insertUUID ) |
|
6895 |
('Insert Date && Time' insertDateAndTime ) |
|
6896 |
('-' ) |
|
6897 |
('Insert File as String Literal...' insertFileAsStringLiteral ) |
|
6898 |
('Paste as String Literal' pasteAsStringLiteral ) |
|
6899 |
). |
|
4213 | 6900 |
"/ CharacterSetView notNil ifTrue:[ |
6901 |
"/ miscItems := miscItems , |
|
6902 |
"/ #( |
|
5529 | 6903 |
"/ ('-' ) |
4213 | 6904 |
"/ ('Special Characters...' specialCharacters OpenSpecialCharacterWindow ) |
5529 | 6905 |
"/ ('Font...' changeFont ) |
4213 | 6906 |
"/ ). |
5529 | 6907 |
"/ ] ifFalse:[ |
6908 |
"/ miscItems := miscItems , |
|
6909 |
"/ #( |
|
6910 |
"/ ('Font...' changeFont ) |
|
6911 |
"/"/ ('Encoding...' changeEncoding ) |
|
6912 |
"/ ). |
|
6913 |
"/ ]. |
|
2866 | 6914 |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6915 |
translateItems := #( |
5826 | 6916 |
('English -> German' (babelFishTranslate: 'en_de') ) |
6917 |
('English -> French' (babelFishTranslate: 'en_fr') ) |
|
6918 |
('English -> Italian' (babelFishTranslate: 'en_it') ) |
|
6919 |
('English -> Spanish' (babelFishTranslate: 'en_es') ) |
|
6920 |
('English -> Portuguese' (babelFishTranslate: 'en_pt') ) |
|
6921 |
('-' ) |
|
6922 |
('German -> English' (babelFishTranslate: 'de_en') ) |
|
6923 |
('French -> English' (babelFishTranslate: 'fr_en') ) |
|
6924 |
('Italian -> English' (babelFishTranslate: 'it_en') ) |
|
6925 |
('Spanish -> English' (babelFishTranslate: 'es_en') ) |
|
6926 |
('Portuguese -> English' (babelFishTranslate: 'pt_en') ) |
|
6927 |
). |
|
3221 | 6928 |
|
6929 |
sortItems := #( |
|
5826 | 6930 |
('Lines' (sortSelection:ignoreCase: #lines false) ) |
6931 |
('Lines by First Word' (sortSelection:ignoreCase: #linesByFirstWord false) ) |
|
6932 |
('Lines by n''th Word' (sortSelection:ignoreCase: #linesByNthWord false) ) |
|
6933 |
('Lines by n''th Number' (sortSelection:ignoreCase: #linesByNthNumber false) ) |
|
6934 |
('Lines by n''th Hex Number' (sortSelection:ignoreCase: #linesByNthHexNumber false) ) |
|
6935 |
('Words' (sortSelection:ignoreCase: #words false) ) |
|
6936 |
('-' ) |
|
6937 |
('Lines (ignore case)' (sortSelection:ignoreCase: #lines true) ) |
|
6938 |
('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true) ) |
|
6939 |
('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true) ) |
|
6940 |
('Words (ignore case)' (sortSelection:ignoreCase: #words true) ) |
|
6941 |
('-' ) |
|
6942 |
('By Line Length' (sortSelection:ignoreCase: #linesByLength nil) ) |
|
6943 |
('Reverse' (sortSelection:ignoreCase: #reverse nil) ) |
|
6944 |
). |
|
2680
208d99c47d7c
babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
6945 |
|
2762 | 6946 |
toolItems := #( |
5826 | 6947 |
('Indent' indent ) |
6948 |
('Toggle Case' convertSelectionToLowercaseOrUppercaseOrUppercaseFirst ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst) |
|
6949 |
('Sort' sort ) |
|
6950 |
('Split...' splitLinesAtCharacterOrString ) |
|
6951 |
('-' ) |
|
6952 |
('Google Spell Check' googleSpellingSuggestion ) |
|
6953 |
('Builtin Spell Check' internalSpellingSuggestion ) |
|
6954 |
('Translate' babelFishTranslate ) |
|
6955 |
('Compare with Clipboard...' compareWithClipboard ) |
|
6956 |
('Compare with File...' compareWithFile ) |
|
6957 |
). |
|
2762 | 6958 |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6959 |
Smalltalk isStandAloneApp ifFalse:[ |
5826 | 6960 |
toolItems := toolItems , #( |
6961 |
('-' ) |
|
6962 |
('Open FileBrowser on It' openFileBrowserOnIt ) |
|
6963 |
('Open Workspace with It' openWorkspaceWithIt ) |
|
6964 |
('Inspect Selected String' inspectSelectedString ) |
|
6965 |
). |
|
3623
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6966 |
]. |
f99c70d99425
close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents:
3595
diff
changeset
|
6967 |
|
2460 | 6968 |
sub := PopUpMenu itemList:items resources:resources performer:model. |
2461 | 6969 |
sub receiver:self. |
2460 | 6970 |
|
2919 | 6971 |
toolSub := PopUpMenu itemList:toolItems resources:resources performer:model. |
6972 |
toolSub receiver:self. |
|
6973 |
sub subMenuAt:#tools put:toolSub. |
|
6974 |
||
3495 | 6975 |
transSub := PopUpMenu itemList:translateItems resources:resources performer:model. |
6976 |
transSub receiver:self. |
|
6977 |
toolSub subMenuAt:#babelFishTranslate put:transSub. |
|
6978 |
||
6979 |
sortSub := PopUpMenu itemList:sortItems resources:resources performer:model. |
|
6980 |
sortSub receiver:self. |
|
6981 |
toolSub subMenuAt:#sort put:sortSub. |
|
3221 | 6982 |
|
2866 | 6983 |
subSub := PopUpMenu itemList:miscItems resources:resources performer:model. |
6984 |
subSub receiver:self. |
|
2952 | 6985 |
subSub checkToggleAt:#autoIndent: put:autoIndent. |
3235 | 6986 |
subSub checkToggleAt:#insertMode: put:(self isInInsertMode). |
2952 | 6987 |
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
|
6988 |
|
2866 | 6989 |
sub subMenuAt:#misc put:subSub. |
6990 |
||
3495 | 6991 |
mainItems := #( |
5826 | 6992 |
('Undo' undo Undo ) |
6993 |
('Again' again Again ) |
|
6994 |
('-' ) |
|
6995 |
('Cut' cut Cut ) |
|
6996 |
('Copy' copySelection Copy ) |
|
6997 |
('Paste' pasteOrReplace Paste ) |
|
6998 |
('-' ) |
|
6999 |
('Accept' accept Accept ) |
|
7000 |
('=' ) |
|
7001 |
('More' others Ctrl ) |
|
7002 |
). |
|
3495 | 7003 |
main := PopUpMenu itemList:mainItems resources:resources. |
7004 |
main subMenuAt:#others put:sub. |
|
7005 |
||
7006 |
sensor := self sensor. |
|
7007 |
(sensor notNil and:[sensor ctrlDown]) ifTrue:[ |
|
7008 |
sensor shiftDown ifTrue:[ |
|
5826 | 7009 |
m := subSub |
7010 |
] ifFalse:[ |
|
7011 |
m := sub |
|
7012 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7013 |
] ifFalse:[ |
5826 | 7014 |
m := main |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7015 |
]. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7016 |
|
4742 | 7017 |
"/ the 'Smalltalk at:' code is here to |
7018 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
4373 | 7019 |
(Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[ |
5826 | 7020 |
"/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'. |
7021 |
m disable:#googleSpellingSuggestion |
|
2676 | 7022 |
]. |
4742 | 7023 |
(Smalltalk at:#'RBSpellChecker') isNil ifTrue:[ |
5826 | 7024 |
m disable:#internalSpellingSuggestion |
4742 | 7025 |
]. |
2676 | 7026 |
|
3811 | 7027 |
HTTPInterface isNil ifTrue:[ |
5826 | 7028 |
m disableAll:#(insertURL) |
3811 | 7029 |
]. |
7030 |
||
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7031 |
self isReadOnly ifTrue:[ |
5826 | 7032 |
m disableAll:#(accept undo again multipleAgain redo |
7033 |
paste pasteOrReplace pasteOrReplaceFromHistory |
|
7034 |
cut indent autoIndent: insertMode: |
|
7035 |
insertFile insertFileAsStringLiteral insertURL |
|
7036 |
babelFishTranslate googleSpellingSuggestion sort |
|
4475 | 7037 |
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst |
5826 | 7038 |
joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral |
7039 |
insertUnicode specialCharacters) |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7040 |
]. |
2817 | 7041 |
self hasSelectionForCopy ifFalse:[ |
5826 | 7042 |
m disable:#copySelection. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7043 |
]. |
2416
56acdd9e31b5
lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents:
2406
diff
changeset
|
7044 |
self hasSelection ifFalse:[ |
5371 | 7045 |
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt |
5826 | 7046 |
openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString). |
2762 | 7047 |
] ifTrue:[ |
5826 | 7048 |
(Error handle:[:ex | |
7049 |
ex return:false |
|
7050 |
] do:[ |
|
7051 |
|fn| |
|
7052 |
fn := self selectionAsString. |
|
7053 |
fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ] |
|
7054 |
]) ifFalse:[ |
|
7055 |
m disableAll:#(openFileBrowserOnIt). |
|
7056 |
] |
|
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7057 |
]. |
2569 | 7058 |
self hasUndoAction ifFalse:[ |
5826 | 7059 |
m disable:#undo. |
3115 | 7060 |
] ifTrue:[ |
5826 | 7061 |
what := undoSupport undoActionInfo. |
7062 |
what notNil ifTrue:[ |
|
7063 |
undoIdx := m indexOf:#undo. |
|
7064 |
m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what). |
|
7065 |
] |
|
1818
aa16d9b96e40
fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents:
1817
diff
changeset
|
7066 |
]. |
2952 | 7067 |
self hasRedoAction ifFalse:[ |
5826 | 7068 |
sub disable:#redo. |
3569
d3eec21d0ece
also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents:
3566
diff
changeset
|
7069 |
] ifTrue:[ |
5826 | 7070 |
what := undoSupport redoActionInfo. |
7071 |
what notNil ifTrue:[ |
|
7072 |
redoIdx := sub indexOf:#redo. |
|
7073 |
sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what). |
|
7074 |
] |
|
2952 | 7075 |
]. |
5216 | 7076 |
self canAccept ifFalse:[ |
5826 | 7077 |
m disable:#accept |
1108 | 7078 |
]. |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7079 |
^ m. |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7080 |
|
4388 | 7081 |
"Modified: / 01-03-2012 / 19:56:58 / cg" |
428
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7082 |
! |
6b0881b0bce1
changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents:
400
diff
changeset
|
7083 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7084 |
getTextSelectionFromHistory |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7085 |
|sel list box history| |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7086 |
|
5643 | 7087 |
history := device getCopyBufferHistory copy. |
3160 | 7088 |
list := history collect:[:entry | |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7089 |
|text shown| |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7090 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7091 |
text := entry asString string asCollectionOfLines. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7092 |
shown := text detect:[:line| line notEmptyOrNil] ifNone:[' ']. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7093 |
text size > 1 ifTrue:[ |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7094 |
shown := shown,(resources string:' ... [%1 lines]' with:text size). |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7095 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7096 |
shown |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7097 |
]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7098 |
|
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7099 |
box := ListSelectionBox |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7100 |
title:(resources string:'Clipboard History') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7101 |
okText:(resources string:'Paste') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7102 |
abortText:(resources string:'Cancel') |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7103 |
list:list |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7104 |
action:[:idx | idx notNil ifTrue:[sel := history at:idx]]. |
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7105 |
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
|
7106 |
box useIndex:true. |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7107 |
box show. |
3160 | 7108 |
^ sel. |
4165
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7109 |
|
869b207a6964
changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4162
diff
changeset
|
7110 |
"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
|
7111 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7112 |
|
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7113 |
getTextSelectionOrTextSelectionFromHistory |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7114 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
7115 |
self sensor shiftDown ifTrue:[ |
3855 | 7116 |
^ self getTextSelectionFromHistory |
2544
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7117 |
]. |
2724 | 7118 |
|
4285
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7119 |
"/ return either the (xterm-) selection or the clipBoard depending on |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7120 |
"/ the Ctrl-Key state. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7121 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7122 |
"/ ouch - this used to be ok for ALT-c / ALT-v, |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7123 |
"/ but no longer works with CTRL-c / CTRL-v. |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7124 |
^ self getClipboardText:#clipboard |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7125 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7126 |
"/ ^ self |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7127 |
"/ getClipboardText:(self sensor ctrlDown |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7128 |
"/ ifTrue:[#selection] |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7129 |
"/ ifFalse:[#clipboard]) |
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7130 |
|
8487c7a8fab0
changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents:
4275
diff
changeset
|
7131 |
"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
|
7132 |
! |
48ab4ed67816
shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents:
2540
diff
changeset
|
7133 |
|
2676 | 7134 |
googleSpellingSuggestion |
7135 |
"insert the google-spelling suggestion for the selected text. |
|
7136 |
Requires that the SOAP stuff is loaded and working." |
|
7137 |
||
2677 | 7138 |
|text suggestion| |
2676 | 7139 |
|
7140 |
self withWaitCursorDo:[ |
|
3799 | 7141 |
text := self selection asString string withoutSeparators. |
7142 |
text size == 0 ifTrue:[^ self]. |
|
7143 |
||
4742 | 7144 |
"/ the 'Smalltalk at:' code is here to |
7145 |
"/ avoid making the SOAP package a prerequisite for this package (libwidg) |
|
7146 |
(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex | |
|
3799 | 7147 |
Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs. |
7148 |
^ self. |
|
7149 |
] do:[ |
|
4742 | 7150 |
suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text. |
3799 | 7151 |
]. |
7152 |
suggestion size == 0 ifTrue:[ |
|
4742 | 7153 |
self information:('No spelling suggestion from Google for: ' , text). |
7154 |
Transcript showCR:('No spelling suggestion from Google for: ' , text). |
|
3799 | 7155 |
^ self. |
7156 |
]. |
|
7157 |
]. |
|
7158 |
self |
|
7159 |
undoablePaste:suggestion |
|
7160 |
info:'Spelling Suggestion'. |
|
3495 | 7161 |
|
7162 |
"Modified: / 28-07-2007 / 13:25:10 / cg" |
|
2676 | 7163 |
! |
7164 |
||
3595 | 7165 |
insertDateAndTime |
7166 |
"insert the curent date and time string" |
|
7167 |
||
7168 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7169 |
self |
3786 | 7170 |
undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)] |
3799 | 7171 |
info:'Paste Date and Time' |
3595 | 7172 |
! |
7173 |
||
2676 | 7174 |
insertFile |
3160 | 7175 |
"insert contents of a file |
2676 | 7176 |
- ask user for filename using a fileSelectionBox." |
7177 |
||
3731 | 7178 |
self insertFileAsStringLiteral:false |
7179 |
! |
|
7180 |
||
7181 |
insertFileAsStringLiteral |
|
7182 |
"insert a file's contents as a string literal. |
|
7183 |
Almost the same as the insert file, but single-quotes are doubled, |
|
7184 |
to make it a legal string literal" |
|
7185 |
||
7186 |
self insertFileAsStringLiteral:true |
|
7187 |
! |
|
7188 |
||
7189 |
insertFileAsStringLiteral:asStringLiteral |
|
7190 |
"insert contents of a file; either as-is or as a string literal. |
|
7191 |
- ask user for filename using a fileSelectionBox." |
|
7192 |
||
3409
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7193 |
|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
|
7194 |
|
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7195 |
((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
|
7196 |
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
|
7197 |
and:[ selFn isRegularFile ]]) |
d650e3ae9085
insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents:
3406
diff
changeset
|
7198 |
ifTrue:[ |
3731 | 7199 |
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
|
7200 |
]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7201 |
|
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7202 |
[ |
3731 | 7203 |
|why| |
7204 |
||
7205 |
file := Dialog |
|
7206 |
requestFileName:(resources string:'Insert Contents Of:') |
|
7207 |
default:initial |
|
7208 |
ok:(resources string:'Insert') |
|
7209 |
abort:(resources string:'Cancel') |
|
7210 |
pattern:nil |
|
7211 |
fromDirectory:directoryForFileDialog. |
|
7212 |
file isNil ifTrue:[ |
|
7213 |
"cancel" |
|
7214 |
^ self. |
|
7215 |
]. |
|
7216 |
file := file asFilename. |
|
7217 |
directoryForFileDialog := file. |
|
7218 |
||
7219 |
ok := file isReadable and:[file isDirectory not]. |
|
7220 |
ok ifFalse:[ |
|
7221 |
file isReadable ifFalse:[ |
|
7222 |
why := '%1 is unreadable.\\Please try again.' |
|
7223 |
] ifTrue:[ |
|
7224 |
why := '%1 is a directory.\\Please try again.' |
|
7225 |
]. |
|
7226 |
Dialog warn:(resources stringWithCRs:why with:file pathName). |
|
7227 |
]. |
|
2909 | 7228 |
] doUntil:[ok]. |
2757
b98097eaf8dc
Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents:
2756
diff
changeset
|
7229 |
|
5063 | 7230 |
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
|
7231 |
self |
3786 | 7232 |
undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ] |
3799 | 7233 |
info:'Paste File' |
3495 | 7234 |
|
7235 |
"Modified: / 28-07-2007 / 13:23:32 / cg" |
|
7236 |
! |
|
7237 |
||
3811 | 7238 |
insertURL |
7239 |
"insert contents of a URL |
|
7240 |
- ask user for URL using a dialog." |
|
7241 |
||
7242 |
self insertURLAsStringLiteral:false |
|
7243 |
! |
|
7244 |
||
7245 |
insertURLAsStringLiteral:asStringLiteral |
|
7246 |
"insert contents of a file; either as-is or as a string literal. |
|
7247 |
- ask user for filename using a fileSelectionBox." |
|
7248 |
||
7249 |
|sel url text response initial| |
|
7250 |
||
7251 |
(sel := self selectionAsString) notEmptyOrNil |
|
7252 |
ifTrue:[ |
|
7253 |
initial := sel. |
|
7254 |
]. |
|
7255 |
||
7256 |
url := Dialog |
|
7257 |
request:(resources string:'Insert Contents of URL:') |
|
7258 |
initialAnswer:initial |
|
7259 |
okLabel:(resources string:'Insert') |
|
7260 |
title:(resources string:'URL'). |
|
7261 |
url isNil ifTrue:[ |
|
7262 |
"cancel" |
|
7263 |
^ self. |
|
7264 |
]. |
|
7265 |
response := HTTPInterface get:url. |
|
7266 |
response isErrorResponse ifTrue:[ |
|
7267 |
Dialog warn:(resources string:'Could not fetch the document: %1' with:url). |
|
7268 |
^ self. |
|
7269 |
]. |
|
7270 |
text := response data asString. |
|
7271 |
||
7272 |
self |
|
7273 |
undoableDo:[ |
|
7274 |
self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) |
|
7275 |
] |
|
7276 |
info:'Insert Contents of URL' |
|
7277 |
! |
|
7278 |
||
3495 | 7279 |
insertUUID |
7280 |
"insert a new UUID's string" |
|
7281 |
||
7282 |
typeOfSelection := nil. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7283 |
self |
3786 | 7284 |
undoableDo:[ self pasteOrReplace:(UUID genUUID printString)] |
3799 | 7285 |
info:'Paste New UUID' |
3495 | 7286 |
|
7287 |
"Created: / 28-07-2007 / 13:01:16 / cg" |
|
2676 | 7288 |
! |
7289 |
||
4940 | 7290 |
insertUnicode |
7291 |
"open a Dialog requesting an integer value and insert it as unicode character" |
|
7292 |
||
7293 |
|unicodePoint unicodeChar unicodeString| |
|
7294 |
||
5904 | 7295 |
unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):'). |
4940 | 7296 |
unicodeString size < 2 ifTrue:[ |
5904 | 7297 |
^ self. |
4940 | 7298 |
]. |
7299 |
(unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[ |
|
5904 | 7300 |
unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self]. |
4940 | 7301 |
] ifFalse:[ |
5904 | 7302 |
unicodePoint := Integer readFrom:unicodeString onError:[^ self]. |
5787 | 7303 |
]. |
4940 | 7304 |
|
7305 |
unicodeChar := Character value:unicodePoint. |
|
7306 |
self keyPress:unicodeChar x:0 y:0. |
|
7307 |
self keyRelease:unicodeChar x:0 y:0. |
|
7308 |
! |
|
7309 |
||
5331 | 7310 |
inspectSelectedString |
7311 |
"inspect the selected text" |
|
7312 |
||
7313 |
self selectionAsString inspect. |
|
7314 |
! |
|
7315 |
||
4742 | 7316 |
internalSpellingSuggestion |
7317 |
"insert the internal-spelling suggestion for the selected text. |
|
7318 |
Requires that the RefactoryBrowser/line/spelCheck stuff is loaded." |
|
7319 |
||
7320 |
|text suggestions best| |
|
7321 |
||
7322 |
self withWaitCursorDo:[ |
|
7323 |
text := self selection asString string withoutSeparators. |
|
7324 |
text size == 0 ifTrue:[^ self]. |
|
7325 |
||
7326 |
suggestions := RBSpellChecker default bestMatchesFor:text. |
|
7327 |
suggestions size == 0 ifTrue:[ |
|
7328 |
self information:('No spelling suggestion from builtin checker for: ' , text). |
|
7329 |
Transcript showCR:('No spelling suggestion from builtin checker for: ' , text). |
|
7330 |
^ self. |
|
7331 |
]. |
|
7332 |
Transcript showCR:suggestions. |
|
7333 |
best := suggestions first. |
|
7334 |
]. |
|
7335 |
self |
|
7336 |
undoablePaste:best |
|
7337 |
info:'Spelling Suggestion'. |
|
7338 |
! |
|
7339 |
||
4884 | 7340 |
openFileBrowserOnFileNamed:fileNameString |
7341 |
"open a fileBrowser on the given fileNameString" |
|
2762 | 7342 |
|
4630 | 7343 |
|fn| |
2762 | 7344 |
|
4884 | 7345 |
fn := fileNameString asFilename. |
2762 | 7346 |
fn exists ifFalse:[ |
4884 | 7347 |
fn := fileNameString withoutSeparators withoutQuotes asFilename. |
4042 | 7348 |
fn exists ifFalse:[ |
5082 | 7349 |
^ self warn:(resources |
7350 |
string:'Sorry - file "%1" was not found in directory "%2"' |
|
7351 |
with:fn baseName allBold |
|
7352 |
with:fn directory baseName allBold). |
|
4042 | 7353 |
]. |
2762 | 7354 |
]. |
4449
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7355 |
UserPreferences fileBrowserClass openOn:fn |
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7356 |
|
59fe55c937ea
changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents:
4430
diff
changeset
|
7357 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
2762 | 7358 |
! |
7359 |
||
4884 | 7360 |
openFileBrowserOnIt |
7361 |
"open a fileBrowser on the selected fileName" |
|
7362 |
||
7363 |
|fileNameString| |
|
7364 |
||
7365 |
fileNameString := self selectionAsString. |
|
7366 |
self openFileBrowserOnFileNamed:fileNameString |
|
7367 |
||
7368 |
"Modified: / 06-09-2012 / 14:47:22 / cg" |
|
7369 |
! |
|
7370 |
||
3483
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7371 |
openWorkspaceWithIt |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7372 |
"open a workspace containing the selected text" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7373 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7374 |
|text| |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7375 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7376 |
text := self selectionAsString. |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7377 |
WorkspaceApplication openWith:text selected:true |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7378 |
|
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7379 |
"Created: / 26-05-2007 / 06:05:22 / cg" |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7380 |
! |
8ef0f9a0737f
+openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents:
3482
diff
changeset
|
7381 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7382 |
paste |
1289 | 7383 |
"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
|
7384 |
Then paste at cursor position." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7385 |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7386 |
self checkModificationsAllowed ifTrue:[ |
4823 | 7387 |
self withSelfAndTextForPasteDo:[:me :text | |
7388 |
me unselect. |
|
7389 |
me undoablePaste:text |
|
7390 |
] |
|
2952 | 7391 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7392 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7393 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7394 |
paste:someText |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7395 |
"paste someText at cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7396 |
|
3825 | 7397 |
self paste:someText withCR:false |
7398 |
! |
|
7399 |
||
7400 |
paste:someText withCR:withCR |
|
7401 |
"paste someText at cursor" |
|
7402 |
||
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7403 |
|s nLines startLine startCol l1 l2 c1 c2 codingErrorReported| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7404 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7405 |
self checkModificationsAllowed ifFalse:[^ self]. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7406 |
someText isNil ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7407 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7408 |
s := someText. |
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7409 |
codingErrorReported := false. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7410 |
CharacterEncoderError handle:[:ex | |
3825 | 7411 |
|code msg| |
7412 |
||
7413 |
code := ex parameter. |
|
7414 |
codingErrorReported ifFalse:[ |
|
4940 | 7415 |
msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'. |
3825 | 7416 |
code notNil ifTrue:[ |
7417 |
msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16). |
|
7418 |
]. |
|
7419 |
Dialog warn:(resources stringWithCRs:msg). |
|
7420 |
codingErrorReported := true. |
|
7421 |
]. |
|
7422 |
ex proceedWith:ex defaultValue |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7423 |
] do:[ |
3825 | 7424 |
s isString ifTrue:[ |
4940 | 7425 |
s encoding ~~ gc characterEncoding ifTrue:[ |
7426 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
|
3825 | 7427 |
]. |
7428 |
||
7429 |
s := s asStringCollection. |
|
7430 |
(someText endsWith:Character cr) ifTrue:[ |
|
7431 |
"/ s := s copyWith:nil. |
|
7432 |
s := s copyWith:'' "/ an empty line at the end |
|
7433 |
||
7434 |
] |
|
7435 |
] ifFalse:[ |
|
7436 |
s isStringCollection ifTrue:[ |
|
4940 | 7437 |
s := s encodeFrom:(s encoding) into:gc characterEncoding. |
3825 | 7438 |
] ifFalse:[ |
7439 |
(self |
|
7440 |
confirm:(resources |
|
7441 |
stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?' |
|
7442 |
with:s class name)) ifFalse:[^ self]. |
|
7443 |
s := StringCollection with:s storeString . |
|
7444 |
"/ ^ self |
|
7445 |
]. |
|
7446 |
]. |
|
2856
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7447 |
]. |
bc6bb86d4d2e
character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents:
2854
diff
changeset
|
7448 |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7449 |
(nLines := s size) == 0 ifTrue:[^ self]. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7450 |
(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
|
7451 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7452 |
typeOfSelection := #paste. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7453 |
|
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7454 |
startLine := l1 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7455 |
startCol := c1 := cursorCol. |
3180 | 7456 |
|
5194 | 7457 |
"do not autoindent here. |
7458 |
It does make things very ugly, in the inspector |
|
7459 |
(try inspecting a multiline string)..." |
|
7460 |
self withAutoIndent:false do:[ |
|
7461 |
"do not expand tabs into spaces here - |
|
7462 |
they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr. |
|
7463 |
Some Subviews want to paste with unexpanded tabs!!" |
|
7464 |
||
7465 |
self insertLines:s withCR:withCR. |
|
7466 |
]. |
|
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7467 |
l2 := cursorLine. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7468 |
c2 := (cursorCol - 1). |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7469 |
self selectFromLine:l1 col:c1 toLine:l2 col:c2. |
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7470 |
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
|
7471 |
"/ 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
|
7472 |
"/ 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
|
7473 |
"/ 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
|
7474 |
self setCursorLine: l1. |
269a12794578
Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4843
diff
changeset
|
7475 |
self setCursorCol: c1. |
2853
f8c1d3963b49
preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
7476 |
|
4328 | 7477 |
"Modified: / 14-02-1996 / 11:14:14 / stefan" |
4360 | 7478 |
"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
|
7479 |
"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
|
7480 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7481 |
|
3731 | 7482 |
pasteAsStringLiteral |
7483 |
"insert clipboard string as a string literal. |
|
7484 |
Almost the same as a normal paste, but single-quotes are doubled, |
|
7485 |
to make it a legal string literal" |
|
7486 |
||
7487 |
typeOfSelection := nil. |
|
7488 |
self |
|
5107 | 7489 |
undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ] |
3786 | 7490 |
info:'Paste as String Literal' |
3731 | 7491 |
! |
7492 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7493 |
pasteOrReplace |
1289 | 7494 |
"paste the copybuffer; if there is a selection, replace it. |
3160 | 7495 |
otherwise paste at cursor position. |
7496 |
Replace is not done for selections which were created by a paste, |
|
2010 | 7497 |
to allow multiple paste operations in a row." |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7498 |
|
2724 | 7499 |
self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7500 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7501 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7502 |
pasteOrReplace:someText |
1289 | 7503 |
"paste someText; if there is a selection, replace it. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7504 |
otherwise paste at cursor position. Replace is not done |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7505 |
for originating by a paste, to allow multiple |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7506 |
paste." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7507 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7508 |
self checkModificationsAllowed ifFalse:[^ self]. |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7509 |
|
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7510 |
self undoableDo:[ |
4823 | 7511 |
((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[ |
7512 |
self replace:someText |
|
7513 |
] ifFalse:[ |
|
7514 |
self paste:someText. |
|
7515 |
] |
|
3542 | 7516 |
] info:'Paste/Replace'. |
1289 | 7517 |
|
2107
9d44232af0a0
textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents:
2101
diff
changeset
|
7518 |
"Modified: / 30.1.2000 / 02:33:00 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7519 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7520 |
|
5387 | 7521 |
pasteOrReplaceByKeyPress |
7522 |
"paste a previous item from the copybuffer history. |
|
7523 |
(i.e. repaste some previously deleted or copied text)" |
|
7524 |
||
7525 |
|text| |
|
7526 |
||
7527 |
self checkModificationsAllowed ifFalse:[ |
|
7528 |
self flashReadOnly. |
|
7529 |
^ self |
|
7530 |
]. |
|
7531 |
text := self getClipboardText:#clipboard. |
|
7532 |
text notNil ifTrue:[ |
|
7533 |
self pasteOrReplace:text |
|
7534 |
] |
|
7535 |
! |
|
7536 |
||
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7537 |
pasteOrReplaceFromHistory |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7538 |
"paste a previous item from the copybuffer history. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7539 |
(i.e. repaste some previously deleted or copied text)" |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7540 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7541 |
|text| |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7542 |
|
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7543 |
self checkModificationsAllowed ifFalse:[ |
4988 | 7544 |
self flashReadOnly. |
4823 | 7545 |
^ self |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7546 |
]. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7547 |
text := self getTextSelectionFromHistory. |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7548 |
text notNil ifTrue:[ |
4823 | 7549 |
self pasteOrReplace:text |
3474
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7550 |
] |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7551 |
! |
357e16440725
slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents:
3473
diff
changeset
|
7552 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7553 |
replace |
1289 | 7554 |
"replace the selection by the contents of the copybuffer" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7555 |
|
3269
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7556 |
self hasSelection ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7557 |
self checkModificationsAllowed ifFalse:[^ self]. |
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7558 |
|
03d04670a5d2
replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents:
3268
diff
changeset
|
7559 |
self withSelfAndTextForPasteDo:[:me :text | |
3786 | 7560 |
me undoableDo:[ me replace:text ] |
7561 |
info:'Replace' |
|
2952 | 7562 |
] |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7563 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7564 |
|
121 | 7565 |
replace:someText |
1289 | 7566 |
"replace the selection by someText" |
121 | 7567 |
|
3160 | 7568 |
|selected selectedString |
7569 |
selStartLine selStartCol selEndLine selEndCol| |
|
121 | 7570 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7571 |
self checkModificationsAllowed ifFalse:[^ self]. |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7572 |
|
3130 | 7573 |
self undoableDo:[ |
4010 | 7574 |
selected := self selection. |
7575 |
selected isNil ifTrue:[ |
|
7576 |
^ self paste:someText |
|
7577 |
]. |
|
7578 |
||
7579 |
self deleteSelection. |
|
7580 |
||
7581 |
"take care, if we replace a selection without space by a word selected |
|
7582 |
with one - in this case we usually do not want the space. |
|
7583 |
But, if we replace a word-selected selection by something without a |
|
7584 |
space, we DO want the space added." |
|
7585 |
||
7586 |
selected size == 1 ifTrue:[ |
|
7587 |
selectedString := selected at:1. |
|
7588 |
]. |
|
7589 |
||
7590 |
someText size == 1 ifTrue:[ |
|
7591 |
|cutOffSpace addSpace replacement replacementString| |
|
7592 |
||
7593 |
cutOffSpace := false. |
|
7594 |
addSpace := false. |
|
7595 |
replacement := someText copyFrom:1. |
|
7596 |
||
7597 |
selectedString notNil ifTrue:[ |
|
7598 |
((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[ |
|
7599 |
"selection has no space" |
|
7600 |
||
7601 |
((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[ |
|
7602 |
cutOffSpace := true |
|
7603 |
] |
|
7604 |
] ifTrue:[ |
|
7605 |
addSpace := true |
|
7606 |
] |
|
7607 |
]. |
|
7608 |
replacementString := replacement at:1. |
|
7609 |
cutOffSpace ifTrue:[ |
|
7610 |
(replacementString startsWith:' ') ifTrue:[ |
|
7611 |
replacementString := replacementString withoutSpaces |
|
7612 |
]. |
|
7613 |
] ifFalse:[ |
|
7614 |
selectStyle == #wordLeft ifTrue:[ |
|
7615 |
"want a space at left" |
|
7616 |
(replacementString startsWith:' ') ifFalse:[ |
|
7617 |
replacementString := replacementString withoutSpaces. |
|
7618 |
replacementString := ' ' , replacementString |
|
7619 |
] |
|
7620 |
]. |
|
7621 |
selectStyle == #wordRight ifTrue:[ |
|
7622 |
"want a space at right" |
|
7623 |
||
7624 |
(replacementString endsWith:' ') ifFalse:[ |
|
7625 |
replacementString := replacementString withoutSpaces. |
|
7626 |
replacementString := replacementString , ' ' |
|
7627 |
] |
|
7628 |
]. |
|
7629 |
]. |
|
7630 |
replacement at:1 put: replacementString. |
|
7631 |
self paste:replacement. |
|
7632 |
] ifFalse:[ |
|
7633 |
self paste:someText |
|
7634 |
]. |
|
4053 | 7635 |
self setLastStringToReplace: selectedString. |
7636 |
||
4048 | 7637 |
lastReplacementInfo lastReplacement: someText. |
4010 | 7638 |
|
7639 |
selStartLine := selectionStartLine. |
|
7640 |
selStartCol := self selectionStartCol. |
|
7641 |
selEndLine := selectionEndLine. |
|
7642 |
selEndCol := self selectionEndCol. |
|
3130 | 7643 |
] |
3542 | 7644 |
info:'Replace' |
362
3993ba6c31a0
Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents:
331
diff
changeset
|
7645 |
|
1480
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7646 |
"Modified: / 14.2.1996 / 10:37:02 / stefan" |
eabb1848e2fa
fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents:
1476
diff
changeset
|
7647 |
"Modified: / 5.4.1998 / 16:55:28 / cg" |
121 | 7648 |
! |
7649 |
||
3430 | 7650 |
searchReplace |
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7651 |
"search for a string - show a box to enter searchpattern |
3430 | 7652 |
replace for the found searchpattern or replace all searchpattern found to a new pattern - show a box to enter replacepattern |
7653 |
- 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
|
7654 |
|
3430 | 7655 |
|searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action| |
7656 |
||
7657 |
modal := false "(UserPreferences current searchDialogIsModal)". |
|
7658 |
lastSearchDirection := #forward. |
|
7659 |
ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true. |
|
5251 | 7660 |
caseHolder := ValueHolder with:ign. |
7661 |
patternHolder := ValueHolder with:''. |
|
7662 |
replacePatternHolder := ValueHolder with:''. |
|
3430 | 7663 |
lastSearchPattern notNil ifTrue:[ |
4823 | 7664 |
initialString := lastSearchPattern |
3430 | 7665 |
]. |
7666 |
self hasSelectionWithinSingleLine ifTrue:[ |
|
4823 | 7667 |
initialString := self selectionAsString |
3430 | 7668 |
]. |
7669 |
initialString isNil ifTrue:[ |
|
4823 | 7670 |
LastSearchPatterns size > 0 ifTrue:[ |
7671 |
initialString := LastSearchPatterns first |
|
7672 |
] |
|
3430 | 7673 |
]. |
7674 |
initialString notNil ifTrue:[ |
|
4823 | 7675 |
patternHolder value:initialString. |
7676 |
replacePatternHolder value:initialString. |
|
3430 | 7677 |
]. |
7678 |
flag := true. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7679 |
search := [:fwd | |
4823 | 7680 |
self |
7681 |
search:patternHolder value |
|
7682 |
ignoreCase:caseHolder value |
|
7683 |
forward:fwd. |
|
7684 |
]. |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
7685 |
replace := [:all | |
4823 | 7686 |
self |
7687 |
replace:patternHolder value |
|
7688 |
by:replacePatternHolder value |
|
7689 |
all:all |
|
7690 |
ignoreCase:caseHolder value |
|
7691 |
]. |
|
3430 | 7692 |
bindings := IdentityDictionary new. |
7693 |
bindings at:#searchPattern put:patternHolder. |
|
7694 |
bindings at:#replacePattern put:replacePatternHolder. |
|
7695 |
modal ifTrue:[ |
|
4823 | 7696 |
bindings at:#nextAction |
7697 |
put:[ |
|
7698 |
flag := true. |
|
7699 |
action := search. |
|
7700 |
searchBox doAccept. |
|
7701 |
]. |
|
7702 |
bindings at:#prevAction |
|
7703 |
put:[ |
|
7704 |
flag := false. |
|
7705 |
action := search. |
|
7706 |
searchBox doAccept. |
|
7707 |
]. |
|
7708 |
bindings at:#replaceAction |
|
7709 |
put:[ |
|
7710 |
flag := false. |
|
7711 |
action := replace. |
|
7712 |
searchBox doAccept. |
|
7713 |
]. |
|
7714 |
bindings at:#replaceAllAction |
|
7715 |
put:[ |
|
7716 |
flag := true. |
|
7717 |
action := replace. |
|
7718 |
searchBox doAccept. |
|
7719 |
]. |
|
3430 | 7720 |
] ifFalse:[ |
4823 | 7721 |
bindings at:#nextAction put:[ search value:true. ]. |
7722 |
bindings at:#prevAction put:[ search value:false. ]. |
|
7723 |
bindings at:#replaceAction put:[ replace value:false. ]. |
|
7724 |
bindings at:#replaceAllAction put:[ replace value:true. ]. |
|
3430 | 7725 |
]. |
7726 |
bindings at:#ignoreCase put:caseHolder. |
|
7727 |
bindings at:#patternList put:LastSearchPatterns. |
|
7728 |
modal ifTrue:[ |
|
4823 | 7729 |
searchBox := SimpleDialog new. |
3430 | 7730 |
] ifFalse:[ |
4823 | 7731 |
searchBox := ApplicationModel new. |
7732 |
searchBox createBuilder. |
|
3430 | 7733 |
]. |
7734 |
searchBox resources:(self resources). |
|
7735 |
bldr := searchBox builder. |
|
7736 |
bldr addBindings:bindings. |
|
7737 |
searchBox allButOpenFrom:(self class searchReplaceDialogSpec). |
|
7738 |
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp). |
|
7739 |
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp). |
|
7740 |
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown). |
|
7741 |
modal ifTrue:[ |
|
4823 | 7742 |
searchBox openDialog. |
7743 |
searchBox accepted ifTrue:[ |
|
7744 |
action value:flag |
|
7745 |
]. |
|
3430 | 7746 |
] ifFalse:[ |
4823 | 7747 |
(bldr componentAt:#nextButton) isReturnButton:false. |
7748 |
(bldr componentAt:#cancelButton) |
|
7749 |
label:(resources string:'Close'); |
|
7750 |
action:[ searchBox closeRequest ]. |
|
7751 |
||
7752 |
"/ searchBox masterApplication:self application. |
|
7753 |
||
7754 |
self topView beMaster. |
|
7755 |
(searchBox window) |
|
7756 |
beSlave; |
|
7757 |
openInGroup:(self windowGroup). |
|
7758 |
||
7759 |
"/ searchBox window open. |
|
7760 |
||
5283 | 7761 |
searchBox window assignKeyboardFocusToFirstKeyboardConsumer. |
3430 | 7762 |
] |
7763 |
||
7764 |
"Modified: / 11-07-2006 / 11:20:06 / fm" |
|
7765 |
! |
|
7766 |
||
121 | 7767 |
showDeleted |
7768 |
"open a readonly editor on all deleted text" |
|
7769 |
||
7770 |
|v| |
|
7771 |
||
7772 |
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
|
7773 |
v readOnly:true. |
121 | 7774 |
v topView label:'deleted text'. |
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7775 |
! |
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7776 |
|
3221 | 7777 |
sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
4763 | 7778 |
"sort/reorder the selected lines. |
7779 |
how: |
|
7780 |
#lines |
|
7781 |
#linesByFirstWord |
|
7782 |
#linesByNthWord |
|
7783 |
#linesByNthNumber |
|
7784 |
#linesByNthHexNumber |
|
7785 |
#words |
|
7786 |
#linesByLength |
|
7787 |
#reverse |
|
7788 |
" |
|
7789 |
||
7790 |
|lines extractor innerExtractor fetcher operation lineWise nStr n s words| |
|
3221 | 7791 |
|
7792 |
lineWise := true. |
|
7793 |
||
4763 | 7794 |
how == #reverse ifTrue:[ |
7795 |
operation := [:lines | lines reverse]. |
|
7796 |
] ifFalse:[ |
|
7797 |
operation := [:linesOrWords | |
|
7798 |
linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)] |
|
7799 |
]. |
|
7800 |
||
7801 |
how == #linesByLength ifTrue:[ |
|
7802 |
fetcher := [:l | l size]. |
|
7803 |
] ifFalse:[ |
|
7804 |
how == #lines ifTrue:[ |
|
7805 |
extractor := [:l | l withoutLeadingSeparators]. |
|
7806 |
] ifFalse:[ |
|
7807 |
how == #linesByFirstWord ifTrue:[ |
|
7808 |
extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')]. |
|
7809 |
] ifFalse:[ |
|
7810 |
((how == #linesByNthWord) or:[ how == #linesByNthNumber or:[ how == #linesByNthHexNumber]]) ifTrue:[ |
|
7811 |
nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2). |
|
7812 |
nStr isEmptyOrNil ifTrue:[^ self]. |
|
7813 |
n := Integer readFrom:nStr onError:[^ self]. |
|
7814 |
LastColumnNumberForSort := n. |
|
7815 |
extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')]. |
|
7816 |
how == #linesByNthNumber ifTrue:[ |
|
7817 |
innerExtractor := extractor. |
|
7818 |
extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0] |
|
7819 |
] ifFalse:[ |
|
7820 |
how == #linesByNthHexNumber ifTrue:[ |
|
7821 |
innerExtractor := extractor. |
|
7822 |
extractor := [:l | |
|
7823 |
|s| |
|
7824 |
s := innerExtractor value:l. |
|
7825 |
(s startsWith:'16r') ifTrue:[ |
|
7826 |
(Integer readSmalltalkSyntaxFrom:s) ? 0 |
|
7827 |
] ifFalse:[ |
|
7828 |
Integer readFrom:s radix:16 onError:[ 0 ] |
|
7829 |
] |
|
7830 |
] |
|
4753 | 7831 |
] |
4763 | 7832 |
]. |
7833 |
] ifFalse:[ |
|
7834 |
how == #words ifTrue:[ |
|
7835 |
lineWise := false. |
|
7836 |
extractor := [:w | w]. |
|
7837 |
] ifFalse:[ |
|
7838 |
self error:'unknown sort criteria: ', how printString. |
|
4753 | 7839 |
] |
4373 | 7840 |
] |
7841 |
] |
|
4763 | 7842 |
]. |
7843 |
ignoreCase ifTrue:[ |
|
7844 |
fetcher := [:l | (extractor value:l) asLowercase]. |
|
7845 |
] ifFalse:[ |
|
7846 |
fetcher := extractor. |
|
7847 |
]. |
|
7848 |
]. |
|
3221 | 7849 |
]. |
7850 |
||
7851 |
lineWise ifTrue:[ |
|
4763 | 7852 |
"process the lines of the selection (aka a collection of lines)" |
4373 | 7853 |
start == end ifTrue:[^ self ]. |
7854 |
lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? '']. |
|
4763 | 7855 |
lines := operation value:lines. |
4373 | 7856 |
(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line]. |
4763 | 7857 |
] ifFalse:[ |
7858 |
"process the whole selection as a string" |
|
7859 |
s := self selectionAsString. |
|
7860 |
words := s asCollectionOfWords. |
|
7861 |
words := operation value:words. |
|
7862 |
s := words asStringCollection asStringWith:Character space. |
|
7863 |
self replace:s. |
|
7864 |
]. |
|
3221 | 7865 |
self textChanged. |
4373 | 7866 |
|
4414
308d40ee857b
changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents:
4396
diff
changeset
|
7867 |
"Modified: / 31-03-2012 / 10:59:28 / cg" |
3221 | 7868 |
! |
7869 |
||
7870 |
sortSelection:how ignoreCase:ignoreCase |
|
7871 |
"sort the selected lines" |
|
7872 |
||
7873 |
|start end| |
|
7874 |
||
7875 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7876 |
||
7877 |
start := selectionStartLine. |
|
7878 |
end := selectionEndLine. |
|
7879 |
(selectionEndCol == 0) ifTrue:[ |
|
3786 | 7880 |
end := end - 1 |
3221 | 7881 |
]. |
7882 |
||
7883 |
self |
|
4373 | 7884 |
undoableDo:[ |
7885 |
self sort:how ignoreCase:ignoreCase fromLine:start toLine:end |
|
7886 |
] |
|
3786 | 7887 |
info:'Sort' |
4373 | 7888 |
|
7889 |
"Modified (format): / 15-02-2012 / 16:52:53 / cg" |
|
3221 | 7890 |
! |
7891 |
||
2624
22d352e56c27
preps for special characters
Claus Gittinger <cg@exept.de>
parents:
2617
diff
changeset
|
7892 |
specialCharacters |
2915 | 7893 |
CharacterSetView |
4823 | 7894 |
openAsInputFor:self |
7895 |
label:'Special Character Input' |
|
7896 |
clickLabel:'Click to Insert Character'. |
|
2866 | 7897 |
! |
7898 |
||
5370 | 7899 |
splitLinesAtCharacterOrString |
7900 |
"ask user for the character and split after it" |
|
7901 |
||
7902 |
|sel in out separator record| |
|
7903 |
||
7904 |
selectionStartLine isNil ifTrue:[^ self]. |
|
7905 |
||
7906 |
separator := Dialog request:(resources string:'Split selected lines after which separator character or string:'). |
|
7907 |
separator isEmptyOrNil ifTrue:[^ self]. |
|
7908 |
||
7909 |
sel := self selectionAsString. |
|
7910 |
in := sel readStream. |
|
5887 | 7911 |
out := CharacterWriteStream on:''. |
5370 | 7912 |
[in atEnd] whileFalse:[ |
5887 | 7913 |
record := in throughAll:separator. |
7914 |
out nextPutLine:record. |
|
5370 | 7915 |
]. |
7916 |
self |
|
7917 |
undoableDo:[ |
|
5887 | 7918 |
self replaceSelectionBy:(out contents). |
7919 |
] |
|
7920 |
info:'Split Selection' |
|
5370 | 7921 |
! |
7922 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7923 |
undoablePaste:someText |
3495 | 7924 |
self undoablePaste:someText info:nil. |
7925 |
||
7926 |
"Modified: / 28-07-2007 / 13:25:46 / cg" |
|
7927 |
! |
|
7928 |
||
7929 |
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
|
7930 |
self |
4823 | 7931 |
undoableDo:[ |
7932 |
self paste:someText. |
|
7933 |
] |
|
7934 |
info:infoOrNil |
|
3495 | 7935 |
|
7936 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
|
7937 |
! |
|
7938 |
||
7939 |
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
|
7940 |
self |
4823 | 7941 |
undoableDo:[ |
7942 |
self pasteOrReplace:someText. |
|
7943 |
] |
|
7944 |
info:infoOrNil |
|
3495 | 7945 |
|
7946 |
"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
|
7947 |
! |
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
7948 |
|
4114
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7949 |
undoablePasteReplacingAll:someText info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7950 |
self |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7951 |
undoableDo:[ |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7952 |
self selectAll. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7953 |
self pasteOrReplace:someText. |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7954 |
] |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7955 |
info:infoOrNil |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7956 |
|
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7957 |
"Created: / 28-07-2007 / 13:25:30 / cg" |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7958 |
! |
321416257cc5
added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents:
4110
diff
changeset
|
7959 |
|
2724 | 7960 |
withSelfAndTextForPasteDo:aBlock |
7961 |
"common code for paste/replace of the copybuffer" |
|
7962 |
||
7963 |
|sel| |
|
7964 |
||
7965 |
self checkModificationsAllowed ifFalse:[ |
|
4988 | 7966 |
self flashReadOnly. |
4823 | 7967 |
^ self |
2724 | 7968 |
]. |
7969 |
||
7970 |
sel := self getTextSelectionOrTextSelectionFromHistory. |
|
7971 |
sel notNil ifTrue:[ |
|
4823 | 7972 |
aBlock value:self value:sel. |
2724 | 7973 |
] |
105 | 7974 |
! ! |
7975 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7976 |
!EditTextView methodsFor:'private'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
7977 |
|
3880 | 7978 |
beep |
5244 | 7979 |
"output an audible beep or bell on my screen device" |
7980 |
||
3880 | 7981 |
UserPreferences current beepInEditor ifTrue:[ |
7982 |
super beep |
|
7983 |
] |
|
7984 |
! |
|
7985 |
||
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
7986 |
checkModificationsAllowed |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7987 |
"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
|
7988 |
evaluate the exceptionBlock if not. |
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
7989 |
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
|
7990 |
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
|
7991 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
7992 |
self isReadOnly ifTrue: [ |
4823 | 7993 |
exceptionBlock isNil ifTrue:[ |
7994 |
^ false |
|
7995 |
]. |
|
7996 |
||
7997 |
(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[ |
|
7998 |
^ false |
|
7999 |
] |
|
331
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8000 |
]. |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8001 |
^ true |
1300
be8b356b2e59
first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
8002 |
|
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8003 |
"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
|
8004 |
! |
c58f0c52d2d7
made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents:
324
diff
changeset
|
8005 |
|
2596 | 8006 |
currentSelectionBgColor |
8007 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 8008 |
^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor |
2596 | 8009 |
]. |
5216 | 8010 |
"/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. |
2596 | 8011 |
^ super currentSelectionBgColor |
8012 |
||
8013 |
" |
|
8014 |
DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green |
|
8015 |
" |
|
8016 |
! |
|
8017 |
||
8018 |
currentSelectionFgColor |
|
8019 |
typeOfSelection == #paste ifTrue:[ |
|
4823 | 8020 |
^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor |
2596 | 8021 |
]. |
8022 |
^ super currentSelectionFgColor |
|
8023 |
! |
|
8024 |
||
3996 | 8025 |
resetVariablesBeforeNewSearch |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8026 |
"clear the autosearch action, when the first pattern is searched for" |
3996 | 8027 |
|
8028 |
super resetVariablesBeforeNewSearch. |
|
8029 |
||
8030 |
"/ new search invalidates remembered string |
|
4048 | 8031 |
lastStringFromReplaceForNextSearch := nil. |
4451
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8032 |
|
71e8b21c63ce
comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents:
4449
diff
changeset
|
8033 |
"Modified (comment): / 07-03-2012 / 23:21:06 / cg" |
3996 | 8034 |
! |
8035 |
||
4053 | 8036 |
setLastStringToReplace: aString |
8037 |
||
8038 |
"This method will set the information coming from the last replace into the replacementInfo" |
|
8039 |
||
8040 |
|lastReplaceIgnoredCase| |
|
8041 |
||
4064 | 8042 |
"/ The searchAction is mantained until a cut/replace or a search with a user selection is done |
8043 |
self clearSearchAction. |
|
8044 |
||
4053 | 8045 |
lastReplacementInfo lastStringToReplace: aString. |
8046 |
lastStringFromReplaceForNextSearch := aString. |
|
8047 |
||
8048 |
"If the replace came after a search, the next replace will have the ignored case from that search action" |
|
4107 | 8049 |
lastReplaceIgnoredCase := (typeOfSelection == #search) |
8050 |
ifTrue: [lastSearchIgnoredCase] |
|
8051 |
ifFalse: [nil]. |
|
4053 | 8052 |
lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase. |
8053 |
! |
|
8054 |
||
2225
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8055 |
suppressEmphasisInSelection |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8056 |
"selection is shown without emphasis" |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8057 |
|
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8058 |
^ true |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8059 |
! |
65ac7cbffc60
added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents:
2213
diff
changeset
|
8060 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8061 |
textChanged |
522 | 8062 |
"my text was modified (internally). |
8063 |
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
|
8064 |
contentsChanged, which is triggered when the size has changed, and |
4635 | 8065 |
is used to notify scrollers, other views etc.). |
8066 |
||
5979 | 8067 |
As some authors of this code have been very sloppy in the past |
4635 | 8068 |
(not sending contentsChanged, but textChanged), |
8069 |
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
|
8070 |
|
641 | 8071 |
self contentsChanged. |
1015 | 8072 |
self modified:true. |
5774 | 8073 |
dependents notNil ifTrue:[ self changed:#textChanged ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8074 |
contentsWasSaved := false |
641 | 8075 |
|
1015 | 8076 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
2207 | 8077 |
! |
8078 |
||
2617 | 8079 |
textChangedButNoSizeChange |
2207 | 8080 |
"my text was modified (internally). |
8081 |
Sent whenever text has been edited (not to confuse with |
|
8082 |
contentsChanged, which is triggered when the size has changed, and |
|
8083 |
is used to notify scrollers, other views etc.)" |
|
8084 |
||
8085 |
self modified:true. |
|
8086 |
contentsWasSaved := false |
|
8087 |
||
8088 |
"Modified: 14.2.1997 / 16:58:38 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8089 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8090 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8091 |
!EditTextView methodsFor:'queries'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8092 |
|
5216 | 8093 |
canAccept |
8094 |
"true if text can be accepts. |
|
8095 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8096 |
||
8097 |
^ acceptEnabled ~~ false |
|
8098 |
! |
|
8099 |
||
8100 |
canCut |
|
8101 |
"true if there is a selection possibly to be cut. |
|
8102 |
Used to disable the menu if there is nothing selector or the text is readonly" |
|
8103 |
||
8104 |
self isReadOnly ifTrue:[ ^ false ]. |
|
8105 |
^ self hasSelection |
|
8106 |
! |
|
8107 |
||
8108 |
canDoAgain |
|
8109 |
"true if there is a possible repeat last edit operation. |
|
8110 |
Used to disable the menu if there is nothing" |
|
8111 |
||
8112 |
self isReadOnly ifTrue:[ ^ false ]. |
|
5972 | 8113 |
^ lastReplacementInfo lastStringToReplace notNil |
8114 |
||
8115 |
"Modified: / 19-11-2016 / 20:19:02 / cg" |
|
5216 | 8116 |
! |
8117 |
||
1526
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8118 |
currentLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8119 |
"the current line (for relative gotos)" |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8120 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8121 |
^ cursorLine |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8122 |
|
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8123 |
"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
|
8124 |
! |
7676f301bb8f
added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents:
1515
diff
changeset
|
8125 |
|
4064 | 8126 |
hasSearchActionSelection |
8127 |
||
8128 |
^ typeOfSelection == #searchAction |
|
8129 |
! |
|
8130 |
||
1878 | 8131 |
isKeyboardConsumer |
8132 |
"return true, if the receiver is a keyboard consumer; |
|
5283 | 8133 |
Return true here if not readOnly, redefined from SimpleView." |
1878 | 8134 |
|
3476 | 8135 |
^ self isReadOnly not |
1878 | 8136 |
! |
8137 |
||
997 | 8138 |
specClass |
1390 | 8139 |
"redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)" |
8140 |
||
997 | 8141 |
self class == EditTextView ifTrue:[^ TextEditorSpec]. |
1049 | 8142 |
^ super specClass |
8143 |
||
1390 | 8144 |
"Modified: / 31.10.1997 / 19:48:19 / cg" |
997 | 8145 |
! |
8146 |
||
324 | 8147 |
tabMeansNextField |
323
58102e6bc087
added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
8148 |
"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
|
8149 |
|
313
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8150 |
"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
|
8151 |
|
1733
c5139b7402f0
use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents:
1732
diff
changeset
|
8152 |
^ self isReadOnly or:[tabMeansNextField] |
324 | 8153 |
|
8154 |
"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
|
8155 |
! |
7c799cd68343
only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents:
309
diff
changeset
|
8156 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8157 |
widthOfContents |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8158 |
"return the width of the contents in pixels |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8159 |
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
|
8160 |
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
|
8161 |
line (and possibly see the cursor behind the line)" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8162 |
|
697 | 8163 |
|w dev| |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8164 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8165 |
w := super widthOfContents. |
5643 | 8166 |
(dev := device ) isNil ifTrue:[ |
4889 | 8167 |
"/ really don't know ... |
4823 | 8168 |
dev := Screen current |
606
682579fa3b62
fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents:
597
diff
changeset
|
8169 |
]. |
4889 | 8170 |
^ w + (gc font widthOn:dev) |
697 | 8171 |
|
8172 |
"Modified: 28.5.1996 / 19:32:25 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8173 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8174 |
|
1588 | 8175 |
!EditTextView methodsFor:'realization'! |
8176 |
||
8177 |
realize |
|
8178 |
"make the view visible - scroll to make the cursor visible." |
|
8179 |
||
8180 |
super realize. |
|
8181 |
||
8182 |
self makeCursorVisible. |
|
5643 | 8183 |
cursorFgColor := cursorFgColor onDevice:device. |
8184 |
cursorBgColor := cursorBgColor onDevice:device. |
|
1588 | 8185 |
|
8186 |
"Modified: 20.12.1996 / 14:16:05 / cg" |
|
8187 |
"Created: 24.7.1997 / 18:24:12 / cg" |
|
8188 |
! ! |
|
8189 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8190 |
!EditTextView methodsFor:'redrawing'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8191 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8192 |
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8193 |
"redraw the cursor, if it sits in a line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8194 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8195 |
cursorShown ifTrue:[ |
4823 | 8196 |
cursorVisibleLine notNil ifTrue:[ |
8197 |
(cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[ |
|
8198 |
self drawCursorCharacter |
|
8199 |
] |
|
8200 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8201 |
] |
105 | 8202 |
! |
8203 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8204 |
redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8205 |
"redraw the cursor, if it sits in visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8206 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8207 |
cursorShown ifTrue:[ |
4823 | 8208 |
(visLine == cursorVisibleLine) ifTrue:[ |
8209 |
self drawCursorCharacter |
|
8210 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8211 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8212 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8213 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8214 |
redrawFromVisibleLine:startVisLine to:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8215 |
"redraw a visible line range" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8216 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8217 |
super redrawFromVisibleLine:startVisLine to:endVisLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8218 |
self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8219 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8220 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8221 |
redrawVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8222 |
"redraw a visible line" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8223 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8224 |
super redrawVisibleLine:visLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8225 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8226 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8227 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8228 |
redrawVisibleLine:visLine col:colNr |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8229 |
"redraw the single character in visibleline at colNr" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8230 |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8231 |
super redrawVisibleLine:visLine col:colNr. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8232 |
cursorShown ifTrue:[ |
4823 | 8233 |
(visLine == cursorVisibleLine) ifTrue:[ |
8234 |
(colNr == cursorCol) ifTrue:[ |
|
8235 |
self drawCursorCharacter. |
|
8236 |
^ self |
|
8237 |
] |
|
8238 |
] |
|
3510
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8239 |
]. |
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8240 |
|
4bd0b20bd05d
cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents:
3495
diff
changeset
|
8241 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8242 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8243 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8244 |
redrawVisibleLine:visLine from:startCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8245 |
"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
|
8246 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8247 |
super redrawVisibleLine:visLine from:startCol. |
4494 | 8248 |
cursorShown ifTrue:[ |
8249 |
self redrawCursorIfInVisibleLine:visLine |
|
8250 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8251 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8252 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8253 |
redrawVisibleLine:visLine from:startCol to:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8254 |
"redraw a visible line from startCol to endCol" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8255 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8256 |
super redrawVisibleLine:visLine from:startCol to:endCol. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8257 |
self redrawCursorIfInVisibleLine:visLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8258 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8259 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8260 |
!EditTextView methodsFor:'scrolling'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8261 |
|
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8262 |
additionalMarginForHorizontalScroll |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8263 |
"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
|
8264 |
width of the document would allow. |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8265 |
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
|
8266 |
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
|
8267 |
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
|
8268 |
|
4889 | 8269 |
^ 10 max:gc font width |
2331
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8270 |
! |
218a017dc1f3
additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents:
2323
diff
changeset
|
8271 |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8272 |
halfPageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8273 |
"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
|
8274 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8275 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8276 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8277 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8278 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8279 |
super halfPageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8280 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8281 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8282 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8283 |
halfPageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8284 |
"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
|
8285 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8286 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8287 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8288 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8289 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8290 |
super halfPageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8291 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8292 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8293 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8294 |
originChanged:delta |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8295 |
"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
|
8296 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8297 |
super originChanged:delta. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8298 |
" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8299 |
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
|
8300 |
" |
2422
aaef7f02402c
added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents:
2417
diff
changeset
|
8301 |
self updateCursorVisibleLine. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8302 |
prevCursorState ifTrue:[ |
4823 | 8303 |
self showCursor |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8304 |
] |
1577
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8305 |
|
4e487247ad33
dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents:
1568
diff
changeset
|
8306 |
"Modified: / 17.6.1998 / 16:13:24 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8307 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8308 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8309 |
originWillChange |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8310 |
"sent before scrolling - have to hide the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8311 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8312 |
prevCursorState := cursorShown. |
1601 | 8313 |
"/ cursorShown := false. |
1591 | 8314 |
cursorShown ifTrue:[ |
4823 | 8315 |
self hideCursor |
1591 | 8316 |
] |
8317 |
||
1601 | 8318 |
"Modified: / 6.7.1998 / 13:07:23 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8319 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8320 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8321 |
pageDown |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8322 |
"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
|
8323 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8324 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8325 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8326 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8327 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8328 |
super pageDown. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8329 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8330 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8331 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8332 |
pageUp |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8333 |
"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
|
8334 |
within the real text " |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8335 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8336 |
|prevCursorLine| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8337 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8338 |
prevCursorLine := cursorVisibleLine. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8339 |
super pageUp. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8340 |
self cursorVisibleLine:prevCursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8341 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8342 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8343 |
!EditTextView methodsFor:'searching'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8344 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8345 |
searchBwd:pattern ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8346 |
"do a backward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8347 |
|
2822 | 8348 |
self searchBwd:pattern ignoreCase:false ifAbsent:aBlock |
1339 | 8349 |
! |
8350 |
||
8351 |
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
|
8352 |
"do a backward search" |
|
8353 |
||
8354 |
cursorLine isNil ifTrue:[^ self]. |
|
4464
bbdc850e9d93
search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents:
4458
diff
changeset
|
8355 |
super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock |
3580 | 8356 |
! |
8357 |
||
8358 |
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8359 |
"do a backward search" |
|
8360 |
||
8361 |
cursorLine isNil ifTrue:[^ self]. |
|
8362 |
||
3160 | 8363 |
self |
4119 | 8364 |
searchBackwardFor:pattern |
8365 |
ignoreCase:ign |
|
8366 |
startingAtLine:startLine col:startCol |
|
5717 | 8367 |
ifFound:[:line :col :endColOrNil | |
4119 | 8368 |
self cursorMovementAllowed ifTrue:[ |
8369 |
self cursorLine:line col:col. |
|
8370 |
]. |
|
5717 | 8371 |
self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil. |
1339 | 8372 |
"/ self makeLineVisible:cursorLine |
4119 | 8373 |
typeOfSelection := #search] |
8374 |
ifAbsent:aBlock |
|
1339 | 8375 |
|
8376 |
"Modified: 9.10.1997 / 13:02:13 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8377 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8378 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8379 |
searchForAndSelectMatchingParenthesis |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8380 |
"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
|
8381 |
|
2554 | 8382 |
self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8383 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8384 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8385 |
searchForMatchingParenthesis |
3160 | 8386 |
"search for a matching parenthesis starting at cursor position. |
8387 |
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
|
8388 |
backwards if its a closing parenthesis. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8389 |
Positions the cursor if found, peeps if not" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8390 |
|
2822 | 8391 |
self cursorMovementAllowed ifFalse:[^ self]. |
8392 |
||
3160 | 8393 |
self |
4823 | 8394 |
searchForMatchingParenthesisFromLine:cursorLine col:cursorCol |
8395 |
ifFound:[:line :col | self cursorLine:line col:col] |
|
8396 |
ifNotFound:[self showNotFound] |
|
8397 |
onError:[self beep] |
|
1339 | 8398 |
|
8399 |
"Modified: 9.10.1997 / 12:56:30 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8400 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8401 |
|
3967 | 8402 |
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock |
1339 | 8403 |
"do a forward search" |
8404 |
||
8405 |
cursorLine isNil ifTrue:[^ self]. |
|
3967 | 8406 |
self |
8407 |
searchForwardFor:pattern |
|
8408 |
ignoreCase:ign |
|
8409 |
match: match |
|
8410 |
startingAtLine:startLine col:startCol |
|
5717 | 8411 |
ifFound:[:line :col :endColOrNil| |
3967 | 8412 |
self cursorMovementAllowed ifTrue:[ |
8413 |
self cursorLine:line col:col. |
|
8414 |
]. |
|
5717 | 8415 |
self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil. |
1339 | 8416 |
"/ self makeLineVisible:cursorLine |
3967 | 8417 |
typeOfSelection := #search |
8418 |
] |
|
8419 |
ifAbsent:aBlock |
|
1339 | 8420 |
|
8421 |
"Modified: 9.10.1997 / 12:57:47 / cg" |
|
8422 |
"Created: 9.10.1997 / 13:01:12 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8423 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8424 |
|
3967 | 8425 |
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock |
8426 |
"do a forward search" |
|
8427 |
||
8428 |
self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock |
|
8429 |
! |
|
8430 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8431 |
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8432 |
"do a forward search" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8433 |
|
2822 | 8434 |
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
|
8435 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8436 |
|
3982 | 8437 |
searchPatternForSearchBar |
8438 |
||
8439 |
"Returns the next searchPattern from the user selection or from the autoSearch" |
|
8440 |
||
8441 |
|searchPattern| |
|
8442 |
||
4138 | 8443 |
searchPattern := self searchPatternFromUserSelectionOrReplace. |
3982 | 8444 |
searchPattern isNil |
8445 |
ifTrue: [searchPattern := lastSearchPattern] |
|
8446 |
ifFalse: [lastSearchPattern := searchPattern]. |
|
8447 |
^ searchPattern |
|
8448 |
! |
|
8449 |
||
3578 | 8450 |
setSearchPatternWithMatchEscapes: match |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8451 |
"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
|
8452 |
cursor to start of pattern" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8453 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8454 |
|sel| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8455 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8456 |
"/ |
3967 | 8457 |
"/ 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
|
8458 |
"/ original string (for search after again) |
4121 | 8459 |
"/ 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
|
8460 |
"/ |
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8461 |
"/ (lastStringFromReplaceForNextSearch notNil |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8462 |
"/ and:[typeOfSelection ~~ #search]) ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8463 |
"/ lastStringFromReplaceForNextSearch isString ifTrue:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8464 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8465 |
"/ ] ifFalse:[ |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8466 |
"/ lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8467 |
"/ ]. |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8468 |
"/ ^ self |
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8469 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8470 |
|
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8471 |
"/ |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8472 |
"/ if there is a selection: |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8473 |
"/ 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
|
8474 |
"/ if there was a previous search, only take the selection if |
3967 | 8475 |
"/ 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
|
8476 |
"/ (to allow search-paste to be repeated) |
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8477 |
"/ |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8478 |
sel := self selection. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8479 |
sel notNil ifTrue:[ |
3967 | 8480 |
(lastSearchPattern isNil |
4484 | 8481 |
or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]] |
8482 |
) ifTrue:[ |
|
3967 | 8483 |
self cursorLine:selectionStartLine col:selectionStartCol. |
8484 |
lastSearchPattern := sel asStringWithoutFinalCR. |
|
8485 |
match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes]. |
|
8486 |
] |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8487 |
] |
559
3ff87e9447c6
keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents:
522
diff
changeset
|
8488 |
|
4249
44daffb1b034
comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents:
4248
diff
changeset
|
8489 |
"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
|
8490 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8491 |
|
5717 | 8492 |
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil |
8493 |
super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil. |
|
4484 | 8494 |
typeOfSelection := #search. |
8495 |
! |
|
8496 |
||
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8497 |
startPositionForSearchBackward |
2822 | 8498 |
^ self startPositionForSearchBackwardBasedOnCursorOrSelection |
8499 |
! |
|
8500 |
||
8501 |
startPositionForSearchBackwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8502 |
|startLine startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8503 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8504 |
selectionStartLine notNil ifTrue:[ |
4823 | 8505 |
startLine := selectionStartLine. |
8506 |
startCol := selectionStartCol |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8507 |
] ifFalse:[ |
4823 | 8508 |
cursorLine isNil ifTrue:[ |
8509 |
startLine := list size. |
|
8510 |
startCol := self listAt:startLine size. |
|
8511 |
] ifFalse:[ |
|
8512 |
startLine := cursorLine min:list size. |
|
8513 |
startCol := cursorCol |
|
8514 |
] |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8515 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8516 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8517 |
^ startCol @ cursorLine |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8518 |
! |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8519 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8520 |
startPositionForSearchForward |
2822 | 8521 |
^ self startPositionForSearchForwardBasedOnCursorOrSelection |
8522 |
! |
|
8523 |
||
8524 |
startPositionForSearchForwardBasedOnCursorOrSelection |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8525 |
|startCol| |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8526 |
|
3160 | 8527 |
"/ 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
|
8528 |
"/ 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
|
8529 |
startCol := cursorCol. |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8530 |
self hasSelection ifTrue:[ |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8531 |
^ selectionEndCol @ selectionEndLine. |
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8532 |
] ifFalse:[ |
4064 | 8533 |
(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[ |
8534 |
startCol := 0 |
|
8535 |
]. |
|
8536 |
startCol := startCol min:(self at:cursorLine) size |
|
2756
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8537 |
]. |
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8538 |
|
2bdd7ceaf05c
initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
8539 |
^ startCol @ cursorLine |
4424
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8540 |
|
b38e9e3b483b
changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents:
4421
diff
changeset
|
8541 |
"Modified (format): / 24-05-2012 / 13:58:37 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8542 |
! ! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8543 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8544 |
!EditTextView methodsFor:'selections'! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8545 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8546 |
addToSelectionAfter:aBlock |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8547 |
"Extends the selection accroding to cursor position |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8548 |
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
|
8549 |
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
|
8550 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8551 |
"/ Following comment is in czech and thus now very useful. |
4970 | 8552 |
"/ 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
|
8553 |
"/ 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
|
8554 |
"/ 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
|
8555 |
"/ written by Martin Dvorak. Yeah, being bit nostalgic... |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8556 |
|
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8557 |
"Pokud existuje selekce, upravi ji |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8558 |
podle aktualni pozice kurzoru a pozice |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8559 |
po provedeni blocku. |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8560 |
Urceno k implementaci Shift-Home a Shift-End |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8561 |
Nejak nevim, jak to presneji popsat :-)" |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8562 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8563 |
| 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
|
8564 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8565 |
curLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8566 |
curCol := cursorCol. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8567 |
|
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8568 |
self hasSelection ifTrue: [ |
4970 | 8569 |
startLine := selectionStartLine. |
8570 |
startCol := selectionStartCol. |
|
8571 |
endLine := selectionEndLine. |
|
8572 |
endCol := selectionEndCol. |
|
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8573 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8574 |
startLine := endLine := curLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8575 |
startCol := curCol. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8576 |
endCol := curCol - 1. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8577 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8578 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8579 |
cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8580 |
cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8581 |
self assert: cursorAtTheBeginning | cursorAtTheEnd. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8582 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8583 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8584 |
cursorWasShown := self hideCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8585 |
aBlock value. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8586 |
|
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8587 |
cursorAtTheBeginning ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8588 |
(cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8589 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8590 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8591 |
]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8592 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8593 |
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
|
8594 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8595 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8596 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8597 |
(cursorLine > endLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8598 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8599 |
startLine := endLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8600 |
startCol := endCol + 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8601 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8602 |
endLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8603 |
endCol := cursorCol - 1 |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8604 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8605 |
startLine := cursorLine. |
4823 | 8606 |
startCol := cursorCol. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8607 |
] |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8608 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8609 |
cursorAtTheEnd ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8610 |
(cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8611 |
self unselect; showCursor. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8612 |
^self |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8613 |
]. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8614 |
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
|
8615 |
flip ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8616 |
extModeStandard := UserPreferences current selectionExtensionMode == #standard. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8617 |
]. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8618 |
(cursorLine < startLine or:[flip]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8619 |
(flip and:[ extModeStandard ]) ifTrue:[ |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8620 |
endLine := startLine. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8621 |
endCol := startCol - 1. |
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8622 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8623 |
startLine := cursorLine. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8624 |
startCol := cursorCol |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8625 |
] ifFalse:[ |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8626 |
endLine := cursorLine. |
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8627 |
endCol := cursorCol - 1. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8628 |
] |
4823 | 8629 |
]. |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8630 |
]. |
3023
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8631 |
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
|
8632 |
cursorWasShown ifTrue:[self showCursor]. |
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8633 |
|
4973
e78f1243d4ef
Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4970
diff
changeset
|
8634 |
"Modified: / 27-03-2014 / 10:05:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4970 | 8635 |
"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
|
8636 |
! |
9a6809da7351
shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents:
3020
diff
changeset
|
8637 |
|
1850 | 8638 |
autoMoveCursorToEndOfSelection |
8639 |
"return true, if the cursor should be automatically moved to the |
|
8640 |
end of a selection. |
|
3963
c315f087d655
comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents:
3945
diff
changeset
|
8641 |
Redefined to return false in terminalViews, where the cursor should |
1850 | 8642 |
not be affected by selecting" |
8643 |
||
8644 |
^ true |
|
8645 |
! |
|
8646 |
||
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8647 |
changeTypeOfSelectionTo:newType |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8648 |
typeOfSelection ~~ newType ifTrue:[ |
4823 | 8649 |
typeOfSelection := newType. |
8650 |
selectionStartLine notNil ifTrue:[ |
|
8651 |
self |
|
8652 |
redrawFromLine:selectionStartLine col:selectionStartCol |
|
8653 |
toLine:selectionEndLine col:selectionEndCol |
|
8654 |
]. |
|
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8655 |
]. |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8656 |
! |
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8657 |
|
4707 | 8658 |
findNextWordAfterSelectionAndAddToSelection |
8659 |
|selStartCol selStartLine selEndCol selEndLine| |
|
8660 |
||
8661 |
selectionStartCol isNil ifTrue:[ |
|
8662 |
self selectWordUnderCursor. |
|
8663 |
^ self |
|
8664 |
]. |
|
8665 |
||
8666 |
selStartCol := selectionStartCol. |
|
8667 |
selEndCol := selectionEndCol. |
|
8668 |
selStartLine := selectionStartLine. |
|
8669 |
selEndLine := selectionEndLine. |
|
8670 |
||
8671 |
self cursorToNextWord. |
|
8672 |
self selectWordUnderCursor. |
|
8673 |
||
8674 |
self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol. |
|
8675 |
! |
|
8676 |
||
4138 | 8677 |
searchPatternFromUserSelectionOrReplace |
8678 |
||
8679 |
|sel searchPattern| |
|
8680 |
||
8681 |
"/ |
|
8682 |
"/ if the last operation was a replace, set pattern to last |
|
8683 |
"/ original string (for search after again) |
|
8684 |
"/ |
|
8685 |
(lastStringFromReplaceForNextSearch notNil |
|
8686 |
and:[typeOfSelection ~~ #search]) ifTrue:[ |
|
8687 |
lastStringFromReplaceForNextSearch isString ifTrue:[ |
|
8688 |
searchPattern := lastStringFromReplaceForNextSearch. |
|
8689 |
] ifFalse:[ |
|
8690 |
searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR. |
|
8691 |
]. |
|
8692 |
^ searchPattern |
|
8693 |
]. |
|
8694 |
||
8695 |
"/ |
|
8696 |
"/ if there is a selection: |
|
8697 |
"/ if there was no previous search, take it as search pattern. |
|
8698 |
"/ if there was a previous search, only take the selection if |
|
8699 |
"/ it did not result from a paste. |
|
8700 |
"/ (to allow search-paste to be repeated) |
|
8701 |
"/ |
|
8702 |
sel := self selection. |
|
8703 |
sel notNil ifTrue:[ |
|
8704 |
typeOfSelection ~~ #search ifTrue:[ |
|
8705 |
typeOfSelection ~~ #paste ifTrue:[ |
|
8706 |
self cursorLine:selectionStartLine col:selectionStartCol. |
|
8707 |
searchPattern := sel asStringWithoutFinalCR. |
|
8708 |
] |
|
8709 |
]. |
|
8710 |
]. |
|
8711 |
||
8712 |
^ searchPattern |
|
8713 |
! |
|
8714 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8715 |
selectAll |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8716 |
"select the whole text. |
5593 | 8717 |
redefined to send super selectFrom... since we don't want the |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8718 |
cursor to be moved in this case." |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8719 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8720 |
list isNil ifTrue:[ |
4823 | 8721 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8722 |
] ifFalse:[ |
4823 | 8723 |
super selectFromLine:1 col:1 toLine:(list size + 1) col:0. |
8724 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8725 |
] |
1082 | 8726 |
|
8727 |
"Modified: 28.2.1997 / 19:14:54 / cg" |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8728 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8729 |
|
4117 | 8730 |
selectAllInitially |
8731 |
"select the whole text. This is called only once during the initialization |
|
8732 |
for editFields which are shown in a table or tree. |
|
8733 |
The selectAll is called via this method to allow for easier redefinition and |
|
8734 |
to distinguish auto-select from user-initiated selects." |
|
8735 |
||
8736 |
self selectAll |
|
8737 |
! |
|
8738 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8739 |
selectCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8740 |
"select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8741 |
|
3160 | 8742 |
self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8743 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8744 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8745 |
selectCursorLineFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8746 |
"select cursorline up to cursor position" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8747 |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8748 |
cursorCol > 1 ifTrue:[ |
4823 | 8749 |
self selectFromLine:cursorLine col:1 |
8750 |
toLine:cursorLine col:(cursorCol-1) |
|
823
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8751 |
] |
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8752 |
|
fc61564f7832
escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
8753 |
"Modified: 16.8.1996 / 19:14:14 / cg" |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8754 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8755 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8756 |
selectExpandCursorLine |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8757 |
"expand selection by one line or select cursorline" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8758 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8759 |
selectionStartLine isNil ifTrue:[ |
4823 | 8760 |
self selectCursorLine |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8761 |
] ifFalse:[ |
4823 | 8762 |
self selectFromLine:selectionStartLine col:selectionStartCol |
8763 |
toLine:cursorLine+1 col:0. |
|
8764 |
self makeLineVisible:selectionEndLine |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8765 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8766 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8767 |
|
4257 | 8768 |
selectFromBeginOfLine |
8769 |
"select the text from the beginning of the current line to the current cursor position." |
|
8770 |
||
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8771 |
| newCursorCol ln | |
4271 | 8772 |
|
4257 | 8773 |
list isNil ifTrue:[ |
8774 |
self unselect |
|
8775 |
] ifFalse:[ |
|
8776 |
cursorCol > 1 ifTrue:[ |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8777 |
ln := list at: cursorLine. |
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8778 |
newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1]. |
4271 | 8779 |
self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1. |
8780 |
cursorCol := newCursorCol. |
|
4257 | 8781 |
typeOfSelection := nil |
8782 |
] |
|
8783 |
] |
|
8784 |
||
8785 |
"Created: / 28-06-2011 / 22:47:04 / cg" |
|
4430
61c074a935cf
fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4424
diff
changeset
|
8786 |
"Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8787 |
! |
8788 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8789 |
selectFromBeginning |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8790 |
"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
|
8791 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8792 |
|col| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8793 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8794 |
list isNil ifTrue:[ |
4823 | 8795 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8796 |
] ifFalse:[ |
4823 | 8797 |
cursorCol == 0 ifTrue:[ |
8798 |
col := 0 |
|
8799 |
] ifFalse:[ |
|
8800 |
col := cursorCol - 1 |
|
8801 |
]. |
|
8802 |
super selectFromLine:1 col:1 toLine:cursorLine col:col. |
|
8803 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8804 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8805 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8806 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8807 |
selectFromLine:startLine col:startCol toLine:endLine col:endCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8808 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8809 |
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
|
8810 |
"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
|
8811 |
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
|
8812 |
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
|
8813 |
"/ (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
|
8814 |
"/ 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
|
8815 |
"/ ]. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8816 |
typeOfSelection := nil |
4841
4fca96a61d42
Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4674
diff
changeset
|
8817 |
|
4976
83f3df06495f
Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4975
diff
changeset
|
8818 |
"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
|
8819 |
"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
|
8820 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8821 |
|
4257 | 8822 |
selectToEndOfLine |
8823 |
"select the text from the current cursor position to the end of the current line" |
|
8824 |
||
4271 | 8825 |
| newCursorCol line | |
8826 |
||
4257 | 8827 |
list isNil ifTrue:[ |
8828 |
self unselect |
|
8829 |
] ifFalse:[ |
|
4275
16c80f32c06c
bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4271
diff
changeset
|
8830 |
cursorCol >= 1 ifTrue:[ |
4271 | 8831 |
line := list at: cursorLine. |
8832 |
newCursorCol := line size. |
|
8833 |
[ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ] |
|
8834 |
whileTrue:[newCursorCol := newCursorCol - 1]. |
|
8835 |
||
8836 |
self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol. |
|
8837 |
cursorCol := newCursorCol. |
|
4257 | 8838 |
typeOfSelection := nil |
8839 |
] |
|
8840 |
] |
|
8841 |
||
8842 |
"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
|
8843 |
"Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4257 | 8844 |
! |
8845 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8846 |
selectUpToEnd |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8847 |
"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
|
8848 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8849 |
list isNil ifTrue:[ |
4823 | 8850 |
self unselect |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8851 |
] ifFalse:[ |
4823 | 8852 |
super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0. |
8853 |
typeOfSelection := nil |
|
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8854 |
] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8855 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8856 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8857 |
selectWordUnderCursor |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8858 |
"select the word under the cursor" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8859 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8860 |
self selectWordAtLine:cursorLine col:cursorCol |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8861 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8862 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8863 |
unselect |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8864 |
"forget and unhilight selection - must take care of cursor here" |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8865 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8866 |
|wasOn| |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8867 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8868 |
wasOn := self hideCursor. |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8869 |
super unselect. |
2606
6a3ab90d339f
redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents:
2599
diff
changeset
|
8870 |
typeOfSelection := nil. |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8871 |
wasOn ifTrue:[self showCursor] |
105 | 8872 |
! ! |
8873 |
||
8874 |
!EditTextView methodsFor:'undo & again'! |
|
8875 |
||
2952 | 8876 |
addUndo:action |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8877 |
^ undoSupport addUndo:action. |
2952 | 8878 |
! |
8879 |
||
105 | 8880 |
again |
8881 |
"repeat the last action (which was a cut or replace). |
|
8882 |
If current selection is not last string, search forward to |
|
3160 | 8883 |
next occurrence of it before repeating the last operation." |
105 | 8884 |
|
4048 | 8885 |
|s l c sel savedSelectStyle startColForSearch |
4051 | 8886 |
lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch| |
4048 | 8887 |
|
8888 |
lastStringToReplace := lastReplacementInfo lastStringToReplace. |
|
4010 | 8889 |
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
|
8890 |
^ false |
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8891 |
]. |
4048 | 8892 |
lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase. |
8893 |
lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch. |
|
2579
74d3798f4200
do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents:
2574
diff
changeset
|
8894 |
|
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8895 |
self undoableDo:[ |
4010 | 8896 |
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
|
8897 |
"remove final cr" |
4566
21922c626af2
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4555
diff
changeset
|
8898 |
(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
|
8899 |
"/ s := s withoutSpaces. "XXX - replacing text with spaces ..." |
4010 | 8900 |
|
4053 | 8901 |
"set lastStringToReplace as the next search string |
8902 |
and set lastReplaceIgnoredCase as the next search ignored case flag" |
|
4048 | 8903 |
lastStringFromReplaceForNextSearch := s. |
4053 | 8904 |
lastSearchIgnoredCase := lastReplaceIgnoredCase. |
4010 | 8905 |
|
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8906 |
savedSelectStyle := selectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8907 |
selectStyle := nil. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8908 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8909 |
sel := self selection. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8910 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8911 |
"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
|
8912 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8913 |
(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
|
8914 |
l := selectionStartLine "cursorLine". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8915 |
c := selectionStartCol "cursorCol". |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8916 |
self deleteSelection. |
4051 | 8917 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8918 |
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
|
8919 |
self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1). |
4484 | 8920 |
typeOfSelection := #paste |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8921 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8922 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8923 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8924 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8925 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8926 |
sel isEmptyOrNil ifTrue:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8927 |
startColForSearch := cursorCol - 1 |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8928 |
] ifFalse:[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8929 |
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
|
8930 |
]. |
4048 | 8931 |
self |
8932 |
searchForwardFor:s |
|
8933 |
ignoreCase: lastReplaceIgnoredCase |
|
8934 |
match: lastReplaceWasMatch |
|
8935 |
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
|
8936 |
ifFound: |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8937 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8938 |
:line :col | |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8939 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8940 |
|repl| |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8941 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8942 |
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
|
8943 |
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
|
8944 |
self makeLineVisible:line. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8945 |
|
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8946 |
self deleteSelection. |
4051 | 8947 |
lastReplacementInfo lastReplacement notNil ifTrue:[ |
8948 |
lastReplacementInfo lastReplacement isString ifFalse:[ |
|
8949 |
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
|
8950 |
] ifTrue:[ |
4051 | 8951 |
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
|
8952 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8953 |
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
|
8954 |
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
|
8955 |
undoSupport actionInfo:'replace'. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8956 |
]. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8957 |
selectStyle := savedSelectStyle. |
4484 | 8958 |
typeOfSelection := #paste. |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8959 |
^ true |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8960 |
] |
4048 | 8961 |
ifAbsent: |
3816
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8962 |
[ |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8963 |
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
|
8964 |
self showNotFound. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8965 |
selectStyle := savedSelectStyle. |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8966 |
^ false |
3915f7b67262
again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents:
3813
diff
changeset
|
8967 |
]. |
3127
29767bf8a215
better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents:
3115
diff
changeset
|
8968 |
]. |
2730
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8969 |
|
61a2f1981ac6
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2725
diff
changeset
|
8970 |
^ true. |
501 | 8971 |
|
840
b0071cea13fd
fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents:
828
diff
changeset
|
8972 |
"Modified: 9.10.1996 / 16:14:11 / cg" |
105 | 8973 |
! |
8974 |
||
2952 | 8975 |
hasRedoAction |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8976 |
^ undoSupport hasRedoAction. |
2952 | 8977 |
! |
8978 |
||
8979 |
hasUndoAction |
|
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8980 |
^ undoSupport hasUndoAction. |
2952 | 8981 |
! |
8982 |
||
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8983 |
multipleAgain |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8984 |
"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
|
8985 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8986 |
[self again] whileTrue:[] |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8987 |
! |
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
8988 |
|
2952 | 8989 |
nonUndoableDo:aBlock |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8990 |
undoSupport nonUndoableDo:aBlock. |
2952 | 8991 |
! |
8992 |
||
8993 |
redo |
|
3780 | 8994 |
"undo the last undo" |
8995 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8996 |
undoSupport hasRedoAction ifFalse:[ |
3780 | 8997 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
8998 |
] ifTrue:[ |
3780 | 8999 |
undoSupport redo. |
2952 | 9000 |
] |
9001 |
! |
|
9002 |
||
121 | 9003 |
undo |
3780 | 9004 |
"undo the last edit operation" |
9005 |
||
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9006 |
undoSupport hasUndoAction ifFalse:[ |
5834 | 9007 |
self beep |
2989
5dcc2912bcb6
undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents:
2984
diff
changeset
|
9008 |
] ifTrue:[ |
5834 | 9009 |
undoSupport undo. |
9010 |
self makeSelectionVisible. |
|
9011 |
self makeCursorVisible. |
|
121 | 9012 |
] |
2952 | 9013 |
! |
9014 |
||
9015 |
undoableDo:aBlock |
|
3495 | 9016 |
self undoableDo:aBlock info:nil. |
9017 |
||
9018 |
"Modified: / 28-07-2007 / 13:20:14 / cg" |
|
3130 | 9019 |
! |
9020 |
||
9021 |
undoableDo:aBlock info:aString |
|
5689 | 9022 |
|selectionRestore| |
9023 |
||
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9024 |
self checkModificationsAllowed ifFalse:[ |
4823 | 9025 |
"/ will trigger an error-dialog there (no need for undo-carekeeping) |
9026 |
aBlock value. |
|
3154
42bf7ebd54c8
refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents:
3150
diff
changeset
|
9027 |
] ifTrue:[ |
5689 | 9028 |
undoSupport isInTransaction ifFalse:[ |
9029 |
selectionRestore := RestoreSelectionAndCursor new |
|
9030 |
cursorLine:cursorLine cursorCol:cursorCol |
|
9031 |
selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol |
|
9032 |
selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol |
|
9033 |
info:nil. |
|
9034 |
]. |
|
9035 |
undoSupport |
|
9036 |
undoableDo:[ |
|
9037 |
aBlock value. |
|
9038 |
selectionRestore notNil ifTrue:[ |
|
9039 |
undoSupport transactionNotEmpty ifTrue:[ |
|
9040 |
undoSupport addUndoFirst:selectionRestore |
|
9041 |
]. |
|
9042 |
]. |
|
9043 |
] |
|
9044 |
info:aString. |
|
9045 |
]. |
|
9046 |
||
9047 |
"Modified: / 30-04-2016 / 21:08:30 / cg" |
|
2952 | 9048 |
! ! |
9049 |
||
9050 |
!EditTextView::EditAction class methodsFor:'instance creation'! |
|
9051 |
||
9052 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9053 |
^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4 |
|
9054 |
! |
|
9055 |
||
3115 | 9056 |
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info |
3160 | 9057 |
^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info |
3115 | 9058 |
! |
9059 |
||
2952 | 9060 |
line:arg1 col:arg2 character:arg3 |
9061 |
^ self new line:arg1 col:arg2 character:arg3 |
|
9062 |
! |
|
9063 |
||
3115 | 9064 |
line:arg1 col:arg2 character:arg3 info:info |
3160 | 9065 |
^ (self new line:arg1 col:arg2 character:arg3) info:info |
3115 | 9066 |
! |
9067 |
||
3235 | 9068 |
line:arg1 col:arg2 characters:arg3 info:info |
9069 |
^ (self new line:arg1 col:arg2 characters:arg3) info:info |
|
9070 |
! |
|
9071 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9072 |
line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9073 |
^ self new line:arg1 col:arg2 info:arg3 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9074 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9075 |
|
2952 | 9076 |
line:arg1 col:arg2 string:arg3 |
9077 |
^ self new line:arg1 col:arg2 string:arg3 |
|
3115 | 9078 |
! |
9079 |
||
9080 |
line:arg1 col:arg2 string:arg3 info:info |
|
9081 |
^ (self new line:arg1 col:arg2 string:arg3) info:info |
|
3130 | 9082 |
! |
9083 |
||
9084 |
line:arg1 string:arg3 info:info |
|
9085 |
^ (self new line:arg1 string:arg3) info:info |
|
3131 | 9086 |
! |
9087 |
||
9088 |
text:arg info:info |
|
9089 |
^ (self new text:arg) info:info |
|
3115 | 9090 |
! ! |
9091 |
||
9092 |
!EditTextView::EditAction methodsFor:'accessing'! |
|
9093 |
||
9094 |
info |
|
9095 |
^ userFriendlyInfo |
|
9096 |
! |
|
9097 |
||
9098 |
info:aString |
|
9099 |
userFriendlyInfo := aString |
|
2952 | 9100 |
! ! |
9101 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9102 |
!EditTextView::EditAction methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9103 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9104 |
canCombineWithPreviousPasteStringAction: aPasteStringAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9105 |
^ false. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9106 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9107 |
"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
|
9108 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9109 |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9110 |
!EditTextView::EditAction methodsFor:'queries'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9111 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9112 |
canCombineWithNext:nextAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9113 |
^ false |
5710 | 9114 |
! |
9115 |
||
9116 |
isRestoreSelectionAndCursor |
|
9117 |
^ false |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9118 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9119 |
|
2952 | 9120 |
!EditTextView::DeleteRange methodsFor:'accessing'! |
9121 |
||
3160 | 9122 |
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg |
2952 | 9123 |
"set instance variables (automatically generated)" |
9124 |
||
9125 |
self assert:(line1Arg notNil). |
|
9126 |
self assert:(col1Arg notNil). |
|
9127 |
self assert:(line2Arg notNil). |
|
9128 |
self assert:(col2Arg notNil). |
|
9129 |
||
9130 |
line1 := line1Arg. |
|
9131 |
col1 := col1Arg. |
|
9132 |
line2 := line2Arg. |
|
9133 |
col2 := col2Arg. |
|
9134 |
! ! |
|
9135 |
||
9136 |
!EditTextView::DeleteRange methodsFor:'execution'! |
|
9137 |
||
3160 | 9138 |
executeIn:editor |
2952 | 9139 |
editor unselect. |
3160 | 9140 |
editor |
4823 | 9141 |
deleteFromLine:line1 |
9142 |
col:col1 |
|
9143 |
toLine:line2 |
|
9144 |
col:col2. |
|
2952 | 9145 |
editor cursorLine:line1 col:col1. |
9146 |
! ! |
|
9147 |
||
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9148 |
!EditTextView::DeleteCharacters methodsFor:'accessing'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9149 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9150 |
col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9151 |
^ col1 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9152 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9153 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9154 |
col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9155 |
^ col2 |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9156 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9157 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9158 |
line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9159 |
^ line |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9160 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9161 |
|
3160 | 9162 |
line:lineArg col1:col1Arg col2:col2Arg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9163 |
"set instance variables (automatically generated)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9164 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9165 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9166 |
self assert:(col1Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9167 |
self assert:(col2Arg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9168 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9169 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9170 |
col1 := col1Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9171 |
col2 := col2Arg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9172 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9173 |
|
3160 | 9174 |
line:lineArg col:colArg info:infoArg |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9175 |
self assert:(lineArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9176 |
self assert:(colArg notNil). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9177 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9178 |
line := lineArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9179 |
col1 := col2 := colArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9180 |
self info:infoArg. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9181 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9182 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9183 |
!EditTextView::DeleteCharacters methodsFor:'combining'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9184 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9185 |
canCombineWithNext:anotherAction |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9186 |
^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9187 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9188 |
|
3160 | 9189 |
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9190 |
"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
|
9191 |
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
|
9192 |
(i.e. single-character typing)" |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9193 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9194 |
previousDeleteAction line == line ifTrue:[ |
4823 | 9195 |
previousDeleteAction col2 == (col1-1) ifTrue:[ |
9196 |
^ true |
|
9197 |
]. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9198 |
]. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9199 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9200 |
^ false |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9201 |
! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9202 |
|
3160 | 9203 |
combineWithNext:nextDeleteAction |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9204 |
self assert:(line == nextDeleteAction line). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9205 |
self assert:(col2 == (nextDeleteAction col1 - 1)). |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9206 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9207 |
col2 := nextDeleteAction col2. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9208 |
userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9209 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9210 |
|
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9211 |
!EditTextView::DeleteCharacters methodsFor:'execution'! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9212 |
|
3160 | 9213 |
executeIn:editor |
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9214 |
editor unselect. |
3160 | 9215 |
editor |
4823 | 9216 |
deleteFromLine:line |
9217 |
col:col1 |
|
9218 |
toLine:line |
|
9219 |
col:col2. |
|
3156
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9220 |
editor cursorLine:line col:col1. |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9221 |
! ! |
25ef39958fd8
undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents:
3154
diff
changeset
|
9222 |
|
3235 | 9223 |
!EditTextView::EditMode class methodsFor:'constants'! |
9224 |
||
9225 |
insertAndSelectMode |
|
9226 |
^ InsertAndSelectMode |
|
9227 |
! |
|
9228 |
||
9229 |
insertMode |
|
9230 |
^ InsertMode |
|
9231 |
! |
|
9232 |
||
9233 |
overwriteMode |
|
9234 |
^ OverwriteMode |
|
9235 |
! ! |
|
9236 |
||
9237 |
!EditTextView::EditMode class methodsFor:'queries'! |
|
9238 |
||
9239 |
isInsertAndSelectMode |
|
9240 |
^ false |
|
9241 |
! |
|
9242 |
||
9243 |
isInsertMode |
|
9244 |
^ false |
|
9245 |
! |
|
9246 |
||
9247 |
symbolicName |
|
9248 |
self subclassResponsibility |
|
9249 |
! ! |
|
9250 |
||
9251 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'! |
|
9252 |
||
9253 |
infoPrintString |
|
9254 |
^ 'IS' |
|
9255 |
! ! |
|
9256 |
||
9257 |
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'! |
|
9258 |
||
9259 |
isInsertAndSelectMode |
|
9260 |
^ true |
|
9261 |
! |
|
9262 |
||
9263 |
isInsertMode |
|
9264 |
^ true |
|
9265 |
! ! |
|
9266 |
||
9267 |
!EditTextView::EditMode::InsertMode class methodsFor:'info'! |
|
9268 |
||
9269 |
infoPrintString |
|
9270 |
^ 'I' |
|
9271 |
! ! |
|
9272 |
||
9273 |
!EditTextView::EditMode::InsertMode class methodsFor:'queries'! |
|
9274 |
||
9275 |
isInsertMode |
|
9276 |
^ true |
|
9277 |
! ! |
|
9278 |
||
9279 |
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'! |
|
9280 |
||
9281 |
infoPrintString |
|
9282 |
^ 'O' |
|
9283 |
! ! |
|
9284 |
||
4048 | 9285 |
!EditTextView::LastReplacementInfo methodsFor:'accessing'! |
9286 |
||
9287 |
lastReplaceIgnoredCase |
|
9288 |
^ lastReplaceIgnoredCase ? false |
|
9289 |
! |
|
9290 |
||
9291 |
lastReplaceIgnoredCase:something |
|
9292 |
lastReplaceIgnoredCase := something. |
|
9293 |
! |
|
9294 |
||
9295 |
lastReplaceWasMatch |
|
9296 |
^ lastReplaceWasMatch ? false |
|
9297 |
! |
|
9298 |
||
9299 |
lastReplaceWasMatch:something |
|
9300 |
lastReplaceWasMatch := something. |
|
9301 |
! |
|
9302 |
||
9303 |
lastReplacement |
|
9304 |
^ lastReplacement |
|
9305 |
! |
|
9306 |
||
9307 |
lastReplacement:something |
|
4053 | 9308 |
"/Transcript showCR: 'lastReplacement:', something printString. |
4048 | 9309 |
lastReplacement := something. |
9310 |
! |
|
9311 |
||
9312 |
lastStringToReplace |
|
9313 |
^ lastStringToReplace |
|
9314 |
! |
|
9315 |
||
9316 |
lastStringToReplace:something |
|
9317 |
lastStringToReplace := something. |
|
4818 | 9318 |
! |
9319 |
||
9320 |
previousReplacements |
|
9321 |
^ previousReplacements ? #() |
|
9322 |
! |
|
9323 |
||
9324 |
stillCollectingInput |
|
9325 |
^ stillCollectingInput |
|
9326 |
! |
|
9327 |
||
9328 |
stillCollectingInput:aBoolean |
|
9329 |
stillCollectingInput := aBoolean. |
|
9330 |
! ! |
|
9331 |
||
9332 |
!EditTextView::LastReplacementInfo methodsFor:'history'! |
|
9333 |
||
9334 |
rememberReplacement |
|
9335 |
"remember the previous replacement (called when a new one appears). |
|
9336 |
Mostly for the benefit of the code completion..." |
|
9337 |
||
9338 |
|oldString newString| |
|
9339 |
||
9340 |
oldString := lastStringToReplace. |
|
9341 |
newString := lastReplacement. |
|
9342 |
(oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[ |
|
9343 |
previousReplacements isNil ifTrue:[ |
|
9344 |
previousReplacements := OrderedCollection new. |
|
9345 |
]. |
|
9346 |
previousReplacements := previousReplacements reject:[:entry | entry key = oldString]. |
|
9347 |
previousReplacements addFirst:(oldString -> newString). |
|
9348 |
previousReplacements size > 20 ifTrue:[ |
|
9349 |
previousReplacements removeLast. |
|
9350 |
] |
|
9351 |
]. |
|
4048 | 9352 |
! ! |
9353 |
||
2952 | 9354 |
!EditTextView::PasteString methodsFor:'accessing'! |
9355 |
||
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9356 |
col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9357 |
^ col |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9358 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9359 |
"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
|
9360 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9361 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9362 |
col2 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9363 |
^ col + string size - 1 |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9364 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9365 |
"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
|
9366 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9367 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9368 |
line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9369 |
^ line |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9370 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9371 |
"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
|
9372 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9373 |
|
3160 | 9374 |
line:lineArg col:colArg string:stringArg |
2952 | 9375 |
self assert:(lineArg notNil). |
9376 |
self assert:(colArg notNil). |
|
9377 |
self assert:(stringArg notNil). |
|
9378 |
||
9379 |
line := lineArg. |
|
9380 |
col := colArg. |
|
9381 |
string := stringArg. |
|
9382 |
! |
|
9383 |
||
9384 |
line:lineArg col:colArg string:stringArg selected:selectedArg |
|
9385 |
self assert:(lineArg notNil). |
|
9386 |
self assert:(colArg notNil). |
|
9387 |
self assert:(stringArg notNil). |
|
9388 |
||
9389 |
line := lineArg. |
|
9390 |
col := colArg. |
|
9391 |
string := stringArg. |
|
9392 |
selected := selectedArg. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9393 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9394 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9395 |
string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9396 |
^ string |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9397 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9398 |
"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
|
9399 |
! ! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9400 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9401 |
!EditTextView::PasteString methodsFor:'combining'! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9402 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9403 |
canCombineWithNext:anotherAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9404 |
^ anotherAction canCombineWithPreviousPasteStringAction:self |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9405 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9406 |
"Created: / 25-09-2006 / 12:15:59 / cg" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9407 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9408 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9409 |
canCombineWithPreviousPasteStringAction: previousPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9410 |
"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
|
9411 |
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
|
9412 |
(i.e. single-character deletes)" |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9413 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9414 |
previousPasteAction line == line ifTrue:[ |
4823 | 9415 |
previousPasteAction col == (self col2+1) ifTrue:[ |
9416 |
^ true |
|
9417 |
]. |
|
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9418 |
]. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9419 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9420 |
^ false |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9421 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9422 |
"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
|
9423 |
! |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9424 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9425 |
combineWithNext:nextPasteAction |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9426 |
|s1 s2| |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9427 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9428 |
self assert:(line == nextPasteAction line). |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9429 |
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
|
9430 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9431 |
s1 := nextPasteAction string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9432 |
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
|
9433 |
s2 := string. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9434 |
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
|
9435 |
|
3683
5891af82a177
middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents:
3650
diff
changeset
|
9436 |
string := s1, s2. |
3400
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9437 |
col := nextPasteAction col. |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9438 |
userFriendlyInfo := 'delete ' , string size printString |
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9439 |
|
c3fd4330f9ea
undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents:
3326
diff
changeset
|
9440 |
"Created: / 25-09-2006 / 12:24:10 / cg" |
2952 | 9441 |
! ! |
9442 |
||
9443 |
!EditTextView::PasteString methodsFor:'execution'! |
|
9444 |
||
3160 | 9445 |
executeIn:editor |
2952 | 9446 |
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
|
9447 |
editor paste:string. |
2952 | 9448 |
selected ~~ true ifTrue:[ |
4823 | 9449 |
editor unselect |
2952 | 9450 |
]. |
9451 |
! ! |
|
9452 |
||
9453 |
!EditTextView::ReplaceCharacter methodsFor:'accessing'! |
|
9454 |
||
3235 | 9455 |
col |
9456 |
^ col |
|
9457 |
! |
|
9458 |
||
9459 |
col1 |
|
9460 |
^ col |
|
9461 |
! |
|
9462 |
||
9463 |
col2 |
|
9464 |
^ col |
|
9465 |
! |
|
9466 |
||
9467 |
line |
|
9468 |
^ line |
|
9469 |
! |
|
9470 |
||
3160 | 9471 |
line:lineArg col:colArg character:characterArg |
2952 | 9472 |
line := lineArg. |
9473 |
col := colArg. |
|
9474 |
character := characterArg. |
|
9475 |
! ! |
|
9476 |
||
9477 |
!EditTextView::ReplaceCharacter methodsFor:'execution'! |
|
9478 |
||
3160 | 9479 |
executeIn:editor |
9480 |
editor |
|
4823 | 9481 |
replace:character |
9482 |
atLine:line |
|
9483 |
col:col. |
|
2952 | 9484 |
editor cursorLine:line col:col. |
105 | 9485 |
! ! |
9486 |
||
3235 | 9487 |
!EditTextView::ReplaceCharacters methodsFor:'accessing'! |
9488 |
||
9489 |
characters |
|
9490 |
^ characters |
|
9491 |
! |
|
9492 |
||
9493 |
col1 |
|
9494 |
^ col1 |
|
9495 |
! |
|
9496 |
||
9497 |
col2 |
|
9498 |
^ col2 |
|
9499 |
! |
|
9500 |
||
9501 |
line |
|
9502 |
^ line |
|
9503 |
! |
|
9504 |
||
9505 |
line:lineArg col:colArg character:characterArg |
|
9506 |
line := lineArg. |
|
9507 |
col1 := col2 := colArg. |
|
9508 |
characters := characterArg asString. |
|
9509 |
! |
|
9510 |
||
9511 |
line:lineArg col:colArg characters:charactersArg |
|
9512 |
line := lineArg. |
|
9513 |
col1 := colArg. |
|
9514 |
characters := charactersArg asString. |
|
9515 |
col2 := col1 + charactersArg size - 1 |
|
9516 |
! ! |
|
9517 |
||
9518 |
!EditTextView::ReplaceCharacters methodsFor:'combining'! |
|
9519 |
||
9520 |
canCombineWithNext:anotherAction |
|
9521 |
^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false |
|
9522 |
! |
|
9523 |
||
9524 |
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction |
|
9525 |
"I will combine only if we both are single character deletes, |
|
9526 |
and my col-to-delete is the next after anotherDeleteActions col-to-delete. |
|
9527 |
(i.e. single-character typing)" |
|
9528 |
||
9529 |
previousReplaceAction line == line ifTrue:[ |
|
4823 | 9530 |
previousReplaceAction col2 == (col1-1) ifTrue:[ |
9531 |
^ true |
|
9532 |
]. |
|
3235 | 9533 |
]. |
9534 |
||
9535 |
^ false |
|
9536 |
! |
|
9537 |
||
9538 |
combineWithNext:nextReplaceAction |
|
9539 |
self assert:(line == nextReplaceAction line). |
|
9540 |
self assert:(self col2 == (nextReplaceAction col1 - 1)). |
|
9541 |
||
9542 |
col2 := nextReplaceAction col2. |
|
9543 |
userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString. |
|
9544 |
characters := characters , nextReplaceAction characters. |
|
9545 |
! ! |
|
9546 |
||
9547 |
!EditTextView::ReplaceCharacters methodsFor:'execution'! |
|
9548 |
||
9549 |
executeIn:editor |
|
9550 |
editor |
|
4823 | 9551 |
replaceString:characters |
9552 |
atLine:line |
|
9553 |
col:col1. |
|
3235 | 9554 |
editor cursorLine:line col:col1. |
9555 |
! ! |
|
9556 |
||
3131 | 9557 |
!EditTextView::ReplaceContents methodsFor:'accessing'! |
9558 |
||
9559 |
text:something |
|
9560 |
text := something. |
|
9561 |
! ! |
|
9562 |
||
9563 |
!EditTextView::ReplaceContents methodsFor:'execution'! |
|
9564 |
||
3160 | 9565 |
executeIn:editor |
3131 | 9566 |
editor contents:text |
9567 |
! ! |
|
9568 |
||
3130 | 9569 |
!EditTextView::ReplaceLine methodsFor:'accessing'! |
9570 |
||
3160 | 9571 |
line:lineArg string:stringArg |
3130 | 9572 |
line := lineArg. |
9573 |
text := stringArg. |
|
9574 |
! ! |
|
9575 |
||
9576 |
!EditTextView::ReplaceLine methodsFor:'execution'! |
|
9577 |
||
3160 | 9578 |
executeIn:editor |
3130 | 9579 |
editor list at:line put:text. |
9580 |
editor invalidateLine:line |
|
9581 |
! ! |
|
9582 |
||
3402 | 9583 |
!EditTextView::ReplaceLines methodsFor:'accessing'! |
9584 |
||
9585 |
line:lineArg lines:lineCollectionArg |
|
9586 |
line := lineArg. |
|
9587 |
text := lineCollectionArg. |
|
9588 |
||
9589 |
"Created: / 09-10-2006 / 10:35:22 / cg" |
|
9590 |
! ! |
|
9591 |
||
9592 |
!EditTextView::ReplaceLines methodsFor:'execution'! |
|
9593 |
||
9594 |
executeIn:editor |
|
9595 |
|lnr| |
|
9596 |
||
9597 |
lnr := line. |
|
9598 |
text do:[:eachLine | |
|
4823 | 9599 |
editor list at:lnr put:eachLine. |
9600 |
editor invalidateLine:lnr. |
|
9601 |
lnr := lnr + 1. |
|
3402 | 9602 |
]. |
9603 |
||
9604 |
"Modified: / 09-10-2006 / 10:39:16 / cg" |
|
9605 |
! ! |
|
9606 |
||
5689 | 9607 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'! |
9608 |
||
9609 |
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9610 |
cursorLine := cursorLineArg. |
|
9611 |
cursorCol := cursorColArg. |
|
9612 |
selectionStartLine := selectionStartLineArg. |
|
9613 |
selectionStartCol := selectionStartColArg. |
|
9614 |
selectionEndLine := selectionEndLineArg. |
|
9615 |
selectionEndCol := selectionEndColArg. |
|
9616 |
! |
|
9617 |
||
9618 |
cursorLine:cursorLineArg cursorCol:cursorColArg |
|
9619 |
selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg |
|
9620 |
selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg |
|
9621 |
info:info |
|
9622 |
||
9623 |
cursorLine := cursorLineArg. |
|
9624 |
cursorCol := cursorColArg. |
|
9625 |
selectionStartLine := selectionStartLineArg. |
|
9626 |
selectionStartCol := selectionStartColArg. |
|
9627 |
selectionEndLine := selectionEndLineArg. |
|
9628 |
selectionEndCol := selectionEndColArg. |
|
9629 |
userFriendlyInfo := info. |
|
9630 |
||
9631 |
"Created: / 30-04-2016 / 20:21:18 / cg" |
|
9632 |
! ! |
|
9633 |
||
9634 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'! |
|
9635 |
||
9636 |
executeIn:editor |
|
9637 |
(selectionStartLine notNil and:[selectionEndLine notNil |
|
9638 |
and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[ |
|
9639 |
editor setCursorLine:cursorLine col:cursorCol. |
|
9640 |
editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol |
|
9641 |
] ifFalse:[ |
|
9642 |
editor cursorLine:cursorLine col:cursorCol. |
|
9643 |
]. |
|
9644 |
||
9645 |
"Created: / 30-04-2016 / 20:14:55 / cg" |
|
9646 |
! ! |
|
9647 |
||
5710 | 9648 |
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'! |
9649 |
||
9650 |
isRestoreSelectionAndCursor |
|
9651 |
^ true |
|
9652 |
! ! |
|
9653 |
||
865 | 9654 |
!EditTextView class methodsFor:'documentation'! |
259
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9655 |
|
837ccdc138ea
use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents:
214
diff
changeset
|
9656 |
version |
5361 | 9657 |
^ '$Header$' |
3945 | 9658 |
! |
9659 |
||
9660 |
version_CVS |
|
5361 | 9661 |
^ '$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
|
9662 |
! |
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9663 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9664 |
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
|
9665 |
|
7cd827899263
Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4841
diff
changeset
|
9666 |
^ '$Changeset: <not expanded> $' |
0 | 9667 |
! ! |
4481 | 9668 |